[Numpy-discussion] mapping a function to a masked array
bje at air.net.au
Wed Jan 12 06:45:54 EST 2011
I have a masked array of values that I would like to transform through
a user-defined function. Naturally, I want to ignore any values that
are masked in the initial array.
The user-defined function examines other points around the value in
question, so I need to use ndenumerate (or similar) to get the array
index as I iterate over the array.
So, I have two questions: how to make this run without looping in
Python, and how to avoid masked values. Here is the clunky solution I
have so far:
result = ma.copy (data)
for i, val in ndenumerate (data):
if not data.mask[i]:
result[i] = myfunc (data, i, val)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: Digital signature
More information about the NumPy-Discussion