[AstroPy] Image combine
Wed Mar 7 03:13:14 CST 2012
If you can turn my_sigma_clip into a ufunc, you could do
On 7/03/12 5:43 PM, Jose Miguel Ibáñez wrote:
> Hi !
> Right Kathleen, I mostly refer to the rejection, masking, scaling ...
> algorithms; the idea is to avoid to install all the PyRAF staff only
> because the nice iraf.imcombine task.
> I have tried to implement some of those features, but for the moment
> the main problem is that my routine is extremely slow (~2min)
> following the next schema:
> import numpy as np
> ndim = 2048
> cube = np.random.rand(32,ndim, ndim)
> result = np.zeros([ndim, ndim], np.float32)
> def combine(cube, result):
> for ii in range(ndim):
> for jj in range(ndim):
> result[ii, jj] = my_sigma_clip(cube[:,ii,jj])
> return result
> However, the next numpy sentence is very fast (less than 1 second )
>>> median_result = np.median(cube,0)
> So, I'd also like to find out where is the point of that difference.
> As Erik suggests, I think that kind of combine-like routines should be
> in the next coming astropy package, maybe with the effort of all of
> So Kathleen, I encourage you to continue with your adventure at Gemini
> and let us know about your progress.
> 2012/3/6 Kathleen Labrie<firstname.lastname@example.org>:
>> I think Jose mostly refer to the rejection, masking, scaling, weighing
>> algorithms that iraf imcombine offers. I agree the arithmetic is easy
>> enough to do with numpy and pyfits, even the median. It's the rest
>> of imcombine that can get tricky (and bloated).
>> For the record, here at Gemini, we will soon embark it that foolish adventure
>> of trying to reproduce at least some of the imcombine features (but only
>> the ones we need due to time and resource constraints). We are still
>> at the point of defining which features we really need though, so I don't
>> think it will help Jose much for now.
>> I am very interested to hear if someone has written some code for a
>> imcombine-like routine.
>> On Mar 6, 2012, at 8:52 AM, Erik Tollerud wrote:
>>> I'm not aware of a function that does it exactly with the interface of
>>> imcombine, but it can be done pretty easily with pyfits:
>>> import pyfits
>>> f1 = pyfits.open('filename1')
>>> f2 = pyfits.open('filename2')
>>> h1 = f1.header
>>> im1 = f1.data
>>> im2 = f2.data
>>> newimage = im1 + im2
>>> newhdu = pyfits.PrimaryHDU(data=newimage,header=h1)
>>> That example is specific to addition, of course (the im1 + im2 part,
>>> but it should be clear how to generalize it to other arithmetic
>>> 2012/3/6 Jose Miguel Ibáñez<email@example.com>:
>>>> Hello everyone,
>>>> does anyone know of an implementation of the iraf.imcombine task in
>>>> python+numpy ? (of course, not using pyraf.imcombine call)
>>>> Thanks !
>>>> AstroPy mailing list
>>> Erik Tollerud
>>> AstroPy mailing list
> AstroPy mailing list
More information about the AstroPy