2023-03-02 14:28:47 +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
|
2023-12-01 11:46:30 +00:00
|
|
|
|
2023-03-02 14:28:47 +00:00
|
|
|
label="grib_generalised_tiles_test"
|
2023-03-07 11:14:23 +00:00
|
|
|
temp_grib_a=temp.$label.a.grib
|
|
|
|
temp_grib_b=temp2.$label.b.grib
|
2023-03-07 09:39:06 +00:00
|
|
|
temp_dump=temp.$label.dump
|
2023-03-02 14:28:47 +00:00
|
|
|
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
|
|
|
|
2023-12-01 11:46:30 +00:00
|
|
|
latest=`${tools_dir}/grib_get -p tablesVersionLatest $sample_grib2`
|
|
|
|
|
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=113,tablesVersion=$latest ${sample_grib2} ${temp_grib_a}
|
2023-03-02 14:28:47 +00:00
|
|
|
|
2023-03-07 09:39:06 +00:00
|
|
|
# Check tile related keys are present
|
2023-03-02 14:28:47 +00:00
|
|
|
|
2023-03-07 11:14:23 +00:00
|
|
|
grib_check_key_exists ${temp_grib_a} tileClassification,typeOfTile,numberOfUsedSpatialTiles,numberOfUsedTileAttributeCombinationsForTypeOfTile
|
2023-03-07 09:39:06 +00:00
|
|
|
|
2023-03-07 11:14:23 +00:00
|
|
|
grib_check_key_exists ${temp_grib_a} numberOfUsedTileAttributesForTileAttributeCombination,attributeOfTile,totalNumberOfTileAttributeCombinations
|
2023-03-07 09:39:06 +00:00
|
|
|
|
2023-03-07 11:14:23 +00:00
|
|
|
grib_check_key_exists ${temp_grib_a} tileIndex,uuidOfDataGroup
|
2023-03-07 09:39:06 +00:00
|
|
|
|
|
|
|
# Check list is working correctly and that associated concept is working correctly
|
|
|
|
|
2023-03-08 14:42:13 +00:00
|
|
|
echo 'set numberOfUsedTileAttributesForTileAttributeCombination=2; set attributeOfTile={2, 4}; write;' | ${tools_dir}/grib_filter -o ${temp_grib_b} - ${temp_grib_a}
|
2023-03-07 11:14:23 +00:00
|
|
|
output=$(echo 'print "[attributeOfTile]";' | ${tools_dir}/grib_filter - ${temp_grib_b})
|
2023-03-08 11:13:25 +00:00
|
|
|
[ "$output" = "2 4" ]
|
|
|
|
[ "$(${tools_dir}/grib_get -p tileAttribute ${temp_grib_b})" = "SNOW_ICE" ]
|
2023-03-07 09:39:06 +00:00
|
|
|
|
|
|
|
# Check template is being picked up correctly
|
|
|
|
|
2023-03-07 11:14:23 +00:00
|
|
|
${tools_dir}/grib_dump -O -p section_4 $temp_grib_a > $temp_dump
|
2023-04-26 12:43:34 +00:00
|
|
|
grep -q "Generalised tiles at a horizontal level or horizontal layer at a point in time" $temp_dump
|
2023-03-07 09:39:06 +00:00
|
|
|
|
|
|
|
# Check StatisticalProcessing template also works
|
|
|
|
|
2023-12-01 11:46:30 +00:00
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=114,tablesVersion=$latest ${sample_grib2} ${temp_grib_a}
|
2023-03-07 09:39:06 +00:00
|
|
|
|
2023-03-07 11:14:23 +00:00
|
|
|
grib_check_key_exists ${temp_grib_a} typeOfTile,typeOfStatisticalProcessing
|
2023-03-02 14:28:47 +00:00
|
|
|
|
2023-12-01 10:50:51 +00:00
|
|
|
# Check Ensemble template also works
|
|
|
|
|
2023-12-01 11:46:30 +00:00
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=115,tablesVersion=$latest ${sample_grib2} ${temp_grib_a}
|
2023-12-01 10:50:51 +00:00
|
|
|
|
|
|
|
grib_check_key_exists ${temp_grib_a} typeOfTile,perturbationNumber
|
|
|
|
|
|
|
|
# Check Ensemble StatisticalProcessing template also works
|
|
|
|
|
2023-12-01 11:46:30 +00:00
|
|
|
${tools_dir}/grib_set -s productDefinitionTemplateNumber=116,tablesVersion=$latest ${sample_grib2} ${temp_grib_a}
|
2023-12-01 10:50:51 +00:00
|
|
|
|
|
|
|
grib_check_key_exists ${temp_grib_a} typeOfTile,perturbationNumber,typeOfStatisticalProcessing
|
|
|
|
|
2023-03-07 11:14:23 +00:00
|
|
|
# Clean up
|
|
|
|
rm -f $temp_grib_a $temp_grib_b $temp_dump
|