iris icon indicating copy to clipboard operation
iris copied to clipboard

Support for CellMethod on coordinate

Open cgsandford opened this issue 4 years ago • 2 comments

✨ Feature Request

CellMethod is an essential part of describing some datasets - eg to distinguish between a "point" screen temperature or one that is "max" or "min" in hour (represented as "time: max" or "time: min"). Cell methods can be put on a dataset, but not on a coordinate variable.

The IMPROVER project (https://github.com/metoppv/improver) takes data and calculates probabilities in such a way that the properties of the initial data field (eg max temperature in hour) become properties of a dimension coordinate on the probabilistic data. This means we need a way to represent the original cell methods on that coordinate. This is CF compliant but not CF standard - however iris mandates against it.

Motivation

We are currently defining a standard around IMPROVER-type probabilistic data which follows as closely and logically from CF as possible, with the long term aim of getting that into the actual CF standard. However iris doesn't permit us to implement this CF compliant extension.

This is a blocking problem: we may have to do something different (misleading or untidy / non-standard, eg not using "cell_methods" to label what is in fact a cell method) in the interim until iris can support this, with associated difficulties in managing impacts of changing metadata from an operational system.

Additional context

Workarounds tried:

  • Adding a "cell_methods" attribute rather than CellMethod to the coordinate, which results in a suitable NetCDF file. This is forbidden by the mechanism of the LimitedAttributeDict for which "cell_methods" is a forbidden key. Fails when trying to add the attribute.
  • Adding a "cell_methods" attribute retrospectively using the netCDF4 library. This works. However when the file is read using iris, the cell method is discarded. The cube is read but the metadata is missing.

Discussed with @pp-mo yesterday and we agreed on the logic - this is not in violation of CF and is the most sensible way of representing this data.

cgsandford avatar Jan 08 '21 08:01 cgsandford

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

github-actions[bot] avatar Jun 09 '24 00:06 github-actions[bot]

From @SciTools/peloton

Thank you to the stale bot for reminding us about this.

We've had a look at CF conventions, and 3 years on it doesn't look like cell methods on coordinates has been discussed any further.

Right now, Iris only implements official parts of the CF spec. For unofficial extensions, we believe monkey-patching would be appropriate here. I.e. replacing the LimitedAttributeDict class with your own definition that removes the ban on attributes called cell_methods.

trexfeathers avatar Jun 19 '24 10:06 trexfeathers