Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use map_freqs in ModelMapsEngine #1268

Merged
merged 4 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pyaerocom/aeroval/modelmaps_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,12 @@
logger.info(f"Skipping processing of {outname}: data already exists.")
return []

freq = min(TsType(fq) for fq in self.cfg.time_cfg.freqs)
freq = min(freq, self.cfg.time_cfg.main_freq)
maps_freq = TsType(self.cfg.modelmaps_opts.maps_freq)
if maps_freq == "coarsest": # TODO: Implement this in terms of a TsType object. #1267
freq = min(TsType(fq) for fq in self.cfg.time_cfg.freqs)
freq = min(freq, self.cfg.time_cfg.main_freq)
else:
freq = maps_freq

Check warning on line 169 in pyaerocom/aeroval/modelmaps_engine.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/aeroval/modelmaps_engine.py#L169

Added line #L169 was not covered by tests
tst = TsType(data.ts_type)

if tst < freq:
Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/aeroval/setupclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_json_output_dirs(self, assert_exists=True):


class ModelMapsSetup(BaseModel):
maps_freq: Literal["monthly", "yearly"] = "monthly"
maps_freq: Literal["hourly", "daily", "monthly", "yearly", "coarsest"] = "coarsest"
maps_res_deg: PositiveInt = 5


Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/time_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from iris import coord_categorisation

TS_TYPES = ["minutely", "hourly", "daily", "weekly", "monthly", "yearly", "native"]
TS_TYPES = ["minutely", "hourly", "daily", "weekly", "monthly", "yearly", "native", "coarsest"]

# The following import was removed and the information about available unit
# strings was copied from the netCDF4 module directly here
Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/tstype.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class TsType:
VALID = TS_TYPES
VALID_ITER = VALID[:-1]
VALID_ITER = VALID[:-2]
FROM_PANDAS = PANDAS_FREQ_TO_TS_TYPE
TO_PANDAS = TS_TYPE_TO_PANDAS_FREQ
TO_NUMPY = TS_TYPE_TO_NUMPY_FREQ
Expand Down
2 changes: 1 addition & 1 deletion tests/aeroval/test_setupclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_EvalSetup_ModelMapsSetup(eval_setup: EvalSetup, cfg_exp1: dict, update:
assert modelmaps_opts.maps_res_deg == cfg_exp1["maps_res_deg"] == update["maps_res_deg"]
else: # defaults
assert "maps_freq" not in cfg_exp1
assert modelmaps_opts.maps_freq == "monthly"
assert modelmaps_opts.maps_freq == "coarsest"
assert "maps_res_deg" not in cfg_exp1
assert modelmaps_opts.maps_res_deg == 5

Expand Down
2 changes: 1 addition & 1 deletion tests/io/test_iris_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_check_time_coord(cube: Cube):
"blaa",
2010,
TemporalResolutionError,
"Invalid input for ts_type blaa. Choose from ['minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'native']",
"Invalid input for ts_type blaa. Choose from ['minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'native', 'coarsest']",
id="wrong ts_type",
),
pytest.param(
Expand Down
13 changes: 11 additions & 2 deletions tests/test_tstype.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@


def test_TsType_VALID():
assert TsType.VALID == ["minutely", "hourly", "daily", "weekly", "monthly", "yearly", "native"]
assert TsType.VALID == [
"minutely",
"hourly",
"daily",
"weekly",
"monthly",
"yearly",
"native",
"coarsest",
]


def test_TsType_VALID_ITER():
Expand Down Expand Up @@ -75,7 +84,7 @@ def test_TsType_val():
(
"blaa",
"Invalid input for ts_type blaa. "
"Choose from ['minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'native']",
"Choose from ['minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'native', 'coarsest']",
),
(
"5000daily",
Expand Down