seismic.inventory package



seismic.inventory.add_time_corrections module

Add GPS clock time correction csv_data into inventory file to get a modified station xml file




seismic.inventory.add_time_corrections.add_gpscorrection_into_stationxml(csv_file, input_xml, out_xml=None)[source]

Read in the correction CSV data from a file, get the station metadata node from input_xml file, then add the CSV data into the station xml node to write into out_xml

  • csv_file – input csv file with correction data

  • input_xml – input original stationXML file which contains the metadata for the network and station of csv_file

  • out_xml – Directory of the output xml file


full path of the output xml file


Read the station xml file and extract the csv data to be parsed by pandas


path2xml – path_to_stationxml




Read in the csv data from an input file, get the network_code, station_code, csv_data. Format:

$ head 7D.DE43_clock_correction.csv

path_csvfile – input csv file in /g/data/ha3/Passive/SHARED_DATA/GPS_Clock/corrections/


(network_code, station_code, csv_data)

seismic.inventory.engd2stxml module

seismic.inventory.fdsnxml_convert module

Helper functions to convert FDSN station XML files to Seiscomp3 SC3ML format.

Can be used as a standalone tool as well: src_path dst_path
Check whether conversion to seiscomp3 format is available os this system.

Only works for Python 3, for Python 2 it always returns True (i.e. give it a try).


True if conversion to sc3ml can be performed on this system, False otherwise.

Return type


seismic.inventory.fdsnxml_convert.toSc3ml(src_path, dst_path, response_fdsnxml=None)[source]

Convert file(s) in src_path from FDSN station XML to SC3ML and emit result(s) to dst_path.

If src_path is a file, dst_path will be treated as a file. If dst_path already exists as a folder, an exception is raised.

If src_path is a folder, dst_path will be treated as a folder. If dst_path already exists as a file, an exception is raised. The src_path directory hierarchy will be walked to find all .xml files, each of which will be converted to a mirrored relative path under dst_path.

  • src_path (str or pathlib.Path) – The source path from which to input XML file(s).

  • dst_path (str or pathlib.Path) – The destination path into which converted sc3ml file(s) are output.

  • response_fdsnxml (str or Path) – Path to existing for containing dummy response to insert into records where instrument response is missing.


OSError, FileNotFoundError, RuntimeError, FileExistsError

seismic.inventory.generate_network_plots module

seismic.inventory.inventory_merge module

seismic.inventory.inventory_split module

Split a station inventory file into a separate file per network.

seismic.inventory.inventory_split.inventory_split(inv_file, output_folder, sc3ml=False)[source]

Split an inventory file (station XML) into separate inventory file per network, stored in folder output_folder.

  • inv_file (str or path) – Station inventory to be split. This file is not changed by the script.

  • output_folder (str or path to folder) – Folder where per-network station xml files will be generated.

  • sc3ml (bool, optional) – If True, try to convert output files to sc3ml format if possible using seiscomp3. Defaults to False.

seismic.inventory.inventory_split.split_inventory_by_network(obspy_inv, output_folder, validate=False)[source]

Export a station XML file per network for each network in given obspy Inventory.

  • obspy_inv (obspy.core.inventory.inventory.Inventory) – Obspy Inventory containing the networks to export to file.

  • output_folder (str or pathlib.Path) – Folder in which to output the per-network XML files. Will be created if doesn’t yet exist.

  • validate (bool, optional) – Whether to validate the station data on write, defaults to False

seismic.inventory.inventory_util module

Utility functions and constants shared amongst inventory management modules.

class seismic.inventory.inventory_util.Instrument(sensor, response)

Bases: tuple

Create new instance of Instrument(sensor, response)

property response

Alias for field number 1

property sensor

Alias for field number 0

seismic.inventory.inventory_util.extract_unique_sensors_responses(inv, req, show_progress=True, blacklisted_networks=None, test_mode=False)[source]

For the channel codes in the given inventory, determine a nominal instrument response suitable for that code. Note that no attempt is made here to determine an ACTUAL correct response for a given network and station. The only requirement here is to populate a plausible, non-empty response for a given channel code, to placate Seiscomp3 which requires that an instrument response always be present.


Python dict of (obspy.core.inventory.util.Equipment, obspy.core.inventory.response.Response) indexed by str representing channel code

Return type

{str: Instrument(obspy.core.inventory.util.Equipment, obspy.core.inventory.response.Response) } where Instrument is a collections.namedtuple(“Instrument”, [‘sensor’, ‘response’])


Load a stationxml file


inventory_file (str or path) – Name of stationxml file to load


Station inventory as Obspy Inventory

Return type


seismic.inventory.inventory_util.obtain_nominal_instrument_response(netcode, statcode, chcode, req)[source]

For given network, station and channel code, find suitable response(s) in IRIS database and return as dict of obspy instrument responses.

  • netcode (str) – Network code (may include wildcards)

  • statcode (str) – Station code (may include wildcards)

  • chcode (str) – Channel code (may include wildcards)

  • req (Object conforming to interface of 'requests' library) – Request object to use for URI query


Dictionary of instrument responses from IRIS for given network(s), station(s) and channel(s).

Return type

dict of {str, Instrument(obspy.core.inventory.util.Equipment, obspy.core.inventory.response.Response)}

seismic.inventory.iris_query module

Helper functions for making and managing web queries to IRIS web service.

