pysep.utils.fmt
¶
Pysep-specific formatting functions
Module Contents¶
Functions¶
|
Specfem outputs seismograms with channel band codes set by IRIS. Instrument |
|
Get station codes from the internal stream attribute, where station |
|
Determine data availability based on whether stations are 'on' for a |
|
Generate a unique event tag based on event origin time and location using |
|
Generate a unique event tag based on the event time. This was how the |
|
ObsPy Catalog does not allow indexing by a list of values |
- pysep.utils.fmt.channel_code(dt)[source]¶
Specfem outputs seismograms with channel band codes set by IRIS. Instrument codes are always X for synthetics, but band code will vary with the sampling rate of the data, return the correct code given a sampling rate. Taken from Appenix B of the Specfem3D cartesian manual (June 15, 2018)
- Parameters:
dt (float) – sampling rate of the data in seconds
- Return type:
str
- Returns:
band code as specified by Iris
- Raises:
KeyError – when dt is specified incorrectly
- pysep.utils.fmt.get_codes(st=None, choice=None, suffix=None, up_to=True)[source]¶
Get station codes from the internal stream attribute, where station codes are formatted NN.SSS.LL.CCc where N=network, S=station, L=location, C=channel, and c=component
- Parameters:
st (obspy.core.stream.Stream) – Stream to get codes from by running: tr.get_id()
choice (str) – choice of the part of the code returned, available: * ‘network’: return unique network codes (e.g., NN) * ‘station’: return unique network + station codes (e.g., NN.SSS) * ‘location’: return up to location (e.g., NN.SSS.LL) * ‘channel’: return up to channel, no component (e.g., NN.SSS.LL.CC) * else: return full station code (e.g., NN.SSS.LL.CCc)
suffix (str) – append a string suffix to the end of each code. Used to place wildcards at the end of a code, e.g., `suffix`==’?’ with `choice`==’channel’ will give codes like NN.SSS.LL.CC?
up_to (bool) – if True gives code up to the choice, e.g., choice`==’station’ would return NN.SSS. If False, returns only `choice code, so e.g., SSS for `choice`==’station’
- Return type:
list
- Returns:
unique station codes filtered by choice
- pysep.utils.fmt.get_data_availability(cat, inv)[source]¶
Determine data availability based on whether stations are ‘on’ for a given event origin time. Does not check waveforms, only station metadata, so not foolproof.
- Parameters:
cat (obspy.core.catalog.Catalog) – Catalog of events to consider. Events must include origin information latitude and longitude
inv (obspy.core.inventory.Inventory) – Inventory of stations to consider
- Return type:
dict
- Returns:
keys are event resource ids and values are IDs for stations that were on during the event origin time
- pysep.utils.fmt.format_event_tag(event)[source]¶
Generate a unique event tag based on event origin time and location using Flinn Engdahl regions
- Parameters:
event (obspy.core.event.Event) – event to generate tag from
- Return type:
str
- Returns:
event_name + FE region
- pysep.utils.fmt.format_event_tag_legacy(event)[source]¶
Generate a unique event tag based on the event time. This was how the previous version of PySEP named directories and files. Replaces the old otime2eid from util_helpers
- Parameters:
event (obspy.core.event.Event) – event to generate tag from
- Return type:
str
- Returns:
event_name specified by event time
- pysep.utils.fmt.index_cat(cat, idxs)[source]¶
ObsPy Catalog does not allow indexing by a list of values (e.g., cat[0, 1, 3]) so this convenience function takes care of that by forming a new catalog of events chosen by indices
- Parameters:
idxs (list of int) – list of indices to index catalog by
cat (obspy.core.catalog.Catalog) – Catalog to index. If not given defaults to internal Cat