Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input type for filters #62

Open
magnusuMET opened this issue Nov 6, 2024 · 1 comment
Open

Input type for filters #62

magnusuMET opened this issue Nov 6, 2024 · 1 comment

Comments

@magnusuMET
Copy link
Collaborator

To implement a reader it would be great if the type of filters were known. The relevant code is

def __init__(self, filename_or_obj_or_url, *, filters=None):

As far as I understand it should be filters: Iterable[Filter] | dict[str, Any] | None = None.

In various config files I see filters are given as a dictionary. How can I go from a dictionary to a list of Filters? In the comment for the above filter it is suggested

:param filters: list of filters, or dict of (name, kwargs) for FilterFactory

but FilterFactory does not seem like the right type. FilterCollection might be right, but only stores DataIndexFilter.

@heikoklein
Copy link
Member

Implementing filters is easiest by using the AutoFilterReaderEngine as described in https://pyaro.readthedocs.io/latest/how-to-add-new-reader.html

https://github.com/metno/pyaro-readers/blob/002af7966793635fcf3ae62509ae64132a2e9e02/src/pyaro_readers/netcdf_rw/Netcdf_RWTimeseries.py#L140
shows how the _get_filters() is then used in a filter to apply a TimeBoundsFilter on the data split on files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants