From f54f9d02ea3d29b379493ce7fbc483223b0c8709 Mon Sep 17 00:00:00 2001 From: Jan Griesfeller Date: Wed, 30 Oct 2024 16:29:57 +0100 Subject: [PATCH] WIP: adjust readers to new read method --- .../ascii2netcdf/Ascii2NetcdfTimeseries.py | 10 +++++++++- tests/test_Ascii2NetcdfTimeseries.py | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pyaro_readers/ascii2netcdf/Ascii2NetcdfTimeseries.py b/src/pyaro_readers/ascii2netcdf/Ascii2NetcdfTimeseries.py index 1c4d1af..d4dd994 100644 --- a/src/pyaro_readers/ascii2netcdf/Ascii2NetcdfTimeseries.py +++ b/src/pyaro_readers/ascii2netcdf/Ascii2NetcdfTimeseries.py @@ -49,6 +49,7 @@ def __init__( :param filters: list of filters, defaults to [] """ self._set_filters(filters) + self._revision = datetime.datetime.now() if os.path.isdir(filename): self._directory = filename else: @@ -70,6 +71,9 @@ def __init__( if self._is_year_in_filters(year): self._years.add(year) + self._metadata = self.metadata() + + def read(self): self._variables = self._read_file_variables() station_file = "StationList.csv" station_filepath = os.path.join(self._directory, station_file) @@ -79,7 +83,7 @@ def __init__( dirname = os.path.basename(self._directory) station_file = dirname + station_file # e.g. AirbaseStationList.csv station_filepath = os.path.join(self._directory, station_file) - if os.exists(station_filepath): + if os.path.exists(station_filepath): self._stations = self._read_station_list(station_filepath) else: raise Ascii2NetcdfTimeseriesReaderException( @@ -283,3 +287,7 @@ def description(self) -> str: def url(self): return "https://github.com/metno/pyaro-readers" + + def read(self): + return self.reader_class().read() + diff --git a/tests/test_Ascii2NetcdfTimeseries.py b/tests/test_Ascii2NetcdfTimeseries.py index 403ee43..f9b0caa 100644 --- a/tests/test_Ascii2NetcdfTimeseries.py +++ b/tests/test_Ascii2NetcdfTimeseries.py @@ -20,6 +20,7 @@ def test_1open(self): with pyaro.open_timeseries( self.engine, EBAS_URL, resolution="daily", filters=[] ) as ts: + ts.read() self.assertGreater(len(ts.variables()), 70) self.assertGreater(len(ts.stations()), 300) @@ -29,6 +30,7 @@ def test_2read(self): with pyaro.open_timeseries( self.engine, EBAS_URL, resolution="daily", filters=[] ) as ts: + ts.read() data = ts.data("sulphur_dioxide_in_air") self.assertIn("AM0001", data.stations) self.assertGreater(np.sum(data.values), 10000) @@ -45,6 +47,7 @@ def test_3read(self): "stations": {"include": ["NO0002"]}, }, # Birkenes2 ) as ts: + ts.read() data = ts.data("sulphur_dioxide_in_air") self.assertIn("NO0002", data.stations) self.assertGreater(len(data), 360)