You are trying to convert a GRIB edition 1 field to GRIB edition 2 via grib_set but it fails.


Let's say you have a GRIB1 file with the paramId=201 which is "Maximum temperature at 2 metres since previous post-processing". You try to convert it to edition 2:

% grib_ls -p paramId,shortName mx2t.grib1
paramId     shortName
201         mx2t

% grib_set -s edition=2 mx2t.grib1 mx2t.grib2
ECCODES ERROR: grib_set_values[4] typeOfStatisticalProcessing (type=long) failed: Key/value not found
ECCODES ERROR: grib_set_values[0] edition (type=long) failed: Key/value not found

The conversion fails because the definition of the parameter 201 contains the key "typeOfStatisticalProcessing". Check the GRIB2 representation of this parameter in the Parameter database.
A value of 2 means "Maximum", see code table for key "typeOfStatisticalProcessing".

The grib_set command above sets the Product Definition Template number to 0 (instantaneous) because that is the default.

But this parameter requires a Product Definition Template for interval-based products (not instantaneous), see here.

So we need to select the correct Product Definition Template number:

% grib_set -s edition=2,productDefinitionTemplateNumber=8 mx2t.grib1 mx2t.grib2
% grib_ls -p paramId,shortName mx2t.grib2
paramId     shortName
201         mx2t