climate-ref-esmvaltool 0.5.4__tar.gz → 0.5.5__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_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/PKG-INFO +3 -2
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/pyproject.toml +4 -3
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/__init__.py +2 -2
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/base.py +11 -6
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/ecs.py +24 -18
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/tcr.py +19 -16
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/tcre.py +7 -13
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/zec.py +8 -13
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/integration/test_diagnostics.py +1 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_ecs.py +14 -4
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_tcr.py +10 -3
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_tcre.py +1 -1
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_zec.py +1 -1
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/.gitignore +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/LICENCE +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/NOTICE +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/README.md +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/_version.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/dataset_registry/data.txt +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/__init__.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/climate_at_global_warming_levels.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/cloud_radiative_effects.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/example.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/diagnostics/sea_ice_area_seasonal_cycle.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/py.typed +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/recipe.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/recipes.txt +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/requirements/conda-lock.yml +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/requirements/environment.yml +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/types.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/input_files_climate_at_global_warming_levels.json +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/input_files_cloud_radiative_effects.json +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/input_files_ecs.json +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/input_files_sea_ice_area.json +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/input_files_tcr.json +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/input_files_tcre.json +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/input_files_zec.json +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_base.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_climate_at_global_warming_levels.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_cloud_radiative_effects.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_sea_ice_area.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/test_metrics.py +0 -0
- {climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/test_provider.py +0 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: climate-ref-esmvaltool
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.5
|
|
4
4
|
Summary: ESMValTool diagnostic provider for the Rapid Evaluation Framework
|
|
5
5
|
Author-email: ESMValTool development team <esmvaltool-dev@listserv.dfn.de>
|
|
6
6
|
License: Apache-2.0
|
|
7
7
|
License-File: LICENCE
|
|
8
8
|
License-File: NOTICE
|
|
9
|
-
Classifier: Development Status ::
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
13
|
Classifier: Operating System :: OS Independent
|
|
13
14
|
Classifier: Programming Language :: Python
|
|
14
15
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "climate-ref-esmvaltool"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.5"
|
|
4
4
|
description = "ESMValTool diagnostic provider for the Rapid Evaluation Framework"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -8,9 +8,9 @@ authors = [
|
|
|
8
8
|
]
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
classifiers = [
|
|
11
|
-
"Development Status ::
|
|
12
|
-
"Intended Audience :: Developers",
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
13
12
|
"Operating System :: OS Independent",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
14
|
"Intended Audience :: Science/Research",
|
|
15
15
|
"Programming Language :: Python",
|
|
16
16
|
"Programming Language :: Python :: 3",
|
|
@@ -18,6 +18,7 @@ classifiers = [
|
|
|
18
18
|
"Programming Language :: Python :: 3.12",
|
|
19
19
|
"Programming Language :: Python :: 3.13",
|
|
20
20
|
"Topic :: Scientific/Engineering",
|
|
21
|
+
"License :: OSI Approved :: Apache Software License",
|
|
21
22
|
]
|
|
22
23
|
dependencies = [
|
|
23
24
|
"pooch >= 1.8",
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/__init__.py
RENAMED
|
@@ -3,7 +3,7 @@ Rapid evaluating CMIP data with ESMValTool.
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import climate_ref_esmvaltool.diagnostics
|
|
6
|
-
from climate_ref_core.dataset_registry import dataset_registry_manager
|
|
6
|
+
from climate_ref_core.dataset_registry import DATASET_URL, dataset_registry_manager
|
|
7
7
|
from climate_ref_core.providers import CondaDiagnosticProvider
|
|
8
8
|
from climate_ref_esmvaltool._version import __version__
|
|
9
9
|
from climate_ref_esmvaltool.recipe import _ESMVALTOOL_COMMIT
|
|
@@ -24,7 +24,7 @@ for _diagnostic_cls_name in climate_ref_esmvaltool.diagnostics.__all__:
|
|
|
24
24
|
# Register OBS, OBS6, and raw data
|
|
25
25
|
dataset_registry_manager.register(
|
|
26
26
|
"esmvaltool",
|
|
27
|
-
|
|
27
|
+
base_url=DATASET_URL,
|
|
28
28
|
package="climate_ref_esmvaltool.dataset_registry",
|
|
29
29
|
resource="data.txt",
|
|
30
30
|
)
|
|
@@ -14,7 +14,7 @@ from climate_ref_core.diagnostics import (
|
|
|
14
14
|
ExecutionDefinition,
|
|
15
15
|
ExecutionResult,
|
|
16
16
|
)
|
|
17
|
-
from climate_ref_core.pycmec.metric import CMECMetric
|
|
17
|
+
from climate_ref_core.pycmec.metric import CMECMetric, MetricCV
|
|
18
18
|
from climate_ref_core.pycmec.output import CMECOutput, OutputCV
|
|
19
19
|
from climate_ref_esmvaltool.recipe import load_recipe, prepare_climate_data
|
|
20
20
|
from climate_ref_esmvaltool.types import MetricBundleArgs, OutputBundleArgs, Recipe
|
|
@@ -48,7 +48,7 @@ class ESMValToolDiagnostic(CommandLineDiagnostic):
|
|
|
48
48
|
execution_dataset: ExecutionDatasetCollection,
|
|
49
49
|
metric_args: MetricBundleArgs,
|
|
50
50
|
output_args: OutputBundleArgs,
|
|
51
|
-
) -> tuple[
|
|
51
|
+
) -> tuple[CMECMetric, CMECOutput]:
|
|
52
52
|
"""
|
|
53
53
|
Update the arguments needed to create a CMEC diagnostic and output bundle.
|
|
54
54
|
|
|
@@ -67,7 +67,7 @@ class ESMValToolDiagnostic(CommandLineDiagnostic):
|
|
|
67
67
|
-------
|
|
68
68
|
The arguments needed to create a CMEC diagnostic and output bundle.
|
|
69
69
|
"""
|
|
70
|
-
return metric_args, output_args
|
|
70
|
+
return CMECMetric.model_validate(metric_args), CMECOutput.model_validate(output_args)
|
|
71
71
|
|
|
72
72
|
def build_cmd(self, definition: ExecutionDefinition) -> Iterable[str]:
|
|
73
73
|
"""
|
|
@@ -198,15 +198,20 @@ class ESMValToolDiagnostic(CommandLineDiagnostic):
|
|
|
198
198
|
output_args[OutputCV.PROVENANCE.value][OutputCV.LOG.value] = f"{result_dir}/run/main_log_debug.txt"
|
|
199
199
|
|
|
200
200
|
# Update the diagnostic and output bundle with diagnostic specific executions.
|
|
201
|
-
|
|
201
|
+
metric_bundle, output_bundle = self.format_result(
|
|
202
202
|
result_dir=result_dir,
|
|
203
203
|
execution_dataset=definition.datasets,
|
|
204
204
|
metric_args=metric_args,
|
|
205
205
|
output_args=output_args,
|
|
206
206
|
)
|
|
207
207
|
|
|
208
|
+
# Add the extra information from the groupby operations
|
|
209
|
+
if len(metric_bundle.DIMENSIONS[MetricCV.JSON_STRUCTURE.value]):
|
|
210
|
+
input_selectors = definition.datasets[SourceDatasetType.CMIP6].selector_dict()
|
|
211
|
+
metric_bundle = metric_bundle.prepend_dimensions(input_selectors)
|
|
212
|
+
|
|
208
213
|
return ExecutionResult.build_from_output_bundle(
|
|
209
214
|
definition,
|
|
210
|
-
cmec_output_bundle=
|
|
211
|
-
cmec_metric_bundle=
|
|
215
|
+
cmec_output_bundle=output_bundle,
|
|
216
|
+
cmec_metric_bundle=metric_bundle,
|
|
212
217
|
)
|
|
@@ -11,7 +11,8 @@ from climate_ref_core.constraints import (
|
|
|
11
11
|
)
|
|
12
12
|
from climate_ref_core.datasets import ExecutionDatasetCollection, FacetFilter, SourceDatasetType
|
|
13
13
|
from climate_ref_core.diagnostics import DataRequirement
|
|
14
|
-
from climate_ref_core.pycmec.metric import MetricCV
|
|
14
|
+
from climate_ref_core.pycmec.metric import CMECMetric, MetricCV
|
|
15
|
+
from climate_ref_core.pycmec.output import CMECOutput
|
|
15
16
|
from climate_ref_esmvaltool.diagnostics.base import ESMValToolDiagnostic
|
|
16
17
|
from climate_ref_esmvaltool.recipe import dataframe_to_recipe
|
|
17
18
|
from climate_ref_esmvaltool.types import MetricBundleArgs, OutputBundleArgs, Recipe
|
|
@@ -57,14 +58,14 @@ class EquilibriumClimateSensitivity(ESMValToolDiagnostic):
|
|
|
57
58
|
),
|
|
58
59
|
),
|
|
59
60
|
)
|
|
60
|
-
facets = ("source_id", "region", "metric")
|
|
61
|
+
facets = ("grid_label", "member_id", "source_id", "region", "metric")
|
|
61
62
|
|
|
62
63
|
@staticmethod
|
|
63
64
|
def update_recipe(recipe: Recipe, input_files: pandas.DataFrame) -> None:
|
|
64
65
|
"""Update the recipe."""
|
|
65
66
|
# Only run the diagnostic that computes ECS for a single model.
|
|
66
67
|
recipe["diagnostics"] = {
|
|
67
|
-
"
|
|
68
|
+
"ecs": {
|
|
68
69
|
"description": "Calculate ECS.",
|
|
69
70
|
"variables": {
|
|
70
71
|
"tas": {
|
|
@@ -76,7 +77,7 @@ class EquilibriumClimateSensitivity(ESMValToolDiagnostic):
|
|
|
76
77
|
},
|
|
77
78
|
},
|
|
78
79
|
"scripts": {
|
|
79
|
-
"
|
|
80
|
+
"calculate": {
|
|
80
81
|
"script": "climate_metrics/ecs.py",
|
|
81
82
|
"calculate_mmm": False,
|
|
82
83
|
},
|
|
@@ -103,6 +104,18 @@ class EquilibriumClimateSensitivity(ESMValToolDiagnostic):
|
|
|
103
104
|
for dataset in datasets:
|
|
104
105
|
dataset["timerange"] = timerange
|
|
105
106
|
|
|
107
|
+
# Remove keys from the recipe that are only used for YAML anchors
|
|
108
|
+
keys_to_remove = [
|
|
109
|
+
"CMIP5_RTMT",
|
|
110
|
+
"CMIP6_RTMT",
|
|
111
|
+
"CMIP5_RTNT",
|
|
112
|
+
"CMIP6_RTNT",
|
|
113
|
+
"ECS_SCRIPT",
|
|
114
|
+
"SCATTERPLOT",
|
|
115
|
+
]
|
|
116
|
+
for key in keys_to_remove:
|
|
117
|
+
recipe.pop(key, None)
|
|
118
|
+
|
|
106
119
|
recipe["datasets"] = datasets
|
|
107
120
|
|
|
108
121
|
@staticmethod
|
|
@@ -111,34 +124,27 @@ class EquilibriumClimateSensitivity(ESMValToolDiagnostic):
|
|
|
111
124
|
execution_dataset: ExecutionDatasetCollection,
|
|
112
125
|
metric_args: MetricBundleArgs,
|
|
113
126
|
output_args: OutputBundleArgs,
|
|
114
|
-
) -> tuple[
|
|
127
|
+
) -> tuple[CMECMetric, CMECOutput]:
|
|
115
128
|
"""Format the result."""
|
|
116
|
-
|
|
117
|
-
source_id = input_files.iloc[0].source_id
|
|
118
|
-
|
|
119
|
-
ecs_ds = xarray.open_dataset(result_dir / "work" / "cmip6" / "ecs" / "ecs.nc")
|
|
129
|
+
ecs_ds = xarray.open_dataset(result_dir / "work" / "ecs" / "calculate" / "ecs.nc")
|
|
120
130
|
ecs = float(ecs_ds["ecs"].values[0])
|
|
121
|
-
lambda_ds = xarray.open_dataset(result_dir / "work" / "
|
|
131
|
+
lambda_ds = xarray.open_dataset(result_dir / "work" / "ecs" / "calculate" / "lambda.nc")
|
|
122
132
|
lambda_ = float(lambda_ds["lambda"].values[0])
|
|
123
133
|
|
|
124
134
|
# Update the diagnostic bundle arguments with the computed diagnostics.
|
|
125
135
|
metric_args[MetricCV.DIMENSIONS.value] = {
|
|
126
136
|
MetricCV.JSON_STRUCTURE.value: [
|
|
127
|
-
"source_id",
|
|
128
137
|
"region",
|
|
129
138
|
"metric",
|
|
130
139
|
],
|
|
131
|
-
"source_id": {source_id: {}},
|
|
132
140
|
"region": {"global": {}},
|
|
133
141
|
"metric": {"ecs": {}, "lambda": {}},
|
|
134
142
|
}
|
|
135
143
|
metric_args[MetricCV.RESULTS.value] = {
|
|
136
|
-
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
"lambda": lambda_,
|
|
140
|
-
},
|
|
144
|
+
"global": {
|
|
145
|
+
"ecs": ecs,
|
|
146
|
+
"lambda": lambda_,
|
|
141
147
|
},
|
|
142
148
|
}
|
|
143
149
|
|
|
144
|
-
return metric_args, output_args
|
|
150
|
+
return CMECMetric.model_validate(metric_args), CMECOutput.model_validate(output_args)
|
|
@@ -11,7 +11,8 @@ from climate_ref_core.constraints import (
|
|
|
11
11
|
)
|
|
12
12
|
from climate_ref_core.datasets import ExecutionDatasetCollection, FacetFilter, SourceDatasetType
|
|
13
13
|
from climate_ref_core.diagnostics import DataRequirement
|
|
14
|
-
from climate_ref_core.pycmec.metric import MetricCV
|
|
14
|
+
from climate_ref_core.pycmec.metric import CMECMetric, MetricCV
|
|
15
|
+
from climate_ref_core.pycmec.output import CMECOutput
|
|
15
16
|
from climate_ref_esmvaltool.diagnostics.base import ESMValToolDiagnostic
|
|
16
17
|
from climate_ref_esmvaltool.recipe import dataframe_to_recipe
|
|
17
18
|
from climate_ref_esmvaltool.types import MetricBundleArgs, OutputBundleArgs, Recipe
|
|
@@ -50,14 +51,14 @@ class TransientClimateResponse(ESMValToolDiagnostic):
|
|
|
50
51
|
),
|
|
51
52
|
),
|
|
52
53
|
)
|
|
53
|
-
facets = ("source_id", "region", "metric")
|
|
54
|
+
facets = ("grid_label", "member_id", "source_id", "region", "metric")
|
|
54
55
|
|
|
55
56
|
@staticmethod
|
|
56
57
|
def update_recipe(recipe: Recipe, input_files: pandas.DataFrame) -> None:
|
|
57
58
|
"""Update the recipe."""
|
|
58
59
|
# Only run the diagnostic that computes TCR for a single model.
|
|
59
60
|
recipe["diagnostics"] = {
|
|
60
|
-
"
|
|
61
|
+
"tcr": {
|
|
61
62
|
"description": "Calculate TCR.",
|
|
62
63
|
"variables": {
|
|
63
64
|
"tas": {
|
|
@@ -65,7 +66,7 @@ class TransientClimateResponse(ESMValToolDiagnostic):
|
|
|
65
66
|
},
|
|
66
67
|
},
|
|
67
68
|
"scripts": {
|
|
68
|
-
"
|
|
69
|
+
"calculate": {
|
|
69
70
|
"script": "climate_metrics/tcr.py",
|
|
70
71
|
"calculate_mmm": False,
|
|
71
72
|
},
|
|
@@ -92,6 +93,15 @@ class TransientClimateResponse(ESMValToolDiagnostic):
|
|
|
92
93
|
for dataset in datasets:
|
|
93
94
|
dataset["timerange"] = timerange
|
|
94
95
|
|
|
96
|
+
# Remove keys from the recipe that are only used for YAML anchors
|
|
97
|
+
keys_to_remove = [
|
|
98
|
+
"TCR",
|
|
99
|
+
"SCATTERPLOT",
|
|
100
|
+
"VAR_SETTING",
|
|
101
|
+
]
|
|
102
|
+
for key in keys_to_remove:
|
|
103
|
+
recipe.pop(key, None)
|
|
104
|
+
|
|
95
105
|
recipe["datasets"] = datasets
|
|
96
106
|
|
|
97
107
|
@staticmethod
|
|
@@ -100,31 +110,24 @@ class TransientClimateResponse(ESMValToolDiagnostic):
|
|
|
100
110
|
execution_dataset: ExecutionDatasetCollection,
|
|
101
111
|
metric_args: MetricBundleArgs,
|
|
102
112
|
output_args: OutputBundleArgs,
|
|
103
|
-
) -> tuple[
|
|
113
|
+
) -> tuple[CMECMetric, CMECOutput]:
|
|
104
114
|
"""Format the result."""
|
|
105
|
-
|
|
106
|
-
source_id = input_files.iloc[0].source_id
|
|
107
|
-
|
|
108
|
-
tcr_ds = xarray.open_dataset(result_dir / "work" / "cmip6" / "tcr" / "tcr.nc")
|
|
115
|
+
tcr_ds = xarray.open_dataset(result_dir / "work" / "tcr" / "calculate" / "tcr.nc")
|
|
109
116
|
tcr = float(tcr_ds["tcr"].values[0])
|
|
110
117
|
|
|
111
118
|
# Update the diagnostic bundle arguments with the computed diagnostics.
|
|
112
119
|
metric_args[MetricCV.DIMENSIONS.value] = {
|
|
113
120
|
"json_structure": [
|
|
114
|
-
"source_id",
|
|
115
121
|
"region",
|
|
116
122
|
"metric",
|
|
117
123
|
],
|
|
118
|
-
"source_id": {source_id: {}},
|
|
119
124
|
"region": {"global": {}},
|
|
120
125
|
"metric": {"tcr": {}},
|
|
121
126
|
}
|
|
122
127
|
metric_args[MetricCV.RESULTS.value] = {
|
|
123
|
-
|
|
124
|
-
"
|
|
125
|
-
"tcr": tcr,
|
|
126
|
-
},
|
|
128
|
+
"global": {
|
|
129
|
+
"tcr": tcr,
|
|
127
130
|
},
|
|
128
131
|
}
|
|
129
132
|
|
|
130
|
-
return metric_args, output_args
|
|
133
|
+
return CMECMetric.model_validate(metric_args), CMECOutput.model_validate(output_args)
|
|
@@ -11,7 +11,8 @@ from climate_ref_core.constraints import (
|
|
|
11
11
|
)
|
|
12
12
|
from climate_ref_core.datasets import ExecutionDatasetCollection, FacetFilter, SourceDatasetType
|
|
13
13
|
from climate_ref_core.diagnostics import DataRequirement
|
|
14
|
-
from climate_ref_core.pycmec.metric import MetricCV
|
|
14
|
+
from climate_ref_core.pycmec.metric import CMECMetric, MetricCV
|
|
15
|
+
from climate_ref_core.pycmec.output import CMECOutput
|
|
15
16
|
from climate_ref_esmvaltool.diagnostics.base import ESMValToolDiagnostic
|
|
16
17
|
from climate_ref_esmvaltool.recipe import dataframe_to_recipe
|
|
17
18
|
from climate_ref_esmvaltool.types import MetricBundleArgs, OutputBundleArgs, Recipe
|
|
@@ -63,7 +64,7 @@ class TransientClimateResponseEmissions(ESMValToolDiagnostic):
|
|
|
63
64
|
),
|
|
64
65
|
),
|
|
65
66
|
)
|
|
66
|
-
facets = ("source_id", "region", "metric")
|
|
67
|
+
facets = ("grid_label", "member_id", "source_id", "region", "metric")
|
|
67
68
|
|
|
68
69
|
@staticmethod
|
|
69
70
|
def update_recipe(recipe: Recipe, input_files: pandas.DataFrame) -> None:
|
|
@@ -107,30 +108,23 @@ class TransientClimateResponseEmissions(ESMValToolDiagnostic):
|
|
|
107
108
|
execution_dataset: ExecutionDatasetCollection,
|
|
108
109
|
metric_args: MetricBundleArgs,
|
|
109
110
|
output_args: OutputBundleArgs,
|
|
110
|
-
) -> tuple[
|
|
111
|
+
) -> tuple[CMECMetric, CMECOutput]:
|
|
111
112
|
"""Format the result."""
|
|
112
|
-
input_files = next(c.datasets for _, c in execution_dataset.items())
|
|
113
|
-
source_id = input_files.iloc[0].source_id
|
|
114
|
-
|
|
115
113
|
tcre_ds = xarray.open_dataset(result_dir / "work" / "tcre" / "calculate_tcre" / "tcre.nc")
|
|
116
114
|
tcre = float(tcre_ds["tcre"].values[0])
|
|
117
115
|
|
|
118
116
|
# Update the diagnostic bundle arguments with the computed diagnostics.
|
|
119
117
|
metric_args[MetricCV.DIMENSIONS.value] = {
|
|
120
118
|
"json_structure": [
|
|
121
|
-
"source_id",
|
|
122
119
|
"region",
|
|
123
120
|
"metric",
|
|
124
121
|
],
|
|
125
|
-
"source_id": {source_id: {}},
|
|
126
122
|
"region": {"global": {}},
|
|
127
123
|
"metric": {"tcre": {}},
|
|
128
124
|
}
|
|
129
125
|
metric_args[MetricCV.RESULTS.value] = {
|
|
130
|
-
|
|
131
|
-
"
|
|
132
|
-
"tcre": tcre,
|
|
133
|
-
},
|
|
126
|
+
"global": {
|
|
127
|
+
"tcre": tcre,
|
|
134
128
|
},
|
|
135
129
|
}
|
|
136
|
-
return metric_args, output_args
|
|
130
|
+
return CMECMetric.model_validate(metric_args), CMECOutput.model_validate(output_args)
|
|
@@ -11,7 +11,8 @@ from climate_ref_core.constraints import (
|
|
|
11
11
|
)
|
|
12
12
|
from climate_ref_core.datasets import ExecutionDatasetCollection, FacetFilter, SourceDatasetType
|
|
13
13
|
from climate_ref_core.diagnostics import DataRequirement
|
|
14
|
-
from climate_ref_core.pycmec.metric import MetricCV
|
|
14
|
+
from climate_ref_core.pycmec.metric import CMECMetric, MetricCV
|
|
15
|
+
from climate_ref_core.pycmec.output import CMECOutput
|
|
15
16
|
from climate_ref_esmvaltool.diagnostics.base import ESMValToolDiagnostic
|
|
16
17
|
from climate_ref_esmvaltool.recipe import dataframe_to_recipe
|
|
17
18
|
from climate_ref_esmvaltool.types import MetricBundleArgs, OutputBundleArgs, Recipe
|
|
@@ -50,7 +51,7 @@ class ZeroEmissionCommitment(ESMValToolDiagnostic):
|
|
|
50
51
|
),
|
|
51
52
|
),
|
|
52
53
|
)
|
|
53
|
-
facets = ("source_id", "region", "metric")
|
|
54
|
+
facets = ("grid_label", "member_id", "source_id", "region", "metric")
|
|
54
55
|
|
|
55
56
|
@staticmethod
|
|
56
57
|
def update_recipe(recipe: Recipe, input_files: pandas.DataFrame) -> None:
|
|
@@ -83,27 +84,21 @@ class ZeroEmissionCommitment(ESMValToolDiagnostic):
|
|
|
83
84
|
execution_dataset: ExecutionDatasetCollection,
|
|
84
85
|
metric_args: MetricBundleArgs,
|
|
85
86
|
output_args: OutputBundleArgs,
|
|
86
|
-
) -> tuple[
|
|
87
|
+
) -> tuple[CMECMetric, CMECOutput]:
|
|
87
88
|
"""Format the result."""
|
|
88
|
-
input_files = next(c.datasets for _, c in execution_dataset.items())
|
|
89
|
-
source_id = input_files.iloc[0].source_id
|
|
90
|
-
|
|
91
89
|
zec_ds = xarray.open_dataset(result_dir / "work" / "zec" / "zec" / "zec_50.nc")
|
|
92
90
|
zec = float(zec_ds["zec"].values[0])
|
|
93
91
|
|
|
94
92
|
# Update the diagnostic bundle arguments with the computed diagnostics.
|
|
95
93
|
metric_args[MetricCV.DIMENSIONS.value] = {
|
|
96
|
-
"json_structure":
|
|
97
|
-
"source_id": {source_id: {}},
|
|
94
|
+
"json_structure": ["region", "metric"],
|
|
98
95
|
"region": {"global": {}},
|
|
99
96
|
"metric": {"zec": {}},
|
|
100
97
|
}
|
|
101
98
|
metric_args[MetricCV.RESULTS.value] = {
|
|
102
|
-
|
|
103
|
-
"
|
|
104
|
-
"zec": zec,
|
|
105
|
-
},
|
|
99
|
+
"global": {
|
|
100
|
+
"zec": zec,
|
|
106
101
|
},
|
|
107
102
|
}
|
|
108
103
|
|
|
109
|
-
return metric_args, output_args
|
|
104
|
+
return CMECMetric.model_validate(metric_args), CMECOutput.model_validate(output_args)
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_ecs.py
RENAMED
|
@@ -30,12 +30,22 @@ def test_update_recipe(metric_dataset):
|
|
|
30
30
|
EquilibriumClimateSensitivity().update_recipe(recipe, input_files)
|
|
31
31
|
assert len(recipe["datasets"]) == 2
|
|
32
32
|
assert len(recipe["diagnostics"]) == 1
|
|
33
|
-
assert set(recipe["diagnostics"]["
|
|
33
|
+
assert set(recipe["diagnostics"]["ecs"]["variables"]) == {"tas", "rtnt"}
|
|
34
|
+
undesired_keys = [
|
|
35
|
+
"CMIP5_RTMT",
|
|
36
|
+
"CMIP6_RTMT",
|
|
37
|
+
"CMIP5_RTNT",
|
|
38
|
+
"CMIP6_RTNT",
|
|
39
|
+
"ECS_SCRIPT",
|
|
40
|
+
"SCATTERPLOT",
|
|
41
|
+
]
|
|
42
|
+
for key in undesired_keys:
|
|
43
|
+
assert key not in recipe
|
|
34
44
|
|
|
35
45
|
|
|
36
46
|
def test_format_output(tmp_path, metric_dataset):
|
|
37
47
|
result_dir = tmp_path
|
|
38
|
-
subdir = result_dir / "work" / "
|
|
48
|
+
subdir = result_dir / "work" / "ecs" / "calculate"
|
|
39
49
|
subdir.mkdir(parents=True)
|
|
40
50
|
ecs = xr.Dataset(
|
|
41
51
|
data_vars={
|
|
@@ -58,6 +68,6 @@ def test_format_output(tmp_path, metric_dataset):
|
|
|
58
68
|
)
|
|
59
69
|
|
|
60
70
|
CMECMetric.model_validate(metric_args)
|
|
61
|
-
assert metric_args
|
|
62
|
-
assert metric_args
|
|
71
|
+
assert metric_args.RESULTS["global"]["ecs"] == 1.0
|
|
72
|
+
assert metric_args.RESULTS["global"]["lambda"] == 2.0
|
|
63
73
|
CMECOutput.model_validate(output_args)
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_tcr.py
RENAMED
|
@@ -30,12 +30,19 @@ def test_update_recipe(metric_dataset):
|
|
|
30
30
|
TransientClimateResponse().update_recipe(recipe, input_files)
|
|
31
31
|
assert len(recipe["datasets"]) == 2
|
|
32
32
|
assert len(recipe["diagnostics"]) == 1
|
|
33
|
-
assert set(recipe["diagnostics"]["
|
|
33
|
+
assert set(recipe["diagnostics"]["tcr"]["variables"]) == {"tas"}
|
|
34
|
+
undesired_keys = [
|
|
35
|
+
"TCR",
|
|
36
|
+
"SCATTERPLOT",
|
|
37
|
+
"VAR_SETTING",
|
|
38
|
+
]
|
|
39
|
+
for key in undesired_keys:
|
|
40
|
+
assert key not in recipe
|
|
34
41
|
|
|
35
42
|
|
|
36
43
|
def test_format_output(tmp_path, metric_dataset):
|
|
37
44
|
result_dir = tmp_path
|
|
38
|
-
subdir = result_dir / "work" / "
|
|
45
|
+
subdir = result_dir / "work" / "tcr" / "calculate"
|
|
39
46
|
subdir.mkdir(parents=True)
|
|
40
47
|
tcr = xr.Dataset(
|
|
41
48
|
data_vars={
|
|
@@ -52,5 +59,5 @@ def test_format_output(tmp_path, metric_dataset):
|
|
|
52
59
|
)
|
|
53
60
|
|
|
54
61
|
CMECMetric.model_validate(metric_args)
|
|
55
|
-
assert metric_args
|
|
62
|
+
assert metric_args.RESULTS["global"]["tcr"] == 1.0
|
|
56
63
|
CMECOutput.model_validate(output_args)
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_tcre.py
RENAMED
|
@@ -104,5 +104,5 @@ def test_format_output(tmp_path, metric_dataset):
|
|
|
104
104
|
)
|
|
105
105
|
|
|
106
106
|
CMECMetric.model_validate(metric_args)
|
|
107
|
-
assert metric_args
|
|
107
|
+
assert metric_args.RESULTS["global"]["tcre"] == 1.0
|
|
108
108
|
CMECOutput.model_validate(output_args)
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_zec.py
RENAMED
|
@@ -88,5 +88,5 @@ def test_format_output(tmp_path, metric_dataset):
|
|
|
88
88
|
)
|
|
89
89
|
|
|
90
90
|
CMECMetric.model_validate(metric_args)
|
|
91
|
-
assert metric_args
|
|
91
|
+
assert metric_args.RESULTS["global"]["zec"] == -0.11
|
|
92
92
|
CMECOutput.model_validate(output_args)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/_version.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/py.typed
RENAMED
|
File without changes
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/recipe.py
RENAMED
|
File without changes
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/recipes.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{climate_ref_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/src/climate_ref_esmvaltool/types.py
RENAMED
|
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_esmvaltool-0.5.4 → climate_ref_esmvaltool-0.5.5}/tests/unit/diagnostics/test_base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|