sdap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eamonf...@apache.org
Subject [incubator-sdap-ingester] branch dev updated: KelvinToCelsius converter can now parse 'units' or 'Units' field and exits gracefully if none exists (#28)
Date Tue, 05 Jan 2021 22:03:54 GMT
This is an automated email from the ASF dual-hosted git repository.

eamonford pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git


The following commit(s) were added to refs/heads/dev by this push:
     new 9f84b14  KelvinToCelsius converter can now parse 'units' or 'Units' field and exits
gracefully if none exists (#28)
9f84b14 is described below

commit 9f84b14c90130224ff733b7167409d3b151adc6a
Author: Eamon Ford <eamonford@gmail.com>
AuthorDate: Tue Jan 5 14:03:47 2021 -0800

    KelvinToCelsius converter can now parse 'units' or 'Units' field and exits gracefully
if none exists (#28)
---
 collection_manager/collection_manager/services/S3Observer.py   |  2 --
 .../granule_ingester/processors/kelvintocelsius.py             | 10 +++++++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/collection_manager/collection_manager/services/S3Observer.py b/collection_manager/collection_manager/services/S3Observer.py
index 87458a9..6d87d91 100644
--- a/collection_manager/collection_manager/services/S3Observer.py
+++ b/collection_manager/collection_manager/services/S3Observer.py
@@ -109,8 +109,6 @@ class S3Observer:
         end = time.perf_counter()
         duration = end - start
 
-        print(f"Retrieved {len(new_cache)} objects in {duration}")
-
         return new_cache
 
     def _get_object_key(full_path: str):
diff --git a/granule_ingester/granule_ingester/processors/kelvintocelsius.py b/granule_ingester/granule_ingester/processors/kelvintocelsius.py
index 9ad4f49..c0a9285 100644
--- a/granule_ingester/granule_ingester/processors/kelvintocelsius.py
+++ b/granule_ingester/granule_ingester/processors/kelvintocelsius.py
@@ -27,7 +27,15 @@ 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']
+            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))


Mime
View raw message