mth5.groups.transfer_function

Classes

TransferFunctionsGroup

Container for transfer functions under a station.

TransferFunctionGroup

Wrapper for a single transfer function estimation.

Module Contents

class mth5.groups.transfer_function.TransferFunctionsGroup(group: Any, **kwargs: Any)[source]

Bases: mth5.groups.BaseGroup

Container for transfer functions under a station.

Each child group is a single transfer function estimation managed by TransferFunctionGroup.

Examples

>>> from mth5 import mth5
>>> m5 = mth5.MTH5()
>>> _ = m5.open_mth5("/tmp/example.mth5", mode="a")
>>> station = m5.stations_group.add_station("mt01")
>>> tf_group = station.transfer_functions_group
>>> tf_group.groups_list
[]
tf_summary(as_dataframe: bool = True) pandas.DataFrame | numpy.ndarray[source]

Summarize transfer functions stored for the station.

Parameters:

as_dataframe (bool, default True) – If True return a pandas DataFrame, otherwise a NumPy structured array.

Returns:

Summary rows including station reference, location, and TF metadata.

Return type:

pandas.DataFrame or numpy.ndarray

Examples

>>> summary = tf_group.tf_summary()
>>> summary.columns[:4].tolist()
['station_hdf5_reference', 'station', 'latitude', 'longitude']
add_transfer_function(name: str, tf_object: mt_metadata.transfer_functions.core.TF | None = None) TransferFunctionGroup[source]

Add a transfer function group under this station.

Parameters:
  • name (str) – Transfer function identifier.

  • tf_object (TF, optional) – Transfer function instance to seed metadata and datasets.

Returns:

Wrapper for the created or existing transfer function.

Return type:

TransferFunctionGroup

Examples

>>> tf_group = station.transfer_functions_group
>>> _ = tf_group.add_transfer_function("mt01_4096")
get_transfer_function(tf_id: str) TransferFunctionGroup[source]

Return an existing transfer function by id.

Parameters:

tf_id (str) – Name of the transfer function.

Returns:

Wrapper for the requested transfer function.

Return type:

TransferFunctionGroup

Raises:

MTH5Error – If the transfer function does not exist.

Examples

>>> existing = station.transfer_functions_group.get_transfer_function("mt01_4096")
>>> existing.name
'mt01_4096'
remove_transfer_function(tf_id: str) None[source]

Delete a transfer function reference from the station.

Parameters:

tf_id (str) – Transfer function name.

Notes

HDF5 deletion removes the reference only; storage is not reclaimed.

Examples

>>> tf_group.remove_transfer_function("mt01_4096")
get_tf_object(tf_id: str) mt_metadata.transfer_functions.core.TF[source]

Return a populated mt_metadata.transfer_functions.core.TF.

Parameters:

tf_id (str) – Transfer function name to convert.

Returns:

Transfer function populated with metadata and estimates.

Return type:

mt_metadata.transfer_functions.core.TF

Examples

>>> tf_obj = tf_group.get_tf_object("mt01_4096")
class mth5.groups.transfer_function.TransferFunctionGroup(group: Any, **kwargs: Any)[source]

Bases: mth5.groups.BaseGroup

Wrapper for a single transfer function estimation.

has_estimate(estimate: str) bool[source]

Return True if an estimate exists and is populated.

property period: numpy.ndarray | None[source]

Return period array stored in period dataset, if present.

add_statistical_estimate(estimate_name: str, estimate_data: numpy.ndarray | xarray.DataArray | None = None, estimate_metadata: mt_metadata.transfer_functions.tf.statistical_estimate.StatisticalEstimate | None = None, max_shape: tuple[int | None, int | None, int | None] = (None, None, None), chunks: bool = True, **kwargs: Any) mth5.groups.EstimateDataset[source]

Add a statistical estimate dataset.

Parameters:
  • estimate_name (str) – Dataset name.

  • estimate_data (numpy.ndarray or xarray.DataArray, optional) – Estimate values; if None a placeholder array is created.

  • estimate_metadata (StatisticalEstimate, optional) – Metadata describing the estimate.

  • max_shape (tuple of int or None, default (None, None, None)) – Maximum shape for resizable datasets.

  • chunks (bool, default True) – Chunking flag forwarded to HDF5 dataset creation.

Returns:

Wrapper combining dataset and metadata.

Return type:

EstimateDataset

Raises:

TypeError – If estimate_data is not array-like.

Examples

>>> est = tf_group.add_statistical_estimate("transfer_function")
>>> isinstance(est, EstimateDataset)
True
get_estimate(estimate_name: str) mth5.groups.EstimateDataset[source]

Return a statistical estimate dataset by name.

remove_estimate(estimate_name: str) None[source]

Remove a statistical estimate dataset reference.

to_tf_object() mt_metadata.transfer_functions.core.TF[source]

Convert this group into a populated TF object.

Returns:

TF instance with survey, station, runs, channels, period, and estimate datasets applied.

Return type:

mt_metadata.transfer_functions.core.TF

Raises:

ValueError – If no period dataset is present.

Examples

>>> tf_obj = tf_group.to_tf_object()
from_tf_object(tf_obj: mt_metadata.transfer_functions.core.TF, update_metadata: bool = True) None[source]

Populate datasets from a TF object.

Parameters:
  • tf_obj (TF) – Transfer function object containing estimates and metadata.

  • update_metadata (bool, default True) – If True write transfer function metadata to HDF5.

Raises:

ValueError – If tf_obj is not a TF instance.

Examples

>>> tf_group.from_tf_object(tf_obj)