Hello all,
I can load these cubes but then end up with a cube_list with a cube for each year. The first thing I run into is that the time dimension is not a 'Scalar coordinate' So I have to create a list of slices to do the merge on. But even still I end up with an error because each original cube lists its file_name as an attribute:
MergeError: failed to merge into a single cube.
cube.attributes values differ for keys: 'file_name'
I keep feeling like there must be an easier way to manage this? Am I missing an obvious solution because I'm relatively new to Iris? If that's just life in the city hopefully my code example can help others figure this out, as it wasn't at all obvious to me.
Thanks for any help or insight.
Colin
My code for reference:
#tmax_9495.merge_cubes() #doesn't work that easily
#first delete off the file_name attribute
for cube in tmax_9495:
del cube.metadata.attributes['file_name']
# print cube
#now create a list of slices for each cube that we can merge on
slices = []
for cube in tmax_9495:
slices.extend(list(cube.slices(['longitude', 'latitude'])))
#now we can merge those slices
final_data = iris.cube.CubeList(slices).merge_cube()
print "final data:", final_data
which gives:
first data: tmax / (C) (time: 12; latitude: 88; longitude: 79)
Dimension coordinates:
time x - -
latitude - x -
longitude - - x
Attributes:
Conventions: GDT-1.2
History: Initially created in 2011
SurfSgnConvention: Traditional
associate: time lat lon
authors: D.Raff,L.Brekke,S.Gangopadhyay,T.Pruitt,A.Wood
creation_date: Jan-Mar, 2011
desc: mean monthly maximum daily temperature
description: BCSD surface water projections hydrologic data
file_name: nc_mon/cali/obs.maurer_2002.cali.monthly.tmax.1995.nc
institution: U.S. Bureau of Reclamation
name: tmax
references: U.S. Bureau of Reclamation, 2011, West-Wide Climate Risk Assessments: BCSD...
vic_name: aggregated daily observed
final data: tmax / (C) (time: 24; longitude: 79; latitude: 88)
Dimension coordinates:
time x - -
longitude - x -
latitude - - x
Attributes:
Conventions: GDT-1.2
History: Initially created in 2011
SurfSgnConvention: Traditional
associate: time lat lon
authors: D.Raff,L.Brekke,S.Gangopadhyay,T.Pruitt,A.Wood
creation_date: Jan-Mar, 2011
desc: mean monthly maximum daily temperature
description: BCSD surface water projections hydrologic data
institution: U.S. Bureau of Reclamation
name: tmax
references: U.S. Bureau of Reclamation, 2011, West-Wide Climate Risk Assessments: BCSD...
vic_name: aggregated daily observed