iris-grib
iris-grib copied to clipboard
Rewrite save rules in terms of GribMessage
All the grib2 load rules in iris_grib._load_convert are written in terms of the sectionally-structured GribMessage object.
But all the save rules (iris_grib._save_rules) use the gribapi (and/or eccodes) instead
Technical Debt summary:
-
fix:
- extend GribMessage to add 'create from template' and 'write to file'.
- rewrite existing save rules in terms of GribMessage, and rearrange sectionally (like load rules)
- costs of change:
- different from load rules means more to learn, hard to read
- testing is especially more complicated
-
costs of the legacy support :
- code is rather exposed to changes in the ecmwf APIs
- confusion from the different types of "message" in our docs
- for devs. especially, in our the testing code
- existing save rules are less tidy, as you don't get the benefit of the sectional division of the
GribMessageobject :- unlike the load rules, where appropriate data sections are passed, which is neat + clean
- this also complicates testing with elaborate schemes to mock out gribapi operations
To fix:
- make it possible to create a
GribMessagefrom a gribapi template, and save it to a file. - rework the existing rules to work on
GribMessages instead of a gribapi handle. - refactor the tests likewise (including various test classes mocking out message access)