Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECC-1954: GRIB1 to GRIB2 conversion does not preserve ensemble product template for some statistically processed fields #261

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions definitions/grib1/section.1.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
24 changes: 19 additions & 5 deletions tests/grib1to2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
. ./include.ctest.sh

REDIRECT=/dev/null
label="grib1to2_test"

files="constant_field\
reduced_gaussian_pressure_level_constant \
Expand All @@ -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
Expand All @@ -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" ]
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Loading