From 6c376f047dc6a002bb6dd57af8361cfcf8efed22 Mon Sep 17 00:00:00 2001 From: charlien Date: Thu, 29 Aug 2024 08:32:51 +0200 Subject: [PATCH 1/4] add evaluation type for cams283, tweak rtol fairmode --- pyaerocom/aeroval/fairmode_stats.py | 2 +- pyaerocom/scripts/cams2_83/evaluation.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pyaerocom/aeroval/fairmode_stats.py b/pyaerocom/aeroval/fairmode_stats.py index f6b87cdeb..bef60d99f 100644 --- a/pyaerocom/aeroval/fairmode_stats.py +++ b/pyaerocom/aeroval/fairmode_stats.py @@ -77,7 +77,7 @@ def fairmode_stats(obs_var: str, stats: dict) -> dict: assert np.isclose( rmsu * beta_mqi, np.sqrt((bias) ** 2 + (mod_std - obs_std) ** 2 + (2 * obs_std * mod_std * (1 - R))), - rtol=1e-3, + rtol=1e-2, ), "failed MQI check" fairmode = dict( diff --git a/pyaerocom/scripts/cams2_83/evaluation.py b/pyaerocom/scripts/cams2_83/evaluation.py index ecf1df814..2a7279b6c 100644 --- a/pyaerocom/scripts/cams2_83/evaluation.py +++ b/pyaerocom/scripts/cams2_83/evaluation.py @@ -19,6 +19,7 @@ class EvalType(str, Enum): LONG = "long" + LONG2 = "long2" SEASON = "season" WEEK = "week" DAY = "day" @@ -43,6 +44,14 @@ def freqs_config(self) -> dict: main_freq="daily", forecast_evaluation=True, ) + + if self == "long2": # this is to have the same frequencies than 'long' but avoid L81 + return dict( + freqs=["daily", "monthly"], + ts_type="hourly", + main_freq="daily", + forecast_evaluation=True, + ) if self == "season": return dict( From cf129e18096dddfafc16f8b4c676e032978fd2f7 Mon Sep 17 00:00:00 2001 From: charlien Date: Thu, 29 Aug 2024 10:00:15 +0200 Subject: [PATCH 2/4] add dummy test just to show that the long2 option doe not crash the code --- tests/cams2_83/test_cams2_83_cli_mos.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/cams2_83/test_cams2_83_cli_mos.py b/tests/cams2_83/test_cams2_83_cli_mos.py index 91947235b..cf1dd45aa 100644 --- a/tests/cams2_83/test_cams2_83_cli_mos.py +++ b/tests/cams2_83/test_cams2_83_cli_mos.py @@ -29,6 +29,16 @@ def test_eval_mos_dummy( assert "no output available" in caplog.text +def test_eval_mos_dummy_2( + tmp_path: Path, + caplog, +): + options = f"long2 2024-03-01 2024-05-12 --data-path {tmp_path} --coldata-path {tmp_path} --name 'Test'" + result = runner.invoke(app, options.split()) + assert result.exit_code == 0 + assert "no output available" in caplog.text + + @pytest.mark.usefixtures("fake_CAMS2_83_Processer", "reset_cachedir") def test_eval_mos_standard(tmp_path: Path, coldata_mos: Path, caplog): options = f"day 2024-03-01 2024-03-01 --data-path {tmp_path} --coldata-path {coldata_mos} --cache {tmp_path} --id mos-colocated-data --name 'Test'" From afb0a48368eec4e439b82f7cbedb053238d55c2d Mon Sep 17 00:00:00 2001 From: charlien Date: Fri, 30 Aug 2024 09:52:04 +0200 Subject: [PATCH 3/4] instead of having a new option, skip using make_period_ys if we have a type long evaluation that does not span across 2 different years --- pyaerocom/scripts/cams2_83/evaluation.py | 11 ++--------- tests/cams2_83/test_cams2_83_cli_mos.py | 10 ---------- tests/cams2_83/test_cams2_83_evaluation.py | 7 +++++++ 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/pyaerocom/scripts/cams2_83/evaluation.py b/pyaerocom/scripts/cams2_83/evaluation.py index 2a7279b6c..5f17ab256 100644 --- a/pyaerocom/scripts/cams2_83/evaluation.py +++ b/pyaerocom/scripts/cams2_83/evaluation.py @@ -45,14 +45,6 @@ def freqs_config(self) -> dict: forecast_evaluation=True, ) - if self == "long2": # this is to have the same frequencies than 'long' but avoid L81 - return dict( - freqs=["daily", "monthly"], - ts_type="hourly", - main_freq="daily", - forecast_evaluation=True, - ) - if self == "season": return dict( freqs=["hourly", "daily"], @@ -80,7 +72,8 @@ def freqs_config(self) -> dict: def periods(self, start_date: date, end_date: date) -> list[str]: if self == "long": - return make_period_ys(start_date, end_date) + if (start_date.year != end_date.year): + return make_period_ys(start_date, end_date) return make_period(start_date, end_date) diff --git a/tests/cams2_83/test_cams2_83_cli_mos.py b/tests/cams2_83/test_cams2_83_cli_mos.py index cf1dd45aa..91947235b 100644 --- a/tests/cams2_83/test_cams2_83_cli_mos.py +++ b/tests/cams2_83/test_cams2_83_cli_mos.py @@ -29,16 +29,6 @@ def test_eval_mos_dummy( assert "no output available" in caplog.text -def test_eval_mos_dummy_2( - tmp_path: Path, - caplog, -): - options = f"long2 2024-03-01 2024-05-12 --data-path {tmp_path} --coldata-path {tmp_path} --name 'Test'" - result = runner.invoke(app, options.split()) - assert result.exit_code == 0 - assert "no output available" in caplog.text - - @pytest.mark.usefixtures("fake_CAMS2_83_Processer", "reset_cachedir") def test_eval_mos_standard(tmp_path: Path, coldata_mos: Path, caplog): options = f"day 2024-03-01 2024-03-01 --data-path {tmp_path} --coldata-path {coldata_mos} --cache {tmp_path} --id mos-colocated-data --name 'Test'" diff --git a/tests/cams2_83/test_cams2_83_evaluation.py b/tests/cams2_83/test_cams2_83_evaluation.py index 8c0f62d56..747e62f0a 100644 --- a/tests/cams2_83/test_cams2_83_evaluation.py +++ b/tests/cams2_83/test_cams2_83_evaluation.py @@ -17,6 +17,13 @@ ["2021-2024", "2021", "2022", "2023", "2024"], id="long", ), + pytest.param( + "long", + datetime(2024, 3, 1), + datetime(2024, 8, 31), + ["20240301-20240831"], + id="long", + ), pytest.param( "week", datetime(2023, 12, 28), From 6ddfcf80bff41e3b41980f43a23c14adf0025a2b Mon Sep 17 00:00:00 2001 From: charlien Date: Fri, 30 Aug 2024 14:37:01 +0200 Subject: [PATCH 4/4] cleanup unused type --- pyaerocom/scripts/cams2_83/evaluation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyaerocom/scripts/cams2_83/evaluation.py b/pyaerocom/scripts/cams2_83/evaluation.py index 5f17ab256..b7e1b5f0e 100644 --- a/pyaerocom/scripts/cams2_83/evaluation.py +++ b/pyaerocom/scripts/cams2_83/evaluation.py @@ -19,7 +19,6 @@ class EvalType(str, Enum): LONG = "long" - LONG2 = "long2" SEASON = "season" WEEK = "week" DAY = "day"