Filters (hibou.filters)#
Description#
Tis module provides some tools to synchronize the data from the average weather station with the data from the eddy-covariance station. When the synchronization run, it can apply filters on data.
Some basic filters are provided, but custom filters can also be developed. The provied filters are
using the variables names provided in varnames module. If you have to handle different variables
names, please modify Inputs and Targets to suit your need.
Using a filter#
To use a filter, we only need to add it to a Filters instance via Filters.add_filter. Once
the filters we want are added to the Filters, we can pass this instance to the sync
function. The filters will be applied at each timestep during synchronization.
For each filter provided, the variables used by this filter are given in its documentation.
Creating a new filter#
To create a new filter you have to write a function that has the signature:
my_filter(inputs, targets, **kwargs) -> Bool | List[Bool]:
An example can be:
my_filter(inputs, targets, max_value=1.5):
return data["variable name"] < max_value
You can also use binary operators:
my_filter(inputs, targets, min_value=-50, max_value=10):
return (inputs["variable name"] > min_value) & (inputs["variable name"] < max_value)
Once your filter function is written, you have to add it to your Filters instance:
filters = Filters()
filters.add_filter(my_filter, **kwargs)
Examples#
A basic example with using the provided filters:
# creating a Filters instance
my_filters = Filters()
# add filters
my_filters.add_filter(h_thresholding)
my_filters.add_filter(le_threholding, min_value=-10, max_value=150)
# applying filters on high_freq_data
inputs, targets = sync(
inputs,
targets,
filters_target = my_filters
)
Another example with variables that have different names:
# the constants are stored in Inputs and Targets
Targets.H = "custom H"
Targets.LE = "my LE"
The following step are exactly the same as before.
An example with custom filters:
Targets.CUSTOM_VAR = "my variable"
# creating a filter
my_filter(inputs, targets, threshold: int = 5):
return targets[Targets.CUSTOM_VAR]
# creating a Filters instance
my_filters = Filters()
# add filters
my_filters.add_filter(my_filter, threshold=10)
License#
This project is licensed under the GNU Affero General Public Licence v3.0. For more information please see the LICENSE file.