Add filter-reading support to MTH5 - #1
Conversation
Add filter-reading functionality to MTH5: introduce FilterInfo struct, HDF5 string attribute helpers, and methods to read filter names and filter objects (readFilter, readFilterNamesFromChannel, getChannelFilters). Update MTH5.cpp/h to include attribute parsing, path resolution for Filters groups, name normalization, and basic scanning of filter type groups (zpk, coefficient, time_delay, fap, fir). Include logging via OutputFiles and proper HDF5 resource cleanup. Add usage documentation (MTH5_FILTER_READING.md) and an example program (MTH5_filter_example.cpp). Implementation currently reads metadata and names (filter.name) and leaves detailed per-type dataset parsing as TODOs for future enhancement.
|
@yoshiya-usui I'm not great at C++ so I had some help with copilot to add some functionality to the MTH5 for getting the filters directly from the MTH5. I still need to format the filter into real and imaginary and probably a few more things before this PR is ready. But if you could have a look and comment the structure and hints on how to ensure the functionality works for the workflow of TRACMT. |
|
Thank you for informing me how to add functionality to the MTH5 class to get the filters directly from the MTH5 and for giving me a sample program. |
|
@yoshiya-usui Some documentation on the supported filters stored in an mth5 file is here: https://mth5.readthedocs.io/en/latest/examples/notebooks/filters_example.html. Commonly what we do is take all the filters and make a total channel response which incorporates all the gains, and frequency dependent responses. Those are in frequency, amplitude, phase format now, but could easily be changed to real and imaginary, like in the TRACMT calibration function https://github.com/yoshiya-usui/TRACMT/blob/main/src/CalibrationFunction.cpp. |
Sort channel filters by sequence number and add facilities to validate and combine them into a ChannelResponse. Introduces ChannelResponse struct in MTH5.h and three new methods in MTH5.cpp: validateFilterUnits (checks sequence ordering and unit consistency), createChannelResponse (builds a response from a filter list and sets units/normalization), and getChannelResponse (convenience wrapper that loads filters and creates the response). Also logs operations and errors, and adds declarations for the new methods in the header.
|
Thank you so much for giving detailed information and very insightful modification plans. |
|
I send a reply to your gmail address, as follows, because I am not used to the functions of GitHub (e.g., branching). Your code is definitely smart. I implemented the functions to calculate the frequency response of each filter, tentatively. I have some questions. To correct the Fourier transforms by dividing the response functions, the order of filters should be reversed, right? |
The current functionality of reading an MTH5 only reads the data and the calibrations/filters are skipped for now unless the user creates files for them. This PR aims at adding functionality to the MTH5 class to get the filters directly from the MTH5 file.
Add filter-reading functionality to MTH5: introduce FilterInfo struct, HDF5 string attribute helpers, and methods to read filter names and filter objects (readFilter, readFilterNamesFromChannel, getChannelFilters). Update MTH5.cpp/h to include attribute parsing, path resolution for Filters groups, name normalization, and basic scanning of filter type groups (zpk, coefficient, time_delay, fap, fir). Include logging via OutputFiles and proper HDF5 resource cleanup. Add usage documentation (MTH5_FILTER_READING.md) and an example program (MTH5_filter_example.cpp). Implementation currently reads metadata and names (filter.name) and leaves detailed per-type dataset parsing as TODOs for future enhancement.