climate-ref-esmvaltool 0.6.6__py3-none-any.whl → 0.8.0__py3-none-any.whl

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.
Files changed (22) hide show
  1. climate_ref_esmvaltool/diagnostics/base.py +92 -45
  2. climate_ref_esmvaltool/diagnostics/climate_at_global_warming_levels.py +37 -14
  3. climate_ref_esmvaltool/diagnostics/climate_drivers_for_fire.py +37 -15
  4. climate_ref_esmvaltool/diagnostics/cloud_radiative_effects.py +37 -18
  5. climate_ref_esmvaltool/diagnostics/cloud_scatterplots.py +19 -7
  6. climate_ref_esmvaltool/diagnostics/ecs.py +26 -5
  7. climate_ref_esmvaltool/diagnostics/enso.py +98 -8
  8. climate_ref_esmvaltool/diagnostics/example.py +11 -10
  9. climate_ref_esmvaltool/diagnostics/regional_historical_changes.py +139 -24
  10. climate_ref_esmvaltool/diagnostics/sea_ice_area_basic.py +57 -3
  11. climate_ref_esmvaltool/diagnostics/sea_ice_sensitivity.py +26 -12
  12. climate_ref_esmvaltool/diagnostics/tcr.py +16 -3
  13. climate_ref_esmvaltool/diagnostics/tcre.py +10 -12
  14. climate_ref_esmvaltool/diagnostics/zec.py +17 -3
  15. climate_ref_esmvaltool/recipe.py +9 -5
  16. {climate_ref_esmvaltool-0.6.6.dist-info → climate_ref_esmvaltool-0.8.0.dist-info}/METADATA +2 -1
  17. climate_ref_esmvaltool-0.8.0.dist-info/RECORD +30 -0
  18. {climate_ref_esmvaltool-0.6.6.dist-info → climate_ref_esmvaltool-0.8.0.dist-info}/WHEEL +1 -1
  19. climate_ref_esmvaltool-0.6.6.dist-info/RECORD +0 -30
  20. {climate_ref_esmvaltool-0.6.6.dist-info → climate_ref_esmvaltool-0.8.0.dist-info}/entry_points.txt +0 -0
  21. {climate_ref_esmvaltool-0.6.6.dist-info → climate_ref_esmvaltool-0.8.0.dist-info}/licenses/LICENCE +0 -0
  22. {climate_ref_esmvaltool-0.6.6.dist-info → climate_ref_esmvaltool-0.8.0.dist-info}/licenses/NOTICE +0 -0
@@ -13,7 +13,7 @@ from climate_ref_core.datasets import ExecutionDatasetCollection, FacetFilter, S
13
13
  from climate_ref_core.diagnostics import DataRequirement
14
14
  from climate_ref_core.pycmec.metric import CMECMetric, MetricCV
15
15
  from climate_ref_core.pycmec.output import CMECOutput
16
- from climate_ref_esmvaltool.diagnostics.base import ESMValToolDiagnostic
16
+ from climate_ref_esmvaltool.diagnostics.base import ESMValToolDiagnostic, fillvalues_to_nan
17
17
  from climate_ref_esmvaltool.recipe import dataframe_to_recipe
18
18
  from climate_ref_esmvaltool.types import MetricBundleArgs, OutputBundleArgs, Recipe
19
19
 
@@ -27,10 +27,6 @@ class TransientClimateResponseEmissions(ESMValToolDiagnostic):
27
27
  slug = "transient-climate-response-emissions"
28
28
  base_recipe = "recipe_tcre.yml"
29
29
 
30
- experiments = (
31
- "esm-1pctCO2",
32
- "esm-piControl",
33
- )
34
30
  variables = (
35
31
  "tas",
36
32
  "fco2antt",
@@ -42,29 +38,31 @@ class TransientClimateResponseEmissions(ESMValToolDiagnostic):
42
38
  FacetFilter(
43
39
  facets={
44
40
  "variable_id": variables,
45
- "frequency": "mon",
46
- "experiment_id": experiments,
41
+ "experiment_id": "esm-1pctCO2",
42
+ "table_id": "Amon",
47
43
  },
48
44
  ),
49
45
  FacetFilter(
50
46
  facets={
51
- "variable_id": "fco2antt",
47
+ "variable_id": "tas",
52
48
  "experiment_id": "esm-piControl",
49
+ "table_id": "Amon",
53
50
  },
54
- keep=False,
55
51
  ),
56
52
  ),
