Skip to content

Commit

Permalink
WIP: adjust harpreader tp separate read() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Griesfeller committed Oct 31, 2024
1 parent f54f9d0 commit 59c4f7f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pyaro_readers
version = 0.0.10.dev4
version = 0.0.10.dev5
author = MET Norway
description = implementations of pyaerocom reading plugings using pyaro as interface
long_description = file: README.md
Expand Down
8 changes: 7 additions & 1 deletion src/pyaro_readers/harpreader/harpreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def __init__(
else:
self._files.append(file)

def read(self):
"""reading method"""

bar = tqdm(total=len(self._files))

for f_idx, _file in enumerate(self._files):
Expand All @@ -84,7 +87,7 @@ def __init__(
# skip coordinate names
if _var in self.COORD_NAMES:
continue
if vars_to_read is not None and _var not in vars_to_read:
if self._vars_to_read is not None and _var not in self._vars_to_read:
logger.info(f"Skipping {_var}")
continue
if _var not in self._data:
Expand Down Expand Up @@ -238,3 +241,6 @@ def description(self):

def url(self):
return "https://github.com/metno/pyaro-readers"

def read(self):
return self.reader_class().read()
4 changes: 3 additions & 1 deletion tests/test_HARPReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestHARPReader(unittest.TestCase):
)

testdata_dir = (
"/lustre/storeB/project/aerocom/aerocom1/AEROCOM_OBSDATA/CNEMC/aggregated/"
"/lustre/storeB/project/aerocom/aerocom1/AEROCOM_OBSDATA/SINCA/aggregated/"
)
test_vars = ["PM10_density", "CO_volume_mixing_ratio", "PM2p5_density"]
test_units = ["ug m-3", "ppm", "ug m-3"]
Expand All @@ -26,6 +26,7 @@ def test_1read(self):
self.file,
vars_to_read=self.test_vars,
) as ts:
ts.read()
for _v_idx, var in enumerate(self.test_vars):
data = ts.data(var)
self.assertGreater(len(data), 10000)
Expand All @@ -44,6 +45,7 @@ def test_2open_directory(self):
with pyaro.open_timeseries(
self.engine, self.testdata_dir, filters=[], vars_to_read=self.test_vars
) as ts:
ts.read()
for _v_idx, var in enumerate(self.test_vars):
data = ts.data(var)
assert isinstance(data.units, str)
Expand Down

0 comments on commit 59c4f7f

Please sign in to comment.