-
Notifications
You must be signed in to change notification settings - Fork 23
Description
The #856 it was noted that the collapsed time coordinates came out incorrectly as monotonically decreasing when cf.djf was used in the MRE, whilst using cf.mam led to the correct monotonically increasing time coordinate sequence.
It turns this is because the time coordinates in the original field do not have bounds, and in the cf.djf grouped collapse case, one of the grouped collapses has just one month in it (December 2022), with bounds that equal the coordinate value. In this case, cfdm.DimensionCoordinate._infer_direction tells us that the direction is decreasing due to the use of the strict inequalities < (https://github.com/NCAS-CMS/cf-python/blob/v3.16.3/cf/dimensioncoordinate.py#L130), when non-strict ones (<=) are intended. The decreasing information feeds its way into the sorting of the collapsed groups via reverse=coord.decreasing (https://github.com/NCAS-CMS/cf-python/blob/v3.16.3/cf/field.py#L8747).
Very short PR to follow that fixes this by simply changing the appropriate < to <=.