Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/iris/etc/grib_rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,15 @@ CellMethod("_ratio", cm.coord("time"))

IF
grib.edition == 1
grib.levelType == 'pl'
grib.indicatorOfTypeOfLevel == 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my subsequent work on a similar issue, I've found that this code has another misunderstanding ...
It seems that the gribapi defaults have changed so that default access to this parameter (as in "message.attribute") now returns a string instead of a number as previously. So instead of numbers 1 and 100, we now get 'sfc' and 'pl' (i.e. "surface" and "pressure level").
Also note, the alternative parameters levelType and indicatorOfTypeOfLevel aren't different (as you might expect), but behave exactly the same (and they both now return strings in this way).

So, I believe this whole section should now read :

IF
grib.edition == 1
grib.levelType == 'pl'
THEN
CoordAndDims(DimCoord(points=grib.level, long_name="pressure", units="hPa"))

IF
grib.edition == 1
grib.levelType = 'sfc'
THEN
CoordAndDims(DimCoord(points=0, long_name="height", units="m"))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Changing data types (and contents) of "computed keys", such as levelType, has been problem for many years. However, I didn't expect "coded keys", such as indicatorOfTypeOfLevel, to suffer from this as they should reflect the grib spec, which states the data type. Because we've been using a computed key here for some time I can't be sure if this is a recent change or if it has always been decoded as a string (https://software.ecmwf.int/issues/browse/SUP-484).

I suggest we remove this vulnerability. We can force GribWrapper to give us the coded integer value for this key in GribWrapper.__getattr__, as we currently do for typeOfFirstFixedSurface.

THEN
CoordAndDims(DimCoord(points=grib.level, long_name="pressure", units="hPa"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.


IF
grib.edition == 1
grib.indicatorOfTypeOfLevel = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the typo @bblay is talking about. I'm not sure whether this works or not (it used to), but I agree we should use the equality operator here.

THEN
CoordAndDims(DimCoord(points=0, long_name="height", units="m"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, would you mind removing one of the two spaces?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is is worth setting the standard_name to 'height', rather than the long name, given it is a valid one? Is it also worth adding an attributes={'positive': 'up'} similar to line https://github.com/SciTools/iris/blob/master/lib/iris/etc/pp_rules.txt#L322



###################
Expand Down