From d30893c572d70bfb209555fa7676b6900e2a74e7 Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Sat, 26 May 2018 14:20:19 +0530 Subject: [PATCH 1/2] Initial Stucture for Handling mask for non-maskedd arrays --- ocw/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ocw/utils.py b/ocw/utils.py index 8f2c8c14..6012b573 100755 --- a/ocw/utils.py +++ b/ocw/utils.py @@ -435,7 +435,9 @@ def calc_subregion_area_mean_and_std(dataset_array, subregions): lons = dataset0.lons lats = dataset0.lats subregion_array = np.zeros(lons.shape) - mask_array = dataset_array[0].values[0, :].mask + # Check if the array is a masked array + if hasattr(dataset_array[0].values[0, :], 'mask'): + mask_array = dataset_array[0].values[0, :].mask # dataset0.values.shsape[0]: length of the time dimension # spatial average t_series = ma.zeros([ndata, dataset0.values.shape[0], len(subregions)]) From cd3cb4f216a28a32b7c5c9316e0d333d59054205 Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Sat, 26 May 2018 14:47:45 +0530 Subject: [PATCH 2/2] if its not a masked array --- ocw/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ocw/utils.py b/ocw/utils.py index 6012b573..e23697c1 100755 --- a/ocw/utils.py +++ b/ocw/utils.py @@ -438,6 +438,11 @@ def calc_subregion_area_mean_and_std(dataset_array, subregions): # Check if the array is a masked array if hasattr(dataset_array[0].values[0, :], 'mask'): mask_array = dataset_array[0].values[0, :].mask + else: + x = dataset_array[0].values[0, :] + #check where the missing values exist + masked_array = ma.array(x, mask=np.equal(x,None)) + mask_array = masked_array.mask # dataset0.values.shsape[0]: length of the time dimension # spatial average t_series = ma.zeros([ndata, dataset0.values.shape[0], len(subregions)])