This demo introduces some simple code that requests data using GeoNet's FDSN webservices and the obspy module in python. This notebook uses Python 3.
In [1]:
from obspy import UTCDateTime
from obspy.clients.fdsn import Client as FDSN_Client
from obspy import read_inventory
In [2]:
client = FDSN_Client("GEONET")
Use the station service to access station metadata from GeoNet stations.
Note, that metadata provided is prodominately associated with data types available from the FDSN archive, and therefore does not include things such as Geodetic station information.
This example gets all stations that are operating at the time of the Kaikoura earthquake and that are located within a 0.5 degrees radius of the epicentre. It lists the station codes and plots them on a map.
In [3]:
inventory = client.get_stations(latitude=-42.693,longitude=173.022,maxradius=0.5, starttime = "2016-11-13 11:05:00.000",endtime = "2016-11-14 11:00:00.000")
print(inventory)
_=inventory.plot(projection="local")
The following examples dive into retrieving different information from the inventory object. This object is based on FDSN stationXML and therefore can provide much the same information.
To get all available information into the inventory you will want to request data down to the response level. The default requests information just to a station level. For more information, see the obspy inventory class.
This example gets data from a station, KUZ, and prints a summary of the inventory contents
In [4]:
inventory = client.get_stations(station="KUZ",level="response",
starttime = "2016-11-13 11:05:00.000",endtime = "2016-11-14 11:00:00.000")
print(inventory)
Now, we can look at more information, such as specifics about the station. Such as the time it opened and location.
In [5]:
network = inventory[0]
station = network[0] # equivalent to inventory[0][0]
num_channels = len(station)
print(station)
We can drill down even futher into a particular channel and look at the time it was operating for, whether it was continously recording, the sample rate and some basic sensor information.
In [6]:
channel = station[0] # equivalent to inventory[0][0][0]
print(channel)
This channel states that there is response information available, so we can look at a summary of the response and plot it.
In [7]:
resp = channel.response
print(resp)
resp.plot(0.001,output="VEL",label='KUZ HHZ')
Out[7]: