improver.metadata.utilities module¶
General IMPROVER metadata utilities
-
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.
- Parameters
cube (iris.cube.Cube) – The cube from which x and y coordinates will be used to generate a hash.
- Returns
A hash created using the x and y coordinates of the input cube.
- Return type
-
improver.metadata.utilities.create_new_diagnostic_cube(name, units, coordinate_template, attributes=None, data=None, dtype=<class 'numpy.float32'>)[source]¶ Creates a template for a new diagnostic cube with suitable metadata.
- Parameters
name (str) – Standard or long name for output cube
units (str or cf_units.Unit) – Units for output cube
coordinate_template (iris.cube.Cube) – Cube from which to copy dimensional and auxiliary coordinates
attributes (dict or None) – Dictionary of attribute names and values
data (numpy.ndarray or 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 (numpy.dtype) – Datatype for dummy cube data if “data” argument is None.
- Returns
Cube with correct metadata to accommodate new diagnostic field
- Return type
-
improver.metadata.utilities.generate_hash(data_in)[source]¶ Generate a hash from the data_in that can be used to uniquely identify equivalent data_in.
- Parameters
data_in (any) – The data from which a hash is to be generated. This can be of any type that can be pretty printed.
- Returns
A hexadecimal string which is a hash hexdigest of the data as a string.
- Return type