Downloading seismic data (FDSN)¶
Waveforms and meta data can be retrieved from online FDSN services. The recommended way to do so is through the pyrocko.squirrel framework, using add_fdsn() to declare an FDSN web service as a data source; Squirrel uses the lower-level pyrocko.client.fdsn module under the hood.
Downloading and restituting waveform data¶
Downloading waveform data and instrument response information, and using the
latter to deconvolve the transfer function from the waveform traces, is
covered step by step in the Squirrel tutorial (see the squirrel_rms1.py and
squirrel_rms2.py examples there).
For a one-off download where Squirrel’s indexing and caching machinery would
be overkill, the lower-level pyrocko.client.fdsn module can be used
directly instead:
from pyrocko.client import fdsn
from pyrocko import io, util
tmin = util.stt('2014-01-01 16:10:00.000')
tmax = util.stt('2014-01-01 16:39:59.000')
selection = [
('GE', 'EIL', '*', '*Z', tmin, tmax), # all vertical components
]
request_waveform = fdsn.dataselect(site='geofon', selection=selection)
with open('traces.mseed', 'wb') as file:
file.write(request_waveform.read())
traces = io.load('traces.mseed')
StationXML data manipulation¶
To manipulate StationXML data through
Pyrocko use the pyrocko.io.stationxml module. This example will
change the azimuth and dip values for channels whose codes are X, Y and Z, and
set all channel instrument’s input units to meters.
from pyrocko.io import stationxml from pyrocko.example import get_example_data # Download example StationXML file get_example_data('responses.xml') # load the StationXML downloaded data file sx = stationxml.load_xml(filename='responses.xml') comp_to_azi_dip = { 'X': (0., 0.), 'Y': (90., 0.), 'Z': (0., -90.), } # step through all the networks within the data file for network in sx.network_list: # step through all the stations per networks for station in network.station_list: # step through all the channels per stations for channel in station.channel_list: azi, dip = comp_to_azi_dip[channel.code[-1]] # change the azimuth and dip of the channel per channel alpha code channel.azimuth.value = azi channel.dip.value = dip # set the instrument input units to 'M'eters channel.response.instrument_sensitivity.input_units.name = 'M' # save as new StationXML file sx.dump_xml(filename='changed.xml')
Download fdsn_stationxml_modify.py