Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

CLIMATE - 803 Initial Stucture for Handling mask for non-maskedd arrays #506

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ocw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,14 @@ 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
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)])
Expand Down