2019-11-27 18:11:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright 2005-2019 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
|
|
|
|
set -u
|
|
|
|
# ---------------------------------------------------------
|
2019-11-28 15:53:46 +00:00
|
|
|
# Tests for data quality checks
|
2019-11-27 18:11:57 +00:00
|
|
|
# ---------------------------------------------------------
|
|
|
|
label="grib_data_quality"
|
|
|
|
tempOut=temp.${label}.out
|
|
|
|
tempErr=temp.${label}.err
|
|
|
|
|
|
|
|
input1=${data_dir}/reduced_gaussian_surface.grib1
|
|
|
|
input2=${data_dir}/reduced_gaussian_surface.grib2
|
2019-11-28 15:53:46 +00:00
|
|
|
grib_check_key_equals $input1 paramId 167
|
|
|
|
grib_check_key_equals $input2 paramId 167
|
2019-11-27 18:11:57 +00:00
|
|
|
|
|
|
|
# Data quality checks disabled. Create cause huge values for temperature
|
|
|
|
unset ECCODES_GRIB_DATA_QUALITY_CHECKS
|
|
|
|
${tools_dir}/grib_set -s scaleValuesBy=100 $input1 $tempOut
|
|
|
|
${tools_dir}/grib_set -s scaleValuesBy=100 $input2 $tempOut
|
|
|
|
|
|
|
|
# Data quality checks enabled. Commands should fail
|
|
|
|
export ECCODES_GRIB_DATA_QUALITY_CHECKS=1
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_set -s scaleValuesBy=100 $input1 $tempOut 2>$tempErr
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
grep -q 'GRIB1 simple packing: unable to set values' $tempErr
|
|
|
|
grep -q 'outside allowable limits' $tempErr
|
|
|
|
|
|
|
|
set +e
|
|
|
|
${tools_dir}/grib_set -s scaleValuesBy=100 $input2 $tempOut 2>$tempErr
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
grep -q 'GRIB2 simple packing: unable to set values' $tempErr
|
|
|
|
grep -q 'outside allowable limits' $tempErr
|
|
|
|
|
2019-11-28 15:53:46 +00:00
|
|
|
# Override the defaults
|
|
|
|
# ----------------------
|
|
|
|
tempDir=tempdir.$label
|
|
|
|
rm -rf $tempDir
|
|
|
|
mkdir -p $tempDir
|
|
|
|
# Set a large limit for temperature
|
|
|
|
cat > $tempDir/param_limits.def <<EOF
|
|
|
|
constant default_min_val = -1e9 : long_type, hidden;
|
|
|
|
constant default_max_val = +1e9 : long_type, hidden;
|
|
|
|
concept param_value_min(default_min_val) {
|
|
|
|
0 = { paramId=167; }
|
|
|
|
} : long_type, hidden;
|
|
|
|
concept param_value_max(default_max_val) {
|
|
|
|
40000 = { paramId=167; }
|
|
|
|
} : long_type, hidden;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Command should not fail now
|
|
|
|
export ECCODES_GRIB_DATA_QUALITY_CHECKS=1
|
|
|
|
export ECCODES_DEFINITION_PATH_SUPPLEMENT=$test_dir/$tempDir
|
|
|
|
${tools_dir}/grib_set -s scaleValuesBy=100 $input1 $tempOut
|
|
|
|
|
|
|
|
|
2019-11-27 18:11:57 +00:00
|
|
|
|
|
|
|
# Clean up
|
2019-11-28 15:53:46 +00:00
|
|
|
rm -rf $tempDir
|
2019-11-27 18:11:57 +00:00
|
|
|
rm -f $tempOut $tempErr
|