Skip to content

Fix ordering of cf coordinate bounds #3249

@pp-mo

Description

@pp-mo

It was pointed out that chopping a cube into slices over a dimension and re-merging (which was needed modify each part individually) had the effect of reversing a dimension coordinate with descending values.

And such a reversal breaks the 'is_contiguous' property :

E.g.

>>> co_upwards = DimCoord(points=[20, 30, 40], bounds=[[15, 25], [25, 35], [35, 45]])
>>> co_ upwards.is_contiguous()
True
>>>
>>> co_downwards = co_upwards[::-1]
>>> co_downwards.is_contiguous()
False

Because what ‘contiguous’ means is just "bounds[i, 1] == bounds[i+1, 0], for all i"

According to : cf 1.7, section 7.1,
There under "Bounds for 1-D coordinate variables" we have :

If adjacent intervals are contiguous... For example, if the intervals that contain grid points lat(i) and lat(i+1) are contiguous, then latbnd(i+1,0) = latbnd(i,1)

So, our implementation of 'is_contiguous' does seems to be in line with the CF conventions,
but our reversed (dimension) coordinate effectively has invalid bounds,

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions