2013-03-25 12:04:10 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# --- check nothing bombs when changing packing
|
|
|
|
# --- for now limited to just a few packing schemes
|
|
|
|
|
|
|
|
. ./include.sh
|
|
|
|
|
|
|
|
#set -x
|
|
|
|
|
|
|
|
grib1=${data_dir}/reduced_latlon_surface_constant.grib1
|
|
|
|
grib2=${data_dir}/reduced_latlon_surface_constant.grib2
|
|
|
|
|
|
|
|
packing1="
|
2018-11-09 12:55:32 +00:00
|
|
|
grid_ieee
|
|
|
|
grid_simple
|
|
|
|
grid_simple_matrix"
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
packing2="
|
2018-11-09 12:55:32 +00:00
|
|
|
grid_ieee
|
|
|
|
grid_jpeg
|
|
|
|
grid_simple
|
|
|
|
grid_simple_matrix"
|
|
|
|
#TODO: grid_simple_log_preprocessing
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2018-11-09 12:55:32 +00:00
|
|
|
temp=temp.change_packing.grib
|
2017-11-30 17:49:46 +00:00
|
|
|
rm -f $temp
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
# --- test changing the packing
|
|
|
|
# arg 1 : input grib file
|
|
|
|
# arg 2-n : packing types to test
|
|
|
|
function test_packing() {
|
2018-11-09 12:55:32 +00:00
|
|
|
grib=$1
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2018-11-09 12:55:32 +00:00
|
|
|
if [ ! -f $grib ]; then
|
|
|
|
echo "Input data missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2018-11-09 12:55:32 +00:00
|
|
|
shift
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
packing=$1
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2018-11-09 12:55:32 +00:00
|
|
|
${tools_dir}/grib_set -r -s packingType=$packing $grib $temp
|
|
|
|
result=`${tools_dir}/grib_get -p packingType $temp`
|
|
|
|
|
|
|
|
if [ "$result" != "$packing" ]; then
|
|
|
|
echo "Setting packing did not go right"
|
|
|
|
exit 1
|
|
|
|
fi
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2018-11-09 12:55:32 +00:00
|
|
|
shift
|
|
|
|
done
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2018-11-09 12:55:32 +00:00
|
|
|
rm -f $temp
|
2013-03-25 12:04:10 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 12:55:32 +00:00
|
|
|
# ECC-774
|
|
|
|
# ------------
|
|
|
|
input=${data_dir}/spherical_model_level.grib2
|
|
|
|
output=`${tools_dir}/grib_set -r -s packingType=spectral_simple $input $temp 2>&1`
|
|
|
|
# Check no error was posted i.e. output string is empty
|
|
|
|
[ -z "$output" ]
|
|
|
|
res1=`${tools_dir}/grib_get '-F%.1f' -p avg,enorm $input`
|
|
|
|
res2=`${tools_dir}/grib_get '-F%.1f' -p avg,enorm $temp`
|
|
|
|
[ "$res1" = "$res2" ]
|
|
|
|
rm -f $temp
|
|
|
|
|
|
|
|
|
|
|
|
# Change grib packing test
|
|
|
|
# -------------------------
|
2013-03-25 12:04:10 +00:00
|
|
|
test_packing $grib1 $packing1
|
|
|
|
test_packing $grib2 $packing2
|
2018-11-09 12:55:32 +00:00
|
|
|
|
|
|
|
rm -f $temp
|