Update test scripts

This commit is contained in:
Shahram Najm 2014-08-28 10:03:16 +01:00
parent 71ec71735a
commit 73085e73b8
15 changed files with 78 additions and 148 deletions

View File

@ -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

View File

@ -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

48
tests/ccsds.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<<EOF
@ -54,4 +49,5 @@ EOF
diff x.out list.ref
rm -f x.out list.ref list.filter test.grib $grib2File
rm -f x.out list.ref list.filter test.grib

View File

@ -17,33 +17,6 @@ REDIRECT=/dev/null
cd ${data_dir}
rm -f local.log | true
# GRIB2 definitions for chemicals and aerosols for MACC
sample_g2=$GRIB_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}grib_set -s paramId=210005 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,units,aerosolType,name macc.grb2`
[ "$result" = '0 20 2 aermr05 kg kg**-1 62001 Dust Aerosol (0.55 - 0.9 um) Mixing Ratio' ]
[ `${tools_dir}grib_get -p productDefinitionTemplateNumber macc.grb2` = '44' ]
${tools_dir}grib_set -s paramId=210001 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,units,aerosolType,name macc.grb2`
[ "$result" = '0 20 2 aermr01 kg kg**-1 62008 Sea Salt Aerosol (0.03 - 0.5 um) Mixing Ratio' ]
${tools_dir}grib_set -s paramId=210007 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,typeOfSizeInterval,aerosolType,name macc.grb2`
[ "$result" = '0 20 2 aermr07 255 62016 Hydrophobic Organic Matter Aerosol Mixing Ratio' ]
${tools_dir}grib_set -s paramId=210061 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,productDefinitionTemplateNumber,constituentType,name macc.grb2`
[ "$result" = '0 20 2 co2 40 3 Carbon Dioxide' ]
${tools_dir}grib_set -s paramId=210062 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,productDefinitionTemplateNumber,constituentType,name macc.grb2`
[ "$result" = '0 20 2 ch4 40 2 Methane' ]
rm -f macc.grb2 | true
${tools_dir}grib_set -s edition=2,setLocalDefinition=1 reduced_gaussian_model_level.grib1 loc.grib2
${tools_dir}grib_set -s setLocalDefinition=1 reduced_gaussian_model_level.grib1 loc.grib1

View File

@ -49,27 +49,6 @@ regular_latlon_surface.grib1
regular_latlon_surface.grib2
"
# First create the necessary grib2 files
files2conv="\
reduced_gaussian_model_level\
reduced_gaussian_pressure_level\
reduced_gaussian_model_level\
reduced_gaussian_pressure_level\
reduced_gaussian_pressure_level_constant\
reduced_gaussian_sub_area\
reduced_gaussian_surface\
reduced_latlon_surface\
regular_gaussian_model_level\
regular_gaussian_pressure_level\
regular_gaussian_pressure_level_constant\
regular_gaussian_surface\
regular_latlon_surface\
"
for f in $files2conv; do
rm -f $f.grib2 || true
${tools_dir}grib_set -s editionNumber=2 $f.grib1 $f.grib2
done
for file in $files
do
[ -f "$file" ]
@ -99,10 +78,5 @@ ${tools_dir}grib_ls -p uuidOfVGrid test_uuid.grib2 > /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

View File

@ -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

View File

@ -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

View File

@ -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