climate-ref-esmvaltool 0.6.4__py3-none-any.whl → 0.6.6__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 (27) hide show
  1. climate_ref_esmvaltool/dataset_registry/data.txt +75 -0
  2. climate_ref_esmvaltool/diagnostics/__init__.py +24 -0
  3. climate_ref_esmvaltool/diagnostics/base.py +82 -16
  4. climate_ref_esmvaltool/diagnostics/climate_at_global_warming_levels.py +5 -2
  5. climate_ref_esmvaltool/diagnostics/climate_drivers_for_fire.py +68 -0
  6. climate_ref_esmvaltool/diagnostics/cloud_radiative_effects.py +2 -2
  7. climate_ref_esmvaltool/diagnostics/cloud_scatterplots.py +188 -0
  8. climate_ref_esmvaltool/diagnostics/ecs.py +9 -18
  9. climate_ref_esmvaltool/diagnostics/enso.py +10 -4
  10. climate_ref_esmvaltool/diagnostics/example.py +15 -2
  11. climate_ref_esmvaltool/diagnostics/regional_historical_changes.py +340 -0
  12. climate_ref_esmvaltool/diagnostics/sea_ice_area_basic.py +5 -2
  13. climate_ref_esmvaltool/diagnostics/sea_ice_sensitivity.py +108 -0
  14. climate_ref_esmvaltool/diagnostics/tcr.py +9 -18
  15. climate_ref_esmvaltool/diagnostics/tcre.py +5 -2
  16. climate_ref_esmvaltool/diagnostics/zec.py +5 -2
  17. climate_ref_esmvaltool/recipe.py +46 -7
  18. climate_ref_esmvaltool/recipes.txt +16 -10
  19. climate_ref_esmvaltool/requirements/conda-lock.yml +4081 -3770
  20. climate_ref_esmvaltool/requirements/environment.yml +1 -0
  21. {climate_ref_esmvaltool-0.6.4.dist-info → climate_ref_esmvaltool-0.6.6.dist-info}/METADATA +2 -2
  22. climate_ref_esmvaltool-0.6.6.dist-info/RECORD +30 -0
  23. climate_ref_esmvaltool-0.6.4.dist-info/RECORD +0 -26
  24. {climate_ref_esmvaltool-0.6.4.dist-info → climate_ref_esmvaltool-0.6.6.dist-info}/WHEEL +0 -0
  25. {climate_ref_esmvaltool-0.6.4.dist-info → climate_ref_esmvaltool-0.6.6.dist-info}/entry_points.txt +0 -0
  26. {climate_ref_esmvaltool-0.6.4.dist-info → climate_ref_esmvaltool-0.6.6.dist-info}/licenses/LICENCE +0 -0
  27. {climate_ref_esmvaltool-0.6.4.dist-info → climate_ref_esmvaltool-0.6.6.dist-info}/licenses/NOTICE +0 -0
@@ -5,14 +5,13 @@ from pathlib import Path
5
5
  from typing import TYPE_CHECKING, Any
6
6
 
7
7
  import pooch
8
- from ruamel.yaml import YAML
8
+ import yaml
9
9
 
10
10
  from climate_ref_esmvaltool.types import Recipe
11
11
 
12
12
  if TYPE_CHECKING:
13
13
  import pandas as pd
14
14
 
15
- yaml = YAML()
16
15
 
