ECC-428: Inconsistent number of values when decoding compressed BUFR data

This commit is contained in:
Shahram Najm 2019-09-02 17:26:56 +01:00
commit 259dd1bfc7
21 changed files with 1087 additions and 9 deletions

View File

@ -2836,4 +2836,30 @@ subroutine codes_copy_key( msgid_src, key, msgid_dest, status )
endif
end subroutine codes_copy_key
subroutine codes_bufr_multi_element_constant_arrays_on (status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
iret=codes_f_bufr_multi_element_constant_arrays_on()
if (present(status)) then
status = iret
else
call grib_check(iret,'codes_bufr_multi_element_constant_arrays_on','')
endif
end subroutine codes_bufr_multi_element_constant_arrays_on
subroutine codes_bufr_multi_element_constant_arrays_off (status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
iret=codes_f_bufr_multi_element_constant_arrays_off()
if (present(status)) then
status = iret
else
call grib_check(iret,'codes_bufr_multi_element_constant_arrays_off','')
endif
end subroutine codes_bufr_multi_element_constant_arrays_off
end module eccodes

View File

@ -73,6 +73,7 @@ integer, external :: grib_f_set_int, grib_f_set_int_array, &
grib_f_set_force_real4_array, grib_f_set_force_real8_array, &
grib_f_set_string, grib_f_set_string_array, grib_f_set_missing, &
grib_f_gribex_mode_on,grib_f_gribex_mode_off, &
codes_f_bufr_multi_element_constant_arrays_on,codes_f_bufr_multi_element_constant_arrays_off, &
grib_f_find_nearest_single,grib_f_find_nearest_four_single,grib_f_find_nearest_multiple
integer, external :: grib_f_get_message_size, grib_f_copy_message, grib_f_count_in_file
integer, external :: grib_f_write, grib_f_multi_write, grib_f_multi_append

View File

@ -3472,6 +3472,31 @@ int grib_f_multi_append__(int* ingid, int* sec,int* mgid) {
return grib_f_multi_append_(ingid, sec, mgid);
}
/*****************************************************************************/
int codes_f_bufr_multi_element_constant_arrays_on_() {
codes_bufr_multi_element_constant_arrays_on(NULL);
return GRIB_SUCCESS;
}
int codes_f_bufr_multi_element_constant_arrays_on__() {
return codes_f_bufr_multi_element_constant_arrays_on_();
}
int codes_f_bufr_multi_element_constant_arrays_on() {
return codes_f_bufr_multi_element_constant_arrays_on_();
}
int codes_f_bufr_multi_element_constant_arrays_off_() {
codes_bufr_multi_element_constant_arrays_off(NULL);
return GRIB_SUCCESS;
}
int codes_f_bufr_multi_element_constant_arrays_off__() {
return codes_f_bufr_multi_element_constant_arrays_off_();
}
int codes_f_bufr_multi_element_constant_arrays_off() {
return codes_f_bufr_multi_element_constant_arrays_off_();
}
/*****************************************************************************/
int grib_f_set_definitions_path_(char* path, int len){
grib_context* c = grib_context_get_default();

View File

@ -374,6 +374,13 @@ int codes_f_bufr_copy_data(int* gid1,int* gid2);
int codes_f_bufr_copy_data_(int* gid1,int* gid2);
int codes_f_bufr_copy_data__(int* gid1,int* gid2);
int codes_f_bufr_multi_element_constant_arrays_on_(void);
int codes_f_bufr_multi_element_constant_arrays_on__(void);
int codes_f_bufr_multi_element_constant_arrays_on(void);
int codes_f_bufr_multi_element_constant_arrays_off_(void);
int codes_f_bufr_multi_element_constant_arrays_off__(void);
int codes_f_bufr_multi_element_constant_arrays_off(void);
int grib_f_set_definitions_path_(char *path, int len);
int grib_f_set_definitions_path__(char *path, int len);
int grib_f_set_definitions_path(char *path, int len);

View File

@ -106,5 +106,8 @@ from gribapi import grib_new_from_message as codes_new_from_message
from gribapi import grib_set_definitions_path as codes_set_definitions_path
from gribapi import grib_set_samples_path as codes_set_samples_path
from gribapi import codes_bufr_multi_element_constant_arrays_on
from gribapi import codes_bufr_multi_element_constant_arrays_off
from gribapi import GribInternalError as CodesInternalError
from gribapi.errors import *

View File

@ -2343,3 +2343,15 @@ void grib_c_set_samples_path(const char* path)
grib_context *c = grib_context_get_default();
grib_context_set_samples_path(c, path);
}
int codes_c_bufr_multi_element_constant_arrays_on(void)
{
codes_bufr_multi_element_constant_arrays_on(NULL);
return GRIB_SUCCESS;
}
int codes_c_bufr_multi_element_constant_arrays_off(void)
{
codes_bufr_multi_element_constant_arrays_off(NULL);
return GRIB_SUCCESS;
}

View File

@ -22,6 +22,9 @@ int codes_c_bufr_keys_iterator_get_name(int *iterid, char *name, int len);
int codes_c_bufr_keys_iterator_rewind(int *kiter);
int codes_c_bufr_keys_iterator_delete(int *iterid);
int codes_c_bufr_multi_element_constant_arrays_off(void);
int codes_c_bufr_multi_element_constant_arrays_on(void);
int grib_c_gribex_mode_on(void);
int grib_c_gribex_mode_off(void);
int grib_c_skip_computed(int *iterid);

View File

@ -1946,3 +1946,26 @@ def grib_set_samples_path(samples_path):
@param samples_path samples path
"""
_internal.grib_c_set_samples_path(samples_path)
def codes_bufr_multi_element_constant_arrays_on():
"""
@brief BUFR: Turn on the mode where you get multiple elements
in constant arrays
@exception GribInternalError
"""
_internal.codes_c_bufr_multi_element_constant_arrays_on()
def codes_bufr_multi_element_constant_arrays_off():
"""
@brief BUFR: Turn off the mode where you get multiple elements
in constant arrays i.e. you get a single element
@exception GribInternalError
"""
_internal.codes_c_bufr_multi_element_constant_arrays_off()

View File

@ -90,6 +90,11 @@ int grib_c_gribex_mode_on(void);
int grib_c_gribex_mode_off(void);
// ---
// BUFR bufr_multi_element_constant_arrays mode
int codes_c_bufr_multi_element_constant_arrays_on(void);
int codes_c_bufr_multi_element_constant_arrays_off(void);
// ---
// keys iterator
int grib_c_keys_iterator_next(int* iterid);
int codes_c_bufr_keys_iterator_next(int* iterid);

681
python/gribapi_swig.py Normal file
View File

@ -0,0 +1,681 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.40
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
# This file is compatible with both classic and new-style classes.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_gribapi_swig', [dirname(__file__)])
except ImportError:
import _gribapi_swig
return _gribapi_swig
if fp is not None:
try:
_mod = imp.load_module('_gribapi_swig', fp, pathname, description)
finally:
fp.close()
return _mod
_gribapi_swig = swig_import_helper()
del swig_import_helper
else:
import _gribapi_swig
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static) or hasattr(self,name):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object : pass
_newclass = 0
def cdata(*args):
return _gribapi_swig.cdata(*args)
cdata = _gribapi_swig.cdata
def memmove(*args):
return _gribapi_swig.memmove(*args)
memmove = _gribapi_swig.memmove
GRIB_SUCCESS = _gribapi_swig.GRIB_SUCCESS
GRIB_END_OF_FILE = _gribapi_swig.GRIB_END_OF_FILE
GRIB_INTERNAL_ERROR = _gribapi_swig.GRIB_INTERNAL_ERROR
GRIB_BUFFER_TOO_SMALL = _gribapi_swig.GRIB_BUFFER_TOO_SMALL
GRIB_NOT_IMPLEMENTED = _gribapi_swig.GRIB_NOT_IMPLEMENTED
GRIB_7777_NOT_FOUND = _gribapi_swig.GRIB_7777_NOT_FOUND
GRIB_ARRAY_TOO_SMALL = _gribapi_swig.GRIB_ARRAY_TOO_SMALL
GRIB_FILE_NOT_FOUND = _gribapi_swig.GRIB_FILE_NOT_FOUND
GRIB_CODE_NOT_FOUND_IN_TABLE = _gribapi_swig.GRIB_CODE_NOT_FOUND_IN_TABLE
GRIB_WRONG_ARRAY_SIZE = _gribapi_swig.GRIB_WRONG_ARRAY_SIZE
GRIB_NOT_FOUND = _gribapi_swig.GRIB_NOT_FOUND
GRIB_IO_PROBLEM = _gribapi_swig.GRIB_IO_PROBLEM
GRIB_INVALID_MESSAGE = _gribapi_swig.GRIB_INVALID_MESSAGE
GRIB_DECODING_ERROR = _gribapi_swig.GRIB_DECODING_ERROR
GRIB_ENCODING_ERROR = _gribapi_swig.GRIB_ENCODING_ERROR
GRIB_NO_MORE_IN_SET = _gribapi_swig.GRIB_NO_MORE_IN_SET
GRIB_GEOCALCULUS_PROBLEM = _gribapi_swig.GRIB_GEOCALCULUS_PROBLEM
GRIB_OUT_OF_MEMORY = _gribapi_swig.GRIB_OUT_OF_MEMORY
GRIB_READ_ONLY = _gribapi_swig.GRIB_READ_ONLY
GRIB_INVALID_ARGUMENT = _gribapi_swig.GRIB_INVALID_ARGUMENT
GRIB_NULL_HANDLE = _gribapi_swig.GRIB_NULL_HANDLE
GRIB_INVALID_SECTION_NUMBER = _gribapi_swig.GRIB_INVALID_SECTION_NUMBER
GRIB_VALUE_CANNOT_BE_MISSING = _gribapi_swig.GRIB_VALUE_CANNOT_BE_MISSING
GRIB_WRONG_LENGTH = _gribapi_swig.GRIB_WRONG_LENGTH
GRIB_INVALID_TYPE = _gribapi_swig.GRIB_INVALID_TYPE
GRIB_WRONG_STEP = _gribapi_swig.GRIB_WRONG_STEP
GRIB_WRONG_STEP_UNIT = _gribapi_swig.GRIB_WRONG_STEP_UNIT
GRIB_INVALID_FILE = _gribapi_swig.GRIB_INVALID_FILE
GRIB_INVALID_GRIB = _gribapi_swig.GRIB_INVALID_GRIB
GRIB_INVALID_INDEX = _gribapi_swig.GRIB_INVALID_INDEX
GRIB_INVALID_ITERATOR = _gribapi_swig.GRIB_INVALID_ITERATOR
GRIB_INVALID_KEYS_ITERATOR = _gribapi_swig.GRIB_INVALID_KEYS_ITERATOR
GRIB_INVALID_NEAREST = _gribapi_swig.GRIB_INVALID_NEAREST
GRIB_INVALID_ORDERBY = _gribapi_swig.GRIB_INVALID_ORDERBY
GRIB_MISSING_KEY = _gribapi_swig.GRIB_MISSING_KEY
GRIB_OUT_OF_AREA = _gribapi_swig.GRIB_OUT_OF_AREA
GRIB_CONCEPT_NO_MATCH = _gribapi_swig.GRIB_CONCEPT_NO_MATCH
GRIB_HASH_ARRAY_NO_MATCH = _gribapi_swig.GRIB_HASH_ARRAY_NO_MATCH
GRIB_NO_DEFINITIONS = _gribapi_swig.GRIB_NO_DEFINITIONS
GRIB_WRONG_TYPE = _gribapi_swig.GRIB_WRONG_TYPE
GRIB_END = _gribapi_swig.GRIB_END
GRIB_NO_VALUES = _gribapi_swig.GRIB_NO_VALUES
GRIB_WRONG_GRID = _gribapi_swig.GRIB_WRONG_GRID
GRIB_END_OF_INDEX = _gribapi_swig.GRIB_END_OF_INDEX
GRIB_NULL_INDEX = _gribapi_swig.GRIB_NULL_INDEX
GRIB_PREMATURE_END_OF_FILE = _gribapi_swig.GRIB_PREMATURE_END_OF_FILE
GRIB_INTERNAL_ARRAY_TOO_SMALL = _gribapi_swig.GRIB_INTERNAL_ARRAY_TOO_SMALL
GRIB_MESSAGE_TOO_LARGE = _gribapi_swig.GRIB_MESSAGE_TOO_LARGE
GRIB_CONSTANT_FIELD = _gribapi_swig.GRIB_CONSTANT_FIELD
GRIB_SWITCH_NO_MATCH = _gribapi_swig.GRIB_SWITCH_NO_MATCH
GRIB_UNDERFLOW = _gribapi_swig.GRIB_UNDERFLOW
GRIB_MESSAGE_MALFORMED = _gribapi_swig.GRIB_MESSAGE_MALFORMED
GRIB_CORRUPTED_INDEX = _gribapi_swig.GRIB_CORRUPTED_INDEX
GRIB_INVALID_BPV = _gribapi_swig.GRIB_INVALID_BPV
GRIB_DIFFERENT_EDITION = _gribapi_swig.GRIB_DIFFERENT_EDITION
GRIB_VALUE_DIFFERENT = _gribapi_swig.GRIB_VALUE_DIFFERENT
GRIB_INVALID_KEY_VALUE = _gribapi_swig.GRIB_INVALID_KEY_VALUE
GRIB_STRING_TOO_SMALL = _gribapi_swig.GRIB_STRING_TOO_SMALL
GRIB_WRONG_CONVERSION = _gribapi_swig.GRIB_WRONG_CONVERSION
GRIB_MISSING_BUFR_ENTRY = _gribapi_swig.GRIB_MISSING_BUFR_ENTRY
GRIB_NULL_POINTER = _gribapi_swig.GRIB_NULL_POINTER
GRIB_ATTRIBUTE_CLASH = _gribapi_swig.GRIB_ATTRIBUTE_CLASH
GRIB_TOO_MANY_ATTRIBUTES = _gribapi_swig.GRIB_TOO_MANY_ATTRIBUTES
GRIB_ATTRIBUTE_NOT_FOUND = _gribapi_swig.GRIB_ATTRIBUTE_NOT_FOUND
GRIB_UNSUPPORTED_EDITION = _gribapi_swig.GRIB_UNSUPPORTED_EDITION
GRIB_OUT_OF_RANGE = _gribapi_swig.GRIB_OUT_OF_RANGE
GRIB_WRONG_BITMAP_SIZE = _gribapi_swig.GRIB_WRONG_BITMAP_SIZE
class intp(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, intp, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, intp, name)
__repr__ = _swig_repr
def __init__(self):
this = _gribapi_swig.new_intp()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _gribapi_swig.delete_intp
__del__ = lambda self : None;
def assign(self, *args): return _gribapi_swig.intp_assign(self, *args)
def value(self): return _gribapi_swig.intp_value(self)
def cast(self): return _gribapi_swig.intp_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _gribapi_swig.intp_frompointer
if _newclass:frompointer = staticmethod(_gribapi_swig.intp_frompointer)
intp_swigregister = _gribapi_swig.intp_swigregister
intp_swigregister(intp)
def intp_frompointer(*args):
return _gribapi_swig.intp_frompointer(*args)
intp_frompointer = _gribapi_swig.intp_frompointer
class sizetp(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, sizetp, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, sizetp, name)
__repr__ = _swig_repr
def __init__(self):
this = _gribapi_swig.new_sizetp()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _gribapi_swig.delete_sizetp
__del__ = lambda self : None;
def assign(self, *args): return _gribapi_swig.sizetp_assign(self, *args)
def value(self): return _gribapi_swig.sizetp_value(self)
def cast(self): return _gribapi_swig.sizetp_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _gribapi_swig.sizetp_frompointer
if _newclass:frompointer = staticmethod(_gribapi_swig.sizetp_frompointer)
sizetp_swigregister = _gribapi_swig.sizetp_swigregister
sizetp_swigregister(sizetp)
def sizetp_frompointer(*args):
return _gribapi_swig.sizetp_frompointer(*args)
sizetp_frompointer = _gribapi_swig.sizetp_frompointer
class longp(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, longp, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, longp, name)
__repr__ = _swig_repr
def __init__(self):
this = _gribapi_swig.new_longp()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _gribapi_swig.delete_longp
__del__ = lambda self : None;
def assign(self, *args): return _gribapi_swig.longp_assign(self, *args)
def value(self): return _gribapi_swig.longp_value(self)
def cast(self): return _gribapi_swig.longp_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _gribapi_swig.longp_frompointer
if _newclass:frompointer = staticmethod(_gribapi_swig.longp_frompointer)
longp_swigregister = _gribapi_swig.longp_swigregister
longp_swigregister(longp)
def longp_frompointer(*args):
return _gribapi_swig.longp_frompointer(*args)
longp_frompointer = _gribapi_swig.longp_frompointer
class doublep(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, doublep, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, doublep, name)
__repr__ = _swig_repr
def __init__(self):
this = _gribapi_swig.new_doublep()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _gribapi_swig.delete_doublep
__del__ = lambda self : None;
def assign(self, *args): return _gribapi_swig.doublep_assign(self, *args)
def value(self): return _gribapi_swig.doublep_value(self)
def cast(self): return _gribapi_swig.doublep_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _gribapi_swig.doublep_frompointer
if _newclass:frompointer = staticmethod(_gribapi_swig.doublep_frompointer)
doublep_swigregister = _gribapi_swig.doublep_swigregister
doublep_swigregister(doublep)
def doublep_frompointer(*args):
return _gribapi_swig.doublep_frompointer(*args)
doublep_frompointer = _gribapi_swig.doublep_frompointer
def new_doubleArray(*args):
return _gribapi_swig.new_doubleArray(*args)
new_doubleArray = _gribapi_swig.new_doubleArray
def delete_doubleArray(*args):
return _gribapi_swig.delete_doubleArray(*args)
delete_doubleArray = _gribapi_swig.delete_doubleArray
def doubleArray_getitem(*args):
return _gribapi_swig.doubleArray_getitem(*args)
doubleArray_getitem = _gribapi_swig.doubleArray_getitem
def doubleArray_setitem(*args):
return _gribapi_swig.doubleArray_setitem(*args)
doubleArray_setitem = _gribapi_swig.doubleArray_setitem
def new_longArray(*args):
return _gribapi_swig.new_longArray(*args)
new_longArray = _gribapi_swig.new_longArray
def delete_longArray(*args):
return _gribapi_swig.delete_longArray(*args)
delete_longArray = _gribapi_swig.delete_longArray
def longArray_getitem(*args):
return _gribapi_swig.longArray_getitem(*args)
longArray_getitem = _gribapi_swig.longArray_getitem
def longArray_setitem(*args):
return _gribapi_swig.longArray_setitem(*args)
longArray_setitem = _gribapi_swig.longArray_setitem
def new_intArray(*args):
return _gribapi_swig.new_intArray(*args)
new_intArray = _gribapi_swig.new_intArray
def delete_intArray(*args):
return _gribapi_swig.delete_intArray(*args)
delete_intArray = _gribapi_swig.delete_intArray
def intArray_getitem(*args):
return _gribapi_swig.intArray_getitem(*args)
intArray_getitem = _gribapi_swig.intArray_getitem
def intArray_setitem(*args):
return _gribapi_swig.intArray_setitem(*args)
intArray_setitem = _gribapi_swig.intArray_setitem
def new_stringArray(*args):
return _gribapi_swig.new_stringArray(*args)
new_stringArray = _gribapi_swig.new_stringArray
def delete_stringArray(*args):
return _gribapi_swig.delete_stringArray(*args)
delete_stringArray = _gribapi_swig.delete_stringArray
def stringArray_getitem(*args):
return _gribapi_swig.stringArray_getitem(*args)
stringArray_getitem = _gribapi_swig.stringArray_getitem
def stringArray_setitem(*args):
return _gribapi_swig.stringArray_setitem(*args)
stringArray_setitem = _gribapi_swig.stringArray_setitem
def grib_c_new_from_file(*args):
return _gribapi_swig.grib_c_new_from_file(*args)
grib_c_new_from_file = _gribapi_swig.grib_c_new_from_file
def grib_c_new_any_from_file(*args):
return _gribapi_swig.grib_c_new_any_from_file(*args)
grib_c_new_any_from_file = _gribapi_swig.grib_c_new_any_from_file
def grib_c_new_bufr_from_file(*args):
return _gribapi_swig.grib_c_new_bufr_from_file(*args)
grib_c_new_bufr_from_file = _gribapi_swig.grib_c_new_bufr_from_file
def grib_c_new_gts_from_file(*args):
return _gribapi_swig.grib_c_new_gts_from_file(*args)
grib_c_new_gts_from_file = _gribapi_swig.grib_c_new_gts_from_file
def grib_c_new_metar_from_file(*args):
return _gribapi_swig.grib_c_new_metar_from_file(*args)
grib_c_new_metar_from_file = _gribapi_swig.grib_c_new_metar_from_file
def grib_c_iterator_new(*args):
return _gribapi_swig.grib_c_iterator_new(*args)
grib_c_iterator_new = _gribapi_swig.grib_c_iterator_new
def grib_c_keys_iterator_new(*args):
return _gribapi_swig.grib_c_keys_iterator_new(*args)
grib_c_keys_iterator_new = _gribapi_swig.grib_c_keys_iterator_new
def codes_c_bufr_keys_iterator_new(*args):
return _gribapi_swig.codes_c_bufr_keys_iterator_new(*args)
codes_c_bufr_keys_iterator_new = _gribapi_swig.codes_c_bufr_keys_iterator_new
def grib_c_grib_new_from_samples(*args):
return _gribapi_swig.grib_c_grib_new_from_samples(*args)
grib_c_grib_new_from_samples = _gribapi_swig.grib_c_grib_new_from_samples
def grib_c_bufr_new_from_samples(*args):
return _gribapi_swig.grib_c_bufr_new_from_samples(*args)
grib_c_bufr_new_from_samples = _gribapi_swig.grib_c_bufr_new_from_samples
def grib_c_index_new_from_file(*args):
return _gribapi_swig.grib_c_index_new_from_file(*args)
grib_c_index_new_from_file = _gribapi_swig.grib_c_index_new_from_file
def grib_c_index_add_file(*args):
return _gribapi_swig.grib_c_index_add_file(*args)
grib_c_index_add_file = _gribapi_swig.grib_c_index_add_file
def grib_c_new_from_index(*args):
return _gribapi_swig.grib_c_new_from_index(*args)
grib_c_new_from_index = _gribapi_swig.grib_c_new_from_index
def grib_c_index_write(*args):
return _gribapi_swig.grib_c_index_write(*args)
grib_c_index_write = _gribapi_swig.grib_c_index_write
def grib_c_index_read(*args):
return _gribapi_swig.grib_c_index_read(*args)
grib_c_index_read = _gribapi_swig.grib_c_index_read
def grib_c_new_from_message(*args):
return _gribapi_swig.grib_c_new_from_message(*args)
grib_c_new_from_message = _gribapi_swig.grib_c_new_from_message
def grib_c_count_in_file(*args):
return _gribapi_swig.grib_c_count_in_file(*args)
grib_c_count_in_file = _gribapi_swig.grib_c_count_in_file
def grib_c_release(*args):
return _gribapi_swig.grib_c_release(*args)
grib_c_release = _gribapi_swig.grib_c_release
def grib_c_write(*args):
return _gribapi_swig.grib_c_write(*args)
grib_c_write = _gribapi_swig.grib_c_write
def grib_c_get_size_long(*args):
return _gribapi_swig.grib_c_get_size_long(*args)
grib_c_get_size_long = _gribapi_swig.grib_c_get_size_long
def grib_c_get_string_length(*args):
return _gribapi_swig.grib_c_get_string_length(*args)
grib_c_get_string_length = _gribapi_swig.grib_c_get_string_length
def grib_c_clone(*args):
return _gribapi_swig.grib_c_clone(*args)
grib_c_clone = _gribapi_swig.grib_c_clone
def grib_c_copy_namespace(*args):
return _gribapi_swig.grib_c_copy_namespace(*args)
grib_c_copy_namespace = _gribapi_swig.grib_c_copy_namespace
def grib_c_get_message_size(*args):
return _gribapi_swig.grib_c_get_message_size(*args)
grib_c_get_message_size = _gribapi_swig.grib_c_get_message_size
def grib_c_get_message_offset(*args):
return _gribapi_swig.grib_c_get_message_offset(*args)
grib_c_get_message_offset = _gribapi_swig.grib_c_get_message_offset
def grib_c_get_native_type(*args):
return _gribapi_swig.grib_c_get_native_type(*args)
grib_c_get_native_type = _gribapi_swig.grib_c_get_native_type
def grib_c_multi_new():
return _gribapi_swig.grib_c_multi_new()
grib_c_multi_new = _gribapi_swig.grib_c_multi_new
def grib_c_multi_support_on():
return _gribapi_swig.grib_c_multi_support_on()
grib_c_multi_support_on = _gribapi_swig.grib_c_multi_support_on
def grib_c_multi_write(*args):
return _gribapi_swig.grib_c_multi_write(*args)
grib_c_multi_write = _gribapi_swig.grib_c_multi_write
def grib_c_multi_support_off():
return _gribapi_swig.grib_c_multi_support_off()
grib_c_multi_support_off = _gribapi_swig.grib_c_multi_support_off
def grib_c_multi_release(*args):
return _gribapi_swig.grib_c_multi_release(*args)
grib_c_multi_release = _gribapi_swig.grib_c_multi_release
def grib_c_multi_append(*args):
return _gribapi_swig.grib_c_multi_append(*args)
grib_c_multi_append = _gribapi_swig.grib_c_multi_append
def grib_c_gribex_mode_on():
return _gribapi_swig.grib_c_gribex_mode_on()
grib_c_gribex_mode_on = _gribapi_swig.grib_c_gribex_mode_on
def grib_c_gribex_mode_off():
return _gribapi_swig.grib_c_gribex_mode_off()
grib_c_gribex_mode_off = _gribapi_swig.grib_c_gribex_mode_off
def codes_c_bufr_multi_element_constant_arrays_on():
return _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_on()
codes_c_bufr_multi_element_constant_arrays_on = _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_on
def codes_c_bufr_multi_element_constant_arrays_off():
return _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_off()
codes_c_bufr_multi_element_constant_arrays_off = _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_off
def grib_c_keys_iterator_next(*args):
return _gribapi_swig.grib_c_keys_iterator_next(*args)
grib_c_keys_iterator_next = _gribapi_swig.grib_c_keys_iterator_next
def codes_c_bufr_keys_iterator_next(*args):
return _gribapi_swig.codes_c_bufr_keys_iterator_next(*args)
codes_c_bufr_keys_iterator_next = _gribapi_swig.codes_c_bufr_keys_iterator_next
def grib_c_keys_iterator_delete(*args):
return _gribapi_swig.grib_c_keys_iterator_delete(*args)
grib_c_keys_iterator_delete = _gribapi_swig.grib_c_keys_iterator_delete
def codes_c_bufr_keys_iterator_delete(*args):
return _gribapi_swig.codes_c_bufr_keys_iterator_delete(*args)
codes_c_bufr_keys_iterator_delete = _gribapi_swig.codes_c_bufr_keys_iterator_delete
def grib_c_skip_computed(*args):
return _gribapi_swig.grib_c_skip_computed(*args)
grib_c_skip_computed = _gribapi_swig.grib_c_skip_computed
def grib_c_skip_coded(*args):
return _gribapi_swig.grib_c_skip_coded(*args)
grib_c_skip_coded = _gribapi_swig.grib_c_skip_coded
def grib_c_skip_edition_specific(*args):
return _gribapi_swig.grib_c_skip_edition_specific(*args)
grib_c_skip_edition_specific = _gribapi_swig.grib_c_skip_edition_specific
def grib_c_skip_duplicates(*args):
return _gribapi_swig.grib_c_skip_duplicates(*args)
grib_c_skip_duplicates = _gribapi_swig.grib_c_skip_duplicates
def grib_c_skip_read_only(*args):
return _gribapi_swig.grib_c_skip_read_only(*args)
grib_c_skip_read_only = _gribapi_swig.grib_c_skip_read_only
def grib_c_skip_function(*args):
return _gribapi_swig.grib_c_skip_function(*args)
grib_c_skip_function = _gribapi_swig.grib_c_skip_function
def grib_c_keys_iterator_rewind(*args):
return _gribapi_swig.grib_c_keys_iterator_rewind(*args)
grib_c_keys_iterator_rewind = _gribapi_swig.grib_c_keys_iterator_rewind
def codes_c_bufr_keys_iterator_rewind(*args):
return _gribapi_swig.codes_c_bufr_keys_iterator_rewind(*args)
codes_c_bufr_keys_iterator_rewind = _gribapi_swig.codes_c_bufr_keys_iterator_rewind
def grib_c_bufr_copy_data(*args):
return _gribapi_swig.grib_c_bufr_copy_data(*args)
grib_c_bufr_copy_data = _gribapi_swig.grib_c_bufr_copy_data
def grib_c_keys_iterator_get_name(*args):
return _gribapi_swig.grib_c_keys_iterator_get_name(*args)
grib_c_keys_iterator_get_name = _gribapi_swig.grib_c_keys_iterator_get_name
def codes_c_bufr_keys_iterator_get_name(*args):
return _gribapi_swig.codes_c_bufr_keys_iterator_get_name(*args)
codes_c_bufr_keys_iterator_get_name = _gribapi_swig.codes_c_bufr_keys_iterator_get_name
def grib_c_index_get_size_long(*args):
return _gribapi_swig.grib_c_index_get_size_long(*args)
grib_c_index_get_size_long = _gribapi_swig.grib_c_index_get_size_long
def grib_c_index_get_long(*args):
return _gribapi_swig.grib_c_index_get_long(*args)
grib_c_index_get_long = _gribapi_swig.grib_c_index_get_long
def grib_c_index_get_real8(*args):
return _gribapi_swig.grib_c_index_get_real8(*args)
grib_c_index_get_real8 = _gribapi_swig.grib_c_index_get_real8
def grib_c_index_get_string(*args):
return _gribapi_swig.grib_c_index_get_string(*args)
grib_c_index_get_string = _gribapi_swig.grib_c_index_get_string
def grib_c_index_select_long(*args):
return _gribapi_swig.grib_c_index_select_long(*args)
grib_c_index_select_long = _gribapi_swig.grib_c_index_select_long
def grib_c_index_select_real8(*args):
return _gribapi_swig.grib_c_index_select_real8(*args)
grib_c_index_select_real8 = _gribapi_swig.grib_c_index_select_real8
def grib_c_index_select_string(*args):
return _gribapi_swig.grib_c_index_select_string(*args)
grib_c_index_select_string = _gribapi_swig.grib_c_index_select_string
def grib_c_index_release(*args):
return _gribapi_swig.grib_c_index_release(*args)
grib_c_index_release = _gribapi_swig.grib_c_index_release
def grib_c_iterator_delete(*args):
return _gribapi_swig.grib_c_iterator_delete(*args)
grib_c_iterator_delete = _gribapi_swig.grib_c_iterator_delete
def grib_c_iterator_next(*args):
return _gribapi_swig.grib_c_iterator_next(*args)
grib_c_iterator_next = _gribapi_swig.grib_c_iterator_next
def grib_c_get_string(*args):
return _gribapi_swig.grib_c_get_string(*args)
grib_c_get_string = _gribapi_swig.grib_c_get_string
def grib_c_get_string_array(*args):
return _gribapi_swig.grib_c_get_string_array(*args)
grib_c_get_string_array = _gribapi_swig.grib_c_get_string_array
def grib_c_set_string(*args):
return _gribapi_swig.grib_c_set_string(*args)
grib_c_set_string = _gribapi_swig.grib_c_set_string
def grib_c_get_long(*args):
return _gribapi_swig.grib_c_get_long(*args)
grib_c_get_long = _gribapi_swig.grib_c_get_long
def grib_c_set_long(*args):
return _gribapi_swig.grib_c_set_long(*args)
grib_c_set_long = _gribapi_swig.grib_c_set_long
def grib_c_get_double(*args):
return _gribapi_swig.grib_c_get_double(*args)
grib_c_get_double = _gribapi_swig.grib_c_get_double
def grib_c_set_double(*args):
return _gribapi_swig.grib_c_set_double(*args)
grib_c_set_double = _gribapi_swig.grib_c_set_double
def grib_c_set_real8_array(*args):
return _gribapi_swig.grib_c_set_real8_array(*args)
grib_c_set_real8_array = _gribapi_swig.grib_c_set_real8_array
def grib_c_get_real8_array(*args):
return _gribapi_swig.grib_c_get_real8_array(*args)
grib_c_get_real8_array = _gribapi_swig.grib_c_get_real8_array
def grib_c_get_long_array(*args):
return _gribapi_swig.grib_c_get_long_array(*args)
grib_c_get_long_array = _gribapi_swig.grib_c_get_long_array
def grib_c_set_long_array(*args):
return _gribapi_swig.grib_c_set_long_array(*args)
grib_c_set_long_array = _gribapi_swig.grib_c_set_long_array
def grib_c_get_real8_element(*args):
return _gribapi_swig.grib_c_get_real8_element(*args)
grib_c_get_real8_element = _gribapi_swig.grib_c_get_real8_element
def grib_c_get_real8_elements(*args):
return _gribapi_swig.grib_c_get_real8_elements(*args)
grib_c_get_real8_elements = _gribapi_swig.grib_c_get_real8_elements
def grib_c_set_missing(*args):
return _gribapi_swig.grib_c_set_missing(*args)
grib_c_set_missing = _gribapi_swig.grib_c_set_missing
def grib_c_set_key_vals(*args):
return _gribapi_swig.grib_c_set_key_vals(*args)
grib_c_set_key_vals = _gribapi_swig.grib_c_set_key_vals
def grib_c_is_missing(*args):
return _gribapi_swig.grib_c_is_missing(*args)
grib_c_is_missing = _gribapi_swig.grib_c_is_missing
def grib_c_is_defined(*args):
return _gribapi_swig.grib_c_is_defined(*args)
grib_c_is_defined = _gribapi_swig.grib_c_is_defined
def grib_c_set_string_array(*args):
return _gribapi_swig.grib_c_set_string_array(*args)
grib_c_set_string_array = _gribapi_swig.grib_c_set_string_array
def grib_set_double_ndarray(*args):
return _gribapi_swig.grib_set_double_ndarray(*args)
grib_set_double_ndarray = _gribapi_swig.grib_set_double_ndarray
def grib_set_long_ndarray(*args):
return _gribapi_swig.grib_set_long_ndarray(*args)
grib_set_long_ndarray = _gribapi_swig.grib_set_long_ndarray
def grib_get_double_ndarray(*args):
return _gribapi_swig.grib_get_double_ndarray(*args)
grib_get_double_ndarray = _gribapi_swig.grib_get_double_ndarray
def grib_get_long_ndarray(*args):
return _gribapi_swig.grib_get_long_ndarray(*args)
grib_get_long_ndarray = _gribapi_swig.grib_get_long_ndarray
def grib_get_double_ndelements(*args):
return _gribapi_swig.grib_get_double_ndelements(*args)
grib_get_double_ndelements = _gribapi_swig.grib_get_double_ndelements
def grib_c_find_nearest_single(*args):
return _gribapi_swig.grib_c_find_nearest_single(*args)
grib_c_find_nearest_single = _gribapi_swig.grib_c_find_nearest_single
def grib_c_find_nearest_four_single(*args):
return _gribapi_swig.grib_c_find_nearest_four_single(*args)
grib_c_find_nearest_four_single = _gribapi_swig.grib_c_find_nearest_four_single
def grib_c_get_message(*args):
return _gribapi_swig.grib_c_get_message(*args)
grib_c_get_message = _gribapi_swig.grib_c_get_message
def grib_c_get_error_string(*args):
return _gribapi_swig.grib_c_get_error_string(*args)
grib_c_get_error_string = _gribapi_swig.grib_c_get_error_string
def no_fail_on_wrong_length(*args):
return _gribapi_swig.no_fail_on_wrong_length(*args)
no_fail_on_wrong_length = _gribapi_swig.no_fail_on_wrong_length
def grib_c_get_api_version():
return _gribapi_swig.grib_c_get_api_version()
grib_c_get_api_version = _gribapi_swig.grib_c_get_api_version
def grib_c_gts_header_on():
return _gribapi_swig.grib_c_gts_header_on()
grib_c_gts_header_on = _gribapi_swig.grib_c_gts_header_on
def grib_c_gts_header_off():
return _gribapi_swig.grib_c_gts_header_off()
grib_c_gts_header_off = _gribapi_swig.grib_c_gts_header_off
def grib_c_set_definitions_path(*args):
return _gribapi_swig.grib_c_set_definitions_path(*args)
grib_c_set_definitions_path = _gribapi_swig.grib_c_set_definitions_path
def grib_c_set_samples_path(*args):
return _gribapi_swig.grib_c_set_samples_path(*args)
grib_c_set_samples_path = _gribapi_swig.grib_c_set_samples_path

View File

@ -6167,6 +6167,32 @@ fail:
}
SWIGINTERN PyObject *_wrap_codes_c_bufr_multi_element_constant_arrays_on(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
int result;
if (!PyArg_ParseTuple(args,(char *)":codes_c_bufr_multi_element_constant_arrays_on")) SWIG_fail;
result = (int)codes_c_bufr_multi_element_constant_arrays_on();
resultobj = SWIG_From_int((int)(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_codes_c_bufr_multi_element_constant_arrays_off(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
int result;
if (!PyArg_ParseTuple(args,(char *)":codes_c_bufr_multi_element_constant_arrays_off")) SWIG_fail;
result = (int)codes_c_bufr_multi_element_constant_arrays_off();
resultobj = SWIG_From_int((int)(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_grib_c_keys_iterator_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
int *arg1 = (int *) 0 ;
@ -9083,6 +9109,8 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"grib_c_multi_append", _wrap_grib_c_multi_append, METH_VARARGS, NULL},
{ (char *)"grib_c_gribex_mode_on", _wrap_grib_c_gribex_mode_on, METH_VARARGS, NULL},
{ (char *)"grib_c_gribex_mode_off", _wrap_grib_c_gribex_mode_off, METH_VARARGS, NULL},
{ (char *)"codes_c_bufr_multi_element_constant_arrays_on", _wrap_codes_c_bufr_multi_element_constant_arrays_on, METH_VARARGS, NULL},
{ (char *)"codes_c_bufr_multi_element_constant_arrays_off", _wrap_codes_c_bufr_multi_element_constant_arrays_off, METH_VARARGS, NULL},
{ (char *)"grib_c_keys_iterator_next", _wrap_grib_c_keys_iterator_next, METH_VARARGS, NULL},
{ (char *)"codes_c_bufr_keys_iterator_next", _wrap_codes_c_bufr_keys_iterator_next, METH_VARARGS, NULL},
{ (char *)"grib_c_keys_iterator_delete", _wrap_grib_c_keys_iterator_delete, METH_VARARGS, NULL},

View File

@ -439,6 +439,14 @@ def grib_c_gribex_mode_off():
return _gribapi_swig.grib_c_gribex_mode_off()
grib_c_gribex_mode_off = _gribapi_swig.grib_c_gribex_mode_off
def codes_c_bufr_multi_element_constant_arrays_on():
return _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_on()
codes_c_bufr_multi_element_constant_arrays_on = _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_on
def codes_c_bufr_multi_element_constant_arrays_off():
return _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_off()
codes_c_bufr_multi_element_constant_arrays_off = _gribapi_swig.codes_c_bufr_multi_element_constant_arrays_off
def grib_c_keys_iterator_next(*args):
return _gribapi_swig.grib_c_keys_iterator_next(*args)
grib_c_keys_iterator_next = _gribapi_swig.grib_c_keys_iterator_next

View File

@ -1041,6 +1041,11 @@ int codes_get_gribex_mode(codes_context* c);
*/
void codes_gribex_mode_off(codes_context* c);
void codes_bufr_multi_element_constant_arrays_on(codes_context* c);
void codes_bufr_multi_element_constant_arrays_off(codes_context* c);
/*int codes_get_bufr_multi_element_constant_arrays(codes_context* c);*/
/**
* Sets the search path for definition files.
*

View File

@ -553,6 +553,7 @@ static int decode_string_array(grib_context* c, unsigned char* data, long* pos,
char* sval=0;
int j,modifiedWidth,width;
grib_sarray* sa=grib_sarray_new(c,self->numberOfSubsets,10);
int bufr_multi_element_constant_arrays = c->bufr_multi_element_constant_arrays;
modifiedWidth= bd->width;
@ -585,7 +586,15 @@ static int decode_string_array(grib_context* c, unsigned char* data, long* pos,
grib_sarray_push(c,sa,sval);
}
} else {
grib_sarray_push(c,sa,sval);
if (bufr_multi_element_constant_arrays) {
for (j=0;j<self->numberOfSubsets;j++) {
char* pStr = sval;
if (j>0) pStr = strdup(sval);
grib_sarray_push(c,sa,pStr);
}
} else {
grib_sarray_push(c,sa,sval);
}
}
grib_vsarray_push(c,self->stringValues,sa);
return ret;
@ -600,6 +609,7 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long
unsigned long lval;
int localReference,localWidth,modifiedWidth,modifiedReference;
double modifiedFactor,dval;
int bufr_multi_element_constant_arrays = c->bufr_multi_element_constant_arrays;
*err=0;
@ -643,13 +653,27 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long
grib_darray_push(c,ret,dval);
}
} else {
// ECC-428
if (grib_is_all_bits_one(lval,modifiedWidth) && canBeMissing) {
dval=GRIB_MISSING_DOUBLE;
} else {
dval=localReference*modifiedFactor;
}
grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g", modifiedWidth,lval,dval);
grib_darray_push(c,ret,dval);
/* dataPresentIndicator is special and has to have SINGLE VALUE if constant array */
if (bufr_multi_element_constant_arrays == 1 && bd->code == 31031) {
bufr_multi_element_constant_arrays=0;
}
if(bufr_multi_element_constant_arrays) {
grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g (const array multi values)", modifiedWidth,lval,dval,bd->code);
for (j=0;j<self->numberOfSubsets;j++) {
grib_darray_push(c,ret,dval);
}
} else {
grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g (const array single value)", modifiedWidth,lval,dval,bd->code);
grib_darray_push(c,ret,dval);
}
}
return ret;
@ -1135,7 +1159,14 @@ static int decode_replication(grib_context* c,grib_accessor_bufr_data_array* sel
}
if (self->compressedData) {
dval=grib_darray_new(c,1,100);
grib_darray_push(c,dval,(double)(*numberOfRepetitions));
if(c->bufr_multi_element_constant_arrays) {
long j;
for (j=0;j<self->numberOfSubsets;j++) {
grib_darray_push(c,dval,(double)(*numberOfRepetitions));
}
} else {
grib_darray_push(c,dval,(double)(*numberOfRepetitions));
}
grib_vdarray_push(c,self->numericValues,dval);
} else {
grib_darray_push(c,dval,(double)(*numberOfRepetitions));

View File

@ -1053,6 +1053,7 @@ struct grib_context
int ieee_packing;
int bufrdc_mode;
int bufr_set_to_missing_if_out_of_range;
int bufr_multi_element_constant_arrays;
FILE* log_stream;
grib_trie* classes;
grib_trie* lists;

View File

@ -981,6 +981,8 @@ void grib_context_free(const grib_context *c, void *p);
void grib_context_free_persistent(const grib_context *c, void *p);
void grib_context_reset(grib_context *c);
void grib_context_delete(grib_context *c);
void codes_bufr_multi_element_constant_arrays_on(grib_context* c);
void codes_bufr_multi_element_constant_arrays_off(grib_context* c);
void grib_context_set_definitions_path(grib_context *c, const char *path);
void grib_context_set_samples_path(grib_context *c, const char *path);
void *grib_context_malloc_persistent(const grib_context *c, size_t size);

View File

@ -335,6 +335,7 @@ static grib_context default_grib_context = {
0, /* ieee_packing */
0, /* bufrdc_mode */
0, /* bufr_set_to_missing_if_out_of_range */
0, /* bufr_multi_element_constant_arrays */
0, /* log_stream */
0, /* classes */
0, /* lists */
@ -368,6 +369,7 @@ grib_context* grib_context_get_default()
const char* keep_matrix = NULL;
const char* bufrdc_mode = NULL;
const char* bufr_set_to_missing_if_out_of_range = NULL;
const char* bufr_multi_element_constant_arrays = NULL;
const char* file_pool_max_opened_files = NULL;
#ifdef ENABLE_FLOATING_POINT_EXCEPTIONS
@ -377,6 +379,7 @@ grib_context* grib_context_get_default()
write_on_fail = codes_getenv("ECCODES_GRIB_WRITE_ON_FAIL");
bufrdc_mode = getenv("ECCODES_BUFRDC_MODE_ON");
bufr_set_to_missing_if_out_of_range = getenv("ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE");
bufr_multi_element_constant_arrays = getenv("ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS");
large_constant_fields = codes_getenv("ECCODES_GRIB_LARGE_CONSTANT_FIELDS");
no_abort = codes_getenv("ECCODES_NO_ABORT");
debug = codes_getenv("ECCODES_DEBUG");
@ -387,7 +390,7 @@ grib_context* grib_context_get_default()
no_big_group_split = codes_getenv("ECCODES_GRIB_NO_BIG_GROUP_SPLIT");
no_spd = codes_getenv("ECCODES_GRIB_NO_SPD");
keep_matrix = codes_getenv("ECCODES_GRIB_KEEP_MATRIX");
file_pool_max_opened_files = codes_getenv("ECCODES_FILE_POOL_MAX_OPENED_FILES");
file_pool_max_opened_files = getenv("ECCODES_FILE_POOL_MAX_OPENED_FILES");
/* On UNIX, when we read from a file we get exactly what is in the file on disk.
* But on Windows a file can be opened in binary or text mode. In binary mode the system behaves exactly as in UNIX.
@ -473,6 +476,8 @@ grib_context* grib_context_get_default()
default_grib_context.bufrdc_mode = bufrdc_mode ? atoi(bufrdc_mode) : 0;
default_grib_context.bufr_set_to_missing_if_out_of_range = bufr_set_to_missing_if_out_of_range ?
atoi(bufr_set_to_missing_if_out_of_range) : 0;
default_grib_context.bufr_multi_element_constant_arrays = bufr_multi_element_constant_arrays ?
atoi(bufr_multi_element_constant_arrays) : 0;
default_grib_context.file_pool_max_opened_files = file_pool_max_opened_files ?
atoi(file_pool_max_opened_files) : DEFAULT_FILE_POOL_MAX_OPENED_FILES;
}
@ -737,6 +742,19 @@ void grib_context_delete( grib_context* c)
grib_context_free_persistent(&default_grib_context,c);
}
void codes_bufr_multi_element_constant_arrays_on(grib_context* c)
{
if ( !c ) c=grib_context_get_default();
c->bufr_multi_element_constant_arrays = 1;
}
void codes_bufr_multi_element_constant_arrays_off(grib_context* c)
{
if ( !c ) c=grib_context_get_default();
c->bufr_multi_element_constant_arrays = 0;
}
/*int codes_get_bufr_multi_element_constant_arrays(grib_context* c);*/
void grib_context_set_definitions_path(grib_context* c, const char* path)
{
if (!c) c=grib_context_get_default();

View File

@ -240,19 +240,94 @@ static grib_accessor* search_by_rank(grib_handle* h, const char* name,int rank,c
}
}
static int condition_true(grib_accessor* a,codes_condition* condition) {
static int get_single_long_val(grib_accessor* a, long* result)
{
grib_context* c = a->context;
int err = 0;
size_t size = 1;
if (c->bufr_multi_element_constant_arrays) {
long count=0;
grib_value_count(a,&count);
if(count>1) {
size_t i = 0;
long val0 = 0;
int is_constant=1;
long* values=(long*)grib_context_malloc_clear(c,sizeof(long)*count);
size = count;
err=grib_unpack_long(a,values,&size);
val0 = values[0];
for (i=0;i<size;i++) {
if (val0 != values[i]) {is_constant=0;break;}
}
if (is_constant) {
*result = val0;
grib_context_free(c, values);
} else {
return GRIB_ARRAY_TOO_SMALL;
}
} else {
err = grib_unpack_long(a,result,&size);
}
} else {
err = grib_unpack_long(a,result,&size);
}
return err;
}
static int get_single_double_val(grib_accessor* a, double* result)
{
grib_context* c = a->context;
int err = 0;
size_t size = 1;
if (c->bufr_multi_element_constant_arrays) {
long count=0;
grib_value_count(a,&count);
if(count>1) {
size_t i = 0;
double val0 = 0;
int is_constant=1;
double* values=(double*)grib_context_malloc_clear(c,sizeof(double)*count);
size = count;
err=grib_unpack_double(a,values,&size);
val0 = values[0];
for (i=0;i<size;i++) {
if (val0 != values[i]) {is_constant=0;break;}
}
if (is_constant) {
*result = val0;
grib_context_free(c, values);
} else {
return GRIB_ARRAY_TOO_SMALL;
}
} else {
err = grib_unpack_double(a,result,&size);
}
} else {
err = grib_unpack_double(a,result,&size);
}
return err;
}
static int condition_true(grib_accessor* a,codes_condition* condition)
{
int ret=0, err=0;
size_t size=1;
long lval=0;
double dval=0;
/* The condition has to be of the form:
* key=value
* and the value has to be a single scalar (integer or double).
* If the key is an array of different values, then the condition is false.
* But if the key is a constant array and the value matches then it's true.
*/
switch (condition->rightType) {
case GRIB_TYPE_LONG:
err = grib_unpack_long(a,&lval,&size);
err = get_single_long_val(a, &lval);
if (err) ret = 0;
else ret = lval==condition->rightLong ? 1 : 0;
break;
case GRIB_TYPE_DOUBLE:
err = grib_unpack_double(a,&dval,&size);
err = get_single_double_val(a,&dval);
if (err) ret = 0;
else ret = dval==condition->rightDouble ? 1 : 0;
break;

View File

@ -92,6 +92,7 @@ list( APPEND tests_data_reqd
bufr_keys_iter
bufr_get_element
bufr_wmo_tables
bufr_ecc-428
bufr_ecc-197
bufr_ecc-286
bufr_ecc-288

118
tests/bufr_ecc-428.sh Executable file
View File

@ -0,0 +1,118 @@
#!/bin/sh
# Copyright 2005-2019 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.sh
# ---------------------------------------------------------
# This is the test for the JIRA issue ECC-428
# Decoding compressed BUFR data:
# Option to have constant arrays with multiple repeated values
# rather than a single value
# ---------------------------------------------------------
cd ${data_dir}/bufr
label="bufr_ecc_428_test"
tempRules=temp.${label}.filter
tempText=temp.${label}.text
tempErrs=temp.${label}.errs
tempRef1=temp.${label}.ref1
tempRef2=temp.${label}.ref2
# --------------------------------------------------------
# Test 1
# --------------------------------------------------------
bufrFile=airs_57.bufr # this has 15 subsets
cat > $tempRules <<EOF
set unpack=1;
print "[satelliteIdentifier!0]";
EOF
cat $tempRules
${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText
echo "784" > $tempRef1
diff $tempRef1 $tempText
export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1
${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText
echo "784 784 784 784 784 784 784 784 784 784 784 784 784 784 784" > $tempRef2
diff $tempRef2 $tempText
unset ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS
${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText
diff $tempRef1 $tempText
export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=0
${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText
diff $tempRef1 $tempText
# --------------------------------------------------------
# Test 2: percentConfidence
# --------------------------------------------------------
bufrFile=amv2_87.bufr
cat > $tempRules <<EOF
set unpack=1;
print "[#1#windDirection->percentConfidence!0]";
EOF
cat $tempRules
export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1
${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText 2>$tempErrs
grep -q '^48 54 59.*91 97' $tempText
# --------------------------------------------------------
# Test 3: string arrays
# --------------------------------------------------------
bufrFile=sentinel1.bufr
cat > $tempRules <<EOF
set unpack=1;
print "[stationAcquisition!0]";
EOF
cat $tempRules
export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1
${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText 2>$tempErrs
grep -q '^LBG LBG LBG LBG.*LBG$' $tempText
# --------------------------------------------------------
# Test 4: replication factors
# --------------------------------------------------------
bufrFile=sbu8_206.bufr
cat > $tempRules <<EOF
set unpack=1;
print "[delayedDescriptorReplicationFactor!0]";
EOF
cat $tempRules
export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1
${tools_dir}/codes_bufr_filter $tempRules $bufrFile > $tempText 2>$tempErrs
grep -q '^6 6 6.*24 24.*6 6' $tempText
# --------------------------------------------------------
# Test XX: Currently failing
# --------------------------------------------------------
bufrFile=asca_139.bufr
cat > $tempRules <<EOF
set unpack=1;
print "[/beamIdentifier=2/backscatter]";
EOF
cat $tempRules
${tools_dir}/codes_bufr_filter $tempRules $bufrFile >/dev/null
echo "TODO: Searching for backscatter ... currently failing"
export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1
${tools_dir}/codes_bufr_filter $tempRules $bufrFile 2>$tempErrs
cat $tempErrs
# Clean up
rm -rf $tempRules $tempText $tempRef1 $tempRef2 $tempErrs

View File

@ -139,6 +139,11 @@ int grib_tool_init(grib_runtime_options* options)
json=0;
}
if (grib_options_on("E:")) {
grib_context *c = grib_context_get_default();
if (c->bufr_multi_element_constant_arrays) {
grib_context_log(c, GRIB_LOG_ERROR, "Code generation for encoding is not implemented when ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS is enabled");
exit(1);
}
options->dump_mode = grib_options_get_option("E:");
check_code_gen_dump_mode(options->dump_mode);
json=0;