-
Notifications
You must be signed in to change notification settings - Fork 296
Closed
Labels
StaleA stale issue/pull-requestA stale issue/pull-request
Description
From @pdearnshaw :
This code causes a failed save to NetCDF :
import iris
# Create a model level and pressure level coordinate:
# Important bit is that pressure level coordinate has var_name="pressure"
pcoord = iris.coords.DimCoord([1000.],
standard_name=None,
long_name='pressure',
var_name='pressure',
units='hPa',
attributes={'positive': 'down'})
mcoord = iris.coords.DimCoord([1],
standard_name='model_level_number',
long_name='model_level_number',
var_name='model_level_number',
units='1',
attributes={'positive': 'up'})
# Create a model level and pressure level cube using above coordinates:
# Important bit is that model level cube has var_name="pressure"
pcube = iris.cube.Cube([0.0],
standard_name='air_temperature',
long_name='air_temperature',
var_name='air_temperature',
units='K',
dim_coords_and_dims=[(pcoord, 0)])
mcube = iris.cube.Cube([0.0],
standard_name='air_pressure',
long_name='air_pressure',
var_name='pressure',
units='Pa',
dim_coords_and_dims=[(mcoord, 0)])
# Then save the cubes:
# First save has pressure level cube first and works
iris.save([pcube, mcube], 'netcdf_save_work.nc')
# Second save has model level cube first and fails
iris.save([mcube, pcube], 'netcdf_save_fail.nc')
I essentially create two cubes, one with a model level coordinate and one with a pressure level coordinate. The model level cube has var_name “pressure”, while the pressure level coordinate in the other cube also has var_name=”pressure”. If you save the cubes to a netcdf file in the order of pressure level cube first then the save works. If you reverse the cubes then the save fails in the same way we saw.
(See error trace in separate comment below : it's really long !)
Metadata
Metadata
Assignees
Labels
StaleA stale issue/pull-requestA stale issue/pull-request