Python examples: Pass in the BUFR file to iterate on

This commit is contained in:
Shahram Najm 2019-06-06 12:41:51 +01:00
parent 9e67f97ec5
commit 4613a340d7
2 changed files with 8 additions and 11 deletions

View File

@ -21,11 +21,10 @@ import sys
from eccodes import *
INPUT = '../../data/bufr/syno_1.bufr'
VERBOSE = 1 # verbose error reporting
def example():
def example(INPUT):
# open bufr file
f = open(INPUT, 'rb')
@ -67,7 +66,7 @@ def example():
def main():
try:
example()
example(sys.argv[1])
except CodesInternalError as err:
if VERBOSE:
traceback.print_exc(file=sys.stderr)

View File

@ -10,24 +10,22 @@
. ./include.sh
#Define a common label for all the tmp files
# Define a common label for all the tmp files
label="bufr_keys_iterator_test_p"
#Define tmp file
# Define tmp file
fTmp=${label}".tmp.txt"
rm -f $fTmp
REDIRECT=/dev/null
#The bufr file to use
# The bufr file to use
f=${data_dir}/bufr/syno_1.bufr
$PYTHON $examples_src/bufr_keys_iterator.py $f 2> $REDIRECT > $fTmp
#The input ($f) is hardcoded in the example!!!
$PYTHON $examples_src/bufr_keys_iterator.py 2> $REDIRECT > $fTmp
#TODO: check the output
# Check the output
grep -q '#6#cloudType->percentConfidence' $fTmp
grep -q '#2#verticalSignificanceSurfaceObservations->percentConfidence' $fTmp
#Clean up
# Clean up
rm -f $fTmp