I would like to mask some values of an array. The array is 3D and the mask is 2D.
I want to mask all the coordonates in the direction of frametemperature_reshape.shape[0]
.
I tried the following loop:
for i in range(frametemperature_reshape.shape[0]):
frames_BPnegl = np.ma.array(frametemperature_reshape[i,:,:], mask=mask2)
One way to do this is to create a 3D mask based on replications of the 2D one across the third dimension as follows:
mask3 = mask2 * np.ones(3)[:, None, None].
masked_output = np.ma.array(frametemperature_reshape, mask=mask3)