[Numpy-discussion] C-api and masked arrays
martin.raspaud at smhi.se
Mon Mar 1 10:39:58 EST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Pierre GM skrev:
> On Mar 1, 2010, at 10:04 AM, Martin Raspaud wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>> Hi all,
>> 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 ?
> Keep in mind that masked arrays are pure Python (because I still don't speak C), so there's no real proper C way to deal with them. That depends on the kind of manipulation you have in mind. If the underlying value is not important, you don't have to fill the array, just use its .data (the underlying ndarray). If you expect problems down the road (such as NaNs popping up), then yes, filling the masked array beforehand is the way to go. Don't forget to stitch the mask at the end...
We're talking map projections, so that means that the values will move around,
including masked ones...
So filling the array with a given value is a way of projecting the array and the
mask in one shot...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 260 bytes
Desc: not available
More information about the NumPy-Discussion