From 1090f80c30faccc5ec7c8a95b427caabb5cce949 Mon Sep 17 00:00:00 2001 From: Klaus Zimmermann Date: Thu, 26 Oct 2017 13:56:31 +0200 Subject: [PATCH 1/3] Allow missing_value as a user set attribute This allows the user to set missing_value as an attribute on a cube while ensuring that it is saved as local attribute in the netcdf file. Signed-off-by: Klaus Zimmermann --- lib/iris/_cube_coord_common.py | 2 +- lib/iris/fileformats/netcdf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/iris/_cube_coord_common.py b/lib/iris/_cube_coord_common.py index dd49355bf4..e369a98369 100644 --- a/lib/iris/_cube_coord_common.py +++ b/lib/iris/_cube_coord_common.py @@ -33,7 +33,7 @@ class LimitedAttributeDict(dict): 'calendar', 'leap_month', 'leap_year', 'month_lengths', 'coordinates', 'grid_mapping', 'climatology', 'cell_methods', 'formula_terms', 'compress', - 'missing_value', 'add_offset', 'scale_factor', + 'add_offset', 'scale_factor', '_FillValue') def __init__(self, *args, **kwargs): diff --git a/lib/iris/fileformats/netcdf.py b/lib/iris/fileformats/netcdf.py index 1de8893f61..42b3d00587 100644 --- a/lib/iris/fileformats/netcdf.py +++ b/lib/iris/fileformats/netcdf.py @@ -91,7 +91,7 @@ # CF attributes that should not be global. _CF_DATA_ATTRS = ['flag_masks', 'flag_meanings', 'flag_values', - 'instance_dimension', 'sample_dimension', + 'instance_dimension', 'missing_value', 'sample_dimension', 'standard_error_multiplier'] # CF attributes that should only be global. From 0acbe922a3f61563490ea9b927ec778b80c39f02 Mon Sep 17 00:00:00 2001 From: Klaus Zimmermann Date: Fri, 27 Oct 2017 10:20:29 +0200 Subject: [PATCH 2/3] Fix license test break Signed-off-by: Klaus Zimmermann --- lib/iris/_cube_coord_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iris/_cube_coord_common.py b/lib/iris/_cube_coord_common.py index e369a98369..dfee248784 100644 --- a/lib/iris/_cube_coord_common.py +++ b/lib/iris/_cube_coord_common.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2010 - 2016, Met Office +# (C) British Crown Copyright 2010 - 2017, Met Office # # This file is part of Iris. # From bf71a4f71b8e75f912ec797b42e88a2239812512 Mon Sep 17 00:00:00 2001 From: Klaus Zimmermann Date: Fri, 27 Oct 2017 11:11:22 +0200 Subject: [PATCH 3/3] Added missing_value test This adds missing_value to the list of always data variable attributes in test_attributes. Signed-off-by: Klaus Zimmermann --- lib/iris/tests/test_netcdf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/iris/tests/test_netcdf.py b/lib/iris/tests/test_netcdf.py index 4f783c7f0d..ec92e59b29 100644 --- a/lib/iris/tests/test_netcdf.py +++ b/lib/iris/tests/test_netcdf.py @@ -714,6 +714,7 @@ def test_attributes(self): 'flag_masks': 'a', 'flag_meanings': 'b', 'flag_values': 'c', + 'missing_value': 1.e20, 'STASH': iris.fileformats.pp.STASH(1, 2, 3)} for k, v in six.iteritems(avars): self.cube.attributes[k] = v