From 831d4fadc02448fb67fd794d338c1ea3ff72a0e4 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 8 Apr 2021 15:25:45 +0100 Subject: [PATCH 1/2] ECC-1230: Conversion of param=tp to edition=2 loses ensemble number --- definitions/grib1/section.1.def | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/definitions/grib1/section.1.def b/definitions/grib1/section.1.def index 1ed21d91e..e1ad6471d 100644 --- a/definitions/grib1/section.1.def +++ b/definitions/grib1/section.1.def @@ -319,7 +319,12 @@ alias time.stepType=stepType; # ECC-457: GRIB1 to GRIB2 conversion concept_nofail stepTypeForConversion (unknown, "stepTypeForConversion.def", conceptsDir2, conceptsDir1); if (stepTypeForConversion is "accum" ) { - alias productDefinitionTemplateNumber=eight; + if (productDefinitionTemplateNumber == 1) { + alias productDefinitionTemplateNumber=eleven; + } + else { + alias productDefinitionTemplateNumber=eight; + } } meta md5Section1 md5(offsetSection1,section1Length); From e7dc9e6e4371c54c767de8e21bc8834b8f4beed9 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 8 Apr 2021 16:40:35 +0100 Subject: [PATCH 2/2] ECC-1230: Add test --- tests/CMakeLists.txt | 1 + tests/grib_ecc-1230.sh | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 tests/grib_ecc-1230.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e442182c1..8fa904776 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -82,6 +82,7 @@ if( HAVE_BUILD_TOOLS ) grib_ecc-1170 grib_ecc-1195 grib_ecc-1212 + grib_ecc-1230 bufr_ecc-1195 bufr_json_samples bufr_ecc-359 diff --git a/tests/grib_ecc-1230.sh b/tests/grib_ecc-1230.sh new file mode 100755 index 000000000..a9e5265e4 --- /dev/null +++ b/tests/grib_ecc-1230.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.sh +set -u +REDIRECT=/dev/null +label="prod_ECC-1230-test" +temp1=temp1.$label +temp2=temp2.$label +sample_grib1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl + +# paramId 228 is "Total precipitation" (=tp) +# ------------------------------------------ +${tools_dir}/grib_set -s \ +type=pf,localDefinitionNumber=30,stream=enfo,\ +perturbationNumber=10,numberOfForecastsInEnsemble=51,indicatorOfParameter=228 \ +$sample_grib1 $temp1 +grib_check_key_equals $temp1 "stepTypeForConversion" "accum" +grib_check_key_equals $temp1 "paramId,shortName,productDefinitionTemplateNumber" "228 tp 11" + +# Convert +${tools_dir}/grib_set -s edition=2 $temp1 $temp2 +grib_check_key_equals $temp2 "productDefinitionTemplateNumber" "11" +grib_check_key_equals $temp2 "numberOfForecastsInEnsemble,perturbationNumber" "51 10" + + +# Now check 2m temperature (not accumulated) +# ------------------------------------------ +${tools_dir}/grib_set -s \ +type=pf,localDefinitionNumber=30,stream=enfo,\ +perturbationNumber=10,numberOfForecastsInEnsemble=51,shortName=2t \ +$sample_grib1 $temp1 +grib_check_key_equals $temp1 "productDefinitionTemplateNumber" "1" +# Convert +${tools_dir}/grib_set -s edition=2 $temp1 $temp2 +grib_check_key_equals $temp2 "productDefinitionTemplateNumber" "1" +grib_check_key_equals $temp2 "numberOfForecastsInEnsemble,perturbationNumber" "51 10" + + +# Clean up +rm -f $temp1 $temp2