climate-ref-pmp 0.5.1__tar.gz → 0.5.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/PKG-INFO +1 -1
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/pyproject.toml +1 -1
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/diagnostics/annual_cycle.py +2 -20
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/diagnostics/variability_modes.py +1 -0
- climate_ref_pmp-0.5.3/tests/integration/test_diagnostics.py +23 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/tests/unit/test_annual_cycle.py +2 -32
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/tests/unit/test_variability_modes.py +0 -30
- climate_ref_pmp-0.5.1/tests/integration/test_diagnostics.py +0 -12
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/.gitignore +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/LICENCE +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/NOTICE +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/README.md +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/conftest.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/__init__.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/dataset_registry/pmp_climatology.txt +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/diagnostics/__init__.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/params/pmp_param_MoV-psl.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/params/pmp_param_MoV-ts.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/params/pmp_param_annualcycle_1-clims.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/params/pmp_param_annualcycle_2-metrics.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/pmp_driver.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/py.typed +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/requirements/conda-lock.yml +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/requirements/environment.yml +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/tests/unit/conftest.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/tests/unit/test_pmp_driver.py +0 -0
- {climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/tests/unit/test_provider.py +0 -0
{climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/diagnostics/annual_cycle.py
RENAMED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import json
|
|
3
|
-
from collections.abc import Iterable
|
|
4
3
|
from typing import Any
|
|
5
4
|
|
|
6
5
|
from loguru import logger
|
|
@@ -82,21 +81,6 @@ class AnnualCycle(CommandLineDiagnostic):
|
|
|
82
81
|
self.parameter_file_1 = "pmp_param_annualcycle_1-clims.py"
|
|
83
82
|
self.parameter_file_2 = "pmp_param_annualcycle_2-metrics.py"
|
|
84
83
|
|
|
85
|
-
def build_cmd(self, definition: ExecutionDefinition) -> Iterable[str]:
|
|
86
|
-
"""
|
|
87
|
-
Build the command to run the diagnostic
|
|
88
|
-
|
|
89
|
-
Parameters
|
|
90
|
-
----------
|
|
91
|
-
definition
|
|
92
|
-
Definition of the diagnostic execution
|
|
93
|
-
|
|
94
|
-
Returns
|
|
95
|
-
-------
|
|
96
|
-
Command arguments to execute in the PMP environment
|
|
97
|
-
"""
|
|
98
|
-
raise NotImplementedError("Function not required")
|
|
99
|
-
|
|
100
84
|
def build_cmds(self, definition: ExecutionDefinition) -> list[list[str]]:
|
|
101
85
|
"""
|
|
102
86
|
Build the command to run the diagnostic
|
|
@@ -283,7 +267,7 @@ class AnnualCycle(CommandLineDiagnostic):
|
|
|
283
267
|
cmec_metric_bundle=cmec_metric_bundle,
|
|
284
268
|
)
|
|
285
269
|
|
|
286
|
-
def
|
|
270
|
+
def execute(self, definition: ExecutionDefinition) -> None:
|
|
287
271
|
"""
|
|
288
272
|
Run the diagnostic on the given configuration.
|
|
289
273
|
|
|
@@ -302,8 +286,6 @@ class AnnualCycle(CommandLineDiagnostic):
|
|
|
302
286
|
runs = [self.provider.run(cmd) for cmd in cmds]
|
|
303
287
|
logger.debug(f"runs: {runs}")
|
|
304
288
|
|
|
305
|
-
return self.build_execution_result(definition)
|
|
306
|
-
|
|
307
289
|
|
|
308
290
|
def _transform_results(data: dict[str, Any]) -> dict[str, Any]:
|
|
309
291
|
"""
|
|
@@ -312,7 +294,7 @@ def _transform_results(data: dict[str, Any]) -> dict[str, Any]:
|
|
|
312
294
|
Parameters
|
|
313
295
|
----------
|
|
314
296
|
data : dict
|
|
315
|
-
The original
|
|
297
|
+
The original execution dictionary.
|
|
316
298
|
|
|
317
299
|
Returns
|
|
318
300
|
-------
|
{climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/diagnostics/variability_modes.py
RENAMED
|
@@ -32,6 +32,7 @@ class ExtratropicalModesOfVariability(CommandLineDiagnostic):
|
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
def __init__(self, mode_id: str):
|
|
35
|
+
super().__init__()
|
|
35
36
|
self.mode_id = mode_id.upper()
|
|
36
37
|
self.name = f"Extratropical modes of variability: {mode_id}"
|
|
37
38
|
self.slug = f"extratropical-modes-of-variability-{mode_id.lower()}"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from climate_ref_pmp import provider as pmp_provider
|
|
3
|
+
|
|
4
|
+
from climate_ref_core.diagnostics import Diagnostic
|
|
5
|
+
|
|
6
|
+
diagnostics = [pytest.param(diagnostic, id=diagnostic.slug) for diagnostic in pmp_provider.diagnostics()]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.mark.slow
|
|
10
|
+
@pytest.mark.parametrize("diagnostic", diagnostics)
|
|
11
|
+
def test_diagnostics(diagnostic: Diagnostic, diagnostic_validation):
|
|
12
|
+
validator = diagnostic_validation(diagnostic)
|
|
13
|
+
|
|
14
|
+
definition = validator.get_definition()
|
|
15
|
+
validator.execute(definition)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.mark.parametrize("diagnostic", diagnostics)
|
|
19
|
+
def test_build_results(diagnostic: Diagnostic, diagnostic_validation):
|
|
20
|
+
validator = diagnostic_validation(diagnostic)
|
|
21
|
+
|
|
22
|
+
definition = validator.get_regression_definition()
|
|
23
|
+
validator.validate(definition)
|
|
@@ -2,7 +2,6 @@ import datetime
|
|
|
2
2
|
|
|
3
3
|
import pandas as pd
|
|
4
4
|
import pytest
|
|
5
|
-
from attr import evolve
|
|
6
5
|
from climate_ref_pmp import AnnualCycle
|
|
7
6
|
from climate_ref_pmp import provider as pmp_provider
|
|
8
7
|
from climate_ref_pmp.pmp_driver import _get_resource
|
|
@@ -186,7 +185,7 @@ def test_annual_cycle_diagnostic(
|
|
|
186
185
|
]
|
|
187
186
|
|
|
188
187
|
|
|
189
|
-
def
|
|
188
|
+
def test_diagnostic_execute(mocker, provider):
|
|
190
189
|
diagnostic = AnnualCycle()
|
|
191
190
|
diagnostic.provider = provider
|
|
192
191
|
|
|
@@ -200,36 +199,7 @@ def test_diagnostic_run(mocker, provider):
|
|
|
200
199
|
diagnostic.build_cmds = mocker.MagicMock(return_value=[["mocked_command"], ["mocked_command_2"]])
|
|
201
200
|
diagnostic.build_execution_result = mocker.MagicMock()
|
|
202
201
|
|
|
203
|
-
diagnostic.
|
|
202
|
+
diagnostic.execute("definition")
|
|
204
203
|
|
|
205
204
|
diagnostic.build_cmds.assert_called_once_with("definition")
|
|
206
205
|
assert diagnostic.provider.run.call_count == 2
|
|
207
|
-
diagnostic.build_execution_result.assert_called_once_with("definition")
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
def test_build_cmd_raises():
|
|
211
|
-
diagnostic = AnnualCycle()
|
|
212
|
-
with pytest.raises(NotImplementedError):
|
|
213
|
-
diagnostic.build_cmd("definition")
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
def test_diagnostic_build_result(config, provider, execution_regression_dir, data_catalog):
|
|
217
|
-
diagnostic = AnnualCycle()
|
|
218
|
-
diagnostic.provider = pmp_provider
|
|
219
|
-
diagnostic.provider.configure(config)
|
|
220
|
-
|
|
221
|
-
key = "cmip6_hist-GHG_r1i1p1f1_ACCESS-ESM1-5_ts__pmp-climatology_ERA-5_ts"
|
|
222
|
-
output_directory = execution_regression_dir(diagnostic, key)
|
|
223
|
-
|
|
224
|
-
execution = next(
|
|
225
|
-
solve_executions(
|
|
226
|
-
data_catalog=data_catalog,
|
|
227
|
-
diagnostic=diagnostic,
|
|
228
|
-
provider=diagnostic.provider,
|
|
229
|
-
)
|
|
230
|
-
)
|
|
231
|
-
definition = execution.build_execution_definition(output_root=config.paths.scratch)
|
|
232
|
-
definition = evolve(definition, output_directory=output_directory)
|
|
233
|
-
|
|
234
|
-
result = diagnostic.build_execution_result(definition)
|
|
235
|
-
assert result.successful
|
|
@@ -2,8 +2,6 @@ import shutil
|
|
|
2
2
|
|
|
3
3
|
import pandas as pd
|
|
4
4
|
import pytest
|
|
5
|
-
from attr import evolve
|
|
6
|
-
from climate_ref_pmp import provider as pmp_provider
|
|
7
5
|
from climate_ref_pmp.diagnostics import ExtratropicalModesOfVariability
|
|
8
6
|
from climate_ref_pmp.pmp_driver import _get_resource
|
|
9
7
|
|
|
@@ -118,31 +116,3 @@ def test_mode_id_invalid():
|
|
|
118
116
|
with pytest.raises(ValueError) as excinfo:
|
|
119
117
|
ExtratropicalModesOfVariability("INVALID")
|
|
120
118
|
assert "Unknown mode_id 'INVALID'" in str(excinfo.value)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
@pytest.mark.parametrize(
|
|
124
|
-
"mode",
|
|
125
|
-
sorted(
|
|
126
|
-
set(ExtratropicalModesOfVariability.psl_modes + ExtratropicalModesOfVariability.ts_modes) - {"AMO"}
|
|
127
|
-
),
|
|
128
|
-
)
|
|
129
|
-
def test_diagnostic_build_result(mode, config, provider, execution_regression_dir, data_catalog):
|
|
130
|
-
diagnostic = ExtratropicalModesOfVariability(mode)
|
|
131
|
-
diagnostic.provider = pmp_provider
|
|
132
|
-
diagnostic.provider.configure(config)
|
|
133
|
-
|
|
134
|
-
execution = next(
|
|
135
|
-
solve_executions(
|
|
136
|
-
data_catalog=data_catalog,
|
|
137
|
-
diagnostic=diagnostic,
|
|
138
|
-
provider=diagnostic.provider,
|
|
139
|
-
)
|
|
140
|
-
)
|
|
141
|
-
definition = execution.build_execution_definition(output_root=config.paths.scratch)
|
|
142
|
-
output_directory = execution_regression_dir(diagnostic, definition.key)
|
|
143
|
-
assert output_directory.exists()
|
|
144
|
-
|
|
145
|
-
definition = evolve(definition, output_directory=output_directory)
|
|
146
|
-
|
|
147
|
-
result = diagnostic.build_execution_result(definition)
|
|
148
|
-
assert result.successful
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from climate_ref_pmp import provider as pmp_provider
|
|
3
|
-
|
|
4
|
-
from climate_ref_core.diagnostics import Diagnostic
|
|
5
|
-
|
|
6
|
-
diagnostics = [pytest.param(diagnostic, id=diagnostic.slug) for diagnostic in pmp_provider.diagnostics()]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@pytest.mark.slow
|
|
10
|
-
@pytest.mark.parametrize("diagnostic", diagnostics)
|
|
11
|
-
def test_diagnostics(diagnostic: Diagnostic, diagnostic_validation):
|
|
12
|
-
diagnostic_validation(diagnostic)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/params/pmp_param_MoV-psl.py
RENAMED
|
File without changes
|
{climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/params/pmp_param_MoV-ts.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/requirements/conda-lock.yml
RENAMED
|
File without changes
|
{climate_ref_pmp-0.5.1 → climate_ref_pmp-0.5.3}/src/climate_ref_pmp/requirements/environment.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|