|
From: Jeff W. <js...@fa...> - 2005-07-12 12:23:52
|
Andrew Straw wrote: > Hi Alan, > > It seems MaskedArrays are the preferred way to do this. See the > masked_demo.py example. > > And while I'm at it, does anyone if there is simple function call > which returns only the unmasked values of a masked array (without > filling the masked values in, but simply returning a shorter > sequence)? What is it? I have my own, but it's not pretty: Andrew: If x is a masked array, x.compressed() returns the unmasked contented in a ravelled (i.e. rank-1) array. For example: >>> x = ma.array(arange(5), mask = [0,0,1,0,0]) >>> print x.compressed() [0,1,3,4,] -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 325 Broadway Web : http://www.cdc.noaa.gov/~jsw Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 |