From df2b452ff14791c75e1d036964ad38b54b94a7cf Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 29 Oct 2024 13:38:31 +0000 Subject: [PATCH 1/3] ECC-1954: GRIB1 to GRIB2 conversion does not preserve ensemble product template --- definitions/grib1/section.1.def | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/definitions/grib1/section.1.def b/definitions/grib1/section.1.def index 244cbfc31..c4ee91b86 100644 --- a/definitions/grib1/section.1.def +++ b/definitions/grib1/section.1.def @@ -334,3 +334,10 @@ meta md5Product md5(offsetSection1,section1Length,gridDefinition,section1Flags,d # ECC-1806 concept_nofail paramIdForConversion(zero, "paramIdForConversion.def", conceptsDir2, conceptsDir1) : long_type,read_only; + +if (productDefinitionTemplateNumber == 0 && defined(perturbationNumber) && numberOfForecastsInEnsemble > 0) { + alias productDefinitionTemplateNumber = one; # ensemble instant +} +if (productDefinitionTemplateNumber == 8 && defined(perturbationNumber) && numberOfForecastsInEnsemble > 0) { + alias productDefinitionTemplateNumber = eleven; # ensemble interval +} From f9561ed7d4f8c5cb8187dbc060f1aeb35a441773 Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 29 Oct 2024 16:26:56 +0000 Subject: [PATCH 2/3] ECC-1954: Test --- definitions/grib1/section.1.def | 1 + tests/grib1to2.sh | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/definitions/grib1/section.1.def b/definitions/grib1/section.1.def index c4ee91b86..3bc733b1f 100644 --- a/definitions/grib1/section.1.def +++ b/definitions/grib1/section.1.def @@ -335,6 +335,7 @@ meta md5Product md5(offsetSection1,section1Length,gridDefinition,section1Flags,d # ECC-1806 concept_nofail paramIdForConversion(zero, "paramIdForConversion.def", conceptsDir2, conceptsDir1) : long_type,read_only; +# ECC-1954 if (productDefinitionTemplateNumber == 0 && defined(perturbationNumber) && numberOfForecastsInEnsemble > 0) { alias productDefinitionTemplateNumber = one; # ensemble instant } diff --git a/tests/grib1to2.sh b/tests/grib1to2.sh index 46a73ecd6..b09103229 100755 --- a/tests/grib1to2.sh +++ b/tests/grib1to2.sh @@ -11,6 +11,7 @@ . ./include.ctest.sh REDIRECT=/dev/null +label="grib1to2_test" files="constant_field\ reduced_gaussian_pressure_level_constant \ @@ -29,6 +30,8 @@ files="constant_field\ spherical_pressure_level \ spherical_model_level " +tempLog=temp.$label.log + for f in `echo $files` do file=${data_dir}/$f @@ -53,7 +56,7 @@ done echo "ECC-457,ECC-1298 ECMWF total precipitation..." # --------------------------------------------------- input=${data_dir}/tp_ecmwf.grib -output=temp.grib1to2.grib +output=temp.$label.grib ${tools_dir}/grib_set -s edition=2 $input $output res=`${tools_dir}/grib_get -w count=1 -p edition,paramId,units $output` [ "$res" = "2 228 m" ] @@ -93,8 +96,8 @@ grib_check_key_equals $output shapeOfTheEarth 0 echo "ECC-1329: Cannot convert runoff (paramId=205)" # -------------------------------------------------------- -temp1="temp1.grib1to2.grib1" -temp2="temp2.grib1to2.grib2" +temp1="temp1.$label.grib1" +temp2="temp2.$label.grib2" ${tools_dir}/grib_set -s paramId=205,P1=240,marsType=fc $sample_g1 $temp1 ${tools_dir}/grib_set -s edition=2 $temp1 $temp2 grib_check_key_equals $temp2 discipline,stepType,shortName,paramId '2 accum ro 205' @@ -111,10 +114,20 @@ for sn in e lsp pev sro uvb; do ${tools_dir}/grib_compare -e -b param $temp1 $temp2 done + +echo "ECC-1954: preserve ensemble product template..." +# -------------------------------------------------------- +${tools_dir}/grib_set -s \ + indicatorOfParameter=49,P2=1,timeRangeIndicator=2,localDefinitionNumber=30,perturbationNumber=1,numberOfForecastsInEnsemble=51 \ + $sample_g1 $temp1 +${tools_dir}/grib_set -s edition=2 $temp1 $temp2 +grib_check_key_equals $temp2 productDefinitionTemplateNumber,perturbationNumber '11 1' + + # Turn on (brief) DEBUGGING messages sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl -output=temp.grib1to2.grib -ECCODES_DEBUG=-1 ${tools_dir}/grib_set -s edition=2 $sample_g1 $output +output=temp.$label.grib +ECCODES_DEBUG=-1 ${tools_dir}/grib_set -s edition=2 $sample_g1 $output > $tempLog 2>&1 # -G option sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl @@ -124,3 +137,4 @@ ${tools_dir}/grib_set -G -s edition=2 $sample_g1 $temp2 # Clean up rm -f $output rm -f $temp1 $temp2 +rm -f $tempLog From 3365fb536e66a1180113740095c85ccbe43df3ed Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 29 Oct 2024 17:06:17 +0000 Subject: [PATCH 3/3] ECC-1954: Fix the padding test --- definitions/grib1/section.1.def | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/definitions/grib1/section.1.def b/definitions/grib1/section.1.def index 3bc733b1f..beef92bbb 100644 --- a/definitions/grib1/section.1.def +++ b/definitions/grib1/section.1.def @@ -336,9 +336,9 @@ meta md5Product md5(offsetSection1,section1Length,gridDefinition,section1Flags,d concept_nofail paramIdForConversion(zero, "paramIdForConversion.def", conceptsDir2, conceptsDir1) : long_type,read_only; # ECC-1954 -if (productDefinitionTemplateNumber == 0 && defined(perturbationNumber) && numberOfForecastsInEnsemble > 0) { +if (productDefinitionTemplateNumber == 0 && defined(perturbationNumber) && defined(numberOfForecastsInEnsemble) && numberOfForecastsInEnsemble > 0) { alias productDefinitionTemplateNumber = one; # ensemble instant } -if (productDefinitionTemplateNumber == 8 && defined(perturbationNumber) && numberOfForecastsInEnsemble > 0) { +if (productDefinitionTemplateNumber == 8 && defined(perturbationNumber) && defined(numberOfForecastsInEnsemble) && numberOfForecastsInEnsemble > 0) { alias productDefinitionTemplateNumber = eleven; # ensemble interval }