diff --git a/tests/bitmap.sh b/tests/bitmap.sh index 1e17dfee0..03c3c94bc 100755 --- a/tests/bitmap.sh +++ b/tests/bitmap.sh @@ -3,7 +3,7 @@ # # 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. # @@ -19,9 +19,6 @@ infile=${data_dir}/reduced_gaussian_model_level.grib1 outfile=${data_dir}/with_bitmap.grib1 outfile1=${data_dir}/without_bitmap.grib1 -# Create the grib2 file from grib1 -${tools_dir}grib_set -s editionNumber=2 $grib1 $grib2 2> $REDIRECT > $REDIRECT - rm -f $outfile || true ${tools_dir}grib_set -s bitmapPresent=1 $infile $outfile >$REDIRECT @@ -52,7 +49,7 @@ set values={1,2,3,4,5,6,7,1111,1111,8,9,10}; write ; EOF -${tools_dir}grib_filter -o out.grib1 bitmap.rules $grib1 +${tools_dir}grib_filter -o out.grib1 bitmap.rules $grib1 ${tools_dir}grib_filter -o out.grib2 bitmap.rules $grib2 #exit 0 @@ -62,4 +59,5 @@ ${tools_dir}grib_get_data -m missing out.grib2 > out.grib2.data diff out.grib1.data out.grib2.data rm -f out.grib1.data out.grib2.data out.grib1 out.grib2 bitmap.rules -rm -f $grib2 + + diff --git a/tests/bitsPerValue.sh b/tests/bitsPerValue.sh index 3d39b4560..dce9cfb37 100755 --- a/tests/bitsPerValue.sh +++ b/tests/bitsPerValue.sh @@ -3,7 +3,7 @@ # # 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. # @@ -98,10 +98,6 @@ done files="regular_latlon_surface.grib2 \ regular_latlon_surface.grib1" -# Create the grib2 file from grib1 -${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.grib2 - - for file in `echo $files`; do infile=${data_dir}/$file @@ -122,4 +118,3 @@ done res=`${tools_dir}grib_get -p decimalScaleFactor,bitsPerValue ${data_dir}/gfs.c255.grib2` [ "$res" = "1 20" ] -rm -f ${data_dir}/regular_latlon_surface.grib2 diff --git a/tests/ccsds.sh b/tests/ccsds.sh new file mode 100755 index 000000000..66b9c01ca --- /dev/null +++ b/tests/ccsds.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Copyright 2005-2014 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 + +REDIRECT=/dev/null +BLACKLIST="totalLength,section5Length,section7Length,dataRepresentationTemplateNumber,typeOfPacking" + +infile=${data_dir}/ccsds.grib2 + +rm -f $infile.1 $infile.2 || true +${tools_dir}grib_set -f -r -s packingType=grid_simple $infile $infile.1 2> $REDIRECT +${tools_dir}grib_compare -P -b $BLACKLIST,typeOfCompressionUsed,targetCompressionRatio $infile $infile.1 > $REDIRECT +${tools_dir}grib_set -r -s packingType=grid_ccsds $infile.1 $infile.2 +${tools_dir}grib_compare -P -b $BLACKLIST $infile.1 $infile.2 > $REDIRECT + +templateNumber=`${tools_dir}grib_get -p dataRepresentationTemplateNumber $infile.2` + +if [ $templateNumber -ne 42 ] +then + echo dataRepresentationTemplateNumber=$templateNumber + exit 1 +fi + +rm -f $infile.1 $infile.2 || true + +infile=${data_dir}/reduced_latlon_surface.grib2 + +${tools_dir}grib_set -r -s packingType=grid_ccsds $infile $infile.1 +${tools_dir}grib_compare -P -b $BLACKLIST $infile $infile.1 > $REDIRECT +${tools_dir}grib_set -f -r -s packingType=grid_simple $infile.1 $infile.2 2> $REDIRECT +${tools_dir}grib_compare -P -b $BLACKLIST,typeOfCompressionUsed,targetCompressionRatio $infile.1 $infile.2 > $REDIRECT + +res1=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile` +res2=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile.1` +res3=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile.2` +[ "$res1" = "$res2" ] +[ "$res1" = "$res3" ] + +rm -f $infile.1 $infile.2 || true diff --git a/tests/decimalPrecision.sh b/tests/decimalPrecision.sh index d29fc5e5e..b4bc2c3cb 100755 --- a/tests/decimalPrecision.sh +++ b/tests/decimalPrecision.sh @@ -3,7 +3,7 @@ # # 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. # @@ -15,8 +15,8 @@ REDIRECT=/dev/null files="regular_latlon_surface.grib2 \ regular_latlon_surface.grib1" -# First create the necessary grib2 files -${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.grib2 + + for file in `echo $files` do @@ -31,4 +31,3 @@ do rm -f $outfile1 $outfile2 || true done -rm -f ${data_dir}/regular_latlon_surface.grib2 diff --git a/tests/grib1to2.sh b/tests/grib1to2.sh index 810fd83d6..6fb805057 100755 --- a/tests/grib1to2.sh +++ b/tests/grib1to2.sh @@ -3,7 +3,7 @@ # # 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. # @@ -32,21 +32,20 @@ files="constant_field\ for f in `echo $files` do file=${data_dir}/$f - g2file=${file}.grib2_ - rm -f $g2file || true - ${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${g2file} 2> $REDIRECT > $REDIRECT + rm -f ${file}.grib2 || true + ${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT grib1Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib1` - grib2Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${g2file}` + grib2Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib2` if [ "$grib1Statistics" != "$grib2Statistics" ] then exit 1 fi - #${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1 ${g2file} 2> /dev/null > /dev/null - ${tools_dir}grib_compare -P -c values ${file}.grib1 ${g2file} 2> $REDIRECT > $REDIRECT - rm -f ${g2file} || true + #${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1 ${file}.grib2 2> /dev/null > /dev/null + ${tools_dir}grib_compare -P -c values ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT + done #sed "s:toolsdir:${tools_dir}:" ${tools_dir}grib1to2.txt > ${tools_dir}grib1to2.test diff --git a/tests/grib2to1.sh b/tests/grib2to1.sh index c772ca708..e881a0a59 100755 --- a/tests/grib2to1.sh +++ b/tests/grib2to1.sh @@ -32,11 +32,6 @@ files="constant_field\ for f in `echo $files` do file=${data_dir}/$f - - # First create the grib2 file - rm -f ${file}.grib2 || true - ${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT - rm -f ${file}.grib1_ || true ${tools_dir}grib_set -s editionNumber=1 ${file}.grib2 ${file}.grib1_ 2> $REDIRECT > $REDIRECT @@ -50,7 +45,6 @@ do #${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1_ ${file}.grib2 2> /dev/null > /dev/null rm -f ${file}.grib1_ || true - rm -f ${file}.grib2 || true done # GRIB-262 Conversion works without error for L137 data diff --git a/tests/iterator.sh b/tests/iterator.sh index 097e1a48d..ce820f133 100755 --- a/tests/iterator.sh +++ b/tests/iterator.sh @@ -3,7 +3,7 @@ # # 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. # @@ -21,24 +21,6 @@ files="reduced_latlon_surface.grib1 \ reduced_gaussian_sub_area.grib2 \ regular_latlon_surface.grib2" -# First create the necessary grib2 files from grib1 -files2conv="\ - reduced_latlon_surface\ - reduced_gaussian_pressure_level\ - regular_gaussian_pressure_level\ - reduced_gaussian_sub_area\ - regular_latlon_surface\ -" -for f in $files2conv; do - ${tools_dir}grib_set -s editionNumber=2 ${data_dir}/$f.grib1 ${data_dir}/$f.grib2 -done - -# First create the necessary grib2 files -#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_latlon_surface.grib1 ${data_dir}/reduced_latlon_surface.grib2 -#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_gaussian_pressure_level.grib1 ${data_dir}/reduced_gaussian_pressure_level.grib2 -#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_gaussian_pressure_level.grib1 ${data_dir}/regular_gaussian_pressure_level.grib2 -#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_gaussian_sub_area.grib1 ${data_dir}/reduced_gaussian_sub_area.grib2 - for f in `echo $files` do file=${data_dir}/$f @@ -47,7 +29,3 @@ do [ $numberOfPoints = ${iterator_count} ] done -# Clean up -for f in $files2conv; do - rm -f ${data_dir}/$f.grib2 -done diff --git a/tests/jpeg.sh b/tests/jpeg.sh index 9e460a654..f560f6555 100755 --- a/tests/jpeg.sh +++ b/tests/jpeg.sh @@ -33,8 +33,6 @@ fi rm -f $infile.1 $infile.2 || true infile=${data_dir}/reduced_latlon_surface.grib2 -# Create the grib2 file from grib1 -${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_latlon_surface.grib1 ${data_dir}/reduced_latlon_surface.grib2 ${tools_dir}grib_set -s packingType=grid_jpeg $infile $infile.1 ${tools_dir}grib_compare -P -b $BLACKLIST $infile $infile.1 > $REDIRECT @@ -52,4 +50,3 @@ res=`${tools_dir}grib_get -l 0,50 $infile.1` [ "$res" = "2.47244 2.47244 2.5115 2.51931 " ] rm -f $infile.1 $infile.2 || true -rm -f ${data_dir}/reduced_latlon_surface.grib2 diff --git a/tests/lamb_az_eq_area.sh b/tests/lamb_az_eq_area.sh index ef068db19..783c6302b 100755 --- a/tests/lamb_az_eq_area.sh +++ b/tests/lamb_az_eq_area.sh @@ -10,13 +10,9 @@ . ./include.sh #set -x -GRIB1_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib1 -GRIB2_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2 +GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2 REF_FILE=lamb_az_eq_area.ref -# First create the grib2 file from grib1 -${tools_dir}grib_set -s editionNumber=2 $GRIB1_INFILE $GRIB2_INFILE - # Temporary files created for this test FILTER_FILE=lamb_az_eq_area.filter GRIB_OUTFILE=lamb_az_eq_area.grib2 @@ -45,7 +41,7 @@ write "lamb_az_eq_area.grib2"; EOF # Use this filter and the input GRIB to create a new GRIB -${tools_dir}grib_filter $FILTER_FILE $GRIB2_INFILE +${tools_dir}grib_filter $FILTER_FILE $GRIB_INFILE if [ ! -f "$GRIB_OUTFILE" ]; then echo Failed to create output GRIB from filter >&2 exit 1 @@ -57,5 +53,5 @@ ${tools_dir}grib_get_data $GRIB_OUTFILE > $DATA_OUTFILE diff $DATA_OUTFILE $REF_FILE # Clean up -rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE $GRIB2_INFILE +rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE diff --git a/tests/list.sh b/tests/list.sh index 9c2f1a7b9..d94b934c7 100755 --- a/tests/list.sh +++ b/tests/list.sh @@ -3,7 +3,7 @@ # # 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. # @@ -21,13 +21,8 @@ set scaledValueOfCentralWaveNumber={26870,9272,8377,22334}; write "test.grib"; EOF -# First create the grib2 file from grib1 -gname=reduced_gaussian_model_level -grib1File=${data_dir}/${gname}.grib1 -grib2File=${data_dir}/${gname}.grib2 -${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File +file="${data_dir}/reduced_gaussian_model_level.grib2" -file="$grib2File" ${tools_dir}grib_filter list.filter $file cat >list.filter< /dev/null type=`${tools_dir}grib_get -wcount=1 -p typeOfLevel test_uuid.grib2` [ "$type" = "generalVertical" ] -# Clean up -for f in $files2conv; do - rm -f $f.grib2 -done - cd $workdir diff --git a/tests/set.sh b/tests/set.sh index 3e2159eda..8bcfd5b36 100755 --- a/tests/set.sh +++ b/tests/set.sh @@ -3,7 +3,7 @@ # # 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. # @@ -31,14 +31,7 @@ levtype=`${tools_dir}grib_get -p levtype:l $outfile` centre=`${tools_dir}grib_get -p centre:l $outfile` [ $centre -eq 80 ] -rm -f $outfile || true - -# Create the grib2 file from grib1 -grib1File=${data_dir}/regular_gaussian_surface.grib1 -grib2File=${data_dir}/regular_gaussian_surface.grib2 -${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File - -infile=$grib2File +infile=${data_dir}/regular_gaussian_surface.grib2 outfile=${data_dir}/set.grib2 rm -f $outfile || true @@ -63,4 +56,4 @@ ${tools_dir}grib_set -p levtype $infile $outfile 2> $REDIRECT > $REDIRECT [ $? -ne 0 ] -rm -f $outfile $grib2File || true + diff --git a/tests/statistics.sh b/tests/statistics.sh index f09bafd4e..f4414071f 100755 --- a/tests/statistics.sh +++ b/tests/statistics.sh @@ -12,9 +12,6 @@ files="regular_latlon_surface.grib2 regular_latlon_surface.grib1" -# Create the grib2 file from grib1 -${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.grib2 - for file in $files do @@ -40,4 +37,3 @@ diff statistics.out ${data_dir}/statistics.out.good done rm -f statistics.out statistics.filter || true -rm -f ${data_dir}/regular_latlon_surface.grib2 diff --git a/tests/step.sh b/tests/step.sh index 782a500df..8588ed896 100755 --- a/tests/step.sh +++ b/tests/step.sh @@ -57,13 +57,7 @@ rm -f ${templog} | true # GRIB-180 # Set PDT 4.8 where you can find the EndOfOverallTimeInterval keys -# First create the necessary grib2 file -gname=reduced_latlon_surface_constant -grib1File=${data_dir}/${gname}.grib1 -grib2File=${data_dir}/${gname}.grib2 -rm -f $grib2File || true -${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File - +grib2File=${data_dir}/reduced_latlon_surface_constant.grib2 ${tools_dir}grib_set -sproductDefinitionTemplateNumber=8 $grib2File ${grib2File}.p8tmp # 78 hours is 3 days and 6 hours @@ -71,13 +65,13 @@ ${tools_dir}grib_set -s step=78 $grib2File.p8tmp ${grib2File}.tmp set `${tools_dir}grib_get -p hourOfEndOfOverallTimeInterval,dayOfEndOfOverallTimeInterval ${grib2File}.tmp` hourEnd=$1; dayEnd=$2 [ "$hourEnd" = "18" ] -[ "$dayEnd" = "8" ] +[ "$dayEnd" = "8" ] ${tools_dir}grib_set -s step=12 $grib2File.p8tmp ${grib2File}.tmp set `${tools_dir}grib_get -p hourOfEndOfOverallTimeInterval,dayOfEndOfOverallTimeInterval ${grib2File}.tmp` hourEnd=$1; dayEnd=$2 [ "$hourEnd" = "0" ] -[ "$dayEnd" = "6" ] +[ "$dayEnd" = "6" ] rm -f $grib2File.p8tmp ${grib2File}.tmp | true -rm -f $grib2File x.grib +rm -f x.grib