1
votes

I've two 3D masked arrays of shape (4880,129,135). Let's assume the arrays are A and B with masks m1 and m2 containing boolean values for the respective arrays. I need to create a new mask m3 which contains True for True values in m1 and m2 and False for the False values if either in m1 or m2 is False. Then apply it to the array C.

1
What have you tried so far? Please check How to ask and How to create a Minimal, Reproducible Example.Francisca Concha-Ramírez

1 Answers

0
votes

For numpy arrays of any dimension, the & operator can be used:

C = A & B

This will create a new array C, with the same dimensions as A and B, which is populated with True for each element which has both corresponding elements in A and B as True, otherwise it will be False.

Note, if you want the element in C to be True when either corresponding element in A or B is True, you can use:

C = A | B