pyatoa.utils.form

Formatting functionality

Pyatoa relies on data structure being ordered and consistent throughout all the various bits of data required, as well as a few standardized string formatters to keep everything playing nice. Functions here will aid in reshaping data into the correct formats.

Module Contents

Functions

channel_code(dt)

Specfem outputs seismograms with channel band codes set by IRIS. Instrument

format_iter(iteration)

Format the iteration to be used in internal path naming and labelling.

format_step(count)

Same as for iteration but step count is formatted with a leading 's'

format_event_name(ds_or_event)

Formalize the definition of Event ID in Pyatoa

pyatoa.utils.form.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

pyatoa.utils.form.format_iter(iteration)[source]

Format the iteration to be used in internal path naming and labelling. Standard is to format with a leading ‘i’ character followed by two digits. Inputs can be strings or integers. Assumes iterations won’t go above 99.

Parameters:

iteration (str or int) – input model number, e.g. 0, ‘0’, ‘i0’, ‘i00’

Return type:

str

Returns:

formatted model number, e.g. ‘i00’, or None if no matching format

pyatoa.utils.form.format_step(count)[source]

Same as for iteration but step count is formatted with a leading ‘s’

Parameters:

count (str or int) – input model number, e.g. 0, ‘0’, ‘s0’, ‘s00’

Return type:

str

Returns:

formatted model number, e.g. ‘s00’, or None if no matching format

pyatoa.utils.form.format_event_name(ds_or_event)[source]

Formalize the definition of Event ID in Pyatoa

Parameters:

ds_or_event (pyasdf.ASDFDataSet or obspy.core.event.Event or str) – get dataset event name from the event resource_id

Return type:

str

Returns:

the event name to be used for naming schema in the workflow