Repository: climate
Updated Branches:
  refs/heads/master 2d30ef8ed -> 8cf58f88f


CLIMATE-797 Fix attribute error when dataset has no mask attribute


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/41412cae
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/41412cae
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/41412cae

Branch: refs/heads/master
Commit: 41412caea5c9330ccbec28f4130ced89361789f8
Parents: 7d6f5ae
Author: Michael Anderson <michaelanderson@Michaels-iMac.local>
Authored: Mon Nov 27 19:21:14 2017 -0500
Committer: Michael Anderson <michaelanderson@Michaels-iMac.local>
Committed: Mon Nov 27 19:21:14 2017 -0500

----------------------------------------------------------------------
 ocw/dataset_processor.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/41412cae/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 160ffb7..cf2e90e 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -867,9 +867,13 @@ def mask_missing_data(dataset_array):
 
     mask_array = np.zeros(dataset_array[0].values.shape)
     for dataset in dataset_array:
-        index = np.where(dataset.values.mask == True)
-        if index[0].size > 0:
-            mask_array[index] = 1
+        # CLIMATE-797 - Not every array passed in will be a masked array.
+        # For those that are, action based on the mask passed in.
+        # For those that are not, take no action (else AttributeError).
+        if hasattr(dataset.values, 'mask'):
+            index = np.where(dataset.values.mask == True)
+            if index[0].size > 0:
+                mask_array[index] = 1
     masked_array = []
     for dataset in dataset_array:
         dataset.values = ma.array(dataset.values, mask=mask_array)

Reply via email to