This example will demonstrate how to make a single MTH5 file from various different data types.
from pathlib import Path
from mth5.clients.make_mth5 import MakeMTH5
from mth5.mth5 import MTH5
# test data paths
from mth5_test_data import get_test_data_path
Create a Base MakeMTH5 object¶
Here we are creating a base MakeMTH5 object and set some parameters. The key parameters to set for this example is mth5_file_mode. Here we set it to 'a' which means append mode, which will append to an existing file rather than 'w' which will overwrite an existing file.
We also set the file version to '0.2.0' so that we can have multiple surveys contained within a single file.
base_maker = MakeMTH5(
save_path=Path.cwd(),
mth5_file_mode="a", # need to set the file mode here to append to an existing file
mth5_version="0.2.0",
mth5_filename="example_make_mth5_all.h5",
)
base_kwargs = base_maker.get_h5_kwargs()
base_kwargs["mth5_filename"] = base_maker.mth5_filename
base_kwargs["save_path"] = base_maker.save_path
base_kwargs{'mth5_version': '0.2.0',
'h5_compression': 'gzip',
'h5_compression_opts': 4,
'h5_shuffle': True,
'h5_fletcher32': True,
'h5_data_level': 1,
'mth5_file_mode': 'a',
'mth5_filename': 'example_make_mth5_all.h5',
'save_path': WindowsPath('c:/Users/peaco/OneDrive/Documents/GitHub/mth5/docs/examples/notebooks')}Add Miniseed + StationXML¶
Add data archived at Earthscope as miniseed and StationXML files.
miniseed_path = get_test_data_path("miniseed")
station_xml_path = miniseed_path / Path("cas04_stationxml.xml")
streams_path = miniseed_path / Path("cas_04_streams.mseed")
mth5_fn_path = MakeMTH5.from_fdsn_miniseed_and_stationxml(
station_xml_path,
[streams_path],
**base_kwargs,
)2026-01-20T21:44:47.647294-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_si_units to a CoefficientFilter.
2026-01-20T21:44:47.654680-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_dipole_92.000 to a CoefficientFilter.
2026-01-20T21:44:47.664083-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_si_units to a CoefficientFilter.
2026-01-20T21:44:47.664083-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_dipole_92.000 to a CoefficientFilter.
2026-01-20T21:44:47.675511-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_si_units to a CoefficientFilter.
2026-01-20T21:44:47.675511-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_dipole_92.000 to a CoefficientFilter.
2026-01-20T21:44:47.682786-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_si_units to a CoefficientFilter.
2026-01-20T21:44:47.687764-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_dipole_92.000 to a CoefficientFilter.
2026-01-20T21:44:47.698835-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_si_units to a CoefficientFilter.
2026-01-20T21:44:47.702281-0800 | INFO | mt_metadata.timeseries.filters.obspy_stages | create_filter_from_stage | line: 138 | Converting PoleZerosResponseStage electric_dipole_92.000 to a CoefficientFilter.
Using user defined mth5 file name example_make_mth5_all.h5
2026-01-20T21:44:48.205956-0800 | INFO | mth5.mth5 | _initialize_file | line: 773 | Initialized MTH5 0.2.0 file c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5 in mode a
2026-01-20T21:44:58.120194-0800 | INFO | mth5.groups.base | _add_group | line: 633 | RunGroup a already exists, returning existing group.
2026-01-20T21:45:00.000857-0800 | WARNING | mth5.timeseries.run_ts | _validate_array_list | line: 518 | Station ID CAS04 from ChannelTS does not match original station ID {self.station_metadata.id}. Updating ID to match.
2026-01-20T21:45:00.016747-0800 | WARNING | mth5.timeseries.run_ts | validate_metadata | line: 1035 | start time of dataset 2020-06-02T19:00:00+00:00 does not match metadata start 2020-06-02T18:41:43+00:00 updating metatdata value to 2020-06-02T19:00:00+00:00
2026-01-20T21:45:00.158027-0800 | WARNING | mth5.timeseries.run_ts | validate_metadata | line: 1035 | start time of dataset 2020-06-02T19:00:00+00:00 does not match metadata start 2020-06-02T18:41:43+00:00 updating metatdata value to 2020-06-02T19:00:00+00:00
2026-01-20T21:45:02.450685-0800 | INFO | mth5.groups.base | _add_group | line: 633 | RunGroup b already exists, returning existing group.
2026-01-20T21:45:04.566210-0800 | WARNING | mth5.timeseries.run_ts | _validate_array_list | line: 518 | Station ID CAS04 from ChannelTS does not match original station ID {self.station_metadata.id}. Updating ID to match.
2026-01-20T21:45:06.910326-0800 | INFO | mth5.groups.base | _add_group | line: 633 | RunGroup c already exists, returning existing group.
2026-01-20T21:45:09.299458-0800 | WARNING | mth5.timeseries.run_ts | _validate_array_list | line: 518 | Station ID CAS04 from ChannelTS does not match original station ID {self.station_metadata.id}. Updating ID to match.
2026-01-20T21:45:12.000177-0800 | INFO | mth5.groups.base | _add_group | line: 633 | RunGroup d already exists, returning existing group.
2026-01-20T21:45:14.057773-0800 | WARNING | mth5.timeseries.run_ts | _validate_array_list | line: 518 | Station ID CAS04 from ChannelTS does not match original station ID {self.station_metadata.id}. Updating ID to match.
2026-01-20T21:45:14.071887-0800 | WARNING | mth5.timeseries.run_ts | validate_metadata | line: 1045 | end time of dataset 2020-07-13T19:00:00+00:00 does not match metadata end 2020-07-13T21:46:12+00:00 updating metatdata value to 2020-07-13T19:00:00+00:00
2026-01-20T21:45:14.199518-0800 | WARNING | mth5.timeseries.run_ts | validate_metadata | line: 1045 | end time of dataset 2020-07-13T19:00:00+00:00 does not match metadata end 2020-07-13T21:46:12+00:00 updating metatdata value to 2020-07-13T19:00:00+00:00
2026-01-20T21:45:16.452358-0800 | INFO | mth5.mth5 | close_mth5 | line: 896 | Flushing and closing c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
Add LEMI¶
Add some LEMI-424 data.
lemi_path = get_test_data_path("lemi")
mth5_fn_path = MakeMTH5.from_lemi424(
lemi_path,
survey_id="lemi_424_survey",
station_id="lemi_424_station",
**base_kwargs,
)2026-01-20T21:45:16.477249-0800 | WARNING | mth5.io.lemi.lemi_collection | to_dataframe | line: 155 | No calibration files found in C:\Users\peaco\OneDrive\Documents\GitHub\mth5_test_data\mth5_test_data\lemi, proceeding without calibrations.
2026-01-20T21:45:22.172799-0800 | INFO | mth5.mth5 | close_mth5 | line: 896 | Flushing and closing c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
Add Metronix Data¶
metronix_path = get_test_data_path("metronix")
mth5_fn_path = MakeMTH5.from_metronix(
metronix_path,
sample_rates=[32],
**base_kwargs,
)2026-01-20T21:45:25.994620-0800 | INFO | mth5.mth5 | close_mth5 | line: 896 | Flushing and closing c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
2026-01-20T21:45:26.009925-0800 | INFO | mth5.clients.metronix | make_mth5_from_metronix | line: 125 | Wrote MTH5 file to: c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
Add Phoenix MTU-5C Data¶
Add phoenix MTU-5C data (newer data type)
phoenix_path = get_test_data_path("phoenix") / "sample_data"
mth5_fn_path = MakeMTH5.from_phoenix(
phoenix_path,
sample_rates=[150, 24000],
receiver_calibration_dict=Path(
phoenix_path / "10128_rxcal.json"
),
sensor_calibration_dict=Path(
phoenix_path / "101_sensor.scal.json"
),
**base_kwargs,
)2026-01-20T21:45:26.405954-0800 | WARNING | mth5.io.phoenix.phoenix_collection | to_dataframe | line: 292 | Could not read file C:\Users\peaco\OneDrive\Documents\GitHub\mth5_test_data\mth5_test_data\phoenix\sample_data\10128_2021-04-27-032436\0\10128_608783F4_0_00000002.td_24k, SKIPPING
2026-01-20T21:45:26.489380-0800 | WARNING | mth5.io.phoenix.phoenix_collection | to_dataframe | line: 292 | Could not read file C:\Users\peaco\OneDrive\Documents\GitHub\mth5_test_data\mth5_test_data\phoenix\sample_data\10128_2021-04-27-032436\1\10128_608783F4_1_00000002.td_24k, SKIPPING
2026-01-20T21:45:26.530796-0800 | WARNING | mth5.io.phoenix.phoenix_collection | to_dataframe | line: 292 | Could not read file C:\Users\peaco\OneDrive\Documents\GitHub\mth5_test_data\mth5_test_data\phoenix\sample_data\10128_2021-04-27-032436\2\10128_608783F4_2_00000002.td_24k, SKIPPING
2026-01-20T21:45:26.603901-0800 | WARNING | mth5.io.phoenix.phoenix_collection | to_dataframe | line: 292 | Could not read file C:\Users\peaco\OneDrive\Documents\GitHub\mth5_test_data\mth5_test_data\phoenix\sample_data\10128_2021-04-27-032436\4\10128_608783F4_4_00000002.td_24k, SKIPPING
2026-01-20T21:45:30.973004-0800 | INFO | mth5.mth5 | close_mth5 | line: 896 | Flushing and closing c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
Add Phoenix Legacy Data¶
TODO
Add Zen Data¶
zen_data_path = get_test_data_path("zen")
mth5_fn_path = MakeMTH5.from_zen(
zen_data_path,
calibration_path=None, # "path_to_calibration_file_amtant.cal",
survey_id="zen_survey",
combine=False,
**base_kwargs,
)2026-01-20T21:45:37.655192-0800 | INFO | mth5.mth5 | close_mth5 | line: 896 | Flushing and closing c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
2026-01-20T21:45:37.660056-0800 | INFO | mth5.clients.zen | make_mth5_from_zen | line: 170 | Wrote MTH5 file to: c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
Add NIMS Data¶
nims_data_path = get_test_data_path("nims")
mth5_fn_path = MakeMTH5.from_nims(
nims_data_path,
survey_id="nims_survey",
**base_kwargs,
)2026-01-20T21:45:37.674524-0800 | WARNING | mth5.io.nims.nims | end_time | line: 364 | Estimating end time from n_samples
2026-01-20T21:45:37.676573-0800 | WARNING | mth5.io.nims.nims | end_time | line: 364 | Estimating end time from n_samples
2026-01-20T21:45:44.155393-0800 | WARNING | mth5.io.nims.nims | read_nims | line: 1240 | odd number of bytes 54971209, not even blocks cutting down the data by 72 bits
2026-01-20T21:45:54.519383-0800 | INFO | mth5.mth5 | close_mth5 | line: 896 | Flushing and closing c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
File Contents¶
Now that all the data is loaded in lets have a look at the contents. We will print the outline of the file, the channel summary, and the run summary.
with MTH5() as m:
m = m.open_mth5(mth5_fn_path, mode="r")
print(m)
channel_df = m.channel_summary.to_dataframe()
run_df = m.run_summary/:
====================
|- Group: Experiment
--------------------
|- Group: Reports
-----------------
|- Group: Standards
-------------------
--> Dataset: summary
......................
|- Group: Surveys
-----------------
|- Group: 20_Hz_1V_Sine_wave_test
---------------------------------
|- Group: Filters
-----------------
|- Group: coefficient
---------------------
|- Group: dipole_100m
---------------------
|- Group: v_to_mv
-----------------
|- Group: fap
-------------
|- Group: mtu-5c_rmt03-g_10409_666
----------------------------------
--> Dataset: fap_table
........................
|- Group: mtu-5c_rmt03_10128_e1_10000hz_lowpass
-----------------------------------------------
--> Dataset: fap_table
........................
|- Group: mtu-5c_rmt03_10128_e2_10000hz_lowpass
-----------------------------------------------
--> Dataset: fap_table
........................
|- Group: mtu-5c_rmt03_10128_h1_10000hz_lowpass
-----------------------------------------------
--> Dataset: fap_table
........................
|- Group: mtu-5c_rmt03_10128_h2_10000hz_lowpass
-----------------------------------------------
--> Dataset: fap_table
........................
|- Group: fir
-------------
|- Group: time_delay
--------------------
|- Group: zpk
-------------
|- Group: Reports
-----------------
|- Group: Standards
-------------------
--> Dataset: summary
......................
|- Group: Stations
------------------
|- Group: Masked_Cordinates
---------------------------
|- Group: Features
------------------
|- Group: Fourier_Coefficients
------------------------------
|- Group: Transfer_Functions
----------------------------
|- Group: sr150_0001
--------------------
--> Dataset: e1
.................
--> Dataset: e2
.................
--> Dataset: h1
.................
--> Dataset: h2
.................
|- Group: sr24k_0001
--------------------
--> Dataset: e1
.................
--> Dataset: e2
.................
--> Dataset: h1
.................
--> Dataset: h2
.................
|- Group: CONUS_South
---------------------
|- Group: Filters
-----------------
|- Group: coefficient
---------------------
|- Group: electric_analog_to_digital
------------------------------------
|- Group: electric_dipole_92.000
--------------------------------
|- Group: electric_si_units
---------------------------
|- Group: magnetic_analog_to_digital
------------------------------------
|- Group: fap
-------------
|- Group: fir
-------------
|- Group: time_delay
--------------------
|- Group: electric_time_offset
------------------------------
|- Group: hx_time_offset
------------------------
|- Group: hy_time_offset
------------------------
|- Group: hz_time_offset
------------------------
|- Group: zpk
-------------
|- Group: electric_butterworth_high_pass_30000
----------------------------------------------
--> Dataset: poles
....................
--> Dataset: zeros
....................
|- Group: electric_butterworth_low_pass
---------------------------------------
--> Dataset: poles
....................
--> Dataset: zeros
....................
|- Group: magnetic_butterworth_low_pass
---------------------------------------
--> Dataset: poles
....................
--> Dataset: zeros
....................
|- Group: Reports
-----------------
|- Group: Standards
-------------------
--> Dataset: summary
......................
|- Group: Stations
------------------
|- Group: CAS04
---------------
|- Group: Features
------------------
|- Group: Fourier_Coefficients
------------------------------
|- Group: Transfer_Functions
----------------------------
|- Group: a
-----------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
|- Group: b
-----------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
|- Group: c
-----------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
|- Group: d
-----------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
|- Group: Northern_Mining
-------------------------
|- Group: Filters
-----------------
|- Group: coefficient
---------------------
|- Group: fap
-------------
|- Group: mfs-06_chopper_1
--------------------------
--> Dataset: fap_table
........................
|- Group: fir
-------------
|- Group: time_delay
--------------------
|- Group: zpk
-------------
|- Group: Reports
-----------------
|- Group: Standards
-------------------
--> Dataset: summary
......................
|- Group: Stations
------------------
|- Group: saricam
-----------------
|- Group: Features
------------------
|- Group: Fourier_Coefficients
------------------------------
|- Group: Transfer_Functions
----------------------------
|- Group: run_002
-----------------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
|- Group: lemi_424_survey
-------------------------
|- Group: Filters
-----------------
|- Group: coefficient
---------------------
|- Group: fap
-------------
|- Group: fir
-------------
|- Group: time_delay
--------------------
|- Group: zpk
-------------
|- Group: Reports
-----------------
|- Group: Standards
-------------------
--> Dataset: summary
......................
|- Group: Stations
------------------
|- Group: lemi_424_station
--------------------------
|- Group: Features
------------------
|- Group: Fourier_Coefficients
------------------------------
|- Group: Transfer_Functions
----------------------------
|- Group: sr1_0001
------------------
--> Dataset: bx
.................
--> Dataset: by
.................
--> Dataset: bz
.................
--> Dataset: e1
.................
--> Dataset: e2
.................
--> Dataset: temperature_e
............................
--> Dataset: temperature_h
............................
|- Group: sr1_0002
------------------
--> Dataset: bx
.................
--> Dataset: by
.................
--> Dataset: bz
.................
--> Dataset: e1
.................
--> Dataset: e2
.................
--> Dataset: temperature_e
............................
--> Dataset: temperature_h
............................
|- Group: nims_survey
---------------------
|- Group: Filters
-----------------
|- Group: coefficient
---------------------
|- Group: dipole_101.00
-----------------------
|- Group: dipole_106.00
-----------------------
|- Group: dipole_109.00
-----------------------
|- Group: e_analog_to_digital
-----------------------------
|- Group: h_analog_to_digital
-----------------------------
|- Group: to_mt_units
---------------------
|- Group: fap
-------------
|- Group: fir
-------------
|- Group: time_delay
--------------------
|- Group: ex_time_offset
------------------------
|- Group: ey_time_offset
------------------------
|- Group: hx_time_offset
------------------------
|- Group: hy_time_offset
------------------------
|- Group: hz_time_offset
------------------------
|- Group: zpk
-------------
|- Group: nims_1_pole_butterworth
---------------------------------
--> Dataset: poles
....................
--> Dataset: zeros
....................
|- Group: nims_3_pole_butterworth
---------------------------------
--> Dataset: poles
....................
--> Dataset: zeros
....................
|- Group: nims_5_pole_butterworth
---------------------------------
--> Dataset: poles
....................
--> Dataset: zeros
....................
|- Group: Reports
-----------------
|- Group: Standards
-------------------
--> Dataset: summary
......................
|- Group: Stations
------------------
|- Group: 300
-------------
|- Group: 300b
--------------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
--> Dataset: temperature
..........................
|- Group: Features
------------------
|- Group: Fourier_Coefficients
------------------------------
|- Group: Transfer_Functions
----------------------------
|- Group: Mnp300
----------------
|- Group: Features
------------------
|- Group: Fourier_Coefficients
------------------------------
|- Group: Mnp300a
-----------------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
--> Dataset: temperature
..........................
|- Group: Transfer_Functions
----------------------------
|- Group: zen_survey
--------------------
|- Group: Filters
-----------------
|- Group: coefficient
---------------------
|- Group: dipole_55.00m
-----------------------
|- Group: dipole_56.00m
-----------------------
|- Group: zen_counts2mv
-----------------------
|- Group: fap
-------------
|- Group: ant4_2314_response
----------------------------
--> Dataset: fap_table
........................
|- Group: ant4_2324_response
----------------------------
--> Dataset: fap_table
........................
|- Group: ant4_2334_response
----------------------------
--> Dataset: fap_table
........................
|- Group: fir
-------------
|- Group: time_delay
--------------------
|- Group: zpk
-------------
|- Group: Reports
-----------------
|- Group: Standards
-------------------
--> Dataset: summary
......................
|- Group: Stations
------------------
|- Group: 100
-------------
|- Group: Features
------------------
|- Group: Fourier_Coefficients
------------------------------
|- Group: Transfer_Functions
----------------------------
|- Group: sr256_0002
--------------------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
|- Group: sr4096_0001
---------------------
--> Dataset: ex
.................
--> Dataset: ey
.................
--> Dataset: hx
.................
--> Dataset: hy
.................
--> Dataset: hz
.................
--> Dataset: channel_summary
..............................
--> Dataset: fc_summary
.........................
--> Dataset: tf_summary
.........................
2026-01-20T21:49:02.109752-0800 | INFO | mth5.mth5 | close_mth5 | line: 896 | Flushing and closing c:\Users\peaco\OneDrive\Documents\GitHub\mth5\docs\examples\notebooks\example_make_mth5_all.h5
display(channel_df.head(65))display(run_df)