I am trying to find a way to get the mask from a masked array using only a logical expresion. So if var
is a masked array, I would like to get the mask by comparing it to a nodata object, None or something similar along the lines
>>> var = numpy.ma.masked_array([1, 2 , 3], mask=[True, False, True])
>>> print var == None
... False
>>> print var == numpy.ma.masked
... --
What I would like to get
>>> print var == ???
... array([ True, False, True], dtype=bool)
I know I can access the mask directly through var.mask
, but in my use case I can only evaluate logical operators, such as numpy.equal
.
Any idea what I could use for ???
to get the mask?