improver.metadata.check_datatypes module¶
Utilities for datatype checking
-
improver.metadata.check_datatypes._check_units_and_dtype(obj, units, dtype)[source]¶ Check whether the units and datatype of the input object conform to the standard given.
- Parameters
obj (iris.cube.Cube or iris.coords.Coord) – Cube or coordinate to be checked
units (str) – Required units
dtype (type) – Required datatype
- Returns
True if object conforms; False if not
- Return type
-
improver.metadata.check_datatypes._construct_object_list(cube, coord_names)[source]¶ Construct a list of objects
- Parameters
cube (iris.cube.Cube) – Cube to append to object list
coord_names (list of str or None) – List of coordinate names to take from cube. If None, adds all coordinates present on the input cube.
- Returns
List containing the original cube and specified coordinates
- Return type
list of obj
-
improver.metadata.check_datatypes._get_required_datatype(item)[source]¶ Returns the required datatype of the object (cube or coordinate) passed in, according to the IMPROVER standard. Input object must have attributes “units” and “dtype”.
-
improver.metadata.check_datatypes.check_cube_not_float64(cube, fix=False)[source]¶ Check a cube does not contain any float64 data, excepting time coordinates. The cube can be modified in place, if the fix keyword is specified to be True.
- Parameters
cube (iris.cube.Cube) – The input cube that will be checked for float64 inclusion.
fix (bool) – If fix is True, then the cube is amended to not include float64 data, otherwise, an error will be raised if float64 data is found.
- Raises
TypeError – Raised if 64 bit values are found in the cube.
-
improver.metadata.check_datatypes.check_datatypes(cube, coords=None)[source]¶ Function to check the datatypes of cube diagnostics and coordinates against the expected standard. The default datatype is float32; integer quantities are expected to be 32-bit with the exception of absolute time.
- Parameters
cube (iris.cube.Cube) – Cube to be checked
coords (list or None) – List of coordinate names to check. If None, checks all coordinates present on the input cube.
- Raises
ValueError – if the input cube does not conform to the datatypes standard
-
improver.metadata.check_datatypes.check_time_coordinate_metadata(cube)[source]¶ Function to check time coordinates against the expected standard. The standard for time coordinates is due to technical requirements and if violated the data integrity cannot be guaranteed; so if time coordinates are non-conformant an error is raised.
- Parameters
cube (iris.cube.Cube) – Cube to be checked
- Raises
ValueError – if any the input cube’s time coordinates do not conform to the standard datatypes and units