diff --git a/examples/python/binary_message.py b/examples/python/binary_message.py index 8c6f5d527..ed65ba320 100644 --- a/examples/python/binary_message.py +++ b/examples/python/binary_message.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * VERBOSE=1 # verbose error reporting @@ -20,16 +20,16 @@ def example(): out = open(sys.argv[2],'w') while 1: - gid = grib_new_from_file(f) + gid = codes_new_from_file(f) if gid is None: break - message = grib_get_message(gid) + message = codes_get_message(gid) - newgid = grib_new_from_message(message) - grib_write(newgid,out) - grib_release(newgid) + newgid = codes_new_from_message(message) + codes_write(newgid,out) + codes_release(newgid) - grib_release(gid) + codes_release(gid) out.close() f.close() @@ -37,7 +37,7 @@ def example(): def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/clone.py b/examples/python/clone.py index feb562db9..2c5d02215 100644 --- a/examples/python/clone.py +++ b/examples/python/clone.py @@ -12,7 +12,7 @@ import traceback import sys import random -from gribapi import * +from eccodes import * INPUT='../../data/constant_field.grib1' OUTPUT='out.grib' @@ -22,23 +22,23 @@ def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = grib_new_from_file(fin) + gid = codes_new_from_file(fin) - nx = grib_get(gid,'Ni') - ny = grib_get(gid,'Nj') + nx = codes_get(gid,'Ni') + ny = codes_get(gid,'Nj') for step in range(0,24,6): - clone_id = grib_clone(gid) - grib_set(clone_id,'step',step) + clone_id = codes_clone(gid) + codes_set(clone_id,'step',step) values = [random.random() for i in range(nx*ny)] - grib_set_values(clone_id,values) + codes_set_values(clone_id,values) - grib_write(clone_id,fout) - grib_release(clone_id) + codes_write(clone_id,fout) + codes_release(clone_id) - grib_release(gid) + codes_release(gid) fin.close() fout.close() @@ -46,7 +46,7 @@ def example(): def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/count_messages.py b/examples/python/count_messages.py index 890bd0715..ac8eed998 100644 --- a/examples/python/count_messages.py +++ b/examples/python/count_messages.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/tigge_pf_ecmwf.grib2' VERBOSE=1 # verbose error reporting @@ -19,8 +19,8 @@ VERBOSE=1 # verbose error reporting def example(): f = open(INPUT) - mcount = grib_count_in_file(f) - gid_list = [grib_new_from_file(f) for i in range(mcount)] + mcount = codes_count_in_file(f) + gid_list = [codes_new_from_file(f) for i in range(mcount)] f.close() @@ -41,24 +41,24 @@ def example(): print "processing message number",i+1 for key in keys: - print '%s=%g' % (key,grib_get(gid,key)) + print '%s=%g' % (key,codes_get(gid,key)) print 'There are %d, average is %g, min is %g, max is %g' % ( - grib_get_size(gid,'values'), - grib_get(gid,'average'), - grib_get(gid,'min'), - grib_get(gid,'max') + codes_get_size(gid,'values'), + codes_get(gid,'average'), + codes_get(gid,'min'), + codes_get(gid,'max') ) print '-'*100 - grib_release(gid) + codes_release(gid) def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/get.py b/examples/python/get.py index 567c80d9e..b7eb58f22 100644 --- a/examples/python/get.py +++ b/examples/python/get.py @@ -9,7 +9,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/reduced_latlon_surface.grib1' VERBOSE=1 # verbose error reporting @@ -27,30 +27,30 @@ def example(): ] while 1: - gid = grib_new_from_file(f) + gid = codes_new_from_file(f) if gid is None: break for key in keys: - if not grib_is_defined(gid,key): raise Exception("Key was not defined") - print '%s=%s' % (key,grib_get(gid,key)) + if not codes_is_defined(gid,key): raise Exception("Key was not defined") + print '%s=%s' % (key,codes_get(gid,key)) - if grib_is_defined(gid,"A_very_silly_girl"): raise Exception("Key was defined") + if codes_is_defined(gid,"A_very_silly_girl"): raise Exception("Key was defined") print 'There are %d values, average is %f, min is %f, max is %f' % ( - grib_get_size(gid,'values'), - grib_get(gid,'average'), - grib_get(gid,'min'), - grib_get(gid,'max') + codes_get_size(gid,'values'), + codes_get(gid,'average'), + codes_get(gid,'min'), + codes_get(gid,'max') ) - grib_release(gid) + codes_release(gid) f.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/index.py b/examples/python/index.py index a747bf1b0..5a3721af3 100644 --- a/examples/python/index.py +++ b/examples/python/index.py @@ -11,7 +11,7 @@ import traceback import sys,os -from gribapi import * +from eccodes import * INPUT='../../data/index.grib' VERBOSE=1 # verbose error reporting @@ -33,45 +33,45 @@ def example(): iid = None if (os.path.exists(index_file)): - iid = grib_index_read(index_file) + iid = codes_index_read(index_file) else: - iid = grib_index_new_from_file(INPUT,index_keys) + iid = codes_index_new_from_file(INPUT,index_keys) # multiple files can be added to an index: - # grib_index_add_file(iid,"grib file to add") + # codes_index_add_file(iid,"grib file to add") - grib_index_write(iid,index_file) + codes_index_write(iid,index_file) index_vals = [] for key in index_keys: print "%sSize=%d" % ( key, - grib_index_get_size(iid,key) + codes_index_get_size(iid,key) ) - key_vals = grib_index_get(iid,key) + key_vals = codes_index_get(iid,key) print " ".join(key_vals) index_vals.append(key_vals) for prod in product(*index_vals): for i in range(len(index_keys)): - grib_index_select(iid,index_keys[i],prod[i]) + codes_index_select(iid,index_keys[i],prod[i]) while 1: - gid = grib_new_from_index(iid) + gid = codes_new_from_index(iid) if gid is None: break - print " ".join(["%s=%s" % (key,grib_get(gid,key)) for key in index_keys]) - grib_release(gid) + print " ".join(["%s=%s" % (key,codes_get(gid,key)) for key in index_keys]) + codes_release(gid) - grib_index_release(iid) + codes_index_release(iid) def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/iterator.py b/examples/python/iterator.py index 3a2643f15..fad911004 100644 --- a/examples/python/iterator.py +++ b/examples/python/iterator.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * VERBOSE=1 # verbose error reporting @@ -19,16 +19,16 @@ def example(INPUT): f = open(INPUT) while 1: - gid = grib_new_from_file(f) + gid = codes_new_from_file(f) if gid is None: break - iterid = grib_iterator_new(gid,0) + iterid = codes_iterator_new(gid,0) - missingValue = grib_get_double(gid,"missingValue") + missingValue = codes_get_double(gid,"missingValue") i=0 while 1: - result = grib_iterator_next(iterid) + result = codes_iterator_next(iterid) if not result: break [lat,lon,value] = result @@ -42,15 +42,15 @@ def example(INPUT): i += 1 - grib_iterator_delete(iterid) - grib_release(gid) + codes_iterator_delete(iterid) + codes_release(gid) f.close() def main(): try: example(sys.argv[1]) - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/keys_iterator.py b/examples/python/keys_iterator.py index 951c4d6ef..e1ac2e7e3 100644 --- a/examples/python/keys_iterator.py +++ b/examples/python/keys_iterator.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/reduced_latlon_surface.grib1' VERBOSE=1 # verbose error reporting @@ -20,33 +20,33 @@ def example(): f = open(INPUT) while 1: - gid = grib_new_from_file(f) + gid = codes_new_from_file(f) if gid is None: break - iterid = grib_keys_iterator_new(gid,'ls') + iterid = codes_keys_iterator_new(gid,'ls') # Different types of keys can be skipped - # grib_skip_computed(iterid) - # grib_skip_coded(iterid) - # grib_skip_edition_specific(iterid) - # grib_skip_duplicates(iterid) - # grib_skip_read_only(iterid) - # grib_skip_function(iterid) + # codes_skip_computed(iterid) + # codes_skip_coded(iterid) + # codes_skip_edition_specific(iterid) + # codes_skip_duplicates(iterid) + # codes_skip_read_only(iterid) + # codes_skip_function(iterid) - while grib_keys_iterator_next(iterid): - keyname = grib_keys_iterator_get_name(iterid) - keyval = grib_get_string(iterid,keyname) + while codes_keys_iterator_next(iterid): + keyname = codes_keys_iterator_get_name(iterid) + keyval = codes_get_string(iterid,keyname) print "%s = %s" % (keyname,keyval) - grib_keys_iterator_delete(iterid) - grib_release(gid) + codes_keys_iterator_delete(iterid) + codes_release(gid) f.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/keys_iterator_bufr.py b/examples/python/keys_iterator_bufr.py index e0680d6e7..cca2b7250 100644 --- a/examples/python/keys_iterator_bufr.py +++ b/examples/python/keys_iterator_bufr.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/gts.bufr' VERBOSE=1 # verbose error reporting @@ -23,30 +23,30 @@ def example(): bid = bufr_new_from_file(f) if bid is None: break - iterid = grib_keys_iterator_new(bid) + iterid = codes_keys_iterator_new(bid) # Different types of keys can be skipped - # grib_skip_computed(iterid) - # grib_skip_coded(iterid) - # grib_skip_edition_specific(iterid) - # grib_skip_duplicates(iterid) - # grib_skip_read_only(iterid) - # grib_skip_function(iterid) + # codes_skip_computed(iterid) + # codes_skip_coded(iterid) + # codes_skip_edition_specific(iterid) + # codes_skip_duplicates(iterid) + # codes_skip_read_only(iterid) + # codes_skip_function(iterid) - while grib_keys_iterator_next(iterid): - keyname = grib_keys_iterator_get_name(iterid) - keyval = grib_get_string(iterid,keyname) + while codes_keys_iterator_next(iterid): + keyname = codes_keys_iterator_get_name(iterid) + keyval = codes_get_string(iterid,keyname) print "%s = %s" % (keyname,keyval) - grib_keys_iterator_delete(iterid) - grib_release(bid) + codes_keys_iterator_delete(iterid) + codes_release(bid) f.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/keys_iterator_gts.py b/examples/python/keys_iterator_gts.py index 4b36430ea..8b517048b 100644 --- a/examples/python/keys_iterator_gts.py +++ b/examples/python/keys_iterator_gts.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/gts.bufr' VERBOSE=1 # verbose error reporting @@ -23,27 +23,27 @@ def example(): bid = gts_new_from_file(f) if bid is None: break - iterid = grib_keys_iterator_new(bid) + iterid = codes_keys_iterator_new(bid) # Different types of keys can be skipped - # grib_skip_computed(iterid) - # grib_skip_coded(iterid) - # grib_skip_read_only(iterid) + # codes_skip_computed(iterid) + # codes_skip_coded(iterid) + # codes_skip_read_only(iterid) - while grib_keys_iterator_next(iterid): - keyname = grib_keys_iterator_get_name(iterid) - keyval = grib_get_string(iterid,keyname) + while codes_keys_iterator_next(iterid): + keyname = codes_keys_iterator_get_name(iterid) + keyval = codes_get_string(iterid,keyname) print "%s = %s" % (keyname,keyval) - grib_keys_iterator_delete(iterid) - grib_release(bid) + codes_keys_iterator_delete(iterid) + codes_release(bid) f.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/multi_write.py b/examples/python/multi_write.py index 5f91a47dd..a9e7d3bdf 100644 --- a/examples/python/multi_write.py +++ b/examples/python/multi_write.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/sample.grib2' OUTPUT='out.grib' @@ -21,25 +21,25 @@ def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = grib_new_from_file(fin) + gid = codes_new_from_file(fin) - mgid = grib_multi_new() + mgid = codes_multi_new() for step in range(12,132,12): - grib_set(gid,"step",step) - grib_multi_append(gid,4,mgid) + codes_set(gid,"step",step) + codes_multi_append(gid,4,mgid) - grib_multi_write(mgid,fout) + codes_multi_write(mgid,fout) - grib_multi_release(mgid) - grib_release(gid) + codes_multi_release(mgid) + codes_release(gid) fin.close() fout.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/nearest.py b/examples/python/nearest.py index c1921cb07..fc26e4085 100644 --- a/examples/python/nearest.py +++ b/examples/python/nearest.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/reduced_gaussian_lsm.grib1' VERBOSE=1 # verbose error reporting @@ -20,27 +20,27 @@ def example(): points = ((30,-20),(13,234)) f = open(INPUT) - gid = grib_new_from_file(f) + gid = codes_new_from_file(f) for lat,lon in points: - nearest = grib_find_nearest(gid,lat,lon)[0] + nearest = codes_find_nearest(gid,lat,lon)[0] print lat,lon print nearest.lat,nearest.lon,nearest.value,nearest.distance,nearest.index - four = grib_find_nearest(gid,lat,lon,is_lsm = False,npoints = 4) + four = codes_find_nearest(gid,lat,lon,is_lsm = False,npoints = 4) for i in range(len(four)): print "- %d -" % i print four[i] print "-"*100 - grib_release(gid) + codes_release(gid) f.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/print_data.py b/examples/python/print_data.py index cf06b88c4..9d94f9302 100644 --- a/examples/python/print_data.py +++ b/examples/python/print_data.py @@ -11,31 +11,31 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/regular_latlon_surface.grib1' VERBOSE=1 # verbose error reporting def example(): f = open(INPUT) - gid = grib_new_from_file(f) + gid = codes_new_from_file(f) - values = grib_get_values(gid) + values = codes_get_values(gid) for i in xrange(len(values)): print "%d %.10e" % (i+1,values[i]) print '%d values found in %s' % (len(values),INPUT) for key in ('max','min','average'): - print '%s=%.10e' % (key,grib_get(gid,key)) + print '%s=%.10e' % (key,codes_get(gid,key)) - grib_release(gid) + codes_release(gid) f.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/samples.py b/examples/python/samples.py index a9c10103b..5344b6247 100644 --- a/examples/python/samples.py +++ b/examples/python/samples.py @@ -11,14 +11,14 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/tp_ecmwf.grib' OUTPUT='out.grib' VERBOSE=1 # verbose error reporting def example(): - sample_id = grib_new_from_samples("regular_ll_sfc_grib1") + sample_id = codes_new_from_samples("regular_ll_sfc_grib1") fin = open(INPUT) fout = open(OUTPUT,'w') @@ -34,10 +34,10 @@ def example(): prev_vals = None while 1: - gid = grib_new_from_file(fin) + gid = codes_new_from_file(fin) if gid is None: break - curr_vals = grib_get_values(gid) + curr_vals = codes_get_values(gid) if prev_vals is None: result = prev_vals = curr_vals @@ -54,16 +54,16 @@ def example(): keys['startStep'] += 12 keys['endStep'] += 12 - clone_id = grib_clone(sample_id) + clone_id = codes_clone(sample_id) for key in keys: - grib_set(clone_id,key,keys[key]) + codes_set(clone_id,key,keys[key]) - grib_set_values(clone_id,result * 1000) + codes_set_values(clone_id,result * 1000) - grib_write(clone_id,fout) + codes_write(clone_id,fout) - grib_release(gid) + codes_release(gid) fin.close() fout.close() @@ -71,7 +71,7 @@ def example(): def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/set.py b/examples/python/set.py index 41879be72..096aeda4d 100644 --- a/examples/python/set.py +++ b/examples/python/set.py @@ -9,7 +9,7 @@ import traceback import sys -from gribapi import * +from eccodes import * from datetime import date INPUT='../../data/regular_latlon_surface_constant.grib1' @@ -19,16 +19,16 @@ VERBOSE=1 # verbose error reporting def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = grib_new_from_file(fin) + gid = codes_new_from_file(fin) dt = date.today() today = "%d%02d%02d" % (dt.year,dt.month,dt.day) - grib_set(gid,'dataDate',int(today)) - grib_set(gid,'centre',80) + codes_set(gid,'dataDate',int(today)) + codes_set(gid,'centre',80) - centreIntVal = grib_get(gid,'centre',int) - centreStrVal = grib_get(gid,'centre',str) - dateStrVal = grib_get(gid,'dataDate',str) + centreIntVal = codes_get(gid,'centre',int) + centreStrVal = codes_get(gid,'centre',str) + dateStrVal = codes_get(gid,'dataDate',str) assert(centreIntVal == 80) assert(centreStrVal == 'cnmc') assert(dateStrVal == today) @@ -37,30 +37,30 @@ def example(): print 'get date as a string - date = %s' % dateStrVal # Now do the same but using set_key_vals, setting keys all at once - grib_set_key_vals(gid, 'level=1,centre=98') # with a String - assert(grib_get(gid,'centre',str) == 'ecmf') - assert(grib_get(gid,'level',int) == 1) + codes_set_key_vals(gid, 'level=1,centre=98') # with a String + assert(codes_get(gid,'centre',str) == 'ecmf') + assert(codes_get(gid,'level',int) == 1) - grib_set_key_vals(gid, ['level=2', 'centre=kwbc']) # with a Tuple - assert(grib_get(gid,'centre',int) == 7) - assert(grib_get(gid,'level',int) == 2) + codes_set_key_vals(gid, ['level=2', 'centre=kwbc']) # with a Tuple + assert(codes_get(gid,'centre',int) == 7) + assert(codes_get(gid,'level',int) == 2) - grib_set_key_vals(gid, {'level': 3, 'centre': 84}) # with a Dictionary - assert(grib_get(gid,'centre',str) == 'lfpw') - assert(grib_get(gid,'level',int) == 3) + codes_set_key_vals(gid, {'level': 3, 'centre': 84}) # with a Dictionary + assert(codes_get(gid,'centre',str) == 'lfpw') + assert(codes_get(gid,'level',int) == 3) - grib_gts_header(True) - grib_gts_header(False) + codes_gts_header(True) + codes_gts_header(False) - grib_write(gid,fout) - grib_release(gid) + codes_write(gid,fout) + codes_release(gid) fin.close() fout.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/set_bitmap.py b/examples/python/set_bitmap.py index b2bd41528..f81d8717d 100644 --- a/examples/python/set_bitmap.py +++ b/examples/python/set_bitmap.py @@ -8,7 +8,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT = '../../data/regular_latlon_surface.grib1' OUTPUT = 'out.grib' @@ -18,33 +18,33 @@ VERBOSE = 1 # verbose error reporting def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = grib_new_from_file(fin) + gid = codes_new_from_file(fin) - grib_set(gid,'missingValue', MISSING) - values = grib_get_values(gid) - grib_set(gid, 'bitmapPresent', 1) + codes_set(gid,'missingValue', MISSING) + values = codes_get_values(gid) + codes_set(gid, 'bitmapPresent', 1) # Change some data values to be missing num_missing = 0 for i in range(100): if i % 2 == 0: values[i] = MISSING num_missing += 1 - grib_set_values(gid, values) + codes_set_values(gid, values) # Check counts of missing and non-missing values - num_data = grib_get(gid,'numberOfDataPoints',int) - assert(grib_get(gid,'numberOfCodedValues',int) == num_data-num_missing) - assert(grib_get(gid,'numberOfMissing',int) == num_missing) + num_data = codes_get(gid,'numberOfDataPoints',int) + assert(codes_get(gid,'numberOfCodedValues',int) == num_data-num_missing) + assert(codes_get(gid,'numberOfMissing',int) == num_missing) - grib_write(gid,fout) - grib_release(gid) + codes_write(gid,fout) + codes_release(gid) fin.close() fout.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/set_missing.py b/examples/python/set_missing.py index 8ac955736..285649f62 100644 --- a/examples/python/set_missing.py +++ b/examples/python/set_missing.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * INPUT='../../data/tigge/tigge_ecmf_pl_t.grib' OUTPUT='out.grib' @@ -21,28 +21,28 @@ def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = grib_new_from_file(fin) + gid = codes_new_from_file(fin) - grib_set_long(gid, "scaledValueOfFirstFixedSurface", 15); - grib_set_long(gid, "scaleFactorOfFirstFixedSurface", 1) - level=grib_get_double(gid, "level") + codes_set_long(gid, "scaledValueOfFirstFixedSurface", 15); + codes_set_long(gid, "scaleFactorOfFirstFixedSurface", 1) + level=codes_get_double(gid, "level") assert( level == 1.5 ) # set type of level to surface - grib_set(gid,'typeOfFirstFixedSurface','sfc') - grib_set_missing(gid,'scaleFactorOfFirstFixedSurface') - grib_set_missing(gid,'scaledValueOfFirstFixedSurface') + codes_set(gid,'typeOfFirstFixedSurface','sfc') + codes_set_missing(gid,'scaleFactorOfFirstFixedSurface') + codes_set_missing(gid,'scaledValueOfFirstFixedSurface') - grib_write(gid,fout) + codes_write(gid,fout) - grib_release(gid) + codes_release(gid) fin.close() fout.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/examples/python/set_pv.py b/examples/python/set_pv.py index c9756969e..3cb2d86ef 100644 --- a/examples/python/set_pv.py +++ b/examples/python/set_pv.py @@ -11,7 +11,7 @@ import traceback import sys -from gribapi import * +from eccodes import * VERBOSE=1 # verbose error reporting @@ -29,22 +29,22 @@ def example(): assert(len(pv) == numberOfCoefficients) fout = open('out.grib1','w') - gid = grib_new_from_samples('reduced_gg_sfc_grib1') + gid = codes_new_from_samples('reduced_gg_sfc_grib1') - grib_set(gid,'typeOfLevel','hybrid') - grib_set(gid,'level',2) - grib_set(gid,'PVPresent',1) - grib_set_array(gid,'pv',pv) + codes_set(gid,'typeOfLevel','hybrid') + codes_set(gid,'level',2) + codes_set(gid,'PVPresent',1) + codes_set_array(gid,'pv',pv) - grib_write(gid,fout) + codes_write(gid,fout) - grib_release(gid) + codes_release(gid) fout.close() def main(): try: example() - except GribInternalError,err: + except CodesInternalError,err: if VERBOSE: traceback.print_exc(file=sys.stderr) else: diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 3e430b786..584beb6d1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -65,6 +65,7 @@ if( HAVE_PYTHON ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gribapi_swig.py DESTINATION ${PYTHON_DEST}) install(FILES gribapi.py DESTINATION ${PYTHON_DEST}) + install(FILES eccodes.py DESTINATION ${PYTHON_DEST}) endif() diff --git a/python/eccodes.py b/python/eccodes.py new file mode 100644 index 000000000..917fd27d3 --- /dev/null +++ b/python/eccodes.py @@ -0,0 +1,81 @@ +from gribapi import GRIB_CHECK as CODES_CHECK +from gribapi import grib_new_from_file as codes_new_from_file +from gribapi import grib_count_in_file as codes_count_in_file +from gribapi import grib_multi_support_on as codes_multi_support_on +from gribapi import grib_multi_support_off as codes_multi_support_off +from gribapi import grib_release as codes_release +from gribapi import grib_get_string as codes_get_string +from gribapi import grib_set_string as codes_set_string +from gribapi import grib_gribex_mode_on as codes_gribex_mode_on +from gribapi import grib_gribex_mode_off as codes_gribex_mode_off +from gribapi import grib_write as codes_write +from gribapi import grib_multi_write as codes_multi_write +from gribapi import grib_multi_append as codes_multi_append +from gribapi import grib_get_size as codes_get_size +from gribapi import grib_get_string_length as codes_get_string_length +from gribapi import grib_skip_computed as codes_skip_computed +from gribapi import grib_skip_coded as codes_skip_coded +from gribapi import grib_skip_edition_specific as codes_skip_edition_specific +from gribapi import grib_skip_duplicates as codes_skip_duplicates +from gribapi import grib_skip_read_only as codes_skip_read_only +from gribapi import grib_skip_function as codes_skip_function +from gribapi import grib_iterator_new as codes_iterator_new +from gribapi import grib_iterator_delete as codes_iterator_delete +from gribapi import grib_iterator_next as codes_iterator_next +from gribapi import grib_keys_iterator_new as codes_keys_iterator_new +from gribapi import grib_keys_iterator_next as codes_keys_iterator_next +from gribapi import grib_keys_iterator_delete as codes_keys_iterator_delete +from gribapi import grib_keys_iterator_get_name as codes_keys_iterator_get_name +from gribapi import grib_keys_iterator_rewind as codes_keys_iterator_rewind +from gribapi import grib_get_long as codes_get_long +from gribapi import grib_get_double as codes_get_double +from gribapi import grib_set_long as codes_set_long +from gribapi import grib_set_double as codes_set_double +from gribapi import grib_new_from_samples as codes_new_from_samples +from gribapi import grib_clone as codes_clone +from gribapi import grib_set_double_array as codes_set_double_array +from gribapi import grib_get_double_array as codes_get_double_array +from gribapi import grib_set_long_array as codes_set_long_array +from gribapi import grib_get_long_array as codes_get_long_array +from gribapi import grib_multi_new as codes_multi_new +from gribapi import grib_multi_release as codes_multi_release +from gribapi import grib_copy_namespace as codes_copy_namespace +from gribapi import grib_index_new_from_file as codes_index_new_from_file +from gribapi import grib_index_add_file as codes_index_add_file +from gribapi import grib_index_release as codes_index_release +from gribapi import grib_index_get_size as codes_index_get_size +from gribapi import grib_index_get_long as codes_index_get_long +from gribapi import grib_index_get_string as codes_index_get_string +from gribapi import grib_index_get_double as codes_index_get_double +from gribapi import grib_index_select_long as codes_index_select_long +from gribapi import grib_index_select_double as codes_index_select_double +from gribapi import grib_index_select_string as codes_index_select_string +from gribapi import grib_new_from_index as codes_new_from_index +from gribapi import grib_get_message_size as codes_get_message_size +from gribapi import grib_get_message_offset as codes_get_message_offset +from gribapi import grib_get_double_element as codes_get_double_element +from gribapi import grib_get_double_elements as codes_get_double_elements +from gribapi import grib_get_elements as codes_get_elements +from gribapi import grib_set_missing as codes_set_missing +from gribapi import grib_set_key_vals as codes_set_key_vals +from gribapi import grib_is_missing as codes_is_missing +from gribapi import grib_is_defined as codes_is_defined +from gribapi import grib_find_nearest as codes_find_nearest +from gribapi import grib_get_native_type as codes_get_native_type +from gribapi import grib_get as codes_get +from gribapi import grib_get_array as codes_get_array +from gribapi import grib_get_values as codes_get_values +from gribapi import grib_set_values as codes_set_values +from gribapi import grib_set as codes_set +from gribapi import grib_set_array as codes_set_array +from gribapi import grib_index_get as codes_index_get +from gribapi import grib_index_select as codes_index_select +from gribapi import grib_index_write as codes_index_write +from gribapi import grib_index_read as codes_index_read +from gribapi import grib_no_fail_on_wrong_length as codes_no_fail_on_wrong_length +from gribapi import grib_gts_header as codes_gts_header +from gribapi import grib_get_api_version as codes_get_api_version +from gribapi import grib_get_message as codes_get_message +from gribapi import grib_new_from_message as codes_new_from_message + +from gribapi import GribInternalError as CodesInternalError