mth5.io.metronix.metronix_metadata

Metronix metadata parsing utilities.

This module provides classes for parsing and managing metadata from Metronix ATSS (Audio Time Series System) files and associated JSON metadata files.

Classes

MetronixFileNameMetadata

Parse metadata from Metronix filename conventions

MetronixChannelJSON

Read and parse Metronix JSON metadata files

Created on Fri Nov 22 13:23:42 2024

@author: jpeacock

Classes

MetronixFileNameMetadata

Parse and manage metadata from Metronix filename conventions.

MetronixChannelJSON

Read and parse Metronix JSON metadata files.

Module Contents

class mth5.io.metronix.metronix_metadata.MetronixFileNameMetadata(fn: str | pathlib.Path | None = None, **kwargs: Any)[source]

Parse and manage metadata from Metronix filename conventions.

This class extracts metadata information from Metronix ATSS filenames including system information, channel details, and file properties.

Parameters:
  • fn (Union[str, Path, None], optional) – Path to Metronix file, by default None

  • **kwargs – Additional keyword arguments (currently unused)

system_number[source]

System identification number

Type:

str or None

system_name[source]

Name of the system

Type:

str or None

channel_number[source]

Channel number (parsed from C## format)

Type:

int or None

component[source]

Component designation (e.g., ‘ex’, ‘ey’, ‘hx’, ‘hy’, ‘hz’)

Type:

str or None

sample_rate[source]

Sampling rate in Hz

Type:

float or None

file_type[source]

Type of file (‘metadata’ or ‘timeseries’)

Type:

str or None

system_number: str | None = None[source]
system_name: str | None = None[source]
channel_number: int | None = None[source]
component: str | None = None[source]
sample_rate: float | None = None[source]
file_type: str | None = None[source]
property fn: pathlib.Path | None[source]

Get the file path.

Returns:

File path object or None if not set

Return type:

Path or None

property fn_exists: bool[source]

Check if the file exists.

Returns:

True if file exists, False otherwise

Return type:

bool

property file_size: int[source]

Get file size in bytes.

Returns:

File size in bytes, 0 if file is None

Return type:

int

property n_samples: float[source]

Get estimated number of samples in file.

Assumes 8 bytes per sample (double precision).

Returns:

Estimated number of samples

Return type:

float

property duration: float[source]

Get estimated duration of the file in seconds.

Returns:

Duration in seconds

Return type:

float

class mth5.io.metronix.metronix_metadata.MetronixChannelJSON(fn: str | pathlib.Path | None = None, **kwargs: Any)[source]

Bases: MetronixFileNameMetadata

Read and parse Metronix JSON metadata files.

This class extends MetronixFileNameMetadata to handle JSON metadata files containing channel configuration and calibration information.

Parameters:
  • fn (Union[str, Path, None], optional) – Path to Metronix JSON file, by default None

  • **kwargs – Additional keyword arguments passed to parent class

metadata[source]

Parsed JSON metadata as a SimpleNamespace object

Type:

SimpleNamespace or None

metadata: types.SimpleNamespace | None = None[source]
read(fn: str | pathlib.Path | None = None) None[source]

Read JSON metadata from file.

Parameters:

fn (Union[str, Path, None], optional) – Path to JSON file, by default None (uses self.fn)

Raises:

IOError – If JSON file cannot be found

get_channel_metadata() mt_metadata.timeseries.Electric | mt_metadata.timeseries.Magnetic | None[source]

Translate to mt_metadata.timeseries.Channel object.

Creates either Electric or Magnetic metadata objects based on the component type and applies calibration filters.

Returns:

mt_metadata object based on component type, or None if no metadata

Return type:

Union[Electric, Magnetic, None]

Raises:

ValueError – If component type is not recognized

get_sensor_response_filter() mt_metadata.timeseries.filters.FrequencyResponseTableFilter | None[source]

Get the sensor response frequency-amplitude-phase filter.

Creates a FrequencyResponseTableFilter from the sensor calibration data stored in the JSON metadata.

Returns:

Sensor response filter if calibration data exists, None otherwise

Return type:

FrequencyResponseTableFilter or None

get_channel_response() mt_metadata.timeseries.filters.ChannelResponse[source]

Get all filters needed to calibrate the data.

Returns:

Channel response object containing all calibration filters

Return type:

ChannelResponse