improver.utilities.save module#
Module for saving netcdf cubes with desired attribute types.
- _check_metadata(cube)[source]#
Checks cube metadata that needs to be correct to guarantee data integrity
- Parameters:
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”
- Return type:
- _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. Ensure that if there are any identical duplicate cell methods, only one of these is included in the outputs.
- save_netcdf(cubelist, filename, compression_level=1, least_significant_digit=None, fill_value=None)[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 (
Union[Cube,CubeList]) – Cube or list of cubes to be savedfilename (
str) – Filename to save input cube(s)compression_level (
int) – 1-9 to specify compression level, or 0 to not compress (default compress with complevel 1)least_significant_digit (
Optional[int]) – If specified will truncate the data to a precision given by 10**(-least_significant_digit), e.g. if least_significant_digit=2, then the data will be quantized to a precision of 0.01 (10**(-2)). See http://www.esrl.noaa.gov/psd/data/gridded/conventions/cdc_netcdf_standard.shtml for details. When used with compression level, this will result in lossy compression.fill_value (
Optional[float]) – If specified, will set the fill value for missing data. If not specified, the default fill value for the data type will be used. If the data is not masked then the numpy array’s fill value will retain the default value while the _FillValue attribute in the NetCDF file will be updated.
- Raises:
warning if cubelist contains cubes of varying dimensions. –
- Return type: