Merge pull request #261 from ecmwf/bugfix/ECC-1954-EditionConversion

ECC-1954: GRIB1 to GRIB2 conversion does not preserve ensemble product template for some statistically processed fields
This commit is contained in:
shahramn 2024-10-29 20:41:45 +00:00 committed by GitHub
commit f17a1b5b3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 5 deletions

View File

@ -334,3 +334,11 @@ 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) && defined(numberOfForecastsInEnsemble) && numberOfForecastsInEnsemble > 0) {
alias productDefinitionTemplateNumber = one; # ensemble instant
}
if (productDefinitionTemplateNumber == 8 && defined(perturbationNumber) && defined(numberOfForecastsInEnsemble) && numberOfForecastsInEnsemble > 0) {
alias productDefinitionTemplateNumber = eleven; # ensemble interval
}

View File

@ -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