-
Notifications
You must be signed in to change notification settings - Fork 279
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
added packaged grib support #566
Conversation
MAGIC_NUMBER_64_BIT = FileElement('64-bit magic number', lambda filename, fh: | ||
# Define magic number offset by a number of bytes (WMO bulletin header) | ||
WMO_OFFSET = 21 | ||
MAGIC_NUMBER_32_BIT_OFFSET = FileElement( |
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.
Because this is WMO bulletin specific, it should probably be called something like, MAGIC_NUMBER_32_BIT_WMO_BULLETIN
. Also, the comment would be unnecessary, and the WMO_OFFSET should probably be called something like, WMO_BULLETIN_HEADER_LENGTH
.
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.
xp all the way! 😃
thanks for your comments @bblay, let me know when you have finished your review so that I can make the necessary changes. |
I would like to prioritize this enhancement as an iris user requires it to progress with their work. |
@@ -253,23 +253,26 @@ def __repr__(self): | |||
return 'FileElement(%r, %r)' % (self._name, self._element_getter_fn) | |||
|
|||
|
|||
def _read_n(fh, fmt, n): | |||
def _read_n(fh, fmt, n, offset=None): |
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 default offset of 0 rather than None seems simpler.
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 disagree. None
should mean "don't seek", but 0
or any other number should mean "seek".
I agree with @bblay on this, the offset should be as default where you are in the file (None). This is more generic and does not have an assumed state for the file handler (i.e. we could do anything before getting here with the file handler, since it could contain a multitude of information, in which case we dont want to start at the beginning, it should be relative to the current position). I believe setting to None is more pythonic and also is more in line with the API of the function handler we are passing this argument to. |
I was thinking the offset i.e. the |
ah good spotting thanks @esc24 |
I made it a dictionary since I can foresee that this list of preset offset variables may grow and grow and offsetting will likely not be limited to just WMO bulletin headers |
Please do change this back, many thanks. |
^done |
added packaged grib (wmo bulletin) support
This is an enhancement to support packaged grib files.
Packaged grib files have extra header information, meaning that the signature (magic number) is offset by a specific number of bytes.
This PR adds support by recognising this type of "grib" file for which the grib api can handle.
closes #332
internal ref: WO49559