57
53
  group_by=("source_id", "member_id", "grid_label"),
58
54
  constraints=(
59
- RequireFacets("experiment_id", experiments),
60
- RequireFacets("variable_id", variables),
61
55
  RequireContiguousTimerange(group_by=("instance_id",)),
62
56
  RequireOverlappingTimerange(group_by=("instance_id",)),
57
+ RequireFacets("experiment_id", ("esm-1pctCO2", "esm-piControl")),
58
+ RequireFacets("variable_id", variables),
63
59
  AddSupplementaryDataset.from_defaults("areacella", SourceDatasetType.CMIP6),
64
60
  ),
65
61
  ),
66
62
  )
67
63
  facets = ("grid_label", "member_id", "source_id", "region", "metric")
64
+ # TODO: the ESMValTool diagnostic script does not save the data for the timeseries.
65
+ series = tuple()
68
66
 
69
67
  @staticmethod
70
68
  def update_recipe(
@@ -125,7 +123,7 @@ class TransientClimateResponseEmissions(ESMValToolDiagnostic):
125
123
  ) -> tuple[CMECMetric, CMECOutput]:
126
124
  """Format the result."""
127
125
  tcre_ds = xarray.open_dataset(result_dir / "work" / "tcre" / "calculate_tcre" / "tcre.nc")
128
- tcre = float(tcre_ds["tcre"].values[0])
126
+ tcre = float(fillvalues_to_nan(tcre_ds["tcre"].values)[0])
129
127
 
130
128
  # Update the diagnostic bundle arguments with the computed diagnostics.
131
129
  metric_args[MetricCV.DIMENSIONS.value] = {
@@ -11,9 +11,10 @@ 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.metric_values.typing import SeriesDefinition
14
15
  from climate_ref_core.pycmec.metric import CMECMetric, MetricCV
15
16
  from climate_ref_core.pycmec.output import CMECOutput
16
- from climate_ref_esmvaltool.diagnostics.base import ESMValToolDiagnostic
17
+ from climate_ref_esmvaltool.diagnostics.base import ESMValToolDiagnostic, fillvalues_to_nan
17
18
  from climate_ref_esmvaltool.recipe import dataframe_to_recipe
18
19
  from climate_ref_esmvaltool.types import MetricBundleArgs, OutputBundleArgs, Recipe
19
20
 
@@ -39,19 +40,32 @@ class ZeroEmissionCommitment(ESMValToolDiagnostic):
39
40
  facets={
40
41
  "variable_id": ("tas",),
41
42
  "experiment_id": experiments,
43
+ "table_id": "Amon",
42
44
  },
43
45
  ),
44
46
  ),
45
47
  group_by=("source_id", "member_id", "grid_label"),
46
48
  constraints=(
47
- RequireFacets("experiment_id", experiments),
48
49
  RequireContiguousTimerange(group_by=("instance_id",)),
49
50
  RequireOverlappingTimerange(group_by=("instance_id",)),
51
+ RequireFacets("experiment_id", experiments),
50
52
  AddSupplementaryDataset.from_defaults("areacella", SourceDatasetType.CMIP6),
51
53
  ),
52
54
  ),
53
55
  )
54
56
  facets = ("grid_label", "member_id", "source_id", "region", "metric")
57
+ series = (
58
+ SeriesDefinition(
59
+ file_pattern="work/zec/zec/zec.nc",
60
+ sel={"dim0": 0},
61
+ dimensions={
62
+ "statistic": "zec",
63
+ },
64
+ values_name="zec",
65
+ index_name="time",
66
+ attributes=[],
67
+ ),
68
+ )
55
69
 
56
70
  @staticmethod
57
71
  def update_recipe(
@@ -90,7 +104,7 @@ class ZeroEmissionCommitment(ESMValToolDiagnostic):
90
104
  ) -> tuple[CMECMetric, CMECOutput]:
91
105
  """Format the result."""
92
106
  zec_ds = xarray.open_dataset(result_dir / "work" / "zec" / "zec" / "zec_50.nc")
93
- zec = float(zec_ds["zec"].values[0])
107
+ zec = float(fillvalues_to_nan(zec_ds["zec"].values)[0])
94
108
 
95
109
  # Update the diagnostic bundle arguments with the computed diagnostics.
