-
Notifications
You must be signed in to change notification settings - Fork 44
Label unknown phenomena with a 'GRIB_CODING' attribute #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@ehogan I think you might be interested in this ? |
|
Some practical notes: This is supposed to work just like the "STASH" attribute that Iris uses for loading + saving UM files into Iris (i.e. fieldsfiles or PP). This is intended to avoid confusing existing loading code. A safer way, more consistent with general Iris usage, would be ...
But that's overkill for iris-grib, |
|
From discussion with @bjlittle ...
Two points here :
Given (1), we're probably better off implementing a mechanism identical to the iris-STASH-attribute,
I'll just run off + implement that ... |
|
Update : |
iris_grib/tests/unit/save_rules/test_set_discipline_and_parameter.py
Outdated
Show resolved
Hide resolved
9765acc to
7ee59c5
Compare
|
Thanks @lbdreyer |
iris_grib/tests/unit/save_rules/test_set_discipline_and_parameter.py
Outdated
Show resolved
Hide resolved
iris_grib/_save_rules.py
Outdated
| discipline, category, number = 255, 255, 255 | ||
| identity_found = False | ||
|
|
||
| # First, see if we can find and interpret a 'GRIB_CODING' attribute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced its a good idea to interpret the "GRIB_CODING" attribute first.
I think the standard_name/long_name should take precedence when determining the correct discipline/category/number as that it is the primary means we have of identifying a cube.
This reliance on GRIB_CODING means in future we have to take extra care with attributes and I don't want that requirement.
For example someone could take a copy of a cube, update the data array, and only update the name, then save it out as a cube. This would still have it out as the old discipline/category/number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From an offline discussion with @pp-mo, it turns out that this is how the STASH attribute is handled
In which case, my preference is for matching that behaviour so I'm happy with this as it is.
lbdreyer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more review comments, including some python 2 code that needs dropping
And as discussed offline, round-trip testing may be helpful
iris_grib/grib_phenom_translation.py
Outdated
| import collections | ||
| from collections import namedtuple | ||
| import re | ||
| import six |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs resolving merge conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
| # importing anything else. | ||
| import iris_grib.tests as tests | ||
|
|
||
| import six |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
six should be removed now Py 2 has been dropped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs removing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I got confused + thought I'd done this. Will fix.
| # licensing details. | ||
| """Unit tests for `iris_grib.grib_save_rules.set_discipline_and_parameter`.""" | ||
| from __future__ import (absolute_import, division, print_function) | ||
| from six.moves import (filter, input, map, range, zip) # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer need the Python 2 support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Nicer !
iris_grib/grib_phenom_translation.py
Outdated
| return _CF_GRIB2_TABLE[(standard_name, long_name)] | ||
|
|
||
|
|
||
| class GribCode(namedtuple('GribCode', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GRIB is an acronym so you could argue that this should be GRIBCode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried 'GRIBcode'. Is that ok ?
|
After more thinking and discussing, I propose the following format for the cube attribute: Where |
|
Rebased to fix. |
|
Thanks @lbdreyer. |
iris_grib/grib_phenom_translation.py
Outdated
| return _CF_GRIB2_TABLE[(standard_name, long_name)] | ||
|
|
||
|
|
||
| class GRIBcode(namedtuple('GRIBcode', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't like GRIBcode I read that as GRI Bcode
Maybe it is best to go back to GribCode if you don't like GRIBCode
Wikipedia's article on camel links to an paper that points out a run of uppercase letters can cause problems which I think we're having with GRIBCode. So I don't think we have to strictly treat acronyms as all capital letters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you don't like GRIBCode
I read as "GRIBC ode". It seems to be the opposite problem to your "GRI Bcode" !
But I'll go with yours, it's not an awful problem.
|
Hi @lbdreyer. |
Hi @pp-mo Yep this is almost good to go. Just need you to get rid of the six import |
|
here it is, @lbdreyer ! |
|
🎉 six is now removed 🎉 I'll merge this in .... |
Aims to address #153