MetOffice / CSET

Toolkit for evaluation and investigation of numerical models for weather and climate applications.
https://metoffice.github.io/CSET/
Apache License 2.0
8 stars 1 forks source link

New constraint to filter cubes that contain vertical coordinate #726

Open jwarner8 opened 3 days ago

jwarner8 commented 3 days ago

What problem does your feature request solve?

Currently, we do not have the ability to constrain two cubes with identical variable names, but one contains pressure levels or model levels. We have the ability to extract a given pressure/model level, but what if we want all vertical levels and we have no prior knowledge of how many levels there are. We also can't invert the constraint operator to return cubes that are not 2D. We also can't simply return cubes that have 3 dimensions, as cubes may also contain time or realisation dimensions. This is a case particularly where we are trying to filter for the transect operator.

Describe the solution you'd like

A new operator within constraints.py that can take a CubeList and return the cube that contains a vertical coordinate.

Describe alternatives you've considered

As above, could invert but not currently implemented, or specify all levels (but this is not apparent without digging into the metadata).

jfrost-mo commented 3 days ago

Perhaps rather than a new operator, we could expand the existing generate_level_constraint operator?

An idea for the API would be to filter to all levels in a coord is if the coordinate is specified, but levels are not. E.g:

- operator: constraints.generate_level_constraint
  coordinate: "pressure"
jwarner8 commented 3 days ago

Perhaps rather than a new operator, we could expand the existing generate_level_constraint operator?

An idea for the API would be to filter to all levels in a coord is if the coordinate is specified, but levels are not. E.g:

- operator: constraints.generate_level_constraint
  coordinate: "pressure"

That's a nice implementation, would reduce repetition. Will progress this now

jwarner8 commented 3 days ago

If we build on the constraints,generate_level_constraint operator, we need to specify a vertical coordinate str (in the yaml). This would also be needed in the GUI. Ideally the transect operator could run without needing to specify the vertical coordinate in the GUI (at the moment the transect operator is agnostic to other dimensions other than spatial ones, it'll interpolate any other dimensions). We could make generate_level_constraint have optional arguments coordinate and levels, and if neither are specified only return the cube containing a vertical coordinate against a defined list of acceptable vertical coordinates?

jfrost-mo commented 3 days ago

Ah, so that is the case. In that case your suggestion sounds sensible, though we should ensure clear error messages are produced if the levels are specified without the coordinate, as without the coordinate name we don't know how to interpret the levels.