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

Iterator for FilterCollection #57

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

![pyaro-logo](docs/pics/pyaro256.png "The library that solves the mystery of reading airquality measurement databases.")

The library that solves the mystery of reading airquality measurement databases. (Pronounciation as in French: Poirot)
The library that solves the mystery of reading airquality measurement databases. (Pronunciation as in French: Poirot)

## About

Pyaro is an interface which uses a simple access pattern to different air-pollution databases.
The goal of pyro was threefold.

1. A simple interface for different types of air-pollution databases
2. A programatic interface to these databases easily usable by large applications like [PyAerocom](https://pyaerocom.readthedocs.io)
2. A programmatic interface to these databases easily usable by large applications like [PyAerocom](https://pyaerocom.readthedocs.io)
3. Easy extension for air-pollution database providers or programmers giving the users (1. or 2.) direct access
their databases without the need of a new API.

Expand Down
2 changes: 1 addition & 1 deletion docs/Ungriddeddata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ UngriddedData
===================

UngriddedData is the main class for holding ungridded data -- mostly used for obervational data -- in pyaerocom.
The class can either be instanciated and filled manually (see below for structure), or be created from a dictionary of StationData objects :ref:`_stationsdata_overview`.
The class can either be instantiated and filled manually (see below for structure), or be created from a dictionary of StationData objects :ref:`_stationsdata_overview`.

.. image:: ./pics/UngriddedData.svg
:alt: some image
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pyaro - Airquality Reader-interface for Observations
***************************

Website of pyaro, the Python library that solves the mystery of reading airquality measurement databases. (Pronounciation as in French: Poirot)
Website of pyaro, the Python library that solves the mystery of reading airquality measurement databases. (Pronunciation as in French: Poirot)

About
============
Expand All @@ -11,7 +11,7 @@ Pyaro is an interface which uses a simple access pattern to different air-pollut
The goal of pyro was threefold.

1. A simple interface for different types of air-pollution databases
2. A programatic interface to these databases easily usable by large applications like `PyAerocom <https://pyaerocom.readthedocs.io>`_
2. A programmatic interface to these databases easily usable by large applications like `PyAerocom <https://pyaerocom.readthedocs.io>`_
3. Easy extension for air-pollution database providers or programmers giving the users (1. or 2.) direct access
their databases without the need of a new API.

Expand Down
2 changes: 1 addition & 1 deletion docs/puml/Filter.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class timeseries.FilterFactory {
+list(): [str]
}
note right of timeseries.FilterFactory
Singelton
Singleton
instance available as
pyaro.timeseries.filters
end note
Expand Down
2 changes: 1 addition & 1 deletion docs/puml/UngriddedData.puml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end note
entity "metadata" {
*station_id: float
--
*var_info|varibales : list_of_varnames|dictionary
*var_info|variables : list_of_varnames|dictionary
*instrument_name
*latitude: float
*longitude: float
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/pyaerocom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@
"id": "49b0a0fc-2e7a-435b-92b5-3fbab19db9f7",
"metadata": {},
"source": [
"Configs can become large and complicated. Thus we don't want to have to rewrite these config each time. We have intruduced a catalog system to save configurations. This is done in using YAML files.\n",
"Configs can become large and complicated. Thus we don't want to have to rewrite these config each time. We have introduced a catalog system to save configurations. This is done in using YAML files.\n",
"\n",
"The plan is to have one default catalog that is distributed with pyaerocom, which holds the most used configurations, and the option to have personal catalogs which the user can make themselves.\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions src/pyaro/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def list_timeseries_engines() -> dict[str, TimeseriesEngine]:
Notes
-----
This function lives in the backends namespace (``engs=pyaro.list_timeseries_enginess()``).
More information about each reader is available via the TimeserieEngine obj.url() and
More information about each reader is available via the TimeseriesEngine obj.url() and
obj.description()

# New selection mechanism introduced with Python 3.10. See GH6514.
Expand All @@ -54,7 +54,7 @@ def open_timeseries(name, *args, **kwargs) -> TimeseriesReader:
directly to the TimeseriesReader.open_reader() function

:param name: the name of the entrypoint as key in list_timeseries_readers
:return: an implementation-object of a TimeseriesReader openend to a location
:return: an implementation-object of a TimeseriesReader opened to a location
"""
engine = list_timeseries_engines()[name]

Expand Down
2 changes: 1 addition & 1 deletion src/pyaro/timeseries/Engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class Engine(abc.ABC):
"""The engine is the 'singelton' generator object for databases of the engines type."""
"""The engine is the 'singleton' generator object for databases of the engines type."""

@abc.abstractmethod
def open(self, filename_or_obj_or_url, *, filters=None):
Expand Down
15 changes: 9 additions & 6 deletions src/pyaro/timeseries/Filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get(self, name, **kwargs):
return filter.__class__(**kwargs)

def list(self) -> dict[str, Filter]:
"""List all available filter-names and their initalizations"""
"""List all available filter-names and their initializations"""
return types.MappingProxyType(self._filters)


Expand All @@ -164,7 +164,7 @@ class FilterCollectionException(Exception):


class FilterCollection:
"""A collection of DataIndexFilters which can be appied together.
"""A collection of DataIndexFilters which can be applied together.

:param filterlist: _description_, defaults to []
:return: _description_
Expand Down Expand Up @@ -215,6 +215,9 @@ def filter(self, ts_reader, variable: str) -> Data:
data = ts_reader.data(variable)
return self.filter_data(data, stations, variables)

def __iter__(self):
return self._filters.__iter__()


@registered_filter
class VariableNameFilter(Filter):
Expand Down Expand Up @@ -340,7 +343,7 @@ def name(self):

def has_station(self, station) -> bool:
if len(self._include) > 0:
if not station in self._include:
if station not in self._include:
return False
if station in self._exclude:
return False
Expand Down Expand Up @@ -371,7 +374,7 @@ def name(self):

def has_country(self, country) -> bool:
if len(self._include) > 0:
if not country in self._include:
if country not in self._include:
return False
if country in self._exclude:
return False
Expand Down Expand Up @@ -769,7 +772,7 @@ class TimeResolutionFilter(DataIndexFilter):
certain time-resolutions. Time-resolutions are not exact, and might be interpreted
slightly differently by different observation networks.

Default named time-resoultions are
Default named time-resolutions are
* minute: 59 to 61 s (+-1sec)
* hour: 59*60 s to 61*60 s (+-1min)
* day: 22:59:00 to 25:01:00 to allow for leap-days and a extra min
Expand Down Expand Up @@ -989,7 +992,7 @@ def _convert_altitude_to_meters(self, topo_xr):
Method which attempts to convert the altitude variable in the gridded topography data
to meters.

:param topo_xr xarray dataset containting topo
:param topo_xr xarray dataset containing topo
:raises TypeError
If conversion isn't possible.
:return xr.DataArray
Expand Down
2 changes: 1 addition & 1 deletion src/pyaro/timeseries/Reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def metadata(self) -> dict[str, str]:
return dict()

@abc.abstractmethod
def data(self, varname) -> Data:
def data(self, varname: str) -> Data:
"""Return all data for a variable

:param varname: variable name as returned from variables
Expand Down
2 changes: 1 addition & 1 deletion src/pyaro/timeseries/Wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class VariableNameChangingReader(Reader):
"""A pyaro.timeseries.Reader wrapper taking a real Reader implementation and
changing variable names in the original reader. Exampel:
changing variable names in the original reader. Example:

with VariableNameChangingReader(pyaro.open_timeseries(file, filters=[]),
{'SOx': 'oxidised_sulphur'}) as ts:
Expand Down