I've got several files containing monthly mean temperature on a lat/lon grid for different pressure levels that I'd like to merge into a single cube so I can take cross sections through it.
I've tried copying some code from here:
https://github.com/SciTools/iris/issues/484Which I think does what I want and works fine:
>>> cube.add_dim_coord(DimCoord(np.arange(3), standard_name='latitude', units='degrees'), 0)
>>> cube.add_dim_coord(DimCoord(np.arange(4), standard_name='longitude', units='degrees'), 1)
>>> other = cube.copy()
>>> cube.add_aux_coord(AuxCoord(np.array([10], dtype=np.int), standard_name='height', units='m'))
>>> other.add_aux_coord(AuxCoord([20.], bounds=[[15., 25.]], standard_name='height', units='m'))
>>> merged = iris.cube.CubeList([cube, other]).merge()[0]
>>> print merged
air_temperature / (K) (height: 2; latitude: 3; longitude: 4)
Dimension coordinates:
height x - -
latitude - x -
longitude - - x
>>> merged.coord('height')
DimCoord(array([ 10., 20.]), standard_name='height', units=Unit('m'))
However when I try it with my data, I don't end up with a new pressure level coordinate:
>>>
ERAInt_mm_1000 = iris.load_cube('/data/local/aplb/MARIUS/ERAInterim/1980-2010.t1000.monmean.nc')
>>>
ERAInt_mm_1000.add_aux_coord(AuxCoord(np.array([1000], dtype=np.int), standard_name='air_pressure', units='hPa'))
>>>
del ERAInt_mm_1000.attributes['history']
>>> print
ERAInt_mm_1000
>>>
ERAInt_mm_850 = iris.load_cube('/data/local/aplb/MARIUS/ERAInterim/1980-2010.t850.monmean.nc')
>>>
ERAInt_mm_850.add_aux_coord(AuxCoord(np.array([850], dtype=np.int), standard_name='air_pressure', units='hPa'))
>>>
del ERAInt_mm_850.attributes['history']
>>>
ERAInt_mm = iris.cube.CubeList([ERAInt_mm_1000, ERAInt_mm_850]).merge()[0]
>>>
print ERAInt_mm_1000
>>>
print ERAInt_mm_850
>>>
print ERAInt_mm
air_temperature / (K) (time: 12; latitude: 241; longitude: 480)
Dimension coordinates:
time x - -
latitude - x -
longitude - - x
Scalar coordinates:
air_pressure: 1000 hPa
Attributes:
CDI: Climate Data Interface version 1.7.0 (
http://mpimet.mpg.de/cdi)
CDO: Climate Data Operators version 1.7.0 (
http://mpimet.mpg.de/cdo)
Conventions: CF-1.0
air_temperature / (K) (time: 12; latitude: 241; longitude: 480)
Dimension coordinates:
time x - -
latitude - x -
longitude - - x
Scalar coordinates:
air_pressure: 850 hPa
Attributes:
CDI: Climate Data Interface version 1.7.0 (
http://mpimet.mpg.de/cdi)
CDO: Climate Data Operators version 1.7.0 (
http://mpimet.mpg.de/cdo)
Conventions: CF-1.0
air_temperature / (K) (time: 12; latitude: 241; longitude: 480)
Dimension coordinates:
time x - -
latitude - x -
longitude - - x
Scalar coordinates:
air_pressure: 1000 hPa
Attributes:
CDI: Climate Data Interface version 1.7.0 (
http://mpimet.mpg.de/cdi)
CDO: Climate Data Operators version 1.7.0 (
http://mpimet.mpg.de/cdo)
Conventions: CF-1.0
Any pointers? Thanks!