mirror of https://github.com/ecmwf/eccodes.git
ECC-763: Add basic test for BUFR headers
This commit is contained in:
parent
4481970e7a
commit
8ab46146d5
|
@ -29,6 +29,7 @@ endforeach()
|
|||
#################################################
|
||||
list( APPEND tests_basic
|
||||
grib_set_pv
|
||||
bufr_read_header
|
||||
)
|
||||
list( APPEND tests_extra
|
||||
grib_clone
|
||||
|
@ -51,7 +52,6 @@ list( APPEND tests_extra
|
|||
bufr_expanded
|
||||
bufr_get_keys
|
||||
bufr_keys_iterator
|
||||
bufr_read_header
|
||||
bufr_read_scatterometer
|
||||
bufr_read_tropical_cyclone
|
||||
bufr_read_synop
|
||||
|
|
|
@ -21,11 +21,10 @@ import sys
|
|||
|
||||
from eccodes import *
|
||||
|
||||
INPUT = '../../data/bufr/syno_multi.bufr'
|
||||
VERBOSE = 1 # verbose error reporting
|
||||
|
||||
|
||||
def example():
|
||||
def example(INPUT):
|
||||
# open bufr file
|
||||
f = open(INPUT)
|
||||
|
||||
|
@ -70,7 +69,7 @@ def example():
|
|||
|
||||
def main():
|
||||
try:
|
||||
example()
|
||||
example(sys.argv[1])
|
||||
except CodesInternalError as err:
|
||||
if VERBOSE:
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
|
|
|
@ -3,23 +3,28 @@
|
|||
. ./include.sh
|
||||
|
||||
#-----------------------------------------------------
|
||||
# Test reading the header only from a BUFR
|
||||
# Test reading the header from a BUFR
|
||||
# file with multiple messages
|
||||
#----------------------------------------------------
|
||||
|
||||
#The bufr filename is hardcoded in the python example
|
||||
f=${data_dir}"/bufr/syno_multi.bufr"
|
||||
f=${data_dir}/bufr/syno_multi.bufr
|
||||
fRef=$f".header.ref"
|
||||
fRes=$f".header.test.p"
|
||||
REDIRECT=/dev/null
|
||||
|
||||
#Write the values into a file and compare with reference
|
||||
$PYTHON $examples_src/bufr_read_header.py 2> $REDIRECT > $fRes
|
||||
if [ -f "$f" ]; then
|
||||
# Write the values into a file and compare with reference
|
||||
$PYTHON $examples_src/bufr_read_header.py $f 2> $REDIRECT > $fRes
|
||||
|
||||
#We compare output to the reference by ignoring the whitespaces
|
||||
diff -w $fRef $fRes
|
||||
#We compare output to the reference by ignoring the whitespaces
|
||||
diff -w $fRef $fRes
|
||||
fi
|
||||
|
||||
# Now test reading the header of sample files
|
||||
$PYTHON $examples_src/bufr_read_header.py ${ECCODES_SAMPLES_PATH}/BUFR3_local.tmpl
|
||||
$PYTHON $examples_src/bufr_read_header.py ${ECCODES_SAMPLES_PATH}/BUFR4.tmpl
|
||||
$PYTHON $examples_src/bufr_read_header.py ${ECCODES_SAMPLES_PATH}/BUFR4_local_satellite.tmpl
|
||||
|
||||
#cat $fRes
|
||||
|
||||
#Clean up
|
||||
rm -f $fRes
|
||||
|
|
Loading…
Reference in New Issue