mth5
Top-level package for MTH5.
Submodules
Attributes
Functions
|
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.MTTSfor single channel data -mth5.timeseries.RunTSfor 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.