kujaku11 / mth5

Exchangeable and archivable format for magnetotelluric time series to better serve the community through FAIR principles.
https://mth5.readthedocs.io/en/latest/index.html
MIT License
16 stars 4 forks source link

User Applied Filters and Custom Transformations #198

Open kkappler opened 6 months ago

kkappler commented 6 months ago

Story

As a data processor I want to apply some operation to my time series and then store the output time series in an MTH5.

These operations might be of two flavors:

  1. Some linear filter that I can characterize using the existing filters in mt_metadata.
  2. Some operator (maybe defined within a method, perhaps non-linear)

I would like to add an annotation to my MTH5 so that when I come back to open the file later (or share it with another person) there is a record of the process that was applied.

In case (1) I should be able to describe my filter using one of the pre-existing containers (e.g. PoleZeroFilter, TimeDelay, etc.).
In case (2), I may not have completely characterized the operator in terms of its complex response – the operator may be not even have a simple inverse, or at least not a known one. At a minimum I would like to describe the process with a keyword or name, any parameters that were applied to the operator, and the order in which it was applied (if I did several of these transformations).

These filters are in general not removed by default when calibrating the data, i.e. calling remove_instrument_response.

Background:

Currently, MTH5 offers a Filters Group, that can be used to keep an archive of filter operations during data acquisition. Typical examples of these filters are the transducer response, analog to digital converter, or really, any other stage of linear analog or digital operation on the data before it is archived.

Under the Station > Run > Channel level of the MTH5, each channel is associated with calibration filter information via a list of keywords, which specify the filters, and a corresponding list of booleans, describing if the archived data have the filter applied, or not applied.

The Calibration stage of processing uses these information to determine how to transform the data into physical units from what is stored in the MTH5.

Potential Solution:

Requirements:

Ideally, we would augmenting the filters_list of ChannelResponse with the additional user_applied filters

This should at least support a record of a filtering workflow.

The other way around this would be to create an attribute, similar to ChannelReponse, called say UserAppliedFilters, or similar that lives at the same level as ChannelReponse, but that seems more complicated.

kkappler commented 6 months ago

To prototype this, most changes will be in mt_metadata, but mth5 ts_filters will also need an update.

Steps: