mth5

Top-level package for MTH5.

Submodules

Attributes

config

CHUNK_SIZE

ACCEPTABLE_FILE_TYPES

ACCEPTABLE_FILE_SUFFIXES

ACCEPTABLE_FILE_VERSIONS

ACCEPTABLE_DATA_LEVELS

TF_DTYPE_LIST

TF_DTYPE

CHANNEL_DTYPE_LIST

CHANNEL_DTYPE

FC_DTYPE_LIST

FC_DTYPE

RUN_SUMMARY_LIST

RUN_SUMMARY_DTYPE

RUN_SUMMARY_COLUMNS

STANDARDS_DTYPE_LIST

STANDARDS_DTYPE

Functions

read_file(→ Any)

Universal reader for magnetotelluric time series data files.

Package Contents

mth5.read_file(fn: str | pathlib.Path | list[str | pathlib.Path], file_type: str | None = None, **kwargs: Any) Any[source]

Universal reader for magnetotelluric time series data files.

Automatically detects the file type based on extension and dispatches to the appropriate reader function. Supports both single files and lists of files for multi-file formats.

Parameters:
  • fn (str, Path, or list of str/Path) – Full path(s) to data file(s) to be read. For multi-file formats, pass a list of file paths.

  • file_type (str, optional) – Specific reader type to use if file extension is ambiguous. Must be one of the keys in the readers registry, by default None

  • **kwargs (dict) – Additional keyword arguments passed to the specific reader function. Supported arguments depend on the file format and reader.

Returns:

Time series object containing the data: - mth5.timeseries.MTTS for single channel data - mth5.timeseries.RunTS for multi-channel run data

Return type:

MTTS or RunTS

Raises:
  • IOError – If any specified file does not exist

  • KeyError – If the specified file_type is not supported

  • ValueError – If no reader can be found for the file extension

Examples

Read a single Z3D file (auto-detected)

>>> data = read_file("/path/to/station_001.z3d")
>>> print(type(data))  # <class 'mth5.timeseries.ChannelTS'>

Read with explicit file type for ambiguous extensions

>>> data = read_file("/path/to/data.bin", file_type="nims")
>>> print(data.n_channels)

Read multiple files for a multi-file format

>>> files = ["/path/to/file1.asc", "/path/to/file2.asc"]
>>> run_data = read_file(files, sample_rate=1.0)

Notes

Supported file types and extensions: - zen: .z3d (Zonge Z3D files) - nims: .bin, .bnn (USGS NIMS files) - usgs_ascii: .asc, .zip (USGS ASCII format) - miniseed: .miniseed, .ms, .mseed (miniSEED format) - lemi424: .txt (LEMI-424 format) - phoenix: .bin, .td_30, .td_150, .td_24k (Phoenix formats) - metronix: .atss (Metronix ADU format)

For ambiguous extensions like .bin, specify file_type explicitly.

mth5.config[source]
mth5.CHUNK_SIZE = 8196[source]
mth5.ACCEPTABLE_FILE_TYPES = ['mth5', 'MTH5', 'h5', 'H5'][source]
mth5.ACCEPTABLE_FILE_SUFFIXES[source]
mth5.ACCEPTABLE_FILE_VERSIONS = ['0.1.0', '0.2.0'][source]
mth5.ACCEPTABLE_DATA_LEVELS = [0, 1, 2, 3][source]
mth5.TF_DTYPE_LIST[source]
mth5.TF_DTYPE[source]
mth5.CHANNEL_DTYPE_LIST[source]
mth5.CHANNEL_DTYPE[source]
mth5.FC_DTYPE_LIST[source]
mth5.FC_DTYPE[source]
mth5.RUN_SUMMARY_LIST[source]
mth5.RUN_SUMMARY_DTYPE[source]
mth5.RUN_SUMMARY_COLUMNS[source]
mth5.STANDARDS_DTYPE_LIST[source]
mth5.STANDARDS_DTYPE[source]