2018-01-05 18:18:18 +00:00
|
|
|
#!/bin/sh
|
2020-01-28 14:32:34 +00:00
|
|
|
# (C) Copyright 2005- ECMWF.
|
2018-01-05 18:18:18 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2022-04-03 22:02:48 +00:00
|
|
|
. ./include.ctest.sh
|
2018-01-05 18:18:18 +00:00
|
|
|
|
2022-07-22 16:57:02 +00:00
|
|
|
label="grib_efas_test"
|
2018-01-05 18:18:18 +00:00
|
|
|
sample=temp.sample.$label.grib
|
|
|
|
temp1=temp1.$label.grib
|
|
|
|
temp2=temp2.$label.grib
|
|
|
|
temp3=temp3.$label.grib
|
|
|
|
|
2018-09-14 15:03:41 +00:00
|
|
|
# ---------------------------
|
|
|
|
# Stream EFAS
|
|
|
|
# ---------------------------
|
2018-01-05 18:18:18 +00:00
|
|
|
# Create a starting GRIB with a basic local definition for MARS
|
2021-09-20 12:47:55 +00:00
|
|
|
# The MARS class must be set to categorise the EFAS parameters as 'hydrological'
|
|
|
|
# See key 'datasetForLocal'
|
|
|
|
${tools_dir}/grib_set -s tablesVersion=19,setLocalDefinition=1,class=ce,stream=efas $ECCODES_SAMPLES_PATH/GRIB2.tmpl $sample
|
2018-01-05 18:18:18 +00:00
|
|
|
|
|
|
|
# Test a non-ensemble, instantaneous field
|
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=0 $sample $temp1
|
|
|
|
${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=41 $temp1 $temp2
|
2021-09-18 22:05:00 +00:00
|
|
|
grib_check_key_equals $temp2 productDefinitionTemplateNumber '70'
|
2018-01-05 18:18:18 +00:00
|
|
|
grib_check_key_exists $temp2 isFillup,dateOfForecast,timeOfForecast,anoffset
|
|
|
|
|
|
|
|
# Test an ensemble, instantaneous field
|
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=1,number=13 $sample $temp1
|
|
|
|
${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=41 $temp1 $temp2
|
2021-09-18 22:05:00 +00:00
|
|
|
grib_check_key_equals $temp2 number,productDefinitionTemplateNumber '13 71'
|
2018-01-05 18:18:18 +00:00
|
|
|
|
|
|
|
# Test a non-ensemble, non-instantaneous field
|
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=8,stepType=accum $sample $temp1
|
|
|
|
${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=41 $temp1 $temp2
|
2021-09-18 22:05:00 +00:00
|
|
|
grib_check_key_equals $temp2 productDefinitionTemplateNumber,typeOfStatisticalProcessing '72 1'
|
2018-01-05 18:18:18 +00:00
|
|
|
|
|
|
|
# Test an ensemble, non-instantaneous field (plus mars.origin tests)
|
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=11,stepType=accum $sample $temp1
|
|
|
|
${tools_dir}/grib_set -s \
|
|
|
|
setLocalDefinition=1,localDefinitionNumber=41,type=pf,inputOriginatingCentre=ecmf,typeOfPostProcessing=1 \
|
|
|
|
$temp1 $temp2
|
2021-09-18 22:05:00 +00:00
|
|
|
grib_check_key_equals $temp2 productDefinitionTemplateNumber,typeOfStatisticalProcessing '73 1'
|
2018-01-26 17:10:31 +00:00
|
|
|
grib_check_key_equals $temp2 mars.origin 'ecmf'
|
|
|
|
grib_check_key_equals $temp2 mars.model 'lisflood'
|
2018-01-05 18:18:18 +00:00
|
|
|
|
2021-05-19 16:40:44 +00:00
|
|
|
${tools_dir}/grib_set -s \
|
2021-09-20 12:47:55 +00:00
|
|
|
setLocalDefinition=1,localDefinitionNumber=41,type=fc,inputOriginatingCentre=ecmf,typeOfPostProcessing=10 \
|
2021-05-19 16:40:44 +00:00
|
|
|
$temp1 $temp2
|
|
|
|
grib_check_key_equals $temp2 mars.model 'geff'
|
|
|
|
|
2018-01-05 18:18:18 +00:00
|
|
|
# Parameter tests
|
|
|
|
${tools_dir}/grib_set -s paramId=260267 $temp2 $temp3
|
2021-09-18 22:05:00 +00:00
|
|
|
grib_check_key_equals $temp3 paramId,lengthOfTimeRange '260267 6'
|
2018-01-05 18:18:18 +00:00
|
|
|
|
|
|
|
${tools_dir}/grib_set -s paramId=260268 $temp2 $temp3
|
2021-09-18 22:05:00 +00:00
|
|
|
grib_check_key_equals $temp3 paramId,lengthOfTimeRange '260268 24'
|
2018-01-05 18:18:18 +00:00
|
|
|
|
|
|
|
# Use stepType
|
2021-09-20 12:47:55 +00:00
|
|
|
${tools_dir}/grib_set -s localDefinitionNumber=41,stepType=accum $sample $temp1
|
2018-01-05 18:18:18 +00:00
|
|
|
${tools_dir}/grib_set -s paramId=260267 $temp1 $temp2
|
|
|
|
|
|
|
|
# Test anoffset calculation
|
|
|
|
${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=41,yearOfForecast=2007,monthOfForecast=3,dayOfForecast=24,hourOfForecast=13 \
|
|
|
|
$sample $temp1
|
|
|
|
grib_check_key_equals $temp1 anoffset 25
|
2018-04-03 16:04:09 +00:00
|
|
|
grib_check_key_equals $temp1 anoffsetFirst,anoffsetLast,anoffsetFrequency "MISSING MISSING MISSING"
|
2018-01-05 18:18:18 +00:00
|
|
|
|
2018-06-15 10:28:02 +00:00
|
|
|
# MARS step
|
2018-06-18 09:42:00 +00:00
|
|
|
types="sfo fu go"
|
2018-04-03 14:29:43 +00:00
|
|
|
for t in $types; do
|
2021-09-19 13:09:47 +00:00
|
|
|
${tools_dir}/grib_set -s \
|
2021-09-20 12:47:55 +00:00
|
|
|
setLocalDefinition=1,localDefinitionNumber=41,type=$t,stepType=accum,stepRange=12-36 \
|
2018-04-03 14:29:43 +00:00
|
|
|
$sample $temp1
|
2021-09-19 13:09:47 +00:00
|
|
|
${tools_dir}/grib_set -s paramId=260268 $temp1 $temp2
|
|
|
|
grib_check_key_equals $temp2 mars.step 36 # end step (ECC-701)
|
|
|
|
grib_check_key_exists $temp2 mars.anoffset
|
2018-04-03 14:29:43 +00:00
|
|
|
#${tools_dir}/grib_dump -Da $temp1 | grep mars.step
|
|
|
|
done
|
|
|
|
|
2018-04-27 11:30:58 +00:00
|
|
|
types="fc pf cf"
|
2018-04-03 14:29:43 +00:00
|
|
|
for t in $types; do
|
2021-09-19 13:09:47 +00:00
|
|
|
${tools_dir}/grib_set -s \
|
2021-09-20 12:47:55 +00:00
|
|
|
setLocalDefinition=1,localDefinitionNumber=41,type=$t,stepType=accum,stepRange=12-36 \
|
2018-04-03 14:29:43 +00:00
|
|
|
$sample $temp1
|
2021-09-19 13:09:47 +00:00
|
|
|
${tools_dir}/grib_set -s paramId=260268 $temp1 $temp2
|
|
|
|
grib_check_key_equals $temp2 mars.step 36 # end step
|
2018-04-03 14:29:43 +00:00
|
|
|
#${tools_dir}/grib_dump -Da $temp1 | grep mars.step
|
|
|
|
done
|
|
|
|
|
2018-09-14 15:03:41 +00:00
|
|
|
# ---------------------------
|
2018-09-19 13:31:53 +00:00
|
|
|
# Stream EFCL (Climatology)
|
2018-09-14 15:03:41 +00:00
|
|
|
# ---------------------------
|
2018-09-19 13:31:53 +00:00
|
|
|
${tools_dir}/grib_set -s tablesVersion=19,setLocalDefinition=1,stream=efcl,type=fc $ECCODES_SAMPLES_PATH/GRIB2.tmpl $sample
|
2018-09-14 15:03:41 +00:00
|
|
|
|
|
|
|
# Test a non-ensemble, instantaneous field
|
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=70,typeOfPostProcessing=1 $sample $temp1
|
2018-09-21 10:31:10 +00:00
|
|
|
${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=41,yearOfModelVersion=2019,monthOfModelVersion=12,dayOfModelVersion=13 $temp1 $temp2
|
2018-09-14 15:03:41 +00:00
|
|
|
# ${tools_dir}/grib_ls -m $temp2
|
|
|
|
grib_check_key_equals $temp2 mars.hdate,mars.date '20070323 20191213'
|
|
|
|
# This stream does not have the 'anoffset' key
|
|
|
|
anoffset=`${tools_dir}/grib_get -f -p mars.anoffset $temp2`
|
2018-09-19 13:31:53 +00:00
|
|
|
[ "$anoffset" = "not_found" ]
|
2018-09-14 15:03:41 +00:00
|
|
|
|
2021-07-23 11:31:03 +00:00
|
|
|
# ECC-1264
|
|
|
|
${tools_dir}/grib_set -s localDefinitionNumber=41,yearOfForecast=missing,monthOfForecast=missing $temp1 $temp2
|
|
|
|
#${tools_dir}/grib_dump -O $temp2
|
|
|
|
|
2018-01-05 18:18:18 +00:00
|
|
|
|
|
|
|
# Clean up
|
|
|
|
rm -f $sample $temp1 $temp2 $temp3
|