mt_metadata.timeseries.stationxml package

Submodules

mt_metadata.timeseries.stationxml.fdsn_tools module

Tools for FDSN standards

Created on Wed Sep 30 11:47:01 2020

author:

Jared Peacock

license:

MIT

mt_metadata.timeseries.stationxml.fdsn_tools.angle(value)[source]
mt_metadata.timeseries.stationxml.fdsn_tools.create_location_code(channel_obj)[source]

Get the location code given the components and channel number

Parameters:

channel_obj (Channel) – Channel object

Returns:

2 character location code

Return type:

string

mt_metadata.timeseries.stationxml.fdsn_tools.create_mt_component(channel_code)[source]
Parameters:

channel_code (string) – Three character string {Period}{Component}{Orientation}

Returns:

DESCRIPTION

Return type:

TYPE

Create a component for an MT channel given the measurement and orientation

>>> create_mt_component("LQN")
ex
mt_metadata.timeseries.stationxml.fdsn_tools.get_measurement_code(measurement)[source]

get SEED sensor code given the measurement type

Parameters:

measurement (string) – measurement type, e.g. * temperature * electric * magnetic

Returns:

single character SEED sensor code, if the measurement type has not been defined yet Y is returned.

Return type:

string

mt_metadata.timeseries.stationxml.fdsn_tools.get_orientation_code(azimuth=None, direction=None, orientation='horizontal')[source]

Get orientation code given angle and orientation. This is a general code and the true azimuth is stored in channel

Parameters:
  • azimuth (float) – angel assuming 0 is north, 90 is east, 0 is vertical down

  • direction – character nominated direction [ x | y | z ]

Returns:

single character SEED orientation code

Return type:

string

mt_metadata.timeseries.stationxml.fdsn_tools.get_period_code(sample_rate)[source]

Get the SEED sampling rate code given a sample rate

Parameters:

sample_rate (float) – sample rate in samples per second

Returns:

single character SEED sampling code

Return type:

string

mt_metadata.timeseries.stationxml.fdsn_tools.make_channel_code(sample_rate, measurement_type, azimuth, orientation='horizontal')[source]

Make channel code from given parameters

Parameters:
  • sample_rate (float) – sample rate in samples per second

  • measurement_type (string) – type of measurement, e.g. ‘electric’

  • orientation (float) – orientation azimuth (degrees)

Returns:

three letter channel code

Return type:

string

mt_metadata.timeseries.stationxml.fdsn_tools.read_channel_code(channel_code)[source]

read FDSN channel code

Parameters:

channel_code (string) – Three character string {Period}{Component}{Orientation}

Returns:

DESCRIPTION

Return type:

TYPE

mt_metadata.timeseries.stationxml.utils module

Created on Tue Feb 16 10:33:27 2021

copyright:

Jared Peacock (jpeacock@usgs.gov)

license:

MIT

class mt_metadata.timeseries.stationxml.utils.BaseTranslator[source]

Bases: object

Base translator for StationXML <–> MT Metadata

static flip_dict(original_dict)[source]

Flip keys and values of the dictionary

Need to take care of duplicate names and lists of names

Parameters:

original_dict (dict) – original dictionary

Returns:

reversed dictionary

Return type:

dictionary

get_comment(comments, subject)[source]

Get the correct comment from a list of comments

Parameters:
  • comments (list) – list of obspy.core.inventory.Comments

  • subject (string) – subject heading to get

Returns:

the corresponding comment

Return type:

obspy.core.inventory.Comments

make_mt_comments(mt_element, mt_key_base='mt')[source]

make comments from an MT element from self.mt_comments_list

Parameters:

mt_element – MT metadata element

mt_to_xml(value)[source]
static read_xml_comment(comment)[source]

read stationxml comment

Assuming that separate comments are split by ‘:’ and separated by a comma.

static read_xml_identifier(identifiers)[source]

Read stationxml idenfier, which is a list of doi numbers, make it into a string without the doi

Parameters:

