mirror of https://github.com/ecmwf/eccodes.git
Python examples: Pass in the BUFR file to iterate on
This commit is contained in:
parent
9e67f97ec5
commit
4613a340d7
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue