Examples: add codes_get_double_elements for Python

This commit is contained in:
Shahram Najm 2019-03-26 17:22:28 +00:00
parent a97734cf99
commit 09a6ab48ad
1 changed files with 8 additions and 2 deletions

View File

@ -24,14 +24,20 @@ def example():
gid = codes_grib_new_from_file(f)
values = codes_get_values(gid)
for i in range(len(values)):
num_vals = len(values)
for i in range(num_vals):
print("%d %.10e" % (i + 1, values[i]))
print('%d values found in %s' % (len(values), INPUT))
print('%d values found in %s' % (num_vals, INPUT))
for key in ('max', 'min', 'average'):
print('%s=%.10e' % (key, codes_get(gid, key)))
# Example of accessing specific elements from data values
# Get first, middle and last elements
indexes = [0, num_vals/2, num_vals-1]
elems = codes_get_double_elements(gid, 'values', indexes)
codes_release(gid)
f.close()