Problem

Why I cannot set negative values for the longitude in GRIB edition 2.

Solution

GRIB edition 1 regulates that the longitude can be in either [-180, 180] or [0,360], but GRIB edition 2 regulates that the longitude can only be in the interval [0,360]. ecCodes does comply with these regulations and in the case of GRIB 2, it will scale the longitude to fall in the interval [0,360]. ecCodes does not offer an edition-independent view of the longitude because of the uncertainty brought by GRIB 1, where you do not know what interval a longitude is in exactly.