Description
🐛 Bug Report
iris
fails to correctly save multiple-cubes with varying dimensionality, all of which are based on the same 2D geospatial auxiliary coordinates nat_lat
and nav_lon
.
How To Reproduce
Steps to reproduce the behaviour:
The following example contains a mixture of 3D and 4D cubes, all of which have common 2D x
and y
coordinates (nav_lat
and nav_lon
), which can be successfully loaded by iris
, but incorrectly serialises them to a NetCDF file e.g.,
import iris
fname = "nemo_dn353o_1m_19000101-19000201_grid-T.nc"
cubes = iris.load(fname)
iris.save(cubes, "out.nc")
The example file cube list contains the following cubes:
0: sea_surface_conservative_temperature / (degC) (time: 1; -- : 331; -- : 360)
1: icb heat flux to ocean due to melting latent heat / (J/m2/s) (time: 1; -- : 331; -- : 360)
2: Evap minus Precip over ice / (kg/m2/s) (time: 1; -- : 331; -- : 360)
3: Ice shelf heat content flux of injected water ( from isf to oce ) / (W/m2) (time: 1; -- : 331; -- : 360)
4: sea_surface_absolute_salinity / (g/kg) (time: 1; -- : 331; -- : 360)
5: icb melt rate of icebergs / (kg/m2/s) (time: 1; -- : 331; -- : 360)
6: sea bottom conservative temperature / (degC) (time: 1; -- : 331; -- : 360)
7: sea bottom absolute salinity / (g/kg) (time: 1; -- : 331; -- : 360)
8: Ice shelf latent heat flux ( from isf to oce ) / (W/m2) (time: 1; -- : 331; -- : 360)
9: Evap minus Precip over ocean / (kg/m2/s) (time: 1; -- : 331; -- : 360)
10: Downward salt flux / (g/m2/s) (time: 1; -- : 331; -- : 360)
11: Ice shelf fresh water flux ( from isf to oce ) / (kg/m2/s) (time: 1; -- : 331; -- : 360)
12: Water flux due to freezing/melting / (kg/m2/s) (time: 1; -- : 331; -- : 360)
13: cell_thickness / (m) (time: 1; depth: 75; -- : 331; -- : 360) ❌
14: downwelling_shortwave_flux_in_sea_water / (W/m2) (time: 1; depth: 75; -- : 331; -- : 360) ❌
15: ocean_mixed_layer_thickness / (m) (time: 1; -- : 331; -- : 360)
16: precipitation_flux / (kg/m2/s) (time: 1; -- : 331; -- : 360)
17: sea_ice_area_fraction / (1) (time: 1; -- : 331; -- : 360)
18: sea_surface_height_above_geoid / (m) (time: 1; -- : 331; -- : 360)
19: sea_water_absolute_salinity / (g/kg) (time: 1; depth: 75; -- : 331; -- : 360) ❌
20: sea_water_conservative_temperature / (degC) (time: 1; depth: 75; -- : 331; -- : 360) ❌
21: snowfall_flux / (kg/m2/s) (time: 1; -- : 331; -- : 360)
22: square_of_sea_surface_height_above_geoid / (m2) (time: 1; -- : 331; -- : 360)
23: surface_downward_heat_flux_in_sea_water / (W/m2) (time: 1; -- : 331; -- : 360)
24: water_flux_into_sea_water_from_rivers / (kg/m2/s) (time: 1; -- : 331; -- : 360)
25: water_flux_out_of_sea_ice_and_sea_water / (kg/m2/s) (time: 1; -- : 331; -- : 360)
26: water_flux_out_of_sea_water_due_to_newtonian_relaxation / (kg/m2/s) (time: 1; -- : 331; -- : 360)
The provided example input file has the following NetCDF dimensions
section:
dimensions:
y = 331 ;
x = 360 ;
time_counter = UNLIMITED ; // (1 currently)
nvertex = 4 ;
depth = 75 ;
axis_nbounds = 2 ;
The iris
generated output NetCDF file contains the following dimensions
section:
dimensions:
time_counter = 1 ;
dim1 = 331 ;
dim2 = 360 ;
bnds = 2 ;
bnds_4 = 4 ;
depth = 75 ;
dim2_0 = 331 ;
dim3 = 360 ;
Given the above we have the following NetCDF dimensions
mapping, as iris
has saved a 3D cube first)
y
is mapped todim1
✅x
is mapped todim2
✅time_counter
is mapped totime_counter
✅nvertex
is mapped tobnds_4
✅depth
is mapped todepth
✅
The following mapping behaviour is the issue:
dim2_0
is akin todim1
(i.e.,y
) but for a 4D cube ❌dim3
is akin todim2
(i.e.,x
) but for a 4D cube ❌
Unfortunately the nav_lat
and nav_lon
coordinates are first saved referencing (dim1, dim2)
and not (dim2_0, dim3)
.
This behaviour would be different but also incorrect if a 4D cube was saved first from the cube list. Hence the 4D cubes are incorrectly serialised as the nav_lat
and nav_lon
do not match the dimension names associated with th 4D NetCDF variables.
Expected behaviour
No duplication of spatial dimensions
.
Environment
- Applies up to the latest development version of
iris
Metadata
Metadata
Assignees
Type
Projects
Status