ecmwf/cfgrib

Incorrect writing of regular Gaussian grids as GRIB

iainrussell opened this issue · 0 comments

This was exposed when using ecCodes 2.28.0, which has stricter checking of a GRIB file's geography.

------------------------------------------------------------------------------ Captured stderr call ------------------------------------------------------------------------------
ECCODES ERROR   :  Failed to find index for latitude=87.864
ECCODES ERROR   :  Geoiterator factory: Error instantiating iterator gaussian (Problem with calculation of geographic attributes)
ECCODES ERROR   :  latitudes: Unable to create iterator
------------------------------------------------------------------------------- Captured log call --------------------------------------------------------------------------------
WARNING  cfgrib.messages:messages.py:555 Ignoring index file '/perm/cgi/dev/git/mpy/cfgrib/tests/sample-data/regular_gg_pl.grib.923a8.idx' incompatible with GRIB file
============================================================================ short test summary info =============================================================================
FAILED test_50_sample_data.py::test_canonical_dataset_to_grib[regular_gg_sfc] - gribapi.errors.GeocalculusError: Problem with calculation of geographic attributes
FAILED test_50_sample_data.py::test_canonical_dataset_to_grib[regular_gg_pl] - gribapi.errors.GeocalculusError: Problem with calculation of geographic attributes
======================================================= 2 failed, 30 passed, 84 deselected, 3 xfailed, 2 xpassed in 4.99s ========================================================

The reason behind the failure is that cfgrib is not storing and therefore not writing the first and last latitude coordinates when dealing with regular Gaussian grids. Therefore, the written GRIB file contains these values as they are set in the template, rather than as they are set in the original data.