[Numpy-discussion] C-api and masked arrays

Matt Knox mattknox.ca at gmail.com
Mon Mar 1 18:38:01 EST 2010


Martin Raspaud <martin.raspaud <at> smhi.se> writes:

> We are using at the moment a c extension which should manipulate masked arrays.
> What we do is to fill the masked array with a given value (say 65535 if we run
> uint16 arrays), do the manipulation, and convert back to masked arrays when we
> go back to python.
> 
> This seems like a naive way to do, is there another cleverer way to do it ?

You might want to take a look at the C code in the timeseries scikit. It works
extensively with masked arrays. I don't claim that we use the optimal approach,
but it might give you some ideas. All the code that deals with masked arrays
is located here: 
http://svn.scipy.org/svn/scikits/trunk/timeseries/scikits/timeseries/src/c_tseries
.c

The functions that deal with frequency conversion and calculating moving sums,
averages, etc all deal with masked arrays.

- Matt





More information about the NumPy-Discussion mailing list