mirror of https://github.com/ecmwf/eccodes.git
chemId/paramId split: Add tests to check paramtype
This commit is contained in:
parent
b95219a7d9
commit
37502341d8
|
@ -17,42 +17,57 @@ tempGrib=temp.$label.grib
|
|||
|
||||
sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
check_param_type_is_scalar()
|
||||
{
|
||||
# Check we do not end up with an array for paramtype
|
||||
infile=$1
|
||||
ptype=$2
|
||||
result=$(echo 'print "|[paramtype]|";' | ${tools_dir}/grib_filter - $infile)
|
||||
[ "$result" = "|$ptype|" ]
|
||||
}
|
||||
|
||||
# Base
|
||||
${tools_dir}/grib_set -s shortName=t $sample $tempGrib
|
||||
grib_check_key_equals $tempGrib mars.paramtype "base"
|
||||
grib_check_key_equals $tempGrib mars.paramtype 'base'
|
||||
check_param_type_is_scalar $sample 'base'
|
||||
|
||||
# Aerosols
|
||||
${tools_dir}/grib_set -s productDefinitionTemplateNumber=45,discipline=0,parameterCategory=20,parameterNumber=0 \
|
||||
$sample $tempGrib
|
||||
grib_check_key_equals $tempGrib mars.paramtype "chemical"
|
||||
|
||||
grib_check_key_equals $tempGrib mars.paramtype 'chemical'
|
||||
check_param_type_is_scalar $tempGrib 'chemical'
|
||||
|
||||
# Atmospheric chemical constituents
|
||||
${tools_dir}/grib_set -s productDefinitionTemplateNumber=40,discipline=0,parameterCategory=20,parameterNumber=2 \
|
||||
$sample $tempGrib
|
||||
grib_check_key_equals $tempGrib mars.paramtype "chemical"
|
||||
grib_check_key_equals $tempGrib mars.paramtype 'chemical'
|
||||
check_param_type_is_scalar $tempGrib 'chemical'
|
||||
|
||||
|
||||
# Optical properties of aerosol
|
||||
${tools_dir}/grib_set -s productDefinitionTemplateNumber=48,discipline=0,parameterCategory=20,parameterNumber=102 \
|
||||
$sample $tempGrib
|
||||
${tools_dir}/grib_dump -O -p section_4 $tempGrib
|
||||
grib_check_key_equals $tempGrib mars.paramtype "optical"
|
||||
${tools_dir}/grib_dump -O -p section_4 $tempGrib > /dev/null
|
||||
grib_check_key_equals $tempGrib mars.paramtype 'optical'
|
||||
check_param_type_is_scalar $tempGrib 'optical'
|
||||
|
||||
# Generalised tiles
|
||||
${tools_dir}/grib_set -s productDefinitionTemplateNumber=113 $sample $tempGrib
|
||||
grib_check_key_equals $tempGrib mars.paramtype "tile"
|
||||
grib_check_key_equals $tempGrib mars.paramtype 'tile'
|
||||
check_param_type_is_scalar $tempGrib 'tile'
|
||||
|
||||
# Wave spectra
|
||||
for pdtn in 99 100 101 102; do
|
||||
${tools_dir}/grib_set -s productDefinitionTemplateNumber=$pdtn $sample $tempGrib
|
||||
grib_check_key_equals $tempGrib mars.paramtype "wave_spectra"
|
||||
grib_check_key_equals $tempGrib mars.paramtype 'wave_spectra'
|
||||
check_param_type_is_scalar $tempGrib 'wave_spectra'
|
||||
done
|
||||
|
||||
# Wave
|
||||
for pid in 140200 140250; do
|
||||
${tools_dir}/grib_set -s paramId=$pid $sample $tempGrib
|
||||
grib_check_key_equals $tempGrib mars.paramtype "wave"
|
||||
grib_check_key_equals $tempGrib mars.paramtype 'wave'
|
||||
check_param_type_is_scalar $tempGrib 'wave'
|
||||
done
|
||||
|
||||
# Clean up
|
||||
|
|
Loading…
Reference in New Issue