From: Kuzminski, S. R <SKu...@fa...> - 2004-01-26 12:53:59
|
Could you use masked arrays more efficiently in this case? If you create the array so that values >255 and <0 are masked, then they will be excluded from the sum ( and from any other operations as well ). Stefan -----Original Message----- From: num...@li... [mailto:num...@li...] On Behalf Of Konrad Hinsen Sent: Monday, January 26, 2004 12:17 AM To: RJS Cc: num...@li... Subject: Re: [Numpy-discussion] efficient sum of "sparse" 2D arrays? On 26.01.2004, at 07:14, RJS wrote: > The problem: I have a "stack" of 8, 640 x 480 integer image arrays=20 > from a FITS cube concatenated into a 3D array, and I want to sum each=20 > pixel such that the result ignores clipped values (255+); i.e., if two > images have clipped pixels at (x,y) the result along z will be the sum > of the other 6. > Memory doesn't seem critical for such small arrays, so you can just do sum([where(a < 255, a, 0) for a in images]) Konrad. ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ Numpy-discussion mailing list Num...@li... https://lists.sourceforge.net/lists/listinfo/numpy-discussion |