mth5.groups.station
Attributes
Classes
Collection helper for all stations in a survey. |
|
Utility wrapper for a single station at |
Module Contents
- class mth5.groups.station.MasterStationGroup(group: h5py.Group, **kwargs: Any)[source]
Bases:
mth5.groups.BaseGroupCollection helper for all stations in a survey.
The group lives at
/Survey/Stationsand offers convenience accessors to add, fetch, or remove stations along with a summary table.Examples
>>> from mth5 import mth5 >>> mth5_obj = mth5.MTH5() >>> _ = mth5_obj.open_mth5("/tmp/example.mth5", mode="a") >>> stations = mth5_obj.stations_group >>> _ = stations.add_station("MT001") >>> stations.station_summary.head()
- property station_summary: pandas.DataFrame[source]
Return a summary DataFrame of all stations in the file.
- Returns:
Columns include
station,start,end,latitude, andlongitude. Empty if no stations are present.- Return type:
pandas.DataFrame
Notes
Timestamps are parsed to pandas
datetime64[ns]when possible.Examples
>>> summary = stations.station_summary >>> list(summary.columns) ['station', 'start', 'end', 'latitude', 'longitude']
- add_station(station_name: str, station_metadata: mt_metadata.timeseries.Station | None = None) StationGroup[source]
Add or fetch a station group at
/Survey/Stations/<name>.- Parameters:
station_name (str) – Station identifier, typically matches
metadata.id.station_metadata (mt_metadata.timeseries.Station, optional) – Metadata container to seed the station attributes.
- Returns:
Convenience wrapper for the created or existing station.
- Return type:
- Raises:
ValueError – If
station_nameis empty.
Examples
>>> station = stations.add_station("MT001") >>> station.metadata.id 'MT001'
- get_station(station_name: str) StationGroup[source]
Return an existing station by name.
- Parameters:
station_name (str) – Name of the station to retrieve.
- Returns:
Wrapper for the requested station.
- Return type:
- Raises:
MTH5Error – If the station does not exist.
Examples
>>> existing = stations.get_station("MT001") >>> existing.name 'MT001'
- class mth5.groups.station.StationGroup(group: h5py.Group, station_metadata: mt_metadata.timeseries.Station | None = None, **kwargs: Any)[source]
Bases:
mth5.groups.BaseGroupUtility wrapper for a single station at
/Survey/Stations/<id>.Station groups manage run collections, metadata propagation, and provide summary utilities for quick inspection.
Examples
>>> from mth5 import mth5 >>> m5 = mth5.MTH5() >>> _ = m5.open_mth5("/tmp/example.mth5", mode="a") >>> station = m5.stations_group.add_station("MT001") >>> _ = station.add_run("MT001a") >>> station.run_summary.shape[0] >= 1 True
- initialize_group(**kwargs: Any) None[source]
Create default subgroups and write metadata.
- Parameters:
**kwargs – Additional attributes to set on the instance before initialization.
Examples
>>> station.initialize_group()
- property master_station_group: MasterStationGroup[source]
Shortcut to the containing master station group.
- property transfer_functions_group: mth5.groups.TransferFunctionsGroup[source]
Convenience accessor for
/Station/Transfer_Functions.
- property fourier_coefficients_group: mth5.groups.MasterFCGroup[source]
Convenience accessor for
/Station/Fourier_Coefficients.
- property features_group: mth5.groups.MasterFeaturesGroup[source]
Convenience accessor for
/Station/Features.
- property survey_metadata: mt_metadata.timeseries.Survey[source]
Return survey metadata with this station appended.
- property run_summary: pandas.DataFrame[source]
Return a summary of runs belonging to the station.
- Returns:
Columns include
id,start,end,components,measurement_type,sample_rate, andhdf5_reference.- Return type:
pandas.DataFrame
Notes
Channel lists stored as byte arrays or JSON strings are normalized before summarization.
Examples
>>> station.run_summary.head()
- make_run_name(alphabet: bool = False) str | None[source]
Generate the next run name using an alphabetic or numeric suffix.
- Parameters:
alphabet (bool, default False) – If
Trueuse letters (a,b, …); otherwise use numeric suffixes (001).- Returns:
Proposed run name or
Noneif generation fails.- Return type:
str or None
Examples
>>> station.metadata.id = "MT001" >>> station.make_run_name() 'MT001a'
- locate_run(sample_rate: float, start: str | mt_metadata.common.mttime.MTime) pandas.DataFrame | None[source]
Locate runs matching a sample rate and start time.
- Parameters:
sample_rate (float) – Sample rate in samples per second.
start (str or MTime) – Start time string or
MTimeinstance.
- Returns:
Matching rows from
run_summaryorNonewhen no match exists.- Return type:
pandas.DataFrame or None
Examples
>>> station.locate_run(256.0, "2020-01-01T00:00:00")
- add_run(run_name: str, run_metadata: mt_metadata.timeseries.Run | None = None) mth5.groups.RunGroup[source]
Add a run under this station.
- Parameters:
run_name (str) – Run identifier (for example
id+ suffix).run_metadata (mt_metadata.timeseries.Run, optional) – Metadata container to seed the run attributes.
- Returns:
Wrapper for the created or existing run.
- Return type:
Examples
>>> run = station.add_run("MT001a") >>> run.metadata.id 'MT001a'
- get_run(run_name: str) mth5.groups.RunGroup[source]
Return a run by name.
- Parameters:
run_name (str) – Existing run name.
- Returns:
Wrapper for the requested run.
- Return type:
- Raises:
MTH5Error – If the run does not exist.
Examples
>>> existing_run = station.get_run("MT001a") >>> existing_run.name 'MT001a'
- remove_run(run_name: str) None[source]
Remove a run from this station.
- Parameters:
run_name (str) – Existing run name.
Notes
Deleting removes the reference only; storage is not reclaimed.
Examples
>>> station.remove_run("MT001a")
- update_station_metadata() None[source]
Deprecated alias for
update_metadata().- Raises:
DeprecationWarning – Always raised to direct callers to
update_metadata.
Examples
>>> station.update_station_metadata() Traceback (most recent call last): ... DeprecationWarning: 'update_station_metadata' has been deprecated use 'update_metadata()'
- update_metadata() None[source]
Synchronize station metadata from contained runs.
Notes
The station
time_periodis set to the min/max of all runs, andchannels_recordedcombines all recorded components.Examples
>>> _ = station.update_metadata() >>> station.metadata.time_period.start '2020-01-01T00:00:00'