def grib_index_get_long(indexid,key): """ @brief Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as long or when the native type of the key is long. \b Examples: \ref index.py "index.py" @param indexid id of an index created from a file. The index must have been created with the key in argument. @param key key for wich the values are returned @return tuple with values of key in index @exception GribInternalError """ nval = grib_index_get_size(indexid,key) a = _internal.new_longArray(nval) s = _internal.intp() s.assign(nval) GRIB_CHECK(_internal.grib_c_index_get_long(indexid,key,a,s)) result = [] for i in range(nval): result.append(_internal.longArray_getitem(a,i)) _internal.delete_longArray(a) _internal.delete_intp(s) return tuple(result)
def grib_get_long_array(gribid,key): """ @brief Get the integer array of values for a key from a grib message. If NumPy is enabled, the integer array will be stored in a NumPy ndarray. Otherwise, Python's native array type will be used. @param gribid id of the grib loaded in memory @param key key name @return numpy.ndarray or array @exception GribInternalError """ if with_numpy(): nval = grib_get_size(gribid,key) err,result = _internal.grib_get_long_ndarray(gribid,key,nval) GRIB_CHECK(err) return result else: nval = grib_get_size(gribid,key) a = _internal.new_longArray(nval) s = _internal.intp() s.assign(nval) GRIB_CHECK(_internal.grib_c_get_long_array(gribid,key,a,s)) result = array("l") for i in range(nval): result.append(_internal.longArray_getitem(a,i)) _internal.delete_longArray(a) _internal.delete_intp(s) return result