1- # (C) British Crown Copyright 2010 - 2017 , Met Office
1+ # (C) British Crown Copyright 2010 - 2019 , Met Office
22#
33# This file is part of Iris.
44#
@@ -315,7 +315,8 @@ class _CoordSignature(namedtuple('CoordSignature',
315315
316316class _CubeSignature (namedtuple ('CubeSignature' ,
317317 ['defn' , 'data_shape' , 'data_type' ,
318- 'cell_measures_and_dims' ])):
318+ 'cell_measures_and_dims' ,
319+ 'ancillary_variables_and_dims' ])):
319320 """
320321 Criterion for identifying a specific type of :class:`iris.cube.Cube`
321322 based on its metadata.
@@ -334,6 +335,9 @@ class _CubeSignature(namedtuple('CubeSignature',
334335 * cell_measures_and_dims:
335336 A list of cell_measures and dims for the cube.
336337
338+ * ancillary_variables_and_dims:
339+ A list of ancillary_variables and dims for the cube.
340+
337341 """
338342
339343 __slots__ = ()
@@ -405,6 +409,9 @@ def match(self, other, error_on_mismatch):
405409 msgs .append (msg .format (self .data_type , other .data_type ))
406410 if (self .cell_measures_and_dims != other .cell_measures_and_dims ):
407411 msgs .append ('cube.cell_measures differ' )
412+ if (self .ancillary_variables_and_dims !=
413+ other .ancillary_variables_and_dims ):
414+ msgs .append ('cube.ancillary_variables differ' )
408415
409416 match = not bool (msgs )
410417 if error_on_mismatch and not match :
@@ -1134,6 +1141,10 @@ def __init__(self, cube):
11341141 # they are checked and preserved through merge
11351142 self ._cell_measures_and_dims = cube ._cell_measures_and_dims
11361143
1144+ # ancillary_variables are not merge candidates
1145+ # they are checked and preserved through merge
1146+ self ._ancillary_variables_and_dims = cube ._ancillary_variables_and_dims
1147+
11371148 def _report_duplicate (self , nd_indexes , group_by_nd_index ):
11381149 # Find the first offending source-cube with duplicate metadata.
11391150 index = [group_by_nd_index [nd_index ][1 ]
@@ -1483,10 +1494,13 @@ def _get_cube(self, data):
14831494
14841495 cms_and_dims = [(deepcopy (cm ), dims )
14851496 for cm , dims in self ._cell_measures_and_dims ]
1497+ av_and_dims = [(deepcopy (av ), dims )
1498+ for av , dims in self ._ancillary_variables_and_dims ]
14861499 cube = iris .cube .Cube (data ,
14871500 dim_coords_and_dims = dim_coords_and_dims ,
14881501 aux_coords_and_dims = aux_coords_and_dims ,
14891502 cell_measures_and_dims = cms_and_dims ,
1503+ ancillary_variables_and_dims = av_and_dims ,
14901504 ** kwargs )
14911505
14921506 # Add on any aux coord factories.
@@ -1607,7 +1621,8 @@ def _build_signature(self, cube):
16071621 """
16081622
16091623 return _CubeSignature (cube .metadata , cube .shape ,
1610- cube .dtype , cube ._cell_measures_and_dims )
1624+ cube .dtype , cube ._cell_measures_and_dims ,
1625+ cube ._ancillary_variables_and_dims )
16111626
16121627 def _add_cube (self , cube , coord_payload ):
16131628 """Create and add the source-cube skeleton to the ProtoCube."""
0 commit comments