improver.utilities.save module¶
Module for saving netcdf cubes with desired attribute types.
-
improver.utilities.save._append_metadata_cube(cubelist, global_keys)[source]¶ - Create a metadata cube associated with statistical
post-processing attributes of the input cube list.
- Parameters
cubelist (iris.cube.CubeList) – List of cubes to be saved
global_keys (list) – List of attributes to be treated as global across cubes and within any netCDF files produced using these cubes.
- Returns
iris.cube.CubeList with appended metadata cube
-
improver.utilities.save._check_metadata(cube)[source]¶ Checks cube metadata that needs to be correct to guarantee data integrity
- Parameters
cube (iris.cube.Cube) – Cube to be checked
- Raises
ValueError – if time coordinates do not have the required datatypes and units; needed because values may be wrong
ValueError – if numerical datatypes are other than 32-bit (except where specified); needed because values may be wrong
ValueError – if cube dataset has unknown units; because this may cause misinterpretation on “load”
-
improver.utilities.save._order_cell_methods(cube)[source]¶ Sorts the cell methods on a cube such that if there are multiple methods they are always written in a consistent order in the output cube. The input cube is modified.
- Parameters
cube (iris.cube.Cube) – The cube on which the cell methods are to be sorted.
-
improver.utilities.save.save_netcdf(cubelist, filename)[source]¶ Save the input Cube or CubeList as a NetCDF file and check metadata where required for integrity.
Uses the functionality provided by iris.fileformats.netcdf.save with local_keys to record non-global attributes as data attributes rather than global attributes.
- Parameters
cubelist (iris.cube.Cube or iris.cube.CubeList) – Cube or list of cubes to be saved
filename (str) – Filename to save input cube(s)
- Raises
warning if cubelist contains cubes of varying dimensions. –