ECC-287: GRIB3 tests for templates

This commit is contained in:
Shahram Najm 2017-06-19 11:41:56 +01:00
parent beab512681
commit 2e8c285152
2 changed files with 65 additions and 0 deletions

View File

@ -90,6 +90,7 @@ list( APPEND tests_data_reqd
grib2to1
grib1to3
grib2to3
grib3_templates
badgrib
grib_ls
grib_filter

64
tests/grib3_templates.sh Executable file
View File

@ -0,0 +1,64 @@
#!/bin/sh
# Copyright 2005-2017 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="grib3_templates"
temp1=temp1.$label.grib3
temp2=temp2.$label.grib3
# Create a sample GRIB3 file converting from existing sample
sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
${tools_dir}/grib_set -s editionNumber=3 $sample_g1 $temp1
# Section 4 templates: Horizontal Domain
# -----------------------------------------
${tools_dir}/grib_set -M -s horizontalDomainTemplateNumber=1 $temp1 $temp2
res=`${tools_dir}/grib_get -M -p angleOfRotation $temp2`
[ "$res" = "0" ]
${tools_dir}/grib_set -M -s horizontalDomainTemplateNumber=2 $temp1 $temp2
res=`${tools_dir}/grib_get -M -p stretchingFactorScaled $temp2`
[ "$res" = "0" ]
${tools_dir}/grib_set -M -s horizontalDomainTemplateNumber=3 $temp1 $temp2
res=`${tools_dir}/grib_get -M -p angleOfRotation,stretchingFactorScaled $temp2`
[ "$res" = "0 0" ]
# Section 5 templates: Vertical Domain
# -----------------------------------------
${tools_dir}/grib_set -M -s verticalDomainTemplateNumber=1 $temp1 $temp2
res=`${tools_dir}/grib_get -M -p scaleFactorOfFirstFixedSurface,scaleFactorOfSecondFixedSurface $temp2`
[ "$res" = "0 MISSING" ]
# Section 6 templates: Generating Process
# -----------------------------------------
${tools_dir}/grib_set -M -s generatingProcessTemplateNumber=1 $temp1 $temp2
res=`${tools_dir}/grib_get -M -p numberOfMembersInEnsemble $temp2`
[ "$res" = "0" ]
# Section 7 templates: Observable Property
# -----------------------------------------
${tools_dir}/grib_set -M -s observablePropertyTemplateNumber=1 $temp1 $temp2
res=`${tools_dir}/grib_get -M -p parameterDiscipline,parameterCategory,parameterNumber $temp2`
[ "$res" = "0 0 0" ] # Temperature
res=`${tools_dir}/grib_get -M -p unitsConversionScaleFactor,unitsConversionOffset $temp2`
[ "$res" = "0 0" ]
${tools_dir}/grib_set -M -s observablePropertyTemplateNumber=2 $temp1 $temp2
res=`${tools_dir}/grib_get -M -p constituentType $temp2`
[ "$res" = "0" ]
rm -f $temp1 $temp2