diff --git a/modules/util/util.py b/modules/util/util.py index 53c8c55de7d1c0cb791f1b3ade7686696c8bd4d5..35af7267221b2608dace7bd93c3f750a61023acb 100644 --- a/modules/util/util.py +++ b/modules/util/util.py @@ -295,14 +295,20 @@ def get_grid_values_all(h5f, grid_name, scale_factor_name='scale_factor', add_of attr = attrs.get(scale_factor_name) if attr is None: raise GenericException('Attribute: '+scale_factor_name+' not found for variable: '+grid_name) - scale_factor = attr[0] + if np.isscalar(attr): + scale_factor = attr + else: + scale_factor = attr[0] grd_vals = grd_vals * scale_factor if add_offset_name is not None: attr = attrs.get(add_offset_name) if attr is None: raise GenericException('Attribute: '+add_offset_name+' not found for variable: '+grid_name) - add_offset = attr[0] + if np.isscalar(attr): + add_offset = attr + else: + add_offset = attr[0] grd_vals = grd_vals + add_offset if range_name is not None: @@ -317,7 +323,10 @@ def get_grid_values_all(h5f, grid_name, scale_factor_name='scale_factor', add_of attr = attrs.get(fill_value_name) if attr is None: raise GenericException('Attribute: '+fill_value_name+' not found for variable: '+grid_name) - fill_value = attr[0] + if np.isscalar(attr): + fill_value = attr + else: + fill_value = attr[0] grd_vals = np.where(grd_vals == fill_value, np.nan, grd_vals) return grd_vals