<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Jose,<div><br></div><div>What you're trying to do is already half implemented in numpy and called masked arrays:</div><div><br></div><div>Let's say you want to stack images and you have put them together in a 3d cube (first axis being the images):</div><div><br></div><div>myimages = numpy.ma.MaskedArray(rand(5,100,100), mask=zeros((5,100,100).astype(bool))</div><div><br></div><div>let's do a simple sigma clipping algorithm:</div><div><br></div><div>image_mean = mean(myimages)</div><div>image_std = std(myimages)</div><div><br></div><div>#now let's adjust the mask to mask the pixels that are more than 1 sigma out</div><div><br></div><div>new_mask = abs(myimages - image_mean) > 1.</div><div><br></div><div>myimages.mask = new_mask</div><div><br></div><div>#if you do a mean now it will ignore the values where the mask = True</div><div><br></div><div>mean(myimages, axis=0)</div><div><br></div><div>This will be all near C-speeds (I guess a factor of 100 is easily in there).</div><div>----</div><div><br></div><div>As other's have pointed out using i,j in a loop is a very bad idea for numpy arrays. Numpy arrays are much more easy to handle than in most other languages, there is a bit of getting used to required though. I recommend reviewing the different operations on <a href="http://www.scipy.org/Tentative_NumPy_Tutorial">http://www.scipy.org/Tentative_NumPy_Tutorial</a>. </div><div><br></div><div>Hope that helps,</div><div><br></div><div>    Wolfgang </div><div><div><div>On 2012-03-07, at 4:41 AM, Sergio Pascual wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hello<br><br>I have written a image combine implementation for the pipeline of<br>EMIR[1], a near infrared instrument for the 10m GTC Telescope. It does<br>scaling,<br>weighting and masking. It's written as a C/C++ extension. It's part of<br>a larger package, numina, used for other GTC instruments, but I may<br>split combine if there is interest in it. The package, called numina,<br>its under heavy development, but the combine part is fairly stable.<br><br>You can see the code here <a href="https://guaix.fis.ucm.es/hg/numina/">https://guaix.fis.ucm.es/hg/numina/</a><br><br>The combine part is the module numina.array.combine, fairly all the<br>C/C++ code is in src/<br><br>Regards, Sergio<br><br><br>[1] <a href="http://www.gtc.iac.es/pages/instrumentacion/emir.php">http://www.gtc.iac.es/pages/instrumentacion/emir.php</a><br>[2] <a href="http://www.gtc.iac.es/">http://www.gtc.iac.es/</a><br><br><br><br>El día 6 de marzo de 2012 12:00, Jose Miguel Ibáñez <<a href="mailto:ppmime@gmail.com">ppmime@gmail.com</a>> escribió:<br><blockquote type="cite">Hello everyone,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">does anyone know of an implementation of the iraf.imcombine task in<br></blockquote><blockquote type="cite">python+numpy ? (of course, not using pyraf.imcombine call)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks !<br></blockquote><blockquote type="cite">Jose<br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">AstroPy mailing list<br></blockquote><blockquote type="cite"><a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br></blockquote><blockquote type="cite"><a href="http://mail.scipy.org/mailman/listinfo/astropy">http://mail.scipy.org/mailman/listinfo/astropy</a><br></blockquote><br><br><br>-- <br>Sergio Pascual     <a href="http://guaix.fis.ucm.es/~spr">http://guaix.fis.ucm.es/~spr</a>    +34 91 394 5018<br>gpg fingerprint: 5203 B42D 86A0 5649 410A F4AC A35F D465 F263 BCCC<br>Departamento de Astrofísica -- Universidad Complutense de Madrid (Spain)<br>_______________________________________________<br>AstroPy mailing list<br><a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>http://mail.scipy.org/mailman/listinfo/astropy<br></div></blockquote></div><br></div></body></html>