-
Notifications
You must be signed in to change notification settings - Fork 300
Description
Consider the following treatment of the cube units for the value unknown and no-unit.
First, create come appropriate cubes, and save them (using the latest upstream/master pre 2.3.0):
>>> import iris
>>> nounit = iris.cube.Cube(1, 'air_temp', units='no unit')
>>> nounit = iris.cube.Cube(1, 'air_temperature', units='no unit')
>>> iris.save(nounit, 'nounit.nc')
>>> unknown = iris.cube.Cube(1, 'air_temperature', units='unknown')
>>> iris.save(unknown, 'unknown.nc')Now, let's look at the resultant NetCDF files:
$ ncdump -h nounit.nc
netcdf nounit {
variables:
int64 air_temperature ;
air_temperature:standard_name = "air_temperature" ;
air_temperature:units = "no_unit" ;
// global attributes:
:Conventions = "CF-1.5" ;
}
$ ncdump -h unknown.nc
netcdf unknown {
variables:
int64 air_temperature ;
air_temperature:standard_name = "air_temperature" ;
// global attributes:
:Conventions = "CF-1.5" ;We created the no_unit unit (the aliases in cf-units for no_unit are -, no unit, no-unit, and nounit) for convenience, and doesn't actually map to an valid UDUNITS unit. This is also true for the unknown unit.
The difference here is that iris doesn't explicitly save to NetCDF any units of unknown, and I argue this should also be the case for the no_unit unit e.g.,
$ cfchecker nounit.nc
...
------------------
Checking variable: air_temperature
------------------
ERROR: (3.1): Invalid units: no_unit
ERRORS detected: 1
WARNINGS given: 1
INFORMATION messages: 0Both the unknown and no_unit units should have the same behaviour and should not be saved to NetCDF.
Plus, NetCDF with units containing no_unit may break upstream tools, as it's clearly not CF compliant.