This is an automated email from the ASF dual-hosted git repository. eamonford pushed a commit to branch fix_units_parser in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git
commit 365f84c1dac287052e4412807271e0c3e45db55a Author: Eamon Ford <[email protected]> AuthorDate: Tue Jan 5 13:22:04 2021 -0800 KelvinToCelsius converter can now parse 'units' or 'Units' field and exits gracefully if none exists --- granule_ingester/granule_ingester/processors/kelvintocelsius.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/granule_ingester/granule_ingester/processors/kelvintocelsius.py b/granule_ingester/granule_ingester/processors/kelvintocelsius.py index 9ad4f49..3d1a0a0 100644 --- a/granule_ingester/granule_ingester/processors/kelvintocelsius.py +++ b/granule_ingester/granule_ingester/processors/kelvintocelsius.py @@ -27,7 +27,13 @@ class KelvinToCelsius(TileProcessor): if 'dataset' in kwargs: ds = kwargs['dataset'] variable_name = tile.summary.data_var_name - variable_unit = ds.variables[variable_name].attrs['units'] + if 'units' in ds.variables[variable_name].attrs: + variable_unit = ds.variables[variable_name].attrs['units'] + elif 'Units' in ds.variables[variable_name].attrs: + variable_unit = ds.variables[variable_name].attrs['Units'] + else: + return tile + if any([unit in variable_unit.lower() for unit in kelvins]): var_data = from_shaped_array(the_tile_data.variable_data) - 273.15 the_tile_data.variable_data.CopyFrom(to_shaped_array(var_data))
