mth5.tables.fc_table
Tabulate Fourier coefficients stored in an MTH5 file.
This module provides a small utility for summarizing Fourier-coefficient datasets (e.g., FCChannel) into a structured table and exporting to a convenient pandas.DataFrame for querying and analysis.
Notes
- A basic test for this module exists under
mth5/tests/version_1/test_fcs.py.
- The table is populated by traversing the HDF5 hierarchy and collecting
entries for datasets labeled with the attribute
mth5_type='FCChannel'.
Classes
Summary table for Fourier coefficients. |
Module Contents
- class mth5.tables.fc_table.FCSummaryTable(hdf5_dataset: h5py.Dataset)[source]
Bases:
mth5.tables.MTH5TableSummary table for Fourier coefficients.
This class wraps an HDF5 dataset that stores a summary of Fourier coefficient datasets and provides convenience functions such as summarize() (to populate the table) and to_dataframe() (to export entries).
Examples
Populate and export a summary from an existing MTH5 file:
>>> import h5py >>> from mth5.tables.fc_table import FCSummaryTable >>> f = h5py.File('example.mth5', 'r') >>> # Assume the summary dataset already exists at this path >>> table_ds = f['Exchange']['FC_Summary'] >>> fc_table = FCSummaryTable(table_ds) >>> fc_table.summarize() # walk the file and fill entries >>> df = fc_table.to_dataframe() >>> df.head()
- to_dataframe() pandas.DataFrame[source]
Convert the table to a pandas.DataFrame for easier querying.
- Returns:
A dataframe with decoded string columns and parsed start/end timestamps.
- Return type:
pandas.DataFrame
Examples
Export to a dataframe and filter by component:
>>> df = fc_table.to_dataframe() >>> df[df.component == 'ex']
- summarize() None[source]
Populate the summary table by traversing the HDF5 hierarchy.
The traversal searches for datasets with attribute
mth5_type == 'FCChannel'and adds a corresponding summary row for each.- Return type:
None
Notes
If the table contains rows from a different OS/encoding, row insertion can raise a ValueError. A warning is logged and processing continues for subsequent rows.
Examples
Refresh the table entries:
>>> fc_table.clear_table() >>> fc_table.summarize()