Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data = []
field_names = self._get_abbr_names(subset_nr)
# print('field_names = ', field_names)
# print('DEBUG: names = ',self.get_names(subset_nr))
# print('subset: ', subset_nr)
for field in field_names:
if field[0] in string.digits:
print('cannot get data for field: ',field)
continue
# print('trying field name: ', field)
# key = '/subsetNumber={0:d}/{1:s}'.format(subset_nr, field)
key = field
# print('trying key: ', key)
s = eccodes.codes_get_size(self._bufr, key)
# print('s=', s)
if s==1:
value = eccodes.codes_get(self._bufr, key)
data.append(value)
else:
values = eccodes.codes_get_array(self._bufr, key)
# print('DEBUG: values: ', values)
data.append(values)
# finally convert to a numpy array of type object
# for user convenience
values = numpy.array(data, dtype='object')
return values
# #]
'code',
'units',
'scale',
'reference',
'width'
]
iterid = eccodes.codes_keys_iterator_new(self._bufr, 'ls')
while eccodes.codes_keys_iterator_next(iterid):
keyname = eccodes.codes_keys_iterator_get_name(iterid)
print(' %s: %s' %
(keyname, eccodes.codes_get(self._bufr, keyname)))
# get unexpanded descriptors
key = 'unexpandedDescriptors'
num = eccodes.codes_get_size(self._bufr, key)
print(' size of %s is: %s' % (key, num))
values = eccodes.codes_get_array(self._bufr, key)
for i in xrange(len(values)):
print(" %d %06d" % (i + 1, values[i]))
# get the expanded descriptors
key = 'bufrdcExpandedDescriptors'
num = eccodes.codes_get_size(self._bufr, key)
print(' size of %s is: %s' % (key, num))
values = eccodes.codes_get_array(self._bufr, key)
for i in xrange(len(values)):
print(" %d %06d" % (i + 1, values[i]))
def get_values(self, descr_nr, autoget_cval=False):
# #[
"""
request an array of values containing the values
for a given descriptor number for all subsets
NOTE: this may not work for templates using delayed replication.
"""
if (self.msg_index == -1):
raise NoMsgLoadedError
list_of_names = self._get_abbr_names()
keyname = list_of_names[descr_nr]
print('keyname: ', keyname)
s = eccodes.codes_get_size(self._bufr, keyname)
t = eccodes.codes_get_native_type(self._bufr, keyname)
print('key:', keyname, 'size = ', s, 'type = ', t)
if s==1: # or t==str:
# values = eccodes.codes_get_string(_bufr, keyname)
values = [eccodes.codes_get(self._bufr, keyname),]
else:
values = eccodes.codes_get_array(self._bufr, keyname)
return values
# #]
while eccodes.codes_keys_iterator_next(iterid):
keyname = eccodes.codes_keys_iterator_get_name(iterid)
print(' %s: %s' %
(keyname, eccodes.codes_get(self._bufr, keyname)))
# get unexpanded descriptors
key = 'unexpandedDescriptors'
num = eccodes.codes_get_size(self._bufr, key)
print(' size of %s is: %s' % (key, num))
values = eccodes.codes_get_array(self._bufr, key)
for i in xrange(len(values)):
print(" %d %06d" % (i + 1, values[i]))
# get the expanded descriptors
key = 'bufrdcExpandedDescriptors'
num = eccodes.codes_get_size(self._bufr, key)
print(' size of %s is: %s' % (key, num))
values = eccodes.codes_get_array(self._bufr, key)
for i in xrange(len(values)):
print(" %d %06d" % (i + 1, values[i]))