Make C, Fortran and Python examples ECC-15

This commit is contained in:
Sandor Kertesz 2015-03-23 17:35:23 +00:00
parent 5e3a078f67
commit ef6941fded
8 changed files with 51 additions and 38 deletions

View File

@ -55,18 +55,20 @@ def example():
#---------------------------------------------------------------
#get the value
key='airTemperatureAt2M'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
# print the values of the attributes of the key. Attributes themselves
# are keys as well. Their name is constructed like:
# keyname->attributename
for attr in attrs:
key='airTemperatureAt2M' + "->" + attr
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#--------------------------------------------------------------------
# The 2m temperature data element in this message has an associated
@ -76,17 +78,18 @@ def example():
#get the value
key='airTemperatureAt2M->percentConfidence'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
# print the values of the attributes of the key.
for attr in attrs:
key='airTemperatureAt2M->percentConfidence' + "->" + attr
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
cnt+=1

View File

@ -45,27 +45,32 @@ def example():
#----------------------------------------------
#Native type integer
key='blockNumber'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#Native type integer
key='stationNumber'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#Native type float
key='airTemperatureAt2M'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#Native type string
key='typicalDate'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#---------------------------------
# get values for an array

View File

@ -51,9 +51,11 @@ def example():
# print the values for the selected keys from the message
for key in keys:
if not codes_is_defined(gid,key): raise Exception("Key " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
cnt+=1
# delete handle

View File

@ -19,7 +19,7 @@ $PYTHON bufr_read_header.py 2> $REDIRECT > $fRes
#We compare output to the reference by ignoring the whitespaces
diff -w $fRef $fRes >$REDIRECT 2> $REDIRECT
cat $fRes
#cat $fRes
#Clean up
rm -f $fRes

View File

@ -72,8 +72,10 @@ def example():
# print the values for the selected keys from the message
for key in keys:
if not codes_is_defined(gid,key): raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
cnt+=1

View File

@ -24,7 +24,7 @@ rm -f $fTmp | true
REDIRECT=/dev/null
#Write the values into a file and compare with reference
$PYTHON bufr_read_synop.py #2> $REDIRECT > $fTmp
$PYTHON bufr_read_synop.py 2> $REDIRECT > $fTmp
#TODO: check the output

View File

@ -24,7 +24,7 @@ rm -f $fTmp | true
REDIRECT=/dev/null
#Write the key values into a file
$PYTHON bufr_read_temp.py #2> $REDIRECT > $fTmp
$PYTHON bufr_read_temp.py 2> $REDIRECT > $fTmp
#TODO: check the results

View File

@ -53,10 +53,11 @@ def example():
print ' set bufrHeaderCentre to: %d' % val
key='bufrHeaderCentre'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
codes_set(gid,key,val)
try:
print ' %s: %s' % (key,codes_set(gid,key,val))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#check bufrHeaderCentre's value
print ' %s''s new value is: %d' % (key,codes_get(gid,key))