Base
checkCEDA(source_id, activity_id, experiment_id, M2I, variableList, table_id, member_id='*')
For a given source_id (model), check which variables have data on CEDA, and return a DataFrame similar to intake-esm format, combining paths for identical metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source_id
|
str
|
source_id (e.g. "MPI-ESM1-2-HR") |
required |
activity_id
|
str
|
CMIP6 activity (e.g. "CMIP", "ScenarioMIP") |
required |
experiment_id
|
str
|
Experiment (e.g. "historical", "ssp585") |
required |
M2I
|
dict
|
Mapping source_id -> institution_id (from getModel_to_inst) |
required |
variableList
|
List[str]
|
Variables to check (e.g. |
required |
table_id
|
str
|
Corresponding CMIP6 table_id e.g. 'Amon' |
required |
member_id
|
str
|
The member Id specifically looked for - can be a wild car when searching for all members |
'*'
|
Returns:
Type | Description |
---|---|
DataFrame
|
DataFrame with the following columns:
|
Source code in climdyn_tools/ceda_esgf/base.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
checkESGF(source_id, activity_id, experiment_id, M2I, variableList, table_id, member_id='*')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source_id
|
str
|
source_id (e.g. "MPI-ESM1-2-HR") |
required |
activity_id
|
str
|
CMIP6 activity (e.g. "CMIP", "ScenarioMIP") |
required |
experiment_id
|
str
|
Experiment (e.g. "historical", "ssp585") |
required |
M2I
|
dict
|
Mapping source_id -> institution_id (from getModel_to_inst) |
required |
variableList
|
List[str]
|
Variables to check (e.g. |
required |
table_id
|
str
|
Corresponding CMIP6 table_id e.g. 'Amon' |
required |
member_id
|
str
|
The member Id specifically looked for - can be a wild car when searching for all members |
'*'
|
Returns:
Type | Description |
---|---|
DataFrame
|
DataFrame with the following columns:
|
Source code in climdyn_tools/ceda_esgf/base.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
compare_cat_res_pivot(cat_df, res_df)
Compare two CMIP6 DataFrames (cat_df and res_df) and return a pivot table showing where each (member_id, variable_id) combination exists: 'cat only', 'res only', or 'both'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cat_df
|
DataFrame
|
Catalog dataframe with columns |
required |
res_df
|
DataFrame
|
Result dataframe with columns |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
Pivot table: |
Source code in climdyn_tools/ceda_esgf/base.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
extract_r(member_id)
Extract r<number>
from CMIP6 member_id string like r1i1p1f1
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
member_id
|
str
|
The member id string e.g. |
required |
Returns:
Type | Description |
---|---|
int
|
The |
Source code in climdyn_tools/ceda_esgf/base.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
getCombinedData(source_id, activity_id, experiment_id, M2I, CEDA_vars, ESGF_vars, table_id, member_id, doReadOut=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source_id
|
str
|
CMIP6 model/source ID (e.g., 'NorESM2-LM'). |
required |
activity_id
|
str
|
CMIP6 activity (e.g., 'DAMIP'). |
required |
experiment_id
|
str
|
CMIP6 experiment ID (e.g., 'hist-aer'). |
required |
M2I
|
dict
|
Mapping from model variable names to CMOR variable names. |
required |
CEDA_vars
|
List[str]
|
Variables to retrieve from CEDA. |
required |
ESGF_vars
|
List[str]
|
Variables to retrieve from ESGF. |
required |
table_id
|
str
|
CMIP6 table ID (e.g., 'Amon', 'Lmon'). |
required |
member_id
|
str
|
Variant label for the ensemble member (e.g., 'r1i1p1f1'). |
required |
doReadOut
|
bool
|
Whether to print while loading or not |
False
|
Returns:
Type | Description |
---|---|
Dataset
|
Combined xarray Dataset containing requested variables from CEDA and ESGF.
|
Source code in climdyn_tools/ceda_esgf/base.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
getModel_to_inst(CMIP6Meta)
Build a mapping from CMIP6 source_id (model name) to its first listed institution_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
CMIP6Meta
|
dict
|
Parsed JSON from CMIP6_source_id.json |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary of the form |
Source code in climdyn_tools/ceda_esgf/base.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
initializeCat()
Attempt to initialize an ESGFCatalog object with multiple retries.
The function tries up to 20 times to create an ESGFCatalog instance, waiting a random interval between 15 and 60 seconds between attempts if initialization fails. This helps handle transient network or server issues.
Returns:
Type | Description |
---|---|
Optional[ESGFCatalog]
|
Successfully initialized ESGFCatalog object. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the catalog cannot be initialized after 20 attempts. |
Notes
Each attempt logs its progress, and the exception is encountered if it fails.
Source code in climdyn_tools/ceda_esgf/base.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
load_cmip6_source_id(local_path=None)
Load CMIP6 source_id controlled vocabulary JSON. Tries local path first, then GitHub if not found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
local_path
|
Optional[str]
|
Path to local CMIP6_source_id.json |
None
|
Returns:
Name | Type | Description |
---|---|---|
data |
dict
|
Parsed JSON content |
Source code in climdyn_tools/ceda_esgf/base.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
parse_variant_labels(paths)
Given a list of CMIP6 file paths or variant_labels, extract r, i, p, f values into a DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
paths
|
List[str]
|
CMIP6 file paths or strings containing a variant_label. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
DataFrame with columns |
Raises:
Type | Description |
---|---|
ValueError
|
If any path/label does not contain a valid variant_id. |
Source code in climdyn_tools/ceda_esgf/base.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
rank_members_with_vars(pivot)
Rank member_ids by maximizing CEDA_CHOICE, minimizing ESGF_ONLY, then by r-number. Also attach the list of variable_ids available via CEDA and those only via ESGF.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pivot
|
DataFrame
|
Pivot table where rows correspond to
|
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A dataframe with one row per member containing (the dataframe is sorted descending by |
DataFrame
|
ascending by
|
Source code in climdyn_tools/ceda_esgf/base.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
source_id_in_activity(activity_id, CMIP6Meta)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_id
|
str
|
e.g. "CMIP", "ScenarioMIP" |
required |
CMIP6Meta
|
dict
|
Parsed JSON from CMIP6_source_id.json |
required |
Returns:
Name | Type | Description |
---|---|---|
sil |
List[str]
|
List of source_id names that participate in the activity. |
Source code in climdyn_tools/ceda_esgf/base.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|