17
16
  FACETS = {
18
17
  "CMIP6": {
@@ -25,6 +24,13 @@ FACETS = {
25
24
  "mip": "table_id",
26
25
  "short_name": "variable_id",
27
26
  },
27
+ "obs4MIPs": {
28
+ "dataset": "source_id",
29
+ "frequency": "frequency",
30
+ "grid": "grid_label",
31
+ "institute": "institution_id",
32
+ "short_name": "variable_id",
33
+ },
28
34
  }
29
35
 
30
36
 
@@ -92,7 +98,10 @@ def as_facets(
92
98
  return facets
93
99
 
94
100
 
95
- def dataframe_to_recipe(files: pd.DataFrame) -> dict[str, Any]:
101
+ def dataframe_to_recipe(
102
+ files: pd.DataFrame,
103
+ equalize_timerange: bool = False,
104
+ ) -> dict[str, Any]:
96
105
  """Convert the datasets dataframe to a recipe "variables" section.
97
106
 
98
107
  Parameters
@@ -112,11 +121,27 @@ def dataframe_to_recipe(files: pd.DataFrame) -> dict[str, Any]:
112
121
  if short_name not in variables:
113
122
  variables[short_name] = {"additional_datasets": []}
114
123
  variables[short_name]["additional_datasets"].append(facets)
124
+
125
+ if equalize_timerange:
126
+ # Select a timerange covered by all datasets.
127
+ start_times, end_times = [], []
128
+ for variable in variables.values():
129
+ for dataset in variable["additional_datasets"]:
130
+ if "timerange" in dataset:
131
+ start, end = dataset["timerange"].split("/")
132
+ start_times.append(start)
133
+ end_times.append(end)
134
+ timerange = f"{max(start_times)}/{min(end_times)}"
135
+ for variable in variables.values():
136
+ for dataset in variable["additional_datasets"]:
137
+ if "timerange" in dataset:
138
+ dataset["timerange"] = timerange
139
+
115
140
  return variables
116
141
 
117
142
 
118
- _ESMVALTOOL_COMMIT = "58fd0b8ece981bc97c4fbd213b11f2228d90db28"
119
- _ESMVALTOOL_VERSION = f"2.13.0.dev65+g{_ESMVALTOOL_COMMIT[:9]}"
143
+ _ESMVALTOOL_COMMIT = "2c438d0e0cc8904790294c72450eb7f06552c52a"
144
+ _ESMVALTOOL_VERSION = f"2.13.0.dev148+g{_ESMVALTOOL_COMMIT[:9]}"
120
145
 
121
146
  _RECIPES = pooch.create(
122
147
  path=pooch.os_cache("climate_ref_esmvaltool"),
@@ -144,7 +169,16 @@ def load_recipe(recipe: str) -> Recipe:
144
169
  The loaded recipe.
145
170
  """
146
171
  filename = _RECIPES.fetch(recipe)
147
- return yaml.load(Path(filename).read_text(encoding="utf-8")) # type: ignore[no-any-return]
172
+
173
+ def normalize(obj: Any) -> Any:
174
+ # Ensure objects in the recipe are not shared.
175
+ if isinstance(obj, dict):
176
+ return {k: normalize(v) for k, v in obj.items()}
177
+ if isinstance(obj, list):
178
+ return [normalize(item) for item in obj]
179
+ return obj
180
+
181
+ return normalize(yaml.safe_load(Path(filename).read_text(encoding="utf-8"))) # type: ignore[no-any-return]
148
182
 
149
183
 
150
184
  def prepare_climate_data(datasets: pd.DataFrame, climate_data_dir: Path) -> None:
@@ -167,6 +201,11 @@ def prepare_climate_data(datasets: pd.DataFrame, climate_data_dir: Path) -> None
167
201
  if not isinstance(row.path, str): # pragma: no branch
168
202
  msg = f"Invalid path encountered in {row}"
169
203
  raise ValueError(msg)
170
- tgt = climate_data_dir.joinpath(*row.instance_id.split(".")) / Path(row.path).name
204
+ if row.instance_id.startswith("obs4MIPs."):
205
+ version = row.instance_id.split(".")[-1]
206
+ subdirs: list[str] = ["obs4MIPs", row.source_id, version] # type: ignore[list-item]
207
+ else:
208
+ subdirs = row.instance_id.split(".")
209
+ tgt = climate_data_dir.joinpath(*subdirs) / Path(row.path).name
171
210
  tgt.parent.mkdir(parents=True, exist_ok=True)
172
211
  tgt.symlink_to(row.path)
@@ -1,10 +1,16 @@
1
- examples/recipe_python.yml ab3f06d269bb2c1368f4dc39da9bcb232fb2adb1fa556ba769e6c16294ffb4a3
2
- recipe_calculate_gwl_exceedance_stats.yml 5aa266abc9a8029649b689a2b369a47623b0935d609354332ff4148994642d6b
3
- recipe_ecs.yml 0cc57034fcb64e32015b4ff949ece5df8cdb8c6f493618b50ceded119fb37918
4
- recipe_tcr.yml 35f9ef035a4e71aff5cac5dd26c49da2162fc00291bf3b0bd16b661b7b2f606b
5
- recipe_tcre.yml 48fc9e3baf541bbcef7491853ea3a774053771dca33352b41466425faeaa38af
6
- recipe_zec.yml b0af7f789b7610ab3f29a6617124aa40c40866ead958204fc199eaf82863de51
7
- ref/recipe_enso_basicclimatology.yml 9ea7deb7ee668e39ac44618b96496d898bd82285c22dcee4fce4695e0c9fa82b
8
- ref/recipe_enso_characteristics.yml 34c2518b138068ac96d212910b979d54a8fcedee2c0089b5acd56a42c41dc3e4
9
- ref/recipe_ref_cre.yml 4f35d9639f1008be3b5382a5bd8933a855cb5368ccf5d04a1c70227172e2e82c
10
- ref/recipe_ref_sea_ice_area_basic.yml 7d01a8527880663ca28284772f83a8356d9972fb4f022a4000e50a56ce044b09
1
+ examples/recipe_python.yml ab3f06d269bb2c1368f4dc39da9bcb232fb2adb1fa556ba769e6c16294ffb4a3
2
+ recipe_calculate_gwl_exceedance_stats.yml 5aa266abc9a8029649b689a2b369a47623b0935d609354332ff4148994642d6b
3
+ recipe_ecs.yml 0cc57034fcb64e32015b4ff949ece5df8cdb8c6f493618b50ceded119fb37918
4
+ recipe_seaice_sensitivity.yml f7247c076e161c582d422947c8155f3ca98549e6f2e4c3b1c76414786d7e50c5
5
+ recipe_tcr.yml 35f9ef035a4e71aff5cac5dd26c49da2162fc00291bf3b0bd16b661b7b2f606b
6
+ recipe_tcre.yml 48fc9e3baf541bbcef7491853ea3a774053771dca33352b41466425faeaa38af
7
+ recipe_zec.yml b0af7f789b7610ab3f29a6617124aa40c40866ead958204fc199eaf82863de51
8
+ ref/recipe_enso_basicclimatology.yml 9ea7deb7ee668e39ac44618b96496d898bd82285c22dcee4fce4695e0c9fa82b
9
+ ref/recipe_enso_characteristics.yml 34c2518b138068ac96d212910b979d54a8fcedee2c0089b5acd56a42c41dc3e4
10
+ ref/recipe_ref_annual_cycle_region.yml 64ebc687789dad6c45a2361b45218cb5a0ad0e38c516840c65fc7e8bf7b5ace7
11
+ ref/recipe_ref_cre.yml 4375f262479c3b3e1b348b71080a6d758e195bda76516a591182045a3a29aa32
12
+ ref/recipe_ref_fire.yml 2ad82effaca4e742d8abe6a0aa07bb46e1e92ef0d2d240760f7623b0ba045926
13
+ ref/recipe_ref_sea_ice_area_basic.yml 7d01a8527880663ca28284772f83a8356d9972fb4f022a4000e50a56ce044b09
14
+ ref/recipe_ref_scatterplot.yml b99d1736e16256d161847b025811d7088ad9f892d4887fb009fa99c4079135a0
15
+ ref/recipe_ref_timeseries_region.yml 86f36e442021caba201601d8cf4624f8ce6715ce421670a467c792db2910db22
16
+ ref/recipe_ref_trend_regions.yml 18fe246a51474bd12172ab1ba141efac999a247de7774822f77ae6ef144645fe