2015-07-21 13:24:02 +00:00
|
|
|
#!/bin/sh
|
2015-12-31 12:44:51 +00:00
|
|
|
# Copyright 2005-2016 ECMWF.
|
2015-07-21 13:24:02 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2015-09-23 14:30:30 +00:00
|
|
|
### Regular Lat/Lon Grid
|
|
|
|
###########################################
|
2015-07-21 13:24:02 +00:00
|
|
|
infile=../data/latlon.grib
|
|
|
|
outfile=out.grib_util_set_spec.grib
|
2015-09-23 14:30:30 +00:00
|
|
|
rm -f $outfile
|
2015-07-21 13:24:02 +00:00
|
|
|
|
2016-08-31 16:38:31 +00:00
|
|
|
${test_dir}grib_util_set_spec $infile $outfile > /dev/null
|
2015-07-21 13:24:02 +00:00
|
|
|
|
2016-09-22 15:52:56 +00:00
|
|
|
res=`${tools_dir}grib_get -p edition,section2Used,Ni,Nj,numberOfValues,bitsPerValue $outfile`
|
|
|
|
[ "$res" = "2 0 17 14 238 24" ]
|
2015-07-21 13:24:02 +00:00
|
|
|
|
2016-08-31 16:38:31 +00:00
|
|
|
# Check output file geometry
|
2015-07-21 13:24:02 +00:00
|
|
|
${tools_dir}grib_get_data $outfile > /dev/null
|
|
|
|
|
2016-08-31 16:38:31 +00:00
|
|
|
### Reduced Gaussian Grid N=32 second order packing
|
2015-09-23 14:30:30 +00:00
|
|
|
###########################################
|
2016-08-31 16:38:31 +00:00
|
|
|
infile=../data/reduced_gaussian_model_level.grib2
|
2015-09-23 14:30:30 +00:00
|
|
|
outfile=out.grib_util_set_spec.grib
|
|
|
|
rm -f $outfile
|
|
|
|
|
2016-09-01 12:43:09 +00:00
|
|
|
stats_old=`${tools_dir}grib_get -F%.2f -p min,max $infile`
|
|
|
|
[ "$stats_old" = "160.25 224.45" ]
|
|
|
|
|
2016-08-31 16:38:31 +00:00
|
|
|
${test_dir}grib_util_set_spec $infile $outfile
|
2015-09-23 14:30:30 +00:00
|
|
|
|
2016-09-01 12:43:09 +00:00
|
|
|
# Check output file. Values are scaled up by 1.1
|
2016-08-31 16:38:31 +00:00
|
|
|
grib_check_key_equals $outfile packingType grid_second_order
|
2016-09-01 12:43:09 +00:00
|
|
|
stats_new=`${tools_dir}grib_get -F%.2f -p min,max $outfile`
|
|
|
|
[ "$stats_new" = "176.28 246.90" ]
|
|
|
|
|
2016-08-31 16:38:31 +00:00
|
|
|
${tools_dir}grib_get_data $outfile > /dev/null
|
|
|
|
CHECK_TOOL="${tools_dir}grib_check_gaussian_grid"
|
|
|
|
if [ -x $CHECK_TOOL ]; then
|
|
|
|
$CHECK_TOOL $outfile
|
|
|
|
fi
|
|
|
|
|
|
|
|
### Constant field N=32
|
|
|
|
###########################################
|
|
|
|
infile=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
|
|
|
|
rm -f $outfile
|
|
|
|
|
|
|
|
${test_dir}grib_util_set_spec $infile $outfile
|
|
|
|
grib_check_key_equals $outfile "packingType,const" "grid_simple 1"
|
2015-09-23 14:30:30 +00:00
|
|
|
${tools_dir}grib_get_data $outfile > /dev/null
|
|
|
|
|
|
|
|
|
|
|
|
### Clean up
|
2015-07-21 13:24:02 +00:00
|
|
|
rm -f $outfile
|