ccdproc icon indicating copy to clipboard operation
ccdproc copied to clipboard

Image Combine with wcs offset

Open ysBach opened this issue 8 years ago • 4 comments

For simple and primitive image analysis for non-sidereal tracking data, it is quite common to use script like

imcombine @fits.list output=combined.fits combine="median" offset="wcs"

in IRAF (fits.list is the file containing the list of files), as explained here. I want to request some simple features based on the difference between IRAF and python.

The only module similar to the above IRAF task is wcs_project of ccdproc, AFAIK. However, the result from ccdproc differs from IRAF, which was unexpected for me.

For test, I combined 4 images using the first image's wcs as the target_wcs:

import numpy as np
from ccdproc import CCDData, wcs_project, combine
from astropy.wcs import WCS

prefix = 'reproj_Tutorial/'
filelist = np.loadtxt(prefix+'fits.list', dtype=bytes).astype(str)

reproj = []
wcs_std = WCS((CCDData.read(prefix+filelist[0], unit='adu')).header)

for fname in filelist:
    ccd = CCDData.read(prefix+fname, unit='adu')
    reproj.append(wcs_project(ccd, wcs_std))


med = combine(reproj, output_file='test.fits', method='average')

Since I used the target_wcs as the wcs of the first input image, the NAXIS of ccdproc's result is restricted to the field of view of the first image. I think most people who want to do the image combine with wcs offset want the whole image, not a "cropped" image at a certain FOV.

The following is the result from IRAF (left) and ccdproc (right):

comparison

The lower part and right part are "cropped" in ccdproc's result, since they are out of the first wcs's FOV (NAXIS=1024). The NAXIS=(1054, 1064) for IRAF's result.


So I want

  1. Some options for wcs_project to reproduce similar result as IRAF (e.g., restrict_NAXIS or fix_NAXIS that has default value True for backward compatibility?)

  2. And/or some functionality to use the wcs offset when combining images. I guess it will be very useful if some functions or modules, such as median_combine, have an option to take offset={'wcs', 'world', 'physical', 'grid', <filename>}, and do the reprojection and combination automatically based on the input. For example,

combiner = Combiner([ccd1, ccd2, ...])
avg = combiner.median_combine(offset='wcs')

ysBach avatar May 28 '17 00:05 ysBach

As far as I remember IRAF just calculates the pixel offsets based on the WCS, it doesn't do a complete reprojection.

Should we implement the offset-approach or a reprojection approach?

MSeifert04 avatar Jun 01 '17 18:06 MSeifert04

@MSeifert04

IRAF just calculates the pixel offsets based on the WCS, it doesn't do a complete reprojection.

Yeah, that was what I found from STScI manual after making this issue.

Should we implement the offset-approach or a reprojection approach?

I don't think we have to choose either of them, but we can just have two options :).

When we combine ~ 100 images with offset=wcs, it's quite fast using IRAF, but it takes much time on ccdproc, due to the "complete reprojection". From my experience, primitive combine method of IRAF (calculate just pixel offset) does not differ much from the complete reprojection, especially if we are interested in simple image analysis.

FYI, the reason for making such combined image got clearer after I had a discussion with my friend about an hour ago, so let me summarize it: say we obtained ~ 100 images after tracking a (faint) comet

  1. imcombine @fits.list combine="median" offset="wcs" reject="sigclip": This is used to make the star-only image and see the morphology of the comet. Some stars are so faint to be detected from single image, and this median combined image will lead us to locate stars that are not even catalogued.
  • Since we are interested in the comet only, we will make "mask" to the location of all stars from each image. Then do the combine again with given offset values for each image to see the morphology of the comet (imcombine @fits.list combine="median" offset="comet_center.txt" reject="sigclip"). The median combine will remove all star-like features after we make the stars for each image. If we do average combine, the remaining fluxes or "holes" due to star masking will remain in the resulting image, so median combine is used.
  1. imcombine @fits.list combine="average" offset="wcs" reject="crreject" for stars and offset="comet_center.txt" for the comet: This is used to make an image for photometry. Average combine keeps the flux, while median combine may diminish the flux of stars. The option "crreject" is used for primitive cosmic-ray masking in IRAF.

ysBach avatar Jun 04 '17 08:06 ysBach

This feature would be great. Any update on this?

-Matt

stevans avatar Aug 06 '18 20:08 stevans

I'm also looking for something like this, in order to apply an offset (due to motion of asteroid) when combining images. ccdproc.combine is much faster than anything I've been able to write myself, so having this functionality would be really useful.

Mikea1985 avatar Feb 17 '21 20:02 Mikea1985