Add UERRA test

This commit is contained in:
Shahram Najm 2016-01-21 16:52:24 +00:00
parent b6dacf6704
commit 563f041ce2
8 changed files with 106 additions and 28 deletions

View File

@ -36,6 +36,7 @@ list( APPEND tests1
calendar calendar
unit_tests unit_tests
md5 md5
uerra
) )
list( APPEND tests2 list( APPEND tests2
bufr_dump bufr_dump

View File

@ -45,6 +45,7 @@ TESTS = definitions.sh \
julian.sh \ julian.sh \
statistics.sh \ statistics.sh \
tigge.sh \ tigge.sh \
uerra.sh \
tigge_conversions.sh \ tigge_conversions.sh \
read_any.sh \ read_any.sh \
padding.sh \ padding.sh \

View File

@ -18,27 +18,27 @@ sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}grib_set -s tablesVersion=13,setCalendarId=1,typeOfCalendar=0 $sample $temp1 ${tools_dir}grib_set -s tablesVersion=13,setCalendarId=1,typeOfCalendar=0 $sample $temp1
check_key_equals $temp1 calendarIdPresent 1 grib_check_key_equals $temp1 calendarIdPresent 1
check_key_equals $temp1 section1Length 24 grib_check_key_equals $temp1 section1Length 24
check_key_equals $temp1 calendarIdentificationTemplateNumber 0 grib_check_key_equals $temp1 calendarIdentificationTemplateNumber 0
check_key_equals $temp1 typeOfCalendar 0 grib_check_key_equals $temp1 typeOfCalendar 0
${tools_dir}grib_set -s tablesVersion=13,setCalendarId=1,calendarIdentificationTemplateNumber=1 $sample $temp1 ${tools_dir}grib_set -s tablesVersion=13,setCalendarId=1,calendarIdentificationTemplateNumber=1 $sample $temp1
check_key_equals $temp1 calendarIdPresent 1 grib_check_key_equals $temp1 calendarIdPresent 1
check_key_equals $temp1 section1Length 25 grib_check_key_equals $temp1 section1Length 25
check_key_equals $temp1 calendarIdentificationTemplateNumber 1 grib_check_key_equals $temp1 calendarIdentificationTemplateNumber 1
check_key_equals $temp1 numberOfTensOfThousandsOfYearsOfOffset MISSING grib_check_key_equals $temp1 numberOfTensOfThousandsOfYearsOfOffset MISSING
${tools_dir}grib_set -s tablesVersion=13,setCalendarId=1,calendarIdentificationTemplateNumber=2 $sample $temp1 ${tools_dir}grib_set -s tablesVersion=13,setCalendarId=1,calendarIdentificationTemplateNumber=2 $sample $temp1
check_key_equals $temp1 calendarIdPresent 1 grib_check_key_equals $temp1 calendarIdPresent 1
check_key_equals $temp1 section1Length 26 grib_check_key_equals $temp1 section1Length 26
check_key_equals $temp1 calendarIdentificationTemplateNumber 2 grib_check_key_equals $temp1 calendarIdentificationTemplateNumber 2
check_key_equals $temp1 typeOfCalendar 255 grib_check_key_equals $temp1 typeOfCalendar 255
check_key_equals $temp1 numberOfTensOfThousandsOfYearsOfOffset MISSING grib_check_key_equals $temp1 numberOfTensOfThousandsOfYearsOfOffset MISSING
# Remove the calendar section # Remove the calendar section
${tools_dir}grib_set -s deleteCalendarId=1 $temp1 $temp2 ${tools_dir}grib_set -s deleteCalendarId=1 $temp1 $temp2
check_key_equals $temp2 section1Length 21 grib_check_key_equals $temp2 section1Length 21
check_key_equals $temp2 calendarIdPresent 0 grib_check_key_equals $temp2 calendarIdPresent 0
rm -f $temp1 $temp2 rm -f $temp1 $temp2

View File

@ -13,5 +13,5 @@
samples_dir=$ECCODES_SAMPLES_PATH samples_dir=$ECCODES_SAMPLES_PATH
for gg in ${samples_dir}/reduced_gg_* ${samples_dir}/regular_gg_*; do for gg in ${samples_dir}/reduced_gg_* ${samples_dir}/regular_gg_*; do
${tools_dir}grib_check_gaussian_grid $gg >/dev/null ${tools_dir}grib_check_gaussian_grid $gg >/dev/null
check_key_equals $gg "global" 1 grib_check_key_equals $gg "global" 1
done done

View File

@ -42,10 +42,10 @@ files_subarea="
for gg in $files_global; do for gg in $files_global; do
filepath=${data_dir}/$gg filepath=${data_dir}/$gg
check_key_equals $filepath "global" 1 grib_check_key_equals $filepath "global" 1
done done
for gg in $files_subarea; do for gg in $files_subarea; do
filepath=${data_dir}/$gg filepath=${data_dir}/$gg
check_key_equals $filepath "global" 0 grib_check_key_equals $filepath "global" 0
done done

View File

@ -28,38 +28,38 @@ done
############################ ############################
# check input time and date # check input time and date
check_key_equals $input 'dataDate,dataTime' '20080206 1200' grib_check_key_equals $input 'dataDate,dataTime' '20080206 1200'
# Negative step in same day # Negative step in same day
# -------------------------- # --------------------------
${tools_dir}grib_set -s forecastTime=-2 $input $temp ${tools_dir}grib_set -s forecastTime=-2 $input $temp
check_key_equals $temp 'validityDate,validityTime' '20080206 1000' grib_check_key_equals $temp 'validityDate,validityTime' '20080206 1000'
${tools_dir}grib_set -s forecastTime=-11 $input $temp ${tools_dir}grib_set -s forecastTime=-11 $input $temp
check_key_equals $temp 'validityDate,validityTime' '20080206 100' grib_check_key_equals $temp 'validityDate,validityTime' '20080206 100'
${tools_dir}grib_set -s forecastTime=-12 $input $temp ${tools_dir}grib_set -s forecastTime=-12 $input $temp
check_key_equals $temp 'validityDate,validityTime' '20080206 0' grib_check_key_equals $temp 'validityDate,validityTime' '20080206 0'
# Negative step previous day # Negative step previous day
# -------------------------- # --------------------------
${tools_dir}grib_set -s forecastTime=-13 $input $temp ${tools_dir}grib_set -s forecastTime=-13 $input $temp
check_key_equals $temp 'validityDate,validityTime' '20080205 2300' grib_check_key_equals $temp 'validityDate,validityTime' '20080205 2300'
${tools_dir}grib_set -s forecastTime=-24 $input $temp ${tools_dir}grib_set -s forecastTime=-24 $input $temp
check_key_equals $temp 'validityDate,validityTime' '20080205 1200' grib_check_key_equals $temp 'validityDate,validityTime' '20080205 1200'
${tools_dir}grib_set -s forecastTime=-33 $input $temp ${tools_dir}grib_set -s forecastTime=-33 $input $temp
check_key_equals $temp 'validityDate,validityTime' '20080205 300' grib_check_key_equals $temp 'validityDate,validityTime' '20080205 300'
# Negative step further back # Negative step further back
# -------------------------- # --------------------------
${tools_dir}grib_set -s forecastTime=-38 $input $temp ${tools_dir}grib_set -s forecastTime=-38 $input $temp
check_key_equals $temp 'validityDate,validityTime' '20080204 2200' grib_check_key_equals $temp 'validityDate,validityTime' '20080204 2200'
${tools_dir}grib_set -s forecastTime=-185 $input $temp ${tools_dir}grib_set -s forecastTime=-185 $input $temp
check_key_equals $temp 'validityDate,validityTime' '20080129 1900' grib_check_key_equals $temp 'validityDate,validityTime' '20080129 1900'
# Clean up # Clean up

69
tests/uerra.sh Executable file
View File

@ -0,0 +1,69 @@
#!/bin/sh
# Copyright 2005-2016 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
REDIRECT=/dev/null
#set -eax
grib2_sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
this_test=ecCodes-uerra
tempSample=tempSample.${this_test}.grib2
temp1=temp1.${this_test}.grib2
temp2=temp2.${this_test}.grib2
test_stream_and_type()
{
utype=$1
if [ "$utype" = "oper" ]; then
pspd=8
elif [ "$utype" = "test" ]; then
pspd=9
fi
${tools_dir}grib_set -s tablesVersion=15,productionStatusOfProcessedData=$pspd \
$grib2_sample $tempSample
grib_check_key_equals $tempSample 'stream,mars.stream' 'oper oper'
# Check mars model is not set
model=`${tools_dir}grib_get -f -p mars.model $tempSample`
[ "$model" = "not_found" ]
${tools_dir}grib_set -s typeOfProcessedData=0 $tempSample $temp1
grib_check_key_equals $temp1 'mars.type' 'an'
${tools_dir}grib_set -s typeOfProcessedData=2 $tempSample $temp1
grib_check_key_equals $temp1 'mars.type' 'fc'
${tools_dir}grib_set -s marsStream=enda $tempSample $temp1 # ENSEMBLE
grib_check_key_exists $temp1 'perturbationNumber'
# All combinations
for mt in an fc; do
for ms in oper enda; do
echo "Testing stream=$ms type=$mt ..."
${tools_dir}grib_set -s marsStream=$ms,marsType=$mt $tempSample $temp1
grib_check_key_equals $temp1 'mars.stream,mars.type' "$ms $mt"
# Param 228228 (accum) and 167 (instant)
${tools_dir}grib_set -s stepType=accum,paramId=228228 $temp1 $temp2
grib_check_key_equals $temp2 'stream,type' "$ms $mt"
${tools_dir}grib_set -s paramId=167 $temp1 $temp2
grib_check_key_equals $temp2 'stream,type' "$ms $mt"
done
done
}
test_stream_and_type 'oper'
test_stream_and_type 'test'
rm -f $temp1 $temp2 $tempSample

View File

@ -15,7 +15,7 @@ set -ea
# Check the key(s) in the given grib file have the expected value(s) # Check the key(s) in the given grib file have the expected value(s)
# Assumes the file has only ONE message otherwise output goes on to # Assumes the file has only ONE message otherwise output goes on to
# several lines # several lines
check_key_equals() grib_check_key_equals()
{ {
file=$1 file=$1
key=$2 key=$2
@ -24,3 +24,10 @@ check_key_equals()
[ "$result" = "$val" ] [ "$result" = "$val" ]
} }
grib_check_key_exists()
{
file=$1
key=$2
# grib_get will fail if the key is not found
$tools_dir/grib_get -p $key $file >/dev/null
}