climate_ref.datasets.cmip7_parsers
#
CMIP7 parser functions for extracting metadata from netCDF files
Includes both a fast DRS parser (filename/directory only) and a complete parser that opens netCDF files to extract all metadata.
parse_cmip7_complete(file, **kwargs)
#
Complete parser for CMIP7 files
This parser loads each file and extracts all available metadata from netCDF global attributes.
For some filesystems this may be slow, as it involves a lot of I/O operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str
|
File to parse |
required |
kwargs
|
Any
|
Additional keyword arguments (not used, but required for compatibility) |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with extracted metadata |
Source code in packages/climate-ref/src/climate_ref/datasets/cmip7_parsers.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
parse_cmip7_drs(file, **kwargs)
#
DRS parser for CMIP7 files
This parser extracts metadata according to the CMIP7 Data Reference Syntax (MIP-DRS7). This includes the essential metadata required to identify the dataset and is included in the filename and directory structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str
|
File to parse |
required |
kwargs
|
Any
|
Additional keyword arguments (not used, but required for compatibility) |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with extracted metadata |
Source code in packages/climate-ref/src/climate_ref/datasets/cmip7_parsers.py
parse_cmip7_using_directories(file)
#
Extract attributes of a file using information from CMIP7 DRS
The CMIP7 filename convention (MIP-DRS7 spec) uses _ as a delimiter between fields.
Fields may contain - internally but never _.
Filename format::
<variable_id>_<branding_suffix>_<frequency>_<region>_<grid_label>_
<source_id>_<experiment_id>_<variant_label>[_<timeRangeDD>].nc
Directory structure::
<drs_specs>/<mip_era>/<activity_id>/<institution_id>/<source_id>/
<experiment_id>/<variant_label>/<region>/<frequency>/<variable_id>/
<branding_suffix>/<grid_label>/<version>
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str
|
Path to the CMIP7 file |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with extracted metadata, or INVALID_ASSET dict on failure |