@@ -807,10 +807,11 @@ def __init__(
807807 self .msr = {}
808808 info_msr = {}
809809 for key , msr in f .cell_measures (todict = True ).items ():
810- if not (
811- self .has_measure (msr )
812- and self .has_data (msr )
813- and self .has_units (msr )
810+ if not self .has_measure (msr ):
811+ return
812+
813+ if not msr .nc_get_external () and not (
814+ self .has_data (msr ) and self .has_units (msr )
814815 ):
815816 return
816817
@@ -2972,7 +2973,7 @@ def aggregate(
29722973 output_meta_append (meta )
29732974
29742975 continue
2975-
2976+
29762977 # ------------------------------------------------------------
29772978 # This field has a structural signature, so append it to the
29782979 # list of fields with the same structural signature.
@@ -3601,7 +3602,6 @@ def _create_hash_and_first_values(
36013602 canonical_direction = {}
36023603
36033604 for m in meta :
3604- print (777 )
36053605 field = m .field
36063606 constructs = field .constructs .todict ()
36073607
@@ -3669,11 +3669,11 @@ def _create_hash_and_first_values(
36693669 sort_indices = slice (None , None , - 1 )
36703670 else :
36713671 sort_indices = slice (None )
3672- elif identity in m .domain_topology :
3672+ elif identity in m .domain_topology :
36733673 # ... or which doesn't have a dimension coordinate but
36743674 # does have a domain topology ...
36753675 sort_indices = slice (None )
3676- needs_sorting = False
3676+ needs_sorting = False
36773677 else :
36783678 # ... or which doesn't have a dimension coordinate but
36793679 # does have one or more 1-d auxiliary coordinates
@@ -3753,7 +3753,7 @@ def _create_hash_and_first_values(
37533753 m_hash_values [identity ] = hash_values
37543754 m_first_values [identity ] = first_values
37553755 m_last_values [identity ] = last_values
3756-
3756+
37573757 # ------------------------------------------------------------
37583758 # N-d auxiliary coordinates
37593759 # ------------------------------------------------------------
@@ -3882,7 +3882,6 @@ def _create_hash_and_first_values(
38823882 hash_values .append ((h ,))
38833883
38843884 topology ["hash_values" ] = hash_values
3885- print ('done domain_top' ,topology )
38863885
38873886 # ------------------------------------------------------------
38883887 # Cell connectivities
@@ -3920,7 +3919,6 @@ def _create_hash_and_first_values(
39203919
39213920 connectivity ["hash_values" ] = hash_values
39223921
3923- print ('done cell_conn' , connectivity )
39243922 # ------------------------------------------------------------
39253923 # Field ancillaries
39263924 # ------------------------------------------------------------
@@ -4039,7 +4037,6 @@ def _sort_indices(m, canonical_axes):
40394037 """
40404038 canonical_axes = [m .id_to_axis [identity ] for identity in canonical_axes ]
40414039 sort_indices = tuple ([m .sort_indices [axis ] for axis in canonical_axes ])
4042- print (m .sort_indices , sort_indices , (slice (None ),) * len (sort_indices ))
40434040 needs_sorting = sort_indices != (slice (None ),) * len (sort_indices )
40444041 return sort_indices , needs_sorting
40454042
@@ -4554,39 +4551,51 @@ def _ok_coordinate_arrays(
45544551 f"contiguous={ bool (contiguous )} and "
45554552 f"{ m .axis [axis ]['ids' ][dim_coord_index ]!r} "
45564553 "dimension coordinate cells do not match "
4557- "the cell spacing condition between fields "
4558- f"( { data1 !r} - { data0 !r} = { dim_diff !r} ) "
4554+ "the cell spacing condition between fields: "
4555+ f"{ data1 !r} - { data0 !r} = { dim_diff !r} "
45594556 f"!= { diff !r} "
45604557 )
45614558
45624559 return False
45634560 else :
45644561 # ------------------------------------------------------------
4565- # The aggregating axis does not have a dimension coordinate,
4566- # but it does have at least one 1-d auxiliary coordinate.
4562+ # The aggregating axis does not have a dimension coordinate
45674563 # ------------------------------------------------------------
4568- # Check for duplicate auxiliary coordinate values
4569- for i , identity in enumerate (meta [0 ].axis [axis ]["ids" ]):
4570- set_of_1d_aux_coord_values = set ()
4571- number_of_1d_aux_coord_values = 0
4572- for m in meta :
4573- aux = m .axis [axis ]["keys" ][i ]
4574- # '.data.compute()' is faster than '.array'
4575- array = m .field .constructs [aux ].data .compute ()
4576- set_of_1d_aux_coord_values .update (array )
4577- number_of_1d_aux_coord_values += array .size
4578- if (
4579- len (set_of_1d_aux_coord_values )
4580- != number_of_1d_aux_coord_values
4581- ):
4582- if info :
4583- meta [0 ].message = (
4584- f"no { identity !r} dimension coordinates and "
4585- f"{ identity !r} auxiliary coordinates have "
4586- "duplicate values"
4587- )
4564+ if axis in m .domain_topology or axis in m .cell_connectivity :
4565+ if info :
4566+ meta [0 ].message = (
4567+ f"can't aggregate along the { axis !r} mesh topology "
4568+ "discrete axis"
4569+ )
45884570
4589- return False
4571+ return False
4572+ # else:
4573+ # ------------------------------------------------------------
4574+ # The aggregating axis does not have a dimension coordinate,
4575+ # but it does have at least one 1-d auxiliary coordinate.
4576+ # ------------------------------------------------------------
4577+ # Check for duplicate auxiliary coordinate values
4578+ # for i, identity in enumerate(meta[0].axis[axis]["ids"]):
4579+ # set_of_1d_aux_coord_values = set()
4580+ # number_of_1d_aux_coord_values = 0
4581+ # for m in meta:
4582+ # aux = m.axis[axis]["keys"][i]
4583+ # # Note: '.data.compute()' is faster than '.array'
4584+ # array = m.field.constructs[aux].data.compute()
4585+ # set_of_1d_aux_coord_values.update(array.tolist())
4586+ # number_of_1d_aux_coord_values += array.size
4587+ # if (
4588+ # len(set_of_1d_aux_coord_values)
4589+ # != number_of_1d_aux_coord_values
4590+ # ):
4591+ # if info:
4592+ # meta[0].message = (
4593+ # f"no {identity!r} dimension coordinates and "
4594+ # f"{identity!r} auxiliary coordinates have "
4595+ # "duplicate values"
4596+ # )
4597+ #
4598+ # return False
45904599
45914600 # ----------------------------------------------------------------
45924601 # Still here? Then the aggregating axis does not overlap between
0 commit comments