96
110
  metric_args[MetricCV.DIMENSIONS.value] = {
@@ -87,11 +87,11 @@ def as_facets(
87
87
 
88
88
  """
89
89
  facets = {}
90
- first_row = group.iloc[0]
91
- project = first_row.instance_id.split(".", 2)[0]
90
+ project = group.iloc[0].instance_id.split(".", 2)[0]
92
91
  facets["project"] = project
93
92
  for esmvaltool_name, ref_name in FACETS[project].items():
94
- facets[esmvaltool_name] = getattr(first_row, ref_name)
93
+ values = group[ref_name].unique().tolist()
94
+ facets[esmvaltool_name] = values if len(values) > 1 else values[0]
95
95
  timerange = as_timerange(group)
96
96
  if timerange is not None:
97
97
  facets["timerange"] = timerange
@@ -100,6 +100,7 @@ def as_facets(
100
100
 
101
101
  def dataframe_to_recipe(
102
102
  files: pd.DataFrame,
103
+ group_by: tuple[str, ...] = ("instance_id",),
103
104
  equalize_timerange: bool = False,
104
105
  ) -> dict[str, Any]:
105
106
  """Convert the datasets dataframe to a recipe "variables" section.
@@ -108,14 +109,17 @@ def dataframe_to_recipe(
108
109
  ----------
109
110
  files
110
111
  The pandas dataframe describing the input files.
112
+ group_by
113
+ The columns to group the input files by.
114
+ equalize_timerange
115
+ If True, use the timerange that is covered by all datasets.
111
116
 
112
117
  Returns
113
118
  -------
114
119
  A "variables" section that can be used in an ESMValTool recipe.
115
120
  """
116
121
  variables: dict[str, Any] = {}
117
- # TODO: refine to make it possible to combine historical and scenario runs.
118
- for _, group in files.groupby("instance_id"):
122
+ for _, group in files.groupby(list(group_by)):
119
123
  facets = as_facets(group)
120
124
  short_name = facets.pop("short_name")
121
125
  if short_name not in variables:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: climate-ref-esmvaltool
3
- Version: 0.6.6
3
+ Version: 0.8.0
4
4
  Summary: ESMValTool diagnostic provider for the Rapid Evaluation Framework
5
5
  Author-email: ESMValTool development team <esmvaltool-dev@listserv.dfn.de>, Jared Lewis <jared.lewis@climate-resource.com>
6
6
  License-Expression: Apache-2.0
@@ -19,6 +19,7 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Topic :: Scientific/Engineering
20
20
  Requires-Python: >=3.11
21
21
  Requires-Dist: climate-ref-core
22
+ Requires-Dist: netcdf4>=1.7.2
22
23
  Requires-Dist: pooch>=1.8
23
24
  Requires-Dist: pyyaml
24
25
  Requires-Dist: xarray>=2023.3.0
@@ -0,0 +1,30 @@
1
+ climate_ref_esmvaltool/__init__.py,sha256=4WHuuZJvK50Djb831ws_Y2EtFLWicwsLIxhOvRld2BE,994
2
+ climate_ref_esmvaltool/_version.py,sha256=Ed7geC_W9fxIocCdAvK1fk2k-pDt6FGOM_LEgR06-24,94
3
+ climate_ref_esmvaltool/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ climate_ref_esmvaltool/recipe.py,sha256=elf_LnZaqXzMnOsh87Kp75SqdmeqFOrcZfDE2lj-bl0,6722
5
+ climate_ref_esmvaltool/recipes.txt,sha256=X8yzdTW-TDJH5j-kJ5aq57ztZ6uvFItelVflJcTNEjs,1744
6
+ climate_ref_esmvaltool/types.py,sha256=luUMNS3LJGJEecVrHRDh5l5ElnQgz7G0auCtA_Jwnno,117
7
+ climate_ref_esmvaltool/dataset_registry/data.txt,sha256=aD5lg5x9O1mn2e9ueKefxmuBGH2OED1sqSdoeLrnIBk,24339
8
+ climate_ref_esmvaltool/diagnostics/__init__.py,sha256=GRCsqpp9XY3p9nWQII05IhfzKSSwAoTQ0vc21mlPEbo,2022
9
+ climate_ref_esmvaltool/diagnostics/base.py,sha256=gYp6wZG8Wy_TFFOt3Wwl0ddncrId6b21oM8o3KaDjS8,12735
10
+ climate_ref_esmvaltool/diagnostics/climate_at_global_warming_levels.py,sha256=hL-aXHjJZKIilUqORBu-LjOe_GYBemszkZlqJuF64rg,4136
11
+ climate_ref_esmvaltool/diagnostics/climate_drivers_for_fire.py,sha256=CadaNKAUNv7MeUNAP-4betQluAXyMTOZJx9OW7h2SwI,3041
12
+ climate_ref_esmvaltool/diagnostics/cloud_radiative_effects.py,sha256=m0y-dFrQOvfgdLI2Y5rSadSQkIi6BLWgY_AfLoGcXco,3495
13
+ climate_ref_esmvaltool/diagnostics/cloud_scatterplots.py,sha256=XKTI6WQZALK_2k2IQIz4xcxnOHQ3I5SjscxRac7tFAY,7460
14
+ climate_ref_esmvaltool/diagnostics/ecs.py,sha256=tH80UWBViYWjVCGqi3aLId3wPcksFWHfXA9anlRTWXE,5651
15
+ climate_ref_esmvaltool/diagnostics/enso.py,sha256=QGlOAbMIrbHdCxhJ_oxNVlhE4n13gkIuYLgNQMuG-PI,9215
16
+ climate_ref_esmvaltool/diagnostics/example.py,sha256=-6nsJnRJJx4E1ZHlAe_MRbdJdVSoKviPdSQgYyrVwDA,2453
17
+ climate_ref_esmvaltool/diagnostics/regional_historical_changes.py,sha256=LuIoYJ0OyX78fjgJ1aEFU3xNa9J3omH_hcAm0vmGIqo,15746
18
+ climate_ref_esmvaltool/diagnostics/sea_ice_area_basic.py,sha256=yuqe4HbANXJD78iHEHlXoL6BMpRD8hq-tecfexuLgx0,4980
19
+ climate_ref_esmvaltool/diagnostics/sea_ice_sensitivity.py,sha256=F0UnoWScbBtVzgC7iMvxGMZIQDPa6uu5Oj05BIP_T0U,4790
20
+ climate_ref_esmvaltool/diagnostics/tcr.py,sha256=RrLnO_ox_wnHBHlD6qDxMgvrmqk4off7iFUvg7PnH3M,4701
21
+ climate_ref_esmvaltool/diagnostics/tcre.py,sha256=0dihcBODDmalwohJLcarmvdM3g7S3nkCAzbU5zksxR0,5564
22
+ climate_ref_esmvaltool/diagnostics/zec.py,sha256=WEQKw90Jm-QisAGh7B9AskpMMSM1ojCrvoNmomaFw4Q,4447
23
+ climate_ref_esmvaltool/requirements/conda-lock.yml,sha256=XPQEC3mUJ7Yyr-UaFtbBaceA2pPP22f7JtOTmO1dBDY,596683
24
+ climate_ref_esmvaltool/requirements/environment.yml,sha256=9yDKJyQpOgNx1hbjuncjrqCjTZJ4EhGXmP7fBCI1tyI,88
25
+ climate_ref_esmvaltool-0.8.0.dist-info/METADATA,sha256=Hhl_gov6y5H90--Tuf3gn4kOHjm5ADfCAg4_UB0qs-o,2444
26
+ climate_ref_esmvaltool-0.8.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
27
+ climate_ref_esmvaltool-0.8.0.dist-info/entry_points.txt,sha256=zhPwPv0Fu67MgdOCF8GAilZUHa9wl4T4xlkQ3HX4Sno,69
28
+ climate_ref_esmvaltool-0.8.0.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
+ climate_ref_esmvaltool-0.8.0.dist-info/licenses/NOTICE,sha256=4qTlax9aX2-mswYJuVrLqJ9jK1IkN5kSBqfVvYLF3Ws,128
30
+ climate_ref_esmvaltool-0.8.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,30 +0,0 @@
1
- climate_ref_esmvaltool/__init__.py,sha256=4WHuuZJvK50Djb831ws_Y2EtFLWicwsLIxhOvRld2BE,994
2
- climate_ref_esmvaltool/_version.py,sha256=Ed7geC_W9fxIocCdAvK1fk2k-pDt6FGOM_LEgR06-24,94
3
- climate_ref_esmvaltool/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- climate_ref_esmvaltool/recipe.py,sha256=m8-wWVRla2VRzkZWx2M-Okjvr0X2wUon0ZgXHcTALcw,6561
5
- climate_ref_esmvaltool/recipes.txt,sha256=X8yzdTW-TDJH5j-kJ5aq57ztZ6uvFItelVflJcTNEjs,1744
6
- climate_ref_esmvaltool/types.py,sha256=luUMNS3LJGJEecVrHRDh5l5ElnQgz7G0auCtA_Jwnno,117
7
- climate_ref_esmvaltool/dataset_registry/data.txt,sha256=aD5lg5x9O1mn2e9ueKefxmuBGH2OED1sqSdoeLrnIBk,24339
8
- climate_ref_esmvaltool/diagnostics/__init__.py,sha256=GRCsqpp9XY3p9nWQII05IhfzKSSwAoTQ0vc21mlPEbo,2022
9
- climate_ref_esmvaltool/diagnostics/base.py,sha256=nfNviO8pAftm_OlwNMzJ2cb2bb7_QaTNO-UmEfUPf6Q,10917
10
- climate_ref_esmvaltool/diagnostics/climate_at_global_warming_levels.py,sha256=mkA6WHR_GIdnYwjsaoRbWIgc4nAYD2wtgwmJ7JCsYoM,3605
11
- climate_ref_esmvaltool/diagnostics/climate_drivers_for_fire.py,sha256=CatVUeVixzeGHITJrZfa47cICI79uKxOZ9tYIK4CLKw,2198
12
- climate_ref_esmvaltool/diagnostics/cloud_radiative_effects.py,sha256=hmncLzKwZh5zTXUJb_08AVQa6JJqofKIdpdZ1RdAxTk,2865
13
- climate_ref_esmvaltool/diagnostics/cloud_scatterplots.py,sha256=TKjaQWGWx495IVH8LXGCf0OuDJk37oI0vH7c81Savgc,7169
14
- climate_ref_esmvaltool/diagnostics/ecs.py,sha256=c1VsowWSJKU0PbZR1dpQnkWSWSr2o3aUK3AGTMsGa30,4818
15
- climate_ref_esmvaltool/diagnostics/enso.py,sha256=LfaXbf0VRe14stfWXNv7OwfBEVTI7XDpmYtgIos3Dzw,5505
16
- climate_ref_esmvaltool/diagnostics/example.py,sha256=uJUBmJ9g0OBI_y8JKyH_tAV9BKC6P1Sjc2L31n03I6g,2347
17
- climate_ref_esmvaltool/diagnostics/regional_historical_changes.py,sha256=dBy-sVGCcgqKzugw5ZaF2KlsTym7QTmpR4lcF_ahS1E,12279
18
- climate_ref_esmvaltool/diagnostics/sea_ice_area_basic.py,sha256=95DL1PZfB2JoQSloh9cyLb_qeiUBSItxGC4QX5uJcRE,3253
19
- climate_ref_esmvaltool/diagnostics/sea_ice_sensitivity.py,sha256=-70cmXEi2sM6wFxUiP4sGZCGf9TrR1cvFM-8j5yeo-4,4267
20
- climate_ref_esmvaltool/diagnostics/tcr.py,sha256=MhhGMPXfkEh-IEOPNYcS2G-SgFMGkfp-FRu0TRk2jZI,4196
21
- climate_ref_esmvaltool/diagnostics/tcre.py,sha256=KiByhNnf2aicO9ysEwPvwA-VTWmo_bSKn-Za8IH8DcE,5461
22
- climate_ref_esmvaltool/diagnostics/zec.py,sha256=UvtKbzdgdREmCFH5_OIftGSrClEytbiI2q_VK5cNOfU,3998
23
- climate_ref_esmvaltool/requirements/conda-lock.yml,sha256=XPQEC3mUJ7Yyr-UaFtbBaceA2pPP22f7JtOTmO1dBDY,596683
24
- climate_ref_esmvaltool/requirements/environment.yml,sha256=9yDKJyQpOgNx1hbjuncjrqCjTZJ4EhGXmP7fBCI1tyI,88
25
- climate_ref_esmvaltool-0.6.6.dist-info/METADATA,sha256=vHod-PQNao0QkHepPatnA2QhwFydzOIQxJLYd83lqQg,2414
26
- climate_ref_esmvaltool-0.6.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- climate_ref_esmvaltool-0.6.6.dist-info/entry_points.txt,sha256=zhPwPv0Fu67MgdOCF8GAilZUHa9wl4T4xlkQ3HX4Sno,69
28
- climate_ref_esmvaltool-0.6.6.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
- climate_ref_esmvaltool-0.6.6.dist-info/licenses/NOTICE,sha256=4qTlax9aX2-mswYJuVrLqJ9jK1IkN5kSBqfVvYLF3Ws,128
30
- climate_ref_esmvaltool-0.6.6.dist-info/RECORD,,