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():
|
def example():
|
||||||
f = open(sys.argv[1])
|
f = open(sys.argv[1])
|
||||||
out = open(sys.argv[2], 'w')
|
fout = open(sys.argv[2], 'w')
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
gid = codes_grib_new_from_file(f)
|
gid = codes_grib_new_from_file(f)
|
||||||
|
@ -29,12 +29,12 @@ def example():
|
||||||
message = codes_get_message(gid)
|
message = codes_get_message(gid)
|
||||||
|
|
||||||
newgid = codes_new_from_message(message)
|
newgid = codes_new_from_message(message)
|
||||||
codes_write(newgid, out)
|
codes_write(newgid, fout)
|
||||||
codes_release(newgid)
|
codes_release(newgid)
|
||||||
|
|
||||||
codes_release(gid)
|
codes_release(gid)
|
||||||
|
|
||||||
out.close()
|
fout.close()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
. ./include.sh
|
. ./include.sh
|
||||||
|
|
||||||
INPUT=${data_dir}/tigge_pf_ecmwf.grib2
|
INPUT=${data_dir}/tigge_pf_ecmwf.grib2
|
||||||
OUTPUT=out.grib
|
OUTPUT=temp.binary_message.grib
|
||||||
|
|
||||||
$PYTHON $examples_src/binary_message.py $INPUT $OUTPUT
|
$PYTHON $examples_src/binary_message.py $INPUT $OUTPUT
|
||||||
${tools_dir}/grib_compare $INPUT $OUTPUT
|
${tools_dir}/grib_compare $INPUT $OUTPUT
|
||||||
rm $OUTPUT || true
|
rm -f $OUTPUT
|
||||||
|
|
||||||
# GRIB-568 corrupt grib
|
# GRIB-568 corrupt grib
|
||||||
# We are expecting the command to fail so must turn off "set -e"
|
# We are expecting the command to fail so must turn off "set -e"
|
||||||
|
@ -18,5 +18,4 @@ status=$?
|
||||||
set -e
|
set -e
|
||||||
# Check command did indeed fail
|
# Check command did indeed fail
|
||||||
[ $status != 0 ]
|
[ $status != 0 ]
|
||||||
rm $OUTPUT || true
|
rm -f $OUTPUT
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue