Skip to content

Commit

Permalink
add missing vars @550nm
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Jurgen Griesfeller committed Dec 15, 2023
1 parent f355f95 commit a747dd7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
31 changes: 16 additions & 15 deletions src/pyaro_readers/aeronetsdareader/AeronetSdaTimeseriesReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
ETA50LT1_NAME = "FineModeFraction_500nm[eta]"
AOD550GT1_NAME = "AODGT1_550nm"
AOD550LT1_NAME = "AODLT1_550nm"
AOD550_NAME = "AOD_550nm"

DATA_VARS = [AOD500_NAME, AOD500GT1_NAME, AOD500LT1_NAME, ANG50_NAME, ETA50LT1_NAME]
COMPUTED_VARS = [AOD550GT1_NAME, AOD550LT1_NAME]
COMPUTED_VARS = [AOD550GT1_NAME, AOD550LT1_NAME, AOD550_NAME]
# The computed variables have to be named after the read ones, otherwise the calculation will fail!
DATA_VARS.extend(COMPUTED_VARS)

Expand Down Expand Up @@ -175,13 +176,26 @@ def __init__(
except KeyError:
# computed variable
if variable == AOD550GT1_NAME:
# ang_dummy = self.calc_angstroem_coeff(ts_dummy_data[AOD440_NAME], ts_dummy_data[AOD870_NAME], 0.44, 0.87)
value = self.compute_od_from_angstromexp(
0.55,
ts_dummy_data[AOD500GT1_NAME],
0.50,
ts_dummy_data[ANG50_NAME],
)
elif variable == AOD550LT1_NAME:
value = self.compute_od_from_angstromexp(
0.55,
ts_dummy_data[AOD500LT1_NAME],
0.50,
ts_dummy_data[ANG50_NAME],
)
elif variable == AOD500_NAME:
value = self.compute_od_from_angstromexp(
0.55,
ts_dummy_data[AOD500_NAME],
0.50,
ts_dummy_data[ANG50_NAME],
)
self._data[variable].append(
value, station, lat, lon, alt, start, end, Flag.VALID, np.nan
)
Expand Down Expand Up @@ -226,19 +240,6 @@ def compute_od_from_angstromexp(
"""
return od_ref * (lambda_ref / to_lambda) ** angstrom_coeff

def calc_angstroem_coeff(
self, od1: float, od2: float, wl1: float, wl2: float
) -> float:
"""
small helper method to calculate angstroem coefficient
:param od1:
:param od2:
:param wl1:
:param wl2:
:return:
"""
return -np.log(od1 / od2) / np.log(wl1 / wl2)

def is_valid_url(self, url):
try:
Expand Down
16 changes: 8 additions & 8 deletions tests/test_AERONETSDATimeSeriesReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def test_dl_data_unzipped(self):
TEST_URL,
filters=[],
fill_country_flag=False,
tqdm_desc="test_dl_data_unzipped",
tqdm_desc="test_sda_dl_data_unzipped",
) as ts:
count = 0
for var in ts.variables():
count += len(ts.data(var))
self.assertEqual(count, 69951)
self.assertEqual(count, 79944)
self.assertEqual(len(ts.stations()), 4)

def test_dl_data_zipped(self):
Expand All @@ -53,12 +53,12 @@ def test_dl_data_zipped(self):
TEST_ZIP_URL,
filters=[],
fill_country_flag=False,
tqdm_desc="test_dl_data_zipped",
tqdm_desc="test_sda_dl_data_zipped",
) as ts:
count = 0
for var in ts.variables():
count += len(ts.data(var))
self.assertEqual(count, 69951)
self.assertEqual(count, 79944)
self.assertEqual(len(ts.stations()), 4)

def test_aeronet_data_zipped(self):
Expand All @@ -72,7 +72,7 @@ def test_aeronet_data_zipped(self):
AERONETSDA_URL,
filters=[],
fill_country_flag=False,
tqdm_desc="aeronet data zipped",
tqdm_desc="aeronet SDA data zipped",
) as ts:
count = 0
for var in ts.variables():
Expand All @@ -92,7 +92,7 @@ def test_init(self):
count = 0
for var in ts.variables():
count += len(ts.data(var))
self.assertEqual(count, 69951)
self.assertEqual(count, 79944)
self.assertEqual(len(ts.stations()), 4)

def test_stationfilter(self):
Expand All @@ -104,7 +104,7 @@ def test_stationfilter(self):
count = 0
for var in ts.variables():
count += len(ts.data(var))
self.assertEqual(count, 68320)
self.assertEqual(count, 78080)
self.assertEqual(len(ts.stations()), 3)

def test_wrappers(self):
Expand All @@ -123,7 +123,7 @@ def test_variables_filter(self):
"variables", reader_to_new={"Coarse_Mode_AOD_500nm[tau_c]": new_var_name}
)
with engine.open(
self.file, filters=[vfilter], tqdm_desc="test_variables_filter"
self.file, filters=[vfilter], tqdm_desc="test_sda_variables_filter"
) as ts:
self.assertEqual(ts.data(new_var_name).variable, new_var_name)

Expand Down

0 comments on commit a747dd7

Please sign in to comment.