RE: [Numpy-discussion] efficient sum of "sparse" 2D arrays?
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: numpy-discussion-admin@lists.sourceforge.net [mailto:numpy-discussion-admin@lists.sourceforge.net] On Behalf Of Konrad Hinsen Sent: Monday, January 26, 2004 12:17 AM To: RJS Cc: numpy-discussion@lists.sourceforge.net 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 from a FITS cube concatenated into a 3D array, and I want to sum each 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 Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
participants (1)
-
Kuzminski, Stefan R