@@ -2977,11 +2977,19 @@ def aggregate(
2977
2977
# ------------------------------------------------------------
2978
2978
if axes is None :
2979
2979
# Aggregation will be over as many axes as possible
2980
- aggregating_axes = meta [0 ].axis_ids
2980
+ m0 = meta [0 ]
2981
+ aggregating_axes = m0 .axis_ids [:]
2982
+
2983
+ # For DSG feature types, only consider aggregating the
2984
+ # feature dimension(s).
2985
+ if m0 .featureType :
2986
+ for axis in aggregating_axes [:]:
2987
+ if not dsg_feature_type_axis (m0 , axis ):
2988
+ aggregating_axes .remove (axis )
2989
+
2981
2990
_create_hash_and_first_values (
2982
- meta , None , False , hfl_cache , rtol , atol
2991
+ meta , aggregating_axes , False , hfl_cache , rtol , atol
2983
2992
)
2984
-
2985
2993
else :
2986
2994
# Specific aggregation axes have been selected
2987
2995
aggregating_axes = []
@@ -3484,15 +3492,16 @@ def climatology_cells(
3484
3492
3485
3493
3486
3494
def _create_hash_and_first_values (
3487
- meta , axes , donotchecknonaggregatingaxes , hfl_cache , rtol , atol
3495
+ meta , aggregating_axes , donotchecknonaggregatingaxes , hfl_cache , rtol , atol
3488
3496
):
3489
3497
"""Updates each field's _Meta object.
3490
3498
3491
3499
:Parameters:
3492
3500
3493
3501
meta: `list` of `_Meta`
3494
3502
3495
- axes: `None` or `list`
3503
+ axes: sequence
3504
+ The identities of the possible aggregating axes.
3496
3505
3497
3506
donotchecknonaggregatingaxes: `bool`
3498
3507
@@ -3509,6 +3518,9 @@ def _create_hash_and_first_values(
3509
3518
field = m .field
3510
3519
constructs = field .constructs .todict ()
3511
3520
3521
+ # Store the aggregating axis identities
3522
+ m .aggregating_axes = aggregating_axes
3523
+
3512
3524
m_sort_keys = m .sort_keys
3513
3525
m_sort_indices = m .sort_indices
3514
3526
@@ -3527,9 +3539,9 @@ def _create_hash_and_first_values(
3527
3539
# --------------------------------------------------------
3528
3540
for identity in m .axis_ids :
3529
3541
if (
3530
- axes is not None
3542
+ aggregating_axes is not None
3531
3543
and donotchecknonaggregatingaxes
3532
- and identity not in axes
3544
+ and identity not in aggregating_axes
3533
3545
):
3534
3546
x = [None ] * len (m .axis [identity ]["keys" ])
3535
3547
m_hash_values [identity ] = x
@@ -3671,12 +3683,12 @@ def _create_hash_and_first_values(
3671
3683
3672
3684
coord = constructs [key ]
3673
3685
3674
- axes = aux ["axes" ]
3686
+ c_axes = aux ["axes" ]
3675
3687
canonical_axes = aux ["canonical_axes" ]
3676
- if axes != canonical_axes :
3688
+ if c_axes != canonical_axes :
3677
3689
# Transpose the N-d auxiliary coordinate so that
3678
3690
# it has the canonical axis order
3679
- iaxes = [axes .index (axis ) for axis in canonical_axes ]
3691
+ iaxes = [c_axes .index (axis ) for axis in canonical_axes ]
3680
3692
coord = coord .transpose (iaxes )
3681
3693
3682
3694
sort_indices , needs_sorting = _sort_indices (m , canonical_axes )
@@ -3722,14 +3734,14 @@ def _create_hash_and_first_values(
3722
3734
else :
3723
3735
for canonical_units , msr in m .msr .items ():
3724
3736
hash_values = []
3725
- for key , axes , canonical_axes in zip (
3737
+ for key , c_axes , canonical_axes in zip (
3726
3738
msr ["keys" ], msr ["axes" ], msr ["canonical_axes" ]
3727
3739
):
3728
3740
cell_measure = constructs [key ]
3729
- if axes != canonical_axes :
3741
+ if c_axes != canonical_axes :
3730
3742
# Transpose the cell measure so that it has
3731
3743
# the canonical axis order
3732
- iaxes = [axes .index (axis ) for axis in canonical_axes ]
3744
+ iaxes = [c_axes .index (axis ) for axis in canonical_axes ]
3733
3745
cell_measure = cell_measure .transpose (iaxes )
3734
3746
3735
3747
sort_indices , needs_sorting = _sort_indices (
@@ -3836,12 +3848,12 @@ def _create_hash_and_first_values(
3836
3848
3837
3849
field_anc = constructs [key ]
3838
3850
3839
- axes = anc ["axes" ]
3851
+ c_axes = anc ["axes" ]
3840
3852
canonical_axes = anc ["canonical_axes" ]
3841
- if axes != canonical_axes :
3853
+ if c_axes != canonical_axes :
3842
3854
# Transpose the field ancillary so that it has the
3843
3855
# canonical axis order
3844
- iaxes = [axes .index (axis ) for axis in canonical_axes ]
3856
+ iaxes = [c_axes .index (axis ) for axis in canonical_axes ]
3845
3857
field_anc = field_anc .transpose (iaxes )
3846
3858
3847
3859
sort_indices , needs_sorting = _sort_indices (m , canonical_axes )
@@ -3874,12 +3886,12 @@ def _create_hash_and_first_values(
3874
3886
3875
3887
domain_anc = constructs [key ]
3876
3888
3877
- axes = anc ["axes" ]
3889
+ c_axes = anc ["axes" ]
3878
3890
canonical_axes = anc ["canonical_axes" ]
3879
- if axes != canonical_axes :
3891
+ if c_axes != canonical_axes :
3880
3892
# Transpose the domain ancillary so that it has
3881
3893
# the canonical axis order
3882
- iaxes = [axes .index (axis ) for axis in canonical_axes ]
3894
+ iaxes = [c_axes .index (axis ) for axis in canonical_axes ]
3883
3895
domain_anc = domain_anc .transpose (iaxes )
3884
3896
3885
3897
sort_indices , needs_sorting = _sort_indices (m , canonical_axes )
@@ -4131,7 +4143,7 @@ def _group_fields(meta, axis, info=False):
4131
4143
group is represented by a `list` of `_Meta` objects.
4132
4144
4133
4145
"""
4134
- axes = meta [0 ].axis_ids
4146
+ axes = meta [0 ].aggregating_axes
4135
4147
4136
4148
if axes :
4137
4149
if axis in axes :
0 commit comments