Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorbjoernl committed Sep 5, 2024
1 parent 9a459d9 commit 709e9bf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install_requires =
importlib-metadata >= 3.6; python_version < "3.10"
xarray
netcdf4
cfunits
cf-units
package_dir =
=src
packages = pyaro, pyaro.timeseries, pyaro.csvreader
Expand Down
2 changes: 1 addition & 1 deletion src/pyaro/csvreader/CSVTimeseriesReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def col_keys(cls):
"""
return cls._col_keys

def metadata(self) -> dict():
def metadata(self) -> dict:
return self._metadata

def _unfiltered_data(self, varname) -> Data:
Expand Down
71 changes: 69 additions & 2 deletions tests/test_CSVTimeSeriesReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def test_relaltitude_filter_emep_2(self):
"flag": "0",
}
) as ts:
# At rdiff = 0.89, only the first station should be included.
# At rdiff = 90, only the first station should be included.
self.assertEqual(len(ts.stations()), 1)

def test_relaltitude_filter_emep_3(self):
Expand All @@ -557,9 +557,76 @@ def test_relaltitude_filter_emep_3(self):
"flag": "0",
}
) as ts:
# Since rdiff=1, all stations should be included.
# Since rdiff=300, all stations should be included.
self.assertEqual(len(ts.stations()), 3)

def test_relaltitude_filter_1(self):
engines = pyaro.list_timeseries_engines()
with engines["csv_timeseries"].open(
filename=self.elevation_file,
filters=[pyaro.timeseries.filters.get("relaltitude", topo_file = "./tests/testdata/datadir_elevation/topography.nc", rdiff=0)],
columns={
"variable": 0,
"station": 1,
"longitude": 2,
"latitude": 3,
"value": 4,
"units": 5,
"start_time": 6,
"end_time": 7,
"altitude": 9,
"country": "NO",
"standard_deviation": "NaN",
"flag": "0",
}
) as ts:
self.assertEqual(len(ts.stations()), 0)

def test_relaltitude_filter_2(self):
engines = pyaro.list_timeseries_engines()
with engines["csv_timeseries"].open(
filename=self.elevation_file,
filters=[pyaro.timeseries.filters.get("relaltitude", topo_file = "./tests/testdata/datadir_elevation/topography.nc", rdiff=90)],
columns={
"variable": 0,
"station": 1,
"longitude": 2,
"latitude": 3,
"value": 4,
"units": 5,
"start_time": 6,
"end_time": 7,
"altitude": 9,
"country": "NO",
"standard_deviation": "NaN",
"flag": "0",
}
) as ts:
# At rdiff = 90, only the first station should be included.
self.assertEqual(len(ts.stations()), 1)

def test_relaltitude_filter_3(self):
engines = pyaro.list_timeseries_engines()
with engines["csv_timeseries"].open(
filename=self.elevation_file,
filters=[pyaro.timeseries.filters.get("relaltitude", topo_file = "./tests/testdata/datadir_elevation/topography.nc", rdiff=300)],
columns={
"variable": 0,
"station": 1,
"longitude": 2,
"latitude": 3,
"value": 4,
"units": 5,
"start_time": 6,
"end_time": 7,
"altitude": 9,
"country": "NO",
"standard_deviation": "NaN",
"flag": "0",
}
) as ts:
# Since rdiff=300, all stations should be included.
self.assertEqual(len(ts.stations()), 3)



Expand Down

0 comments on commit 709e9bf

Please sign in to comment.