From 233db58fced7158c95d7a7bfd76fc324a05789d8 Mon Sep 17 00:00:00 2001 From: Marco Zuehlke Date: Mon, 14 Aug 2017 11:41:31 +0200 Subject: [PATCH] - only filter attributes containing None set attributes containing "0". - fix type annotation Fixes #309 --- cate/ops/normalize.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cate/ops/normalize.py b/cate/ops/normalize.py index 8cb340e80..9329407d3 100644 --- a/cate/ops/normalize.py +++ b/cate/ops/normalize.py @@ -184,7 +184,7 @@ def adjust_spatial_attrs(ds: xr.Dataset) -> xr.Dataset: geoattrs = _get_spatial_props(ds, dim) for key in geoattrs: - if geoattrs[key]: + if geoattrs[key] is not None: ds.attrs[key] = geoattrs[key] lon_min = ds.attrs['geospatial_lon_min'] @@ -235,7 +235,7 @@ def adjust_temporal_attrs(ds: xr.Dataset) -> xr.Dataset: return ds -def _get_spatial_props(ds: xr.Dataset, dim: str) -> tuple: +def _get_spatial_props(ds: xr.Dataset, dim: str) -> dict: """ Get spatial boundaries, resolution and units of the given dimension of the given dataset. If the 'bounds' are explicitly defined, these will be used for @@ -253,8 +253,7 @@ def _get_spatial_props(ds: xr.Dataset, dim: str) -> tuple: res_name = 'geospatial_{}_resolution'.format(dim) ret[res_name] = dim_res except KeyError: - raise ValueError('Dimension {} not found in the provided' - ' dataset.').format(dim) + raise ValueError('Dimension {} not found in the provided dataset.'.format(dim)) min_name = 'geospatial_{}_min'.format(dim) max_name = 'geospatial_{}_max'.format(dim)