improver.metadata.utilities module
General IMPROVER metadata utilities
- create_coordinate_hash(cube)[source]
Generate a hash based on the input cube’s x and y coordinates. This acts as a unique identifier for the grid which can be used to allow two grids to be compared.
- create_new_diagnostic_cube(name, units, template_cube, mandatory_attributes, optional_attributes=None, data=None, dtype=<class 'numpy.float32'>)[source]
Creates a new diagnostic cube with suitable metadata.
- Parameters:
name (
str
) – Standard or long name for output cubetemplate_cube (
Cube
) – Cube from which to copy dimensional and auxiliary coordinatesmandatory_attributes (
Union
[Dict
[str
,str
],Dict
]) – Dictionary containing values for the mandatory attributes “title”, “source” and “institution”. These are overridden by values in the optional_attributes dictionary, if specified.optional_attributes (
Union
[Dict
[str
,str
],Dict
,None
]) – Dictionary of optional attribute names and values. If values for mandatory attributes are included in this dictionary they override the values of mandatory_attributes.data (
Union
[MaskedArray
,ndarray
,None
]) – Data array. If not set, cube is filled with zeros using a lazy data object, as this will be overwritten later by the caller routine.dtype (
Type
) – Datatype for dummy cube data if “data” argument is None.
- Return type:
- Returns:
Cube with correct metadata to accommodate new diagnostic field
- generate_hash(data_in)[source]
Generate a hash from the data_in that can be used to uniquely identify equivalent data_in.
- generate_mandatory_attributes(diagnostic_cubes, model_id_attr=None)[source]
Function to generate mandatory attributes for new diagnostics that are generated using several different model diagnostics as input to the calculation. If all input diagnostics have the same attribute use this, otherwise set a default value.