mirror of https://github.com/ecmwf/eccodes.git
Python examples
This commit is contained in:
parent
cc73e100af
commit
ae140b9fb6
|
@ -19,7 +19,7 @@ VERBOSE = 1 # verbose error reporting
|
|||
|
||||
def example():
|
||||
f = open(sys.argv[1])
|
||||
out = open(sys.argv[2], 'w')
|
||||
fout = open(sys.argv[2], 'w')
|
||||
|
||||
while 1:
|
||||
gid = codes_grib_new_from_file(f)
|
||||
|
@ -29,12 +29,12 @@ def example():
|
|||
message = codes_get_message(gid)
|
||||
|
||||
newgid = codes_new_from_message(message)
|
||||
codes_write(newgid, out)
|
||||
codes_write(newgid, fout)
|
||||
codes_release(newgid)
|
||||
|
||||
codes_release(gid)
|
||||
|
||||
out.close()
|
||||
fout.close()
|
||||
f.close()
|
||||
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
. ./include.sh
|
||||
|
||||
INPUT=${data_dir}/tigge_pf_ecmwf.grib2
|
||||
OUTPUT=out.grib
|
||||
OUTPUT=temp.binary_message.grib
|
||||
|
||||
$PYTHON $examples_src/binary_message.py $INPUT $OUTPUT
|
||||
${tools_dir}/grib_compare $INPUT $OUTPUT
|
||||
rm $OUTPUT || true
|
||||
rm -f $OUTPUT
|
||||
|
||||
# GRIB-568 corrupt grib
|
||||
# We are expecting the command to fail so must turn off "set -e"
|
||||
|
@ -18,5 +18,4 @@ status=$?
|
|||
set -e
|
||||
# Check command did indeed fail
|
||||
[ $status != 0 ]
|
||||
rm $OUTPUT || true
|
||||
|
||||
rm -f $OUTPUT
|
||||
|
|
Loading…
Reference in New Issue