climate-ref-ilamb 0.5.4__py3-none-any.whl → 0.6.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.
- climate_ref_ilamb/__init__.py +4 -11
- climate_ref_ilamb/configure/ilamb.yaml +24 -10
- climate_ref_ilamb/configure/iomb.yaml +28 -6
- climate_ref_ilamb/dataset_registry/ilamb.txt +13 -11
- climate_ref_ilamb/dataset_registry/iomb.txt +4 -3
- climate_ref_ilamb/dataset_registry/test.txt +3 -3
- climate_ref_ilamb/datasets.py +0 -2
- climate_ref_ilamb/standard.py +148 -61
- {climate_ref_ilamb-0.5.4.dist-info → climate_ref_ilamb-0.6.0.dist-info}/METADATA +6 -6
- climate_ref_ilamb-0.6.0.dist-info/RECORD +14 -0
- climate_ref_ilamb-0.5.4.dist-info/RECORD +0 -14
- {climate_ref_ilamb-0.5.4.dist-info → climate_ref_ilamb-0.6.0.dist-info}/WHEEL +0 -0
- {climate_ref_ilamb-0.5.4.dist-info → climate_ref_ilamb-0.6.0.dist-info}/licenses/LICENCE +0 -0
- {climate_ref_ilamb-0.5.4.dist-info → climate_ref_ilamb-0.6.0.dist-info}/licenses/NOTICE +0 -0
climate_ref_ilamb/__init__.py
CHANGED
|
@@ -10,9 +10,8 @@ import importlib.resources
|
|
|
10
10
|
|
|
11
11
|
import yaml
|
|
12
12
|
|
|
13
|
-
from climate_ref_core.dataset_registry import dataset_registry_manager
|
|
13
|
+
from climate_ref_core.dataset_registry import DATASET_URL, dataset_registry_manager
|
|
14
14
|
from climate_ref_core.providers import DiagnosticProvider
|
|
15
|
-
from climate_ref_ilamb.datasets import ILAMB_DATA_VERSION
|
|
16
15
|
from climate_ref_ilamb.standard import ILAMBStandard
|
|
17
16
|
|
|
18
17
|
__version__ = importlib.metadata.version("climate-ref-ilamb")
|
|
@@ -22,27 +21,21 @@ provider = DiagnosticProvider("ILAMB", __version__)
|
|
|
22
21
|
# Register some datasets
|
|
23
22
|
dataset_registry_manager.register(
|
|
24
23
|
"ilamb-test",
|
|
25
|
-
base_url=
|
|
24
|
+
base_url=DATASET_URL,
|
|
26
25
|
package="climate_ref_ilamb.dataset_registry",
|
|
27
26
|
resource="test.txt",
|
|
28
|
-
cache_name="ilamb3",
|
|
29
|
-
version=ILAMB_DATA_VERSION,
|
|
30
27
|
)
|
|
31
28
|
dataset_registry_manager.register(
|
|
32
29
|
"ilamb",
|
|
33
|
-
base_url=
|
|
30
|
+
base_url=DATASET_URL,
|
|
34
31
|
package="climate_ref_ilamb.dataset_registry",
|
|
35
32
|
resource="ilamb.txt",
|
|
36
|
-
cache_name="ilamb3",
|
|
37
|
-
version=ILAMB_DATA_VERSION,
|
|
38
33
|
)
|
|
39
34
|
dataset_registry_manager.register(
|
|
40
35
|
"iomb",
|
|
41
|
-
base_url=
|
|
36
|
+
base_url=DATASET_URL,
|
|
42
37
|
package="climate_ref_ilamb.dataset_registry",
|
|
43
38
|
resource="iomb.txt",
|
|
44
|
-
cache_name="ilamb3",
|
|
45
|
-
version=ILAMB_DATA_VERSION,
|
|
46
39
|
)
|
|
47
40
|
|
|
48
41
|
# Dynamically register ILAMB diagnostics
|
|
@@ -2,44 +2,58 @@ registry: ilamb
|
|
|
2
2
|
|
|
3
3
|
gpp-WECANN:
|
|
4
4
|
sources:
|
|
5
|
-
|
|
5
|
+
# TODO: Update to use the obs4REF equiv
|
|
6
|
+
gpp: ilamb/gpp/WECANN/gpp.nc
|
|
6
7
|
relationships:
|
|
7
|
-
pr: pr/GPCPv2.3/pr.nc
|
|
8
|
-
tas: tas/CRU4.02/tas.nc
|
|
8
|
+
pr: ilamb/pr/GPCPv2.3/pr.nc
|
|
9
|
+
tas: ilamb/tas/CRU4.02/tas.nc
|
|
9
10
|
variable_cmap: Greens
|
|
10
11
|
|
|
11
12
|
gpp-FLUXNET2015:
|
|
12
13
|
sources:
|
|
13
|
-
gpp: gpp/FLUXNET2015/gpp.nc
|
|
14
|
+
gpp: ilamb/gpp/FLUXNET2015/gpp.nc
|
|
14
15
|
variable_cmap: Greens
|
|
15
16
|
|
|
16
17
|
mrro-LORA:
|
|
17
18
|
sources:
|
|
18
|
-
|
|
19
|
+
# TODO: Update to use the obs4REF equiv
|
|
20
|
+
mrro: ilamb/mrro/LORA/LORA.nc
|
|
19
21
|
variable_cmap: Blues
|
|
20
22
|
|
|
21
23
|
mrsos-WangMao:
|
|
22
24
|
sources:
|
|
23
|
-
mrsol: mrsol/WangMao/mrsol_olc.nc
|
|
25
|
+
mrsol: ilamb/mrsol/WangMao/mrsol_olc.nc
|
|
24
26
|
alternate_vars:
|
|
25
27
|
- mrsos
|
|
26
|
-
depth: 0.0
|
|
27
28
|
transform:
|
|
29
|
+
- select_depth:
|
|
30
|
+
value: 0
|
|
28
31
|
- soil_moisture_to_vol_fraction
|
|
29
32
|
variable_cmap: Blues
|
|
30
33
|
|
|
31
34
|
cSoil-HWSD2:
|
|
32
35
|
sources:
|
|
33
|
-
cSoil: cSoil/HWSD2/
|
|
36
|
+
cSoil: ilamb/cSoil/HWSD2/cSoil_fx_HWSD2_19600101-20220101.nc
|
|
34
37
|
variable_cmap: viridis
|
|
35
38
|
|
|
36
39
|
lai-AVH15C1:
|
|
37
40
|
sources:
|
|
38
|
-
lai: lai/AVH15C1/lai.nc
|
|
41
|
+
lai: ilamb/lai/AVH15C1/lai.nc
|
|
39
42
|
variable_cmap: Greens
|
|
40
43
|
|
|
41
44
|
nbp-Hoffman:
|
|
42
45
|
analyses:
|
|
43
46
|
- nbp
|
|
44
47
|
sources:
|
|
45
|
-
|
|
48
|
+
# TODO: Update to use the obs4REF equiv
|
|
49
|
+
nbp: ilamb/nbp/HOFFMAN/nbp_1850-2010.nc
|
|
50
|
+
|
|
51
|
+
snc-ESACCI:
|
|
52
|
+
sources:
|
|
53
|
+
snc: ilamb/snc/Snow-cci/snc_mon_Snow-cci_BE_gn_198201-201906.nc
|
|
54
|
+
|
|
55
|
+
burntFractionAll-GFED:
|
|
56
|
+
sources:
|
|
57
|
+
burntArea: ilamb/burntFractionAll/GFED/burntArea.nc
|
|
58
|
+
alternate_vars:
|
|
59
|
+
- burntFractionAll
|
|
@@ -2,26 +2,48 @@ registry: iomb
|
|
|
2
2
|
|
|
3
3
|
thetao-WOA2023-surface:
|
|
4
4
|
sources:
|
|
5
|
-
|
|
5
|
+
# TODO: Update to use the obs4REF equiv
|
|
6
|
+
thetao: ilamb/WOA/thetao_mon_WOA_A5B4_gn_200501-201412.nc
|
|
6
7
|
variable_cmap: Reds
|
|
7
|
-
|
|
8
|
+
transform:
|
|
9
|
+
- select_depth:
|
|
10
|
+
value: 0
|
|
8
11
|
alternate_vars:
|
|
9
12
|
- tos
|
|
10
13
|
|
|
11
14
|
so-WOA2023-surface:
|
|
12
15
|
sources:
|
|
13
|
-
|
|
16
|
+
# TODO: Update to use the obs4REF equiv
|
|
17
|
+
so: ilamb/WOA/so_mon_WOA_A5B4_gn_200501-201412.nc
|
|
18
|
+
transform:
|
|
19
|
+
- select_depth:
|
|
20
|
+
value: 0
|
|
14
21
|
variable_cmap: YlGn
|
|
15
|
-
depth: 0.0
|
|
16
22
|
alternate_vars:
|
|
17
23
|
- sos
|
|
18
24
|
|
|
19
25
|
amoc-RAPID:
|
|
20
26
|
analyses:
|
|
21
27
|
- timeseries
|
|
22
|
-
|
|
28
|
+
related_vars:
|
|
23
29
|
- msftmz
|
|
24
30
|
transform:
|
|
25
31
|
- msftmz_to_rapid
|
|
26
32
|
sources:
|
|
27
|
-
|
|
33
|
+
# TODO: Update to use the obs4REF equiv
|
|
34
|
+
amoc: ilamb/RAPID/amoc_mon_RAPID_BE_NA_200404-202302.nc
|
|
35
|
+
|
|
36
|
+
ohc-NOAA:
|
|
37
|
+
sources:
|
|
38
|
+
ohc: ilamb/NOAA/ohc_yr_OHC_BE_gm_200506-202406.nc
|
|
39
|
+
related_vars:
|
|
40
|
+
- thetao
|
|
41
|
+
- volcello
|
|
42
|
+
transform:
|
|
43
|
+
- select_depth:
|
|
44
|
+
min: 0
|
|
45
|
+
max: 2000
|
|
46
|
+
- ocean_heat_content:
|
|
47
|
+
reference_year: 2005
|
|
48
|
+
analyses:
|
|
49
|
+
- accumulate
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
cSoil/HWSD2/
|
|
2
|
-
gpp/FLUXNET2015/gpp.nc sha1:16fd177e007caef2565687e2cd32884e20ef16e5
|
|
3
|
-
gpp/WECANN/gpp.nc sha1:6e864a6ae201195cdf995a3a81720188af441e13
|
|
4
|
-
lai/AVH15C1/lai.nc sha1:ccace4f84912d63acbb9ee09ee7b743412207a0d
|
|
5
|
-
mrro/LORA/LORA.nc sha1:72bb16787877591d0c54a36d74697d0d208f985a
|
|
6
|
-
mrsol/WangMao/mrsol_olc.nc sha1:24cbc9df69569bed3a39c20e499cfe4f911bd30e
|
|
7
|
-
regions/GlobalLand.nc sha1:2f987d44fdba6ad0e72d14d6a2fecb7e8df2a9c5
|
|
8
|
-
regions/Koppen_coarse.nc sha1:e464030db49f0295a6a22a81ca602b0f3c499b72
|
|
9
|
-
pr/GPCPv2.3/pr.nc sha1:e1b942863ec76a75aa972b6d75e2e08646741259
|
|
10
|
-
tas/CRU4.02/tas.nc sha1:2674da18a1a93483b50b1626e7a7ab741bf53d09
|
|
11
|
-
nbp/HOFFMAN/nbp_1850-2010.nc sha1:8350af00614d6afc6b70ad314aa499a9ece80ec2
|
|
1
|
+
ilamb/cSoil/HWSD2/cSoil_fx_HWSD2_19600101-20220101.nc sha1:7138b0b53aa600878adf95e6aef65f4322a8e287
|
|
2
|
+
ilamb/gpp/FLUXNET2015/gpp.nc sha1:16fd177e007caef2565687e2cd32884e20ef16e5
|
|
3
|
+
ilamb/gpp/WECANN/gpp.nc sha1:6e864a6ae201195cdf995a3a81720188af441e13
|
|
4
|
+
ilamb/lai/AVH15C1/lai.nc sha1:ccace4f84912d63acbb9ee09ee7b743412207a0d
|
|
5
|
+
ilamb/mrro/LORA/LORA.nc sha1:72bb16787877591d0c54a36d74697d0d208f985a
|
|
6
|
+
ilamb/mrsol/WangMao/mrsol_olc.nc sha1:24cbc9df69569bed3a39c20e499cfe4f911bd30e
|
|
7
|
+
ilamb/regions/GlobalLand.nc sha1:2f987d44fdba6ad0e72d14d6a2fecb7e8df2a9c5
|
|
8
|
+
ilamb/regions/Koppen_coarse.nc sha1:e464030db49f0295a6a22a81ca602b0f3c499b72
|
|
9
|
+
ilamb/pr/GPCPv2.3/pr.nc sha1:e1b942863ec76a75aa972b6d75e2e08646741259
|
|
10
|
+
ilamb/tas/CRU4.02/tas.nc sha1:2674da18a1a93483b50b1626e7a7ab741bf53d09
|
|
11
|
+
ilamb/nbp/HOFFMAN/nbp_1850-2010.nc sha1:8350af00614d6afc6b70ad314aa499a9ece80ec2
|
|
12
|
+
ilamb/snc/Snow-cci/snc_mon_Snow-cci_BE_gn_198201-201906.nc sha1:c0bfecd2f8b886e9301428d28bb6ff0507601be2
|
|
13
|
+
ilamb/burntFractionAll/GFED/burntArea.nc sha1:cf9d73c6a8bfc594737c9ba6ca4df613df4a28ab
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
WOA/so_mon_WOA_A5B4_gn_200501-201412.nc sha1:831c42c3b2ba443c255150289a2c725d7f3e5838
|
|
2
|
-
WOA/thetao_mon_WOA_A5B4_gn_200501-201412.nc sha1:86d9056208291d76233e65b26c658c1fa54c3ea6
|
|
3
|
-
RAPID/amoc_mon_RAPID_BE_NA_200404-202302.nc sha1:3efe773e5c2a3c832977791ff7fd9cb9f473fe65
|
|
1
|
+
ilamb/WOA/so_mon_WOA_A5B4_gn_200501-201412.nc sha1:831c42c3b2ba443c255150289a2c725d7f3e5838
|
|
2
|
+
ilamb/WOA/thetao_mon_WOA_A5B4_gn_200501-201412.nc sha1:86d9056208291d76233e65b26c658c1fa54c3ea6
|
|
3
|
+
ilamb/RAPID/amoc_mon_RAPID_BE_NA_200404-202302.nc sha1:3efe773e5c2a3c832977791ff7fd9cb9f473fe65
|
|
4
|
+
ilamb/NOAA/ohc_yr_OHC_BE_gm_200506-202406.nc sha1:a918799d8e24e4f0015b9047a74d470ae9f0445c
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
test/Site/tas.nc sha1:3e757c9feadea581a92e6f4afb402b86168e113a
|
|
2
|
-
test/Grid/gpp.nc sha1:2688085f95fa13617b20c723c66b0009bd661847
|
|
3
|
-
test/Grid/pr.nc sha1:d667eb216939f5797d59b59cb4ade5ec31e67659
|
|
1
|
+
ilamb/test/Site/tas.nc sha1:3e757c9feadea581a92e6f4afb402b86168e113a
|
|
2
|
+
ilamb/test/Grid/gpp.nc sha1:2688085f95fa13617b20c723c66b0009bd661847
|
|
3
|
+
ilamb/test/Grid/pr.nc sha1:d667eb216939f5797d59b59cb4ade5ec31e67659
|
climate_ref_ilamb/datasets.py
CHANGED
climate_ref_ilamb/standard.py
CHANGED
|
@@ -8,6 +8,7 @@ import pandas as pd
|
|
|
8
8
|
import pooch
|
|
9
9
|
from ilamb3 import run
|
|
10
10
|
|
|
11
|
+
from climate_ref_core.constraints import AddSupplementaryDataset
|
|
11
12
|
from climate_ref_core.dataset_registry import dataset_registry_manager
|
|
12
13
|
from climate_ref_core.datasets import FacetFilter, SourceDatasetType
|
|
13
14
|
from climate_ref_core.diagnostics import (
|
|
@@ -23,63 +24,135 @@ from climate_ref_ilamb.datasets import (
|
|
|
23
24
|
)
|
|
24
25
|
|
|
25
26
|
|
|
26
|
-
def
|
|
27
|
+
def format_cmec_output_bundle(
|
|
28
|
+
dataset: pd.DataFrame,
|
|
29
|
+
dimensions: list[str],
|
|
30
|
+
metadata_columns: list[str],
|
|
31
|
+
value_column: str = "value",
|
|
32
|
+
) -> dict[str, Any]:
|
|
33
|
+
"""
|
|
34
|
+
Create a CMEC output bundle for the dataset.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
dataset
|
|
39
|
+
Processed dataset
|
|
40
|
+
dimensions
|
|
41
|
+
The dimensions of the dataset (e.g., ["source_id", "member_id", "region"])
|
|
42
|
+
metadata_columns
|
|
43
|
+
The columns to be used as metadata (e.g., ["Description", "LongName"])
|
|
44
|
+
value_column
|
|
45
|
+
The column containing the values
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
A CMEC output bundle ready to be written to disk
|
|
50
|
+
"""
|
|
51
|
+
# Validate that all required columns exist
|
|
52
|
+
required_columns = set(dimensions) | {value_column} | set(metadata_columns)
|
|
53
|
+
missing_columns = required_columns - set(dataset.columns)
|
|
54
|
+
if missing_columns:
|
|
55
|
+
raise ValueError(f"Missing required columns: {missing_columns}")
|
|
56
|
+
|
|
57
|
+
# Build the dimensions section
|
|
58
|
+
dimensions_dict: dict[str, dict[str, dict[str, str]]] = {}
|
|
59
|
+
|
|
60
|
+
# For each dimension, create a dictionary of unique values and their metadata
|
|
61
|
+
for dim in dimensions:
|
|
62
|
+
unique_values = dataset[dim].unique()
|
|
63
|
+
dim_dict: dict[str, dict[str, str]] = {}
|
|
64
|
+
|
|
65
|
+
for val in unique_values:
|
|
66
|
+
# Get the row for this dimension value
|
|
67
|
+
|
|
68
|
+
dim_dict[str(val)] = {}
|
|
69
|
+
|
|
70
|
+
if dim == dimensions[-1]:
|
|
71
|
+
# If this is the last dimension, add the value column to the metadata
|
|
72
|
+
|
|
73
|
+
dim_dict[str(val)] = dataset[dataset[dim] == val].iloc[0][metadata_columns].to_dict()
|
|
74
|
+
|
|
75
|
+
dimensions_dict[dim] = dim_dict
|
|
76
|
+
|
|
77
|
+
# Build the results section - create nested structure based on dimensions
|
|
78
|
+
def nest_results(df: pd.DataFrame, dims: list[str]) -> dict[str, Any] | float:
|
|
79
|
+
if not dims:
|
|
80
|
+
return float(df[value_column].iloc[0].item())
|
|
81
|
+
|
|
82
|
+
current_dim = dims[0]
|
|
83
|
+
remaining_dims = dims[1:]
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
str(group_name): nest_results(group_df, remaining_dims)
|
|
87
|
+
for group_name, group_df in df.groupby(current_dim)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
results = nest_results(dataset, list(dimensions))
|
|
91
|
+
|
|
92
|
+
return {"DIMENSIONS": {"json_structure": list(dimensions), **dimensions_dict}, "RESULTS": results}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _build_cmec_bundle(df: pd.DataFrame) -> dict[str, Any]:
|
|
27
96
|
"""
|
|
28
97
|
Build a CMEC bundle from information in the dataframe.
|
|
29
98
|
|
|
30
|
-
TODO: Migrate to use pycmec when ready.
|
|
31
|
-
TODO: Add plots and html output.
|
|
32
99
|
"""
|
|
100
|
+
# TODO: Handle the reference data
|
|
101
|
+
# reference_df = df[df["source"] == "Reference"]
|
|
102
|
+
model_df = df[df["source"] != "Reference"]
|
|
103
|
+
|
|
104
|
+
# Source is formatted as "ACCESS-ESM1-5-r1i1p1f1-gn"
|
|
105
|
+
# This assumes that the member_id and grid_label are always the last two parts of the source string
|
|
106
|
+
# and don't contain '-'
|
|
107
|
+
extracted_source = model_df.source.str.extract(r"([\w-]+)-([\w\d]+)-([\w\d]+)")
|
|
108
|
+
model_df["source_id"] = extracted_source[0]
|
|
109
|
+
model_df["member_id"] = extracted_source[1]
|
|
110
|
+
model_df["grid_label"] = extracted_source[2]
|
|
111
|
+
|
|
112
|
+
# Strip out units from the name
|
|
113
|
+
# These are available in the attributes
|
|
114
|
+
extracted_source = model_df.name.str.extract(r"(.*)\s\[.*\]")
|
|
115
|
+
model_df["name"] = extracted_source[0]
|
|
116
|
+
|
|
117
|
+
model_df = model_df.rename(
|
|
118
|
+
columns={
|
|
119
|
+
"analysis": "metric",
|
|
120
|
+
"name": "statistic",
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# Convert the value column to numeric, coercing errors to NaN
|
|
125
|
+
model_df["value"] = pd.to_numeric(model_df["value"], errors="coerce")
|
|
126
|
+
|
|
127
|
+
dimensions = ["experiment_id", "source_id", "member_id", "grid_label", "region", "metric", "statistic"]
|
|
128
|
+
attributes = ["type", "units"]
|
|
129
|
+
|
|
130
|
+
bundle = format_cmec_output_bundle(
|
|
131
|
+
model_df,
|
|
132
|
+
dimensions=dimensions,
|
|
133
|
+
metadata_columns=attributes,
|
|
134
|
+
value_column="value",
|
|
135
|
+
)
|
|
136
|
+
|
|
33
137
|
ilamb_regions = ilr.Regions()
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
"model": {m: {"Description": m, "Source": m} for m in df["source"].unique() if m != "Reference"},
|
|
46
|
-
"metric": {
|
|
47
|
-
name: {
|
|
48
|
-
"Name": name,
|
|
49
|
-
"Abstract": "benchmark score",
|
|
50
|
-
"URI": [
|
|
51
|
-
"https://www.osti.gov/biblio/1330803",
|
|
52
|
-
"https://doi.org/10.1029/2018MS001354",
|
|
53
|
-
],
|
|
54
|
-
"Contact": "forrest AT climatemodeling.org",
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"statistic": {s: {} for s in df["name"].unique()},
|
|
58
|
-
},
|
|
59
|
-
"RESULTS": {
|
|
60
|
-
r: {
|
|
61
|
-
m: {
|
|
62
|
-
name: {
|
|
63
|
-
s: float(
|
|
64
|
-
df[(df["source"] == m) & (df["region"] == r) & (df["name"] == s)].iloc[0]["value"]
|
|
65
|
-
)
|
|
66
|
-
for s in df["name"].unique()
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
for m in df["source"].unique()
|
|
70
|
-
if m != "Reference"
|
|
71
|
-
}
|
|
72
|
-
for r in df["region"].unique()
|
|
73
|
-
},
|
|
74
|
-
}
|
|
138
|
+
for region, region_info in bundle["DIMENSIONS"]["region"].items():
|
|
139
|
+
if region == "None":
|
|
140
|
+
region_info["LongName"] = "None"
|
|
141
|
+
region_info["Description"] = "Reference data extents"
|
|
142
|
+
region_info["Generator"] = "N/A"
|
|
143
|
+
else:
|
|
144
|
+
region_info["LongName"] = ilamb_regions.get_name(region)
|
|
145
|
+
region_info["Description"] = ilamb_regions.get_name(region)
|
|
146
|
+
region_info["Generator"] = ilamb_regions.get_source(region)
|
|
147
|
+
|
|
75
148
|
return bundle
|
|
76
149
|
|
|
77
150
|
|
|
78
|
-
def _form_bundles(
|
|
151
|
+
def _form_bundles(df: pd.DataFrame) -> tuple[CMECMetric, CMECOutput]:
|
|
79
152
|
"""
|
|
80
153
|
Create the output bundles (really a lift to make Ruff happy with the size of run()).
|
|
81
154
|
"""
|
|
82
|
-
metric_bundle = _build_cmec_bundle(
|
|
155
|
+
metric_bundle = _build_cmec_bundle(df)
|
|
83
156
|
output_bundle = CMECOutput.create_template()
|
|
84
157
|
return CMECMetric.model_validate(metric_bundle), CMECOutput.model_validate(output_bundle)
|
|
85
158
|
|
|
@@ -91,20 +164,11 @@ def _set_ilamb3_options(registry: pooch.Pooch, registry_file: str) -> None:
|
|
|
91
164
|
ilamb3.conf.reset()
|
|
92
165
|
ilamb_regions = ilr.Regions()
|
|
93
166
|
if registry_file == "ilamb":
|
|
94
|
-
ilamb_regions.add_netcdf(registry.fetch("regions/GlobalLand.nc"))
|
|
95
|
-
ilamb_regions.add_netcdf(registry.fetch("regions/Koppen_coarse.nc"))
|
|
167
|
+
ilamb_regions.add_netcdf(registry.fetch("ilamb/regions/GlobalLand.nc"))
|
|
168
|
+
ilamb_regions.add_netcdf(registry.fetch("ilamb/regions/Koppen_coarse.nc"))
|
|
96
169
|
ilamb3.conf.set(regions=["global", "tropical"])
|
|
97
170
|
|
|
98
171
|
|
|
99
|
-
def _measure_facets(registry_file: str) -> list[str]:
|
|
100
|
-
"""
|
|
101
|
-
Set options for ILAMB based on which registry file is being used.
|
|
102
|
-
"""
|
|
103
|
-
if registry_file == "ilamb":
|
|
104
|
-
return ["areacella", "sftlf"]
|
|
105
|
-
return []
|
|
106
|
-
|
|
107
|
-
|
|
108
172
|
def _load_csv_and_merge(output_directory: Path) -> pd.DataFrame:
|
|
109
173
|
"""
|
|
110
174
|
Load individual csv scalar data and merge into a dataframe.
|
|
@@ -150,17 +214,36 @@ class ILAMBStandard(Diagnostic):
|
|
|
150
214
|
self.variable_id,
|
|
151
215
|
*ilamb_kwargs.get("relationships", {}).keys(),
|
|
152
216
|
*ilamb_kwargs.get("alternate_vars", []),
|
|
153
|
-
*
|
|
217
|
+
*ilamb_kwargs.get("related_vars", []),
|
|
154
218
|
)
|
|
155
219
|
}
|
|
156
220
|
),
|
|
157
|
-
FacetFilter(facets={"frequency": ("mon",
|
|
221
|
+
FacetFilter(facets={"frequency": ("mon",)}),
|
|
158
222
|
FacetFilter(facets={"experiment_id": ("historical", "land-hist")}),
|
|
223
|
+
# Exclude unneeded snc tables
|
|
224
|
+
FacetFilter(facets={"table_id": ("ImonAnt", "ImonGre")}, keep=False),
|
|
225
|
+
),
|
|
226
|
+
constraints=(
|
|
227
|
+
AddSupplementaryDataset.from_defaults("areacella", SourceDatasetType.CMIP6),
|
|
228
|
+
AddSupplementaryDataset.from_defaults("sftlf", SourceDatasetType.CMIP6),
|
|
229
|
+
)
|
|
230
|
+
if registry_file == "ilamb"
|
|
231
|
+
else (
|
|
232
|
+
AddSupplementaryDataset.from_defaults("areacello", SourceDatasetType.CMIP6),
|
|
233
|
+
AddSupplementaryDataset.from_defaults("sftof", SourceDatasetType.CMIP6),
|
|
159
234
|
),
|
|
160
235
|
group_by=("experiment_id",),
|
|
161
236
|
),
|
|
162
237
|
)
|
|
163
|
-
self.facets = (
|
|
238
|
+
self.facets = (
|
|
239
|
+
"experiment_id",
|
|
240
|
+
"source_id",
|
|
241
|
+
"member_id",
|
|
242
|
+
"grid_label",
|
|
243
|
+
"region",
|
|
244
|
+
"metric",
|
|
245
|
+
"statistic",
|
|
246
|
+
)
|
|
164
247
|
|
|
165
248
|
# Setup ILAMB data and options
|
|
166
249
|
self.registry_file = registry_file
|
|
@@ -197,10 +280,14 @@ class ILAMBStandard(Diagnostic):
|
|
|
197
280
|
-------
|
|
198
281
|
An execution result object
|
|
199
282
|
"""
|
|
283
|
+
selectors = definition.datasets[SourceDatasetType.CMIP6].selector_dict()
|
|
200
284
|
_set_ilamb3_options(self.registry, self.registry_file)
|
|
201
285
|
|
|
202
286
|
df = _load_csv_and_merge(definition.output_directory)
|
|
203
|
-
|
|
287
|
+
# Add the selectors to the dataframe
|
|
288
|
+
for key, value in selectors.items():
|
|
289
|
+
df[key] = value
|
|
290
|
+
metric_bundle, output_bundle = _form_bundles(df)
|
|
204
291
|
|
|
205
292
|
return ExecutionResult.build_from_output_bundle(
|
|
206
293
|
definition, cmec_output_bundle=output_bundle, cmec_metric_bundle=metric_bundle
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: climate-ref-ilamb
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: ILAMB diagnostic provider for the Rapid Evaluation Framework
|
|
5
|
-
Author-email: Nathan Collier <nathaniel.collier@gmail.com>
|
|
6
|
-
License: Apache-2.0
|
|
5
|
+
Author-email: Nathan Collier <nathaniel.collier@gmail.com>, Jared Lewis <jared.lewis@climate-resource.com>
|
|
6
|
+
License-Expression: 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
|
|
@@ -18,8 +19,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
18
19
|
Classifier: Topic :: Scientific/Engineering
|
|
19
20
|
Requires-Python: >=3.11
|
|
20
21
|
Requires-Dist: climate-ref-core
|
|
21
|
-
Requires-Dist: ilamb3>=2025.
|
|
22
|
-
Requires-Dist: types-pyyaml>=6.0.12.20241230
|
|
22
|
+
Requires-Dist: ilamb3>=2025.5.20
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
|
|
25
25
|
# climate-ref-ilamb
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
climate_ref_ilamb/__init__.py,sha256=hMEkSjBY3yo-EbdMNOIvMSdGK14G2s5PERmWrBEtzFk,1414
|
|
2
|
+
climate_ref_ilamb/datasets.py,sha256=MVCt1pxV5dIfYLm6huC0BZWP5stCamYNwXzc7kKW5AI,799
|
|
3
|
+
climate_ref_ilamb/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
climate_ref_ilamb/standard.py,sha256=Z-q_SCrXHh7QAbRwpQq0UqOjsKY0y7XKlDn0fVyNcOI,10468
|
|
5
|
+
climate_ref_ilamb/configure/ilamb.yaml,sha256=4lzZhtn4nq4hV0qjXq9mWlN2cqIkhh_ICtYlL4gtW3k,1194
|
|
6
|
+
climate_ref_ilamb/configure/iomb.yaml,sha256=PxJAivXKNiYp-HbaYOJgUO8LnL9fmSztQKxLM_jFyvQ,944
|
|
7
|
+
climate_ref_ilamb/dataset_registry/ilamb.txt,sha256=_zqrq-Sa-0NTjPDFX6nQIeUalEc7tPrKr_CssOBlseg,1030
|
|
8
|
+
climate_ref_ilamb/dataset_registry/iomb.txt,sha256=b95CUBYEGfeoPyRGx_E267c-2GF-E_lc4XeFkNSOJMo,375
|
|
9
|
+
climate_ref_ilamb/dataset_registry/test.txt,sha256=gBjUJ6W-crghYqKN0QOFmjyqpMxKK50dU3SYTuIA6jM,206
|
|
10
|
+
climate_ref_ilamb-0.6.0.dist-info/METADATA,sha256=HeJDybVHP99XM7BMiPCqeaxHn4zygzIQydMf7Wu-ctc,2317
|
|
11
|
+
climate_ref_ilamb-0.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
12
|
+
climate_ref_ilamb-0.6.0.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
13
|
+
climate_ref_ilamb-0.6.0.dist-info/licenses/NOTICE,sha256=4qTlax9aX2-mswYJuVrLqJ9jK1IkN5kSBqfVvYLF3Ws,128
|
|
14
|
+
climate_ref_ilamb-0.6.0.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
climate_ref_ilamb/__init__.py,sha256=PW3FMUdCT7JCx3WgCx6caJ-fgttrYDyfqQjfsYzGiKc,1711
|
|
2
|
-
climate_ref_ilamb/datasets.py,sha256=LlhdxDkesDZayqTWinrCcwLCJhYH6W-OU9rVXhyO-ds,887
|
|
3
|
-
climate_ref_ilamb/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
climate_ref_ilamb/standard.py,sha256=hv5KhnpCXkNlM1UOqWl6i2X6N29u90bHeO8n_jTSUOY,7298
|
|
5
|
-
climate_ref_ilamb/configure/ilamb.yaml,sha256=bxovGQoKFLzhmV5pjMizm5GBK8bA9OoJtWB2L87hBwY,745
|
|
6
|
-
climate_ref_ilamb/configure/iomb.yaml,sha256=rZa1xPr7H0MzumJmeE_ca6JwT0cRX5pPOh4crm85kw0,476
|
|
7
|
-
climate_ref_ilamb/dataset_registry/ilamb.txt,sha256=FdjBSdR5cFMUWO89CumSMX2YYi6mhAghyn_cNLpOFaE,751
|
|
8
|
-
climate_ref_ilamb/dataset_registry/iomb.txt,sha256=Si4c0Q8kXeyJLpzpmDGTkbQEI0GQ-lbHuXsmvP0QUuo,266
|
|
9
|
-
climate_ref_ilamb/dataset_registry/test.txt,sha256=FiEQbUzeUi5Ww6akNXKoHmcuYkJae5G4n4rRisY7-pg,188
|
|
10
|
-
climate_ref_ilamb-0.5.4.dist-info/METADATA,sha256=LDtC1dFmo5BZ7swTuUKleB5oMk-bZiQvlHr1mSVpzUo,2239
|
|
11
|
-
climate_ref_ilamb-0.5.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
12
|
-
climate_ref_ilamb-0.5.4.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
13
|
-
climate_ref_ilamb-0.5.4.dist-info/licenses/NOTICE,sha256=4qTlax9aX2-mswYJuVrLqJ9jK1IkN5kSBqfVvYLF3Ws,128
|
|
14
|
-
climate_ref_ilamb-0.5.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|