Skip to content

Commit

Permalink
read data on access only
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Griesfeller committed Nov 7, 2024
1 parent bb33109 commit cbbdbcf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/pyaro_readers/actrisebas/ActrisEbasReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def read(
# for actris vocabulary key and value of self.actris_vars_to_read are the same
# for pyaerocom vocabulary they are not (key is pyaerocom variable name there)!
for _var in self.actris_vars_to_read:
if _var in self._data:
logger.info(f"var {_var} already read")
continue
for actris_variable in self.actris_vars_to_read[_var]:
# actris_variable = self.actris_vars_to_read[_var][0]

Expand Down Expand Up @@ -453,12 +456,15 @@ def extract_urls(
return urls_to_dl

def _unfiltered_data(self, varname) -> Data:
self.read()
return self._data[varname]

def _unfiltered_stations(self) -> dict[str, Station]:
self.read()
return self._stations

def _unfiltered_variables(self) -> list[str]:
self.read()
return list(self._data.keys())

def close(self):
Expand Down Expand Up @@ -492,5 +498,3 @@ def description(self):
def url(self):
return "https://github.com/metno/pyaro-readers"

def read(self):
return self.reader_class().read()
4 changes: 0 additions & 4 deletions tests/test_ActrisEbasReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def test_api_reading_small_data_set(self):
with engine.open(
filters=self.station_filter, vars_to_read=self.vars_to_read
) as ts:
ts.read()
self.assertGreaterEqual(len(ts.variables()), 1)
self.assertGreaterEqual(len(ts.stations()), 2)
self.assertGreaterEqual(len(ts._data[ts.variables()[0]]), 1000)
Expand All @@ -68,12 +67,10 @@ def test_api_reading_pyaerocom_naming(self):
for _var in self.pyaerocom_vars_to_read:
engine = pyaro.list_timeseries_engines()[self.engine]
with engine.open(filters=self.station_filter, vars_to_read=[_var]) as ts:
ts.read()
self.assertGreaterEqual(len(ts.variables()), 1)
self.assertGreaterEqual(len(ts.stations()), 2)
self.assertGreaterEqual(len(ts._data[ts.variables()[0]]), 1000)
self.assertGreaterEqual(len(ts.data(ts.variables()[0])), 1000)
self.assertGreaterEqual(len(ts.variables()), 1)
self.assertIn("revision", ts.metadata())

def test_wrappers(self):
Expand All @@ -82,7 +79,6 @@ def test_wrappers(self):
ebas_var_name = "ozone mass concentration"
with VariableNameChangingReader(engine.open(filters=self.station_filter, vars_to_read=[ebas_var_name]),
reader_to_new={ebas_var_name: new_var_name}) as ts:
ts.read()
self.assertEqual(ts.data(new_var_name).variable, new_var_name)
self.assertGreaterEqual(len(ts.variables()), 1)
self.assertGreaterEqual(len(ts.stations()), 2)
Expand Down

0 comments on commit cbbdbcf

Please sign in to comment.