mth5.utils package

Submodules

mth5.utils.exceptions module

Exceptions raised by MTH5

Created on Wed May 13 19:07:21 2020

@author: jpeacock

exception mth5.utils.exceptions.MTH5Error[source]

Bases: Exception

exception mth5.utils.exceptions.MTH5TableError[source]

Bases: Exception

exception mth5.utils.exceptions.MTSchemaError[source]

Bases: Exception

exception mth5.utils.exceptions.MTTSError[source]

Bases: Exception

exception mth5.utils.exceptions.MTTimeError[source]

Bases: Exception

mth5.utils.fdsn_tools module

Tools for FDSN standards

Created on Wed Sep 30 11:47:01 2020

author

Jared Peacock

license

MIT

mth5.utils.fdsn_tools.get_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

mth5.utils.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

mth5.utils.fdsn_tools.get_orientation_code(azimuth, 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

Returns

single character SEED orientation code

Return type

string

mth5.utils.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

mth5.utils.fdsn_tools.make_channel_code(channel_obj)[source]

Make the 3 character SEED channel code

Parameters

channel_obj (Channel) – Channel metadata

Returns

3 character channel code

Type

string

mth5.utils.fdsn_tools.make_mt_channel(code_dict, angle_tol=15)[source]
Parameters

code_dict (TYPE) – DESCRIPTION

Returns

DESCRIPTION

Return type

TYPE

mth5.utils.fdsn_tools.read_channel_code(channel_code)[source]

read FDSN channel code

Parameters

channel_code (TYPE) – DESCRIPTION

Returns

DESCRIPTION

Return type

TYPE

mth5.utils.helpers module

mth5.utils.helpers.initialize_mth5(h5_path, mode='a', file_version='0.1.0')[source]

mth5 initializer for the case of writting files.

Parameters
  • h5_path (string or pathlib.Path) – path to file

  • mode (string) –

    how to open the file, options are

    • ”r”: read

    • ”w”: write

    • ”a”: append

Returns

mth5 object

Return type

mth5.MTH5

mth5.utils.helpers.read_back_data(mth5_path, station_id, run_id, survey=None, close_mth5=True, return_objects=[])[source]

Testing helper function, used to confirm that the h5 file can be accessed and that the data size is as expected.

Parameters
  • mth5_path (Path or string) – the full path the the mth5 that this method is going to try to read

  • station_id (string) – the label for the station, e.g. “PKD”

  • run_id (string) – The label for the run to read. e.g. “001”

  • survey (string) – The label for the survey associated with the run to read.

  • close_mth5 (bool) – Whether or not to close the mth5 object after reading

  • return_objects – List of strings. Specifies what, if anything to return.

Allowed values: [“run”, “run_ts”] :type return_objects: List of strings. :return: run object :rtype: mth5.groups.RunGroup :return: run time series :rtype: mth5.timeseries.RunTS

mth5.utils.mth5_logger module

Logger

Setup a logger with two handlers to remove redundancy between logs entries One is a stream handler for any messages to the console. The other is either a file handler or a null handler.

mth5.utils.mth5_logger.load_logging_config(config_fn=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mth5/checkouts/stable/mth5/utils/logging_config.yaml'))[source]

configure/setup the logging according to the input configfile

Parameters

configfile – .yml, .ini, .conf, .json, .yaml.

Its default is the logging.yml located in the same dir as this module. It can be modofied to use env variables to search for a log config file.

mth5.utils.mth5_logger.setup_logger(logger_name, fn=None, level='debug')[source]

Create a logger, can write to a separate file. This will write to the logs folder in the mt_metadata directory.

Parameters
  • logger_name (string) – name of the logger, typically __name__

  • fn (TYPE, optional) – file name to write to, defaults to None

  • level (TYPE, optional) – DESCRIPTION, defaults to “debug”

Returns

DESCRIPTION

Return type

TYPE

Module contents