climate_ref_core.pycmec.controlled_vocabulary
#
RESERVED_DIMENSION_NAMES = {'attributes', 'json_structure', 'created_at', 'updated_at', 'value', 'id'}
module-attribute
#
These names are reserved for internal use and should not be used as dimension names.
These names have other meanings that would conflict with the controlled vocabulary.
CV
#
A collection of controlled dimensions and values used to validate executions.
A diagnostic bundle does not have to specify all dimensions, but any dimensions not in the CV are not permitted.
Source code in packages/climate-ref-core/src/climate_ref_core/pycmec/controlled_vocabulary.py
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 | |
get_dimension_by_name(name)
#
Get a dimension by name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the dimension |
required |
Returns:
| Type | Description |
|---|---|
Dimension
|
The dimension with the given name |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the dimension is not found |
Source code in packages/climate-ref-core/src/climate_ref_core/pycmec/controlled_vocabulary.py
load_from_file(filename)
staticmethod
#
Load a CV from disk
Returns:
| Type | Description |
|---|---|
A new CV instance
|
|
Source code in packages/climate-ref-core/src/climate_ref_core/pycmec/controlled_vocabulary.py
validate_metrics(metric_value_collection)
#
Validate a set of metric values (either scalar or series) against a CV
The CV describes the accepted dimensions and values within a bundle
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_value_collection
|
CMECMetric | Sequence[SeriesMetricValue]
|
A collection of metric values to validate. This can be a CMECMetric instance or a sequence of SeriesMetricValue instances. |
required |
Raises:
| Type | Description |
|---|---|
ResultValidationError
|
If the validation of the dimensions or values fails |
Source code in packages/climate-ref-core/src/climate_ref_core/pycmec/controlled_vocabulary.py
Dimension
#
Description of a dimension in a diagnostic bundle
This information is also used by the frontend for presentation purposes.
Source code in packages/climate-ref-core/src/climate_ref_core/pycmec/controlled_vocabulary.py
allow_extra_values
instance-attribute
#
If True, additional non-controlled values are allowed. This is used for dimensions where not all the values are known at run time,' for example, the model dimension.
description
instance-attribute
#
A short description of the dimension.
This is used for presentation
long_name
instance-attribute
#
A longer name used for presentation
name = field(validator=validators.not_(validators.in_(RESERVED_DIMENSION_NAMES)))
class-attribute
instance-attribute
#
A short identifier of the dimension.
This is used as a key in the diagnostic bundle and must be unique.
required
instance-attribute
#
If True, this dimension is required to be specified in the executions.
values = field(factory=list)
class-attribute
instance-attribute
#
The list of controlled values for a given dimension.
If allow_extra_values is False,
then only these values are valid for the dimension.
DimensionValue
#
An allowed value for a dimension