climate_ref_core.metric_values.typing
#
MetricValueKind = Literal['model', 'reference']
module-attribute
#
The role of a metric value: a model value or a reference (observation) value.
FileDefinition
#
Bases: BaseModel
A definition of an output file with associated additional dimensions.
Source code in packages/climate-ref-core/src/climate_ref_core/metric_values/typing.py
ScalarMetricValue
#
Bases: BaseModel
A scalar value with an associated dimensions
Source code in packages/climate-ref-core/src/climate_ref_core/metric_values/typing.py
attributes = None
class-attribute
instance-attribute
#
Additional unstructured attributes associated with the metric value
dimensions
instance-attribute
#
Key, value pairs that identify the dimensions of the metric
These values are used for a faceted search of the metric values.
kind = 'model'
class-attribute
instance-attribute
#
Whether the value is a model value or a reference (observation) value.
This is the first-class signal for the role of the value and replaces provider-specific conventions for distinguishing the two.
value
instance-attribute
#
A scalar value
SeriesDefinition
#
Bases: FileDefinition
A definition of a 1-d array with an associated index and additional dimensions.
Source code in packages/climate-ref-core/src/climate_ref_core/metric_values/typing.py
attributes
instance-attribute
#
A list of attributes that should be extracted from the file and included in the series metadata.
index_name
instance-attribute
#
The name of the variable in the file that contains the index of the series.
sel = None
class-attribute
instance-attribute
#
A dictionary of selection criteria to apply with :meth:xarray.Dataset.sel after loading the file.
values_name
instance-attribute
#
The name of the variable in the file that contains the values of the series.
SeriesMetricValue
#
Bases: BaseModel
A 1-d array with an associated index and additional dimensions
These values are typically sourced from the CMEC metrics bundle
Source code in packages/climate-ref-core/src/climate_ref_core/metric_values/typing.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 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 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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
attributes = None
class-attribute
instance-attribute
#
Additional unstructured attributes associated with the metric value
calendar = None
class-attribute
instance-attribute
#
Calendar of a time index (e.g. "360_day"), when the index is temporal.
Presentation metadata. Optional for now; falls back to attributes when absent.
dimensions
instance-attribute
#
Key, value pairs that identify the dimensions of the metric
These values are used for a faceted search of the metric values.
index
instance-attribute
#
A 1-d array of index values
Values must be strings or numbers and have the same length as values. Non-unique index values are not allowed.
index_name
instance-attribute
#
The name of the index.
This is used for presentation purposes and is not used in the controlled vocabulary.
index_units = None
class-attribute
instance-attribute
#
Units of the index (e.g. "days since 1850-01-01").
Presentation metadata. Optional for now; falls back to attributes when absent.
kind = 'model'
class-attribute
instance-attribute
#
Whether the series is a model value or a reference (observation) value.
This is the first-class signal for the role of the value and replaces provider-specific conventions for distinguishing the two.
reference_id = None
class-attribute
instance-attribute
#
Content hash identifying the reference payload of the series.
Stable across executions for an identical reference payload,
so reference series can be deduplicated deterministically.
It is None for model series and is populated at ingest for reference series.
value_long_name = None
class-attribute
instance-attribute
#
Human-readable name of the series values (e.g. "Near-Surface Air Temperature").
Presentation metadata. Optional for now; falls back to attributes when absent.
value_units = None
class-attribute
instance-attribute
#
Units of the series values (e.g. "K").
Presentation metadata. Optional for now; falls back to attributes when absent.
values
instance-attribute
#
A 1-d array of values
dump_to_json(path, series)
classmethod
#
Dump a sequence of SeriesMetricValue to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path to the JSON file. The directory containing this file must already exist. This file will be overwritten if it already exists. |
required |
series
|
Sequence[SeriesMetricValue]
|
The series values to dump. |
required |
Source code in packages/climate-ref-core/src/climate_ref_core/metric_values/typing.py
load_from_json(path)
classmethod
#
Load a sequence of SeriesMetricValue from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path to the JSON file. |
required |
Source code in packages/climate-ref-core/src/climate_ref_core/metric_values/typing.py
validate_index()
#
Validate that index has the same length as values and contains no NaNs
Source code in packages/climate-ref-core/src/climate_ref_core/metric_values/typing.py
validate_values(value)
classmethod
#
Transform None values to NaN in the values field