[AstroPy] PyFits too slow

Johann Cohen-Tanugi Johann.COHEN-TANUGI@LPTA.in2p3...
Fri Jun 26 04:32:30 CDT 2009


this is very very bad : have a look at the numpy tutorials or user's 
guide. You are not making use of vectorization....

Johann

Jose Miguel Ibáñez wrote:
> Hello !
>
> I am trying to iterate through the pixels  of  an FITS image read 
> previusly with PyFits,
> but it is too slow (more that 1CPU minute), so my question is if is 
> there any other way to do that in a
> more efficient/fast  way.
>
> That's the code I'm using:
> ------------------------------------------------------------------
> f=pyfits.open('/tmp/c1.fits',memmap=1)
> b=numpy.zeros([2048,2048],dtype='float32')
> cdata=f[0].data.copy()
> f.close()
> print 'start loop...'
> for i in range(0,2048):
>     for j in range(0,2048):
>         if cdata[i,j]<1 or cdata[i,j]>100000:
>             b[i,j]=1
>
>
> ----------------------------------------------------------------
>
> Any idea ?
>
> Thanks very much,
> JM
> ------------------------------------------------------------------------
>
> _______________________________________________
> AstroPy mailing list
> AstroPy@scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>   


More information about the AstroPy mailing list