doi (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

xml_to_mt(value)[source]

mt_metadata.timeseries.stationxml.xml_channel_mt_channel module

Created on Fri Feb 19 16:14:41 2021

copyright:

Jared Peacock (jpeacock@usgs.gov)

license:

MIT

class mt_metadata.timeseries.stationxml.xml_channel_mt_channel.XMLChannelMTChannel[source]

Bases: BaseTranslator

translate back and forth between StationXML Channel and MT Channel

mt_to_xml(mt_channel, filters_dict, hard_code=True)[source]

Translate mt_metadata.timeseries.Channel to obspy.core.inventory.Channel

Parameters:

xml_channel (mt_metadata.timeseries.Channel) – MT Channel object

Returns:

MT Channel

Return type:

obspy.core.inventory.Channel

xml_to_mt(xml_channel, existing_filters={})[source]

Translate obspy.core.inventory.Channel to mt_metadata.timeseries.Channel

Parameters:

xml_channel (obspy.core.inventory.Channel) – Obspy Channel object

Returns:

MT Channel

Return type:

mt_metadata.timeseries.Channel

mt_metadata.timeseries.stationxml.xml_equipment_mt_run module

Created on Thu Feb 18 12:49:13 2021

copyright:

Jared Peacock (jpeacock@usgs.gov)

license:

MIT

class mt_metadata.timeseries.stationxml.xml_equipment_mt_run.XMLEquipmentMTRun[source]

Bases: BaseTranslator

translate back and forth between StationXML Station and MT Station

mt_to_xml(mt_run)[source]

Convert an :class:mt_metadata.timeseries.Run` to XML equipment and comments

Parameters:

mt_run (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

xml_to_mt(equipment)[source]

Read in an equipment block.

Parameters:

equipment (obspy.core.inventory.Equipment) – an Equipment element

mt_metadata.timeseries.stationxml.xml_inventory_mt_experiment module

Created on Mon Feb 22 09:27:10 2021

copyright:

Jared Peacock (jpeacock@usgs.gov)

license:

MIT

class mt_metadata.timeseries.stationxml.xml_inventory_mt_experiment.XMLInventoryMTExperiment[source]

Bases: object

Read the full files and put the elements in the appropriate locations.

add_run(xml_station, mt_run, filters_dict)[source]

Check to see if channel information already exists in the channel list of an xml station.

Parameters:
  • xml_station (TYPE) – DESCRIPTION

  • xml_channel (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

compare_xml_channel(xml_channel_01, xml_channel_02)[source]

Compare xml channels to see if a new epoch needs to be made or not.

Parameters:
  • xml_channel_01 (TYPE) – DESCRIPTION

  • xml_channel_02 (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

mt_to_xml(mt_experiment, mt_fn=None, stationxml_fn=None, ns_dict=None)[source]

Convert from MT mt_metadata.timeseries.Experiment to obspy.core.inventory.Inventory

Parameters:
  • mt_experiment (TYPE) – DESCRIPTION

  • mt_fn (TYPE, optional) – DESCRIPTION, defaults to None

  • stationxml_fn (TYPE, optional) – DESCRIPTION, defaults to None

  • ns_dict (TYPE, optional) – DESCRIPTION, defaults to None

Raises:

ValueError – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

xml_to_mt(inventory_object=None, stationxml_fn=None, mt_fn=None)[source]

Read in a StationXML using Obspy obspy.core.inventory.Inventory and convert to an MT mt_metadata.timeseries.Experiment

Parameters:
  • inventory_object (obspy.core.inventory.Inventory) – inventory object or StationXML file name

  • stationxml_fn (Path or string) – full path to StationXML file

  • mt_fn (Path or string) – full path to MT file

Returns:

DESCRIPTION

Return type:

TYPE

mt_metadata.timeseries.stationxml.xml_network_mt_survey module

Created on Tue Feb 16 10:18:29 2021

copyright:

Jared Peacock (jpeacock@usgs.gov)

license:

MIT

class mt_metadata.timeseries.stationxml.xml_network_mt_survey.XMLNetworkMTSurvey[source]

Bases: BaseTranslator

translate back and forth between StationXML Network and MT Survey

mt_to_xml(survey, code='ZU')[source]

Convert MT Survey to Obspy Network

Note

For now the default code is ZU which is an IRIS catch-all network

xml_to_mt(network)[source]

Translate a StationXML Network object to MT Survey object

Parameters:

network (obspy.core.inventory.Network) – StationXML network element

mt_metadata.timeseries.stationxml.xml_station_mt_station module

Created on Thu Feb 18 12:49:13 2021

copyright:

Jared Peacock (jpeacock@usgs.gov)

license:

MIT

class mt_metadata.timeseries.stationxml.xml_station_mt_station.XMLStationMTStation[source]

Bases: BaseTranslator

translate back and forth between StationXML Station and MT Station

mt_to_xml(mt_station)[source]

Convert MT Survey to Obspy Network

Note

For now the default code is ZU which is an IRIS catch-all network

xml_to_mt(xml_station)[source]

Translate a StationXML station object to MT Survey object

Parameters:

station (obspy.core.inventory.station) – StationXML station element

Module contents

Tools to translate StationXML to MT Metadata

class mt_metadata.timeseries.stationxml.XMLChannelMTChannel[source]

Bases: BaseTranslator

translate back and forth between StationXML Channel and MT Channel

mt_to_xml(mt_channel, filters_dict, hard_code=True)[source]

Translate mt_metadata.timeseries.Channel to obspy.core.inventory.Channel

Parameters:

xml_channel (mt_metadata.timeseries.Channel) – MT Channel object

Returns:

MT Channel

Return type:

obspy.core.inventory.Channel

xml_to_mt(xml_channel, existing_filters={})[source]

Translate obspy.core.inventory.Channel to mt_metadata.timeseries.Channel

Parameters:

xml_channel (obspy.core.inventory.Channel) – Obspy Channel object

Returns:

MT Channel

Return type:

mt_metadata.timeseries.Channel

class mt_metadata.timeseries.stationxml.XMLEquipmentMTRun[source]

Bases: BaseTranslator

translate back and forth between StationXML Station and MT Station

mt_to_xml(mt_run)[source]

Convert an :class:mt_metadata.timeseries.Run` to XML equipment and comments

Parameters:

mt_run (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

xml_to_mt(equipment)[source]

Read in an equipment block.

Parameters:

equipment (obspy.core.inventory.Equipment) – an Equipment element

class mt_metadata.timeseries.stationxml.XMLInventoryMTExperiment[source]

Bases: object

Read the full files and put the elements in the appropriate locations.

add_run(xml_station, mt_run, filters_dict)[source]

Check to see if channel information already exists in the channel list of an xml station.

Parameters:
  • xml_station (TYPE) – DESCRIPTION

  • xml_channel (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

compare_xml_channel(xml_channel_01, xml_channel_02)[source]

Compare xml channels to see if a new epoch needs to be made or not.

Parameters:
  • xml_channel_01 (TYPE) – DESCRIPTION

  • xml_channel_02 (TYPE) – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

mt_to_xml(mt_experiment, mt_fn=None, stationxml_fn=None, ns_dict=None)[source]

Convert from MT mt_metadata.timeseries.Experiment to obspy.core.inventory.Inventory

Parameters:
  • mt_experiment (TYPE) – DESCRIPTION

  • mt_fn (TYPE, optional) – DESCRIPTION, defaults to None

  • stationxml_fn (TYPE, optional) – DESCRIPTION, defaults to None

  • ns_dict (TYPE, optional) – DESCRIPTION, defaults to None

Raises:

ValueError – DESCRIPTION

Returns:

DESCRIPTION

Return type:

TYPE

xml_to_mt(inventory_object=None, stationxml_fn=None, mt_fn=None)[source]

Read in a StationXML using Obspy obspy.core.inventory.Inventory and convert to an MT mt_metadata.timeseries.Experiment

Parameters:
  • inventory_object (obspy.core.inventory.Inventory) – inventory object or StationXML file name

  • stationxml_fn (Path or string) – full path to StationXML file

  • mt_fn (Path or string) – full path to MT file

Returns:

DESCRIPTION

Return type:

TYPE

class mt_metadata.timeseries.stationxml.XMLNetworkMTSurvey[source]

Bases: BaseTranslator

translate back and forth between StationXML Network and MT Survey

mt_to_xml(survey, code='ZU')[source]

Convert MT Survey to Obspy Network

Note

For now the default code is ZU which is an IRIS catch-all network

xml_to_mt(network)[source]

Translate a StationXML Network object to MT Survey object

Parameters:

network (obspy.core.inventory.Network) – StationXML network element

class mt_metadata.timeseries.stationxml.XMLStationMTStation[source]

Bases: BaseTranslator

translate back and forth between StationXML Station and MT Station

mt_to_xml(mt_station)[source]

Convert MT Survey to Obspy Network

Note

For now the default code is ZU which is an IRIS catch-all network

xml_to_mt(xml_station)[source]

Translate a StationXML station object to MT Survey object

Parameters:

station (obspy.core.inventory.station) – StationXML station element