seismic.inventory.iris_query.form_channel_request_url(netmask='*', statmask='*', chanmask='*')[source]

Form request URL to download station inventory in stationxml format, down to channel level, with the given filters applied to network codes, station codes and channel codes.

  • netmask (str, optional) – Pattern of network codes to match, comma separated with wildcards, defaults to “*”

  • statmask (str, optional) – Pattern of station codes to match, comma separated with wildcards, defaults to “*”

  • chanmask (str, optional) – Pattern of channel codes to match, comma separated with wildcards, defaults to “*”


Fully formed URL to perform IRIS query and get back FDSN station XML result.

Return type


seismic.inventory.iris_query.form_response_request_url(netmask, statmask, chanmask)[source]

Form request URL to download station inventory in stationxml format, down to response level, for the given network, station and channel codes.

  • netmask (str, optional) – Pattern of network codes to match, comma separated with wildcards

  • statmask (str, optional) – Pattern of station codes to match, comma separated with wildcards

  • chanmask (str, optional) – Pattern of channel codes to match, comma separated with wildcards


Fully formed URL to perform IRIS query and get back FDSN station XML result.

Return type


seismic.inventory.iris_query.set_text_encoding(resp, quiet=False)[source]

For the given response object, set its encoding from the contents of the text returned from server.


resp (requests.Response) – Query response object returned by response.get()

seismic.inventory.pdconvert module

seismic.inventory.plotting module

seismic.inventory.response module


Implements a Class for reading/storing responses from a number of sources. The ResponseFactory class is used for attaching ‘bogus’ responses to station inventories that lack them.


CreationDate: 14/02/19


Revision History:

LastUpdate: 14/02/19 RH LastUpdate: dd/mm/yyyy Who Optional description

class seismic.inventory.response.ResponseFactory[source]

Bases: object

The ResponseFactory class encapsulates the generation of a collection of named Instrument Response Objects from a variety of sources. Currently it provides the facility to create Response objects from two sources, namely, Poles and Zeroes supplied by the user and from StationXML files generated from RESP files using the PDCC tool (link below). The conversion of RESP files into a corresponding StationXML file, at this stage, must take place externally, because ObsPy lacks that functionality. The intended usage of this class during the creation of an ASDF dataset is as follows:

1. User creates a number of uniquely named Response objects (see associated tests as well) pertaining to different
   channels in a given survey.
2. User fetches these Response objects from an instance of ResponseFactory as needed, while creating ObsPy Channel
   objects, during which Response objects can be passed in as an argument.
3. User builds a hierarchy of channel->station->network inventories, with the appropriate instrument response
   information embedded
4. The master FDSN StaionXML file output after step 3 can then be converted into an SC3ML file (which can be
   ingested by SeisComp3) using the fdsnxml2inv tool.

PDCC tool:

CreateFromInventory(name, obspy_inventory)[source]

Create response from an Inventory

CreateFromPAZ(name, pzTransferFunctionType, normFactor, normFreq, stageGain, stageGainFreq, poles, zeros)[source]
CreateFromStationXML(name, respFileName)[source]

Create response from an XML file

  • name (str) – Name of the response for later retrieval

  • respFileName (str) – XML file to load

class ResponseFromInventory(source_inventory)[source]

Bases: object

Helper class to get Obspy Response object from an Inventory


RuntimeError – Raises error if response not found



source_inventory (obspy.core.inventory.inventory.Inventory) – Inventory from which to extract response

class ResponseFromPAZ(pzTransferFunctionType='LAPLACE (RADIANS/SECOND)', normFactor=80000.0, normFreq=0.01, stageGain=2000.0, stageGainFreq=0.01, poles=[0j], zeros=[0j])[source]

Bases: object

class ResponseFromStationXML(respFileName)[source]

Bases: seismic.inventory.response.ResponseFactory.ResponseFromInventory

Helper class to get Obspy Response object from a station xml file



respFileName (str) – XML file to load


Retrieve response by name


name (str) – Name given to response at creation time


RuntimeError – Raises error if name is not recognized


The requested response

Return type


seismic.inventory.table_format module

seismic.inventory.update_iris_inventory module

Automatically update IRIS-ALL.xml file from IRIS web portal.

Output file is saved as FDSN station xml. Script also generates human readable form as IRIS-ALL.txt.

Example usages:

python -o outfile.xml
python --netmask=U* --statmask=K*
python --netmask=UW,LO --output outfile.xml

Helper function to clean up temporary file on disk.


tmp_filename (str) – File name to clean up

seismic.inventory.update_iris_inventory.regenerate_human_readable(iris_data, outfile)[source]

Generate human readable, tabular version of the IRIS database.

  • iris_data (str) – String containing result string returned from IRIS query (without data errors).

  • outfile (str) – Output text file name


Perform text subtitutions to fix known errors in station xml returned from IRIS.


iris (requests.models.Response) – Response to IRIS query request containing response text


The text from the response with known faulty data substituted with fixed data.

Return type


seismic.inventory.update_iris_inventory.update_iris_station_xml(req, output_file, options=None)[source]

Pull the latest IRIS complete station inventory (down to station level, not including instrument responses) from IRIS web service and save to file in FDSN station xml format.

  • req (Object conforming to interface of 'requests' library) – Request object to use for URI query

  • output_file (str) – Destination file to generate

  • options (Python dict of key-values pairs matching command line options, optional) – Filtering options for network, station and channel codes, defaults to None

Module contents