diff_cube = ctrl_cube.copy()
diff_cube = ctrl_cube.data - exp1_cube.databias_cube = ctrl_cube.copy()
bias_cube = ctrl_cube.data - erai_cube.dataexp1_cube.remove_coord(exp1_cube.coord(axis='T'))
exp1_cube.add_dim_coord(ctrl_cube.coord(axis='T').copy(), time_position)
diff_cube = ctrl_cube - exp1_cubedef my_equalise_attributes(cubes):
"""
Delete cube attributes that are not identical over all cubes in a group.
This function simply deletes any attributes which are not the same for
all the given cubes. The cubes will then have identical attributes. The
given cubes are modified in-place.
Arguments:
* cubes (iterable of :class:`iris.cube.Cube`):
A collection of cubes to compare and adjust.
"""
# Work out which attributes are identical across all the cubes.
common_keys = cubes[0].attributes.keys()
dtype = cubes[0].dtype
for cube in cubes[1:]:
cube_keys = cube.attributes.keys()
common_keys = [
key for key in common_keys
if key in cube_keys
and np.all(cube.attributes[key] == cubes[0].attributes[key])]
# Match data type and fill value to those of first cube.
if cube.dtype != dtype:
cube._my_data = cube._my_data.astype(dtype)
# Remove all the other attributes.
for cube in cubes:
for key in cube.attributes.keys():
if key not in common_keys:
del cube.attributes[key]
# Iterate for each co-ordinate in first cube.
for coord0 in cubes[0].coords():
coord_name = coord0.standard_name
if coord_name is not None:
dtype_points = coord0.points.dtype
dtype_bounds = getattr(coord0.bounds, 'dtype', None)
long_name = coord0.long_name
var_name = coord0.var_name
circular = getattr(coord0, 'circular', None)
# Work out which attributes are identical (for this co-ordinate)
# across all the cubes.
common_coord_keys = coord0.attributes.keys()
for cube in cubes[1:]:
coord = cube.coord(coord_name)
cube_coord_keys = coord.attributes.keys()
common_coord_keys = [key for key in common_coord_keys if key in
cube_coord_keys and
np.all(coord.attributes[key] ==
coord0.attributes[key])]
# Match names and data types to those of coord in first cube.
if coord.points.dtype != dtype_points:
coord.points = coord.points.astype(dtype_points,
copy=False)
d = getattr(coord.bounds, 'dtype', None)
if d != dtype_bounds and d is not None:
coord.bounds = coord.bounds.astype(dtype_bounds,
copy=False)
if coord.long_name != long_name:
coord.long_name = long_name
if coord.var_name != var_name:
coord.var_name = var_name
if circular is not None and \
getattr(coord, 'circular', None) != circular:
coord.circular = circular
# Remove all the other attributes (for this co-ordinate).
for cube in cubes:
coord = cube.coord(coord_name)
for key in coord.attributes.keys():
if key not in common_coord_keys:
del coord.attributes[key]diff_cube = ctrl_cube.copy()
diff_cube.data = ctrl_cube.data - exp1_cube.data