Skip to main content

Archivable and exchangeable format for magnetotelluric data

Project description

MTH5

PyPI Version Conda Version MIT License Documentation Status Codecov Zenodo Binder

MTH5 is an HDF5-based data container for magnetotelluric time series data, with support for related products such as transfer functions and Fourier coefficients. The package provides tools to read, write, inspect, and manipulate MTH5 files.

MTH5 uses h5py to interact with HDF5, xarray to work with indexed time-series data and metadata together, and mt_metadata for metadata models.

This project is developed in cooperation with the Incorporated Research Institutions for Seismology, the U.S. Geological Survey, and other collaborators. Facilities of the IRIS Consortium are supported by the National Science Foundation's Seismological Facilities for the Advancement of Geoscience Award under Cooperative Support Agreement EAR-1851048. USGS support is provided in part through the Community for Data Integration and IMAGe through the Minerals Resources Program.

Features

  • Read and write HDF5 files formatted for magnetotelluric time series, transfer functions, and Fourier coefficients.
  • Create an MTH5 file and add, retrieve, or remove surveys, stations, runs, channels, filters, transfer functions, and Fourier coefficients with their associated metadata.
  • Store data in xarray objects so data and metadata stay aligned and time-indexed.
  • Read several input formats through companion I/O packages and plugins, including Z3D, NIMS BIN, USGS ASCII, LEMI, StationXML plus miniseed, Metronix (atss plus json), and Phoenix MTU5C.

Installation

Install from PyPI

python -m pip install mth5

Install from conda-forge

conda config --add channels conda-forge
conda config --set channel_priority strict
conda install mth5

Install from source

git clone https://github.com/kujaku11/mth5.git
cd mth5
python -m pip install -e .

For development dependencies:

python -m pip install -e .[dev,test]

General Usage

The typical workflow is:

  1. Open or create an MTH5 file.
  2. Add a survey, then stations, runs, and channels.
  3. Update metadata and write it back to the file.
  4. Add derived products such as transfer functions or Fourier coefficients.
  5. Reopen the file later for inspection, processing, or export.

Example:

from mth5.mth5 import MTH5

with MTH5() as mth5_object:
    mth5_object.open_mth5("example_mth5.h5", "a")

    survey_group = mth5_object.add_survey("example")

    station_group = mth5_object.add_station("mt001", survey="example")
    station_group = survey_group.stations_group.add_station("mt002")
    station_group.metadata.location.latitude = "40:05:01"
    station_group.metadata.location.longitude = -122.3432
    station_group.metadata.location.elevation = 403.1
    station_group.metadata.acquired_by.author = "me"
    station_group.metadata.orientation.reference_frame = "geomagnetic"

    station_group.write_metadata()

    run_01 = mth5_object.add_run("mt002", "001", survey="example")
    station_group.add_run("002")

    mth5_object.add_channel(
        "mt002", "001", "ex", "electric", None, survey="example"
    )
    run_01.add_channel("hy", "magnetic", None)

    station_group.transfer_functions_group.add_transfer_function("tf01")
    station_group.fourier_coefficients_group.add_fc_group("fc01")

    print(mth5_object)

Additional resources:

Project Overview

Introduction

The goal of MTH5 is to provide a self-describing hierarchical data format for working with, sharing, and archiving magnetotelluric data. The project was developed with community input and mirrors the way magnetotelluric data are collected and organized in practice.

The metadata model follows the standards proposed by the IRIS-PASSCAL MT Software Working Group and documented in MT Metadata Standards.

Code Structure

As the code base grew, some functionality was split into companion packages:

  • mt-timeseries contains the ChannelTS and RunTS objects.
  • mt-io contains readers for supported source data formats and utilities for building ChannelTS and RunTS objects.

MTH5 Format

The MTH5 hierarchy attaches metadata at each level of the file structure.

MTH5 File Version 0.1.0

MTH5 Format version 0.1.0

MTH5 file version 0.1.0 used Survey as the top-level group. That structure limited each file to a single survey. It remains relevant for archived files and historical reference, including datasets already stored in ScienceBase and files used by Aurora.

MTH5 File Version 0.2.0

MTH5 Format version 0.2.0

MTH5 file version 0.2.0 uses Experiment as the top-level group. This allows multiple surveys to coexist in a single file, which makes cross-survey workflows such as remote reference processing easier to manage.

MTH5 is comprehensively logged. If problems arise, check mth5_debug.log when debug mode is enabled in mth5.__init__, and mth5_error.log in your current working directory.

Contributing

Contributions are welcome in the form of bug reports, feature requests, documentation improvements, and pull requests.

To start contributing:

  1. Fork the repository.
  2. Create a local clone.
  3. Install the package in editable mode with development dependencies.
  4. Create a feature branch.
  5. Run formatting and tests before opening a pull request.

Typical local setup:

git clone https://github.com/your-username/mth5.git
cd mth5
python -m pip install -e .[dev,test]
pytest -n auto tests -k "not slow"

See CONTRIBUTING.rst for the full contribution workflow and project expectations.

Raising Issues

Use the GitHub issue tracker for:

  • Bug reports
  • Feature requests
  • Documentation problems
  • Questions about unexpected behavior

When opening an issue, include:

  • Your operating system and Python version
  • The MTH5 version you are using
  • A minimal reproducible example or the exact steps to reproduce the problem
  • Any relevant error messages, logs, or sample data details

Credits

This project is developed in cooperation with the Incorporated Research Institutions for Seismology, the U.S. Geological Survey, and other collaborators. Facilities of the IRIS Consortium are supported by the National Science Foundation's Seismological Facilities for the Advancement of Geoscience Award under Cooperative Support Agreement EAR-1851048. USGS support is provided in part through the Community for Data Integration and IMAGe through the Minerals Resources Program.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mth5-0.6.6.tar.gz (24.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mth5-0.6.6-py3-none-any.whl (7.3 MB view details)

Uploaded Python 3

File details

Details for the file mth5-0.6.6.tar.gz.

File metadata

  • Download URL: mth5-0.6.6.tar.gz
  • Upload date:
  • Size: 24.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for mth5-0.6.6.tar.gz
Algorithm Hash digest
SHA256 cb34e5640f0a2e5d4836cb1b2113ec43fd806b2bac07a6e0ad34e811f0c0c99b
MD5 ad9c6772d3772efec8aea4bb40d82754
BLAKE2b-256 4f912a5b15cbf5c15af7990d5a9e527ec5a4a0ea90b106acfdd118340068416e

See more details on using hashes here.

File details

Details for the file mth5-0.6.6-py3-none-any.whl.

File metadata

  • Download URL: mth5-0.6.6-py3-none-any.whl
  • Upload date:
  • Size: 7.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for mth5-0.6.6-py3-none-any.whl
Algorithm Hash digest
SHA256 eef0ff5ba1a2c36b3a2cf8920e03b88b0f6ffc99603e588f348871496ddb9298
MD5 bf8c7d11eb7a177c92e442eb8676ce41
BLAKE2b-256 4ba6307b80ce9f97df613915701b972dac1f5cf490527494feb004e865878874

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page