eccodes/tests/grib_ecc-1560.sh

67 lines
2.9 KiB
Bash
Raw Permalink Normal View History

2023-04-02 13:53:33 +00:00
#!/bin/sh
# (C) Copyright 2005- 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.ctest.sh
label="grib_ecc-1560_test"
temp_PDTN00_Grib=temp.$label.PDTN00.grib
2023-04-02 13:53:33 +00:00
temp_PDTN08_Grib=temp.$label.PDTN08.grib
temp_PDTN11_Grib=temp.$label.PDTN11.grib
2023-04-02 14:31:27 +00:00
tempGrib=temp.$label.grib
2023-04-02 13:53:33 +00:00
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
2023-07-24 20:43:06 +00:00
# ECC-1644
# --------------
${tools_dir}/grib_set -s scaleFactorOfFirstFixedSurface=0,scaledValueOfFirstFixedSurface=0 \
$sample_grib2 $temp_PDTN00_Grib
${tools_dir}/grib_set -s productDefinitionTemplateNumber=11 $temp_PDTN00_Grib $temp_PDTN11_Grib
${tools_dir}/grib_compare -b totalLength,section4Length,productDefinitionTemplateNumber $temp_PDTN00_Grib $temp_PDTN11_Grib
2023-07-24 20:43:06 +00:00
${tools_dir}/grib_set -s typeOfFirstFixedSurface=100,scaleFactorOfFirstFixedSurface=-2,scaledValueOfFirstFixedSurface=10 \
$sample_grib2 $temp_PDTN00_Grib
${tools_dir}/grib_set -s productDefinitionTemplateNumber=11 $temp_PDTN00_Grib $temp_PDTN11_Grib
${tools_dir}/grib_compare -b totalLength,section4Length,productDefinitionTemplateNumber $temp_PDTN00_Grib $temp_PDTN11_Grib
# Set PDTN=8 and level to 1.5 metres above ground
# --------------------------------------------------
2023-04-02 13:53:33 +00:00
${tools_dir}/grib_set -s \
productDefinitionTemplateNumber=8,typeOfFirstFixedSurface=103,scaledValueOfFirstFixedSurface=15,scaleFactorOfFirstFixedSurface=1 \
$sample_grib2 $temp_PDTN08_Grib
grib_check_key_equals $temp_PDTN08_Grib level:d 1.5
# Now we change to PDTN 11
${tools_dir}/grib_set -s productDefinitionTemplateNumber=11 $temp_PDTN08_Grib $temp_PDTN11_Grib
grib_check_key_equals $temp_PDTN11_Grib level:d 1.5
grib_check_key_equals $temp_PDTN11_Grib scaledValueOfFirstFixedSurface 15
grib_check_key_equals $temp_PDTN11_Grib scaleFactorOfFirstFixedSurface 1
2023-04-02 13:53:33 +00:00
2023-04-02 14:31:27 +00:00
# Set whole value using the int/double encoding
2023-04-02 14:31:27 +00:00
# -----------------------------------------------
${tools_dir}/grib_set -s typeOfFirstFixedSurface=105,level:i=34 $sample_grib2 $tempGrib
grib_check_key_equals $tempGrib scaleFactorOfFirstFixedSurface 0
grib_check_key_equals $tempGrib scaledValueOfFirstFixedSurface 34
${tools_dir}/grib_set -s typeOfFirstFixedSurface=105,level:d=34 $sample_grib2 $tempGrib
grib_check_key_equals $tempGrib scaleFactorOfFirstFixedSurface 0
grib_check_key_equals $tempGrib scaledValueOfFirstFixedSurface 34
${tools_dir}/grib_set -s typeOfFirstFixedSurface=105,level:d=3.456 $sample_grib2 $tempGrib
grib_check_key_equals $tempGrib scaleFactorOfFirstFixedSurface 3
grib_check_key_equals $tempGrib scaledValueOfFirstFixedSurface 3456
2023-04-02 14:31:27 +00:00
2023-04-02 13:53:33 +00:00
# Clean up
2023-04-02 14:31:27 +00:00
rm -f $temp_PDTN08_Grib $temp_PDTN11_Grib $tempGrib
2023-08-24 12:00:47 +00:00
rm -f $temp_PDTN00_Grib