View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Imcombine using wcs: weird coordinate system error

rrg wrote on Jun 19, 2007

Hi all,
I have a stack of images (2048x2048) with reasonable WCS data in the headers, like:
CRVAL1  =      241.23971710972 /
CRVAL2  =      43.358557401931 /
CRPIX1  =     1025.00017818278 /
CRPIX2  =     1024.98884738801 /
CTYPE1  = 'RA---TAN'           /
CTYPE2  = 'DEC--TAN'           /
EQUINOX =                2000. /
WCSDIM  =                    2
CD1_1   =  -6.9046572469549E-5
CD1_2   =  -1.6518674845624E-6
CD2_1   =  -1.6910818686302E-6
CD2_2   =  6.90626502541518E-5
LTV1    =     2049.00003262489
LTV2    =                2049.
LTM1_1  =  -7.5497901264043E-8
LTM2_1  =   -0.999999999999996
LTM1_2  =   -0.999999999999994
LTM2_2  =  7.54979012640429E-8
WAT0_001= 'system=image'
WAT1_001= 'wtype=tan axtype=ra'
WAT2_001= 'wtype=tan axtype=dec'

When displayed in DS9, these look ok: N up, E left, with x increasing to the right and y increasing upwards.

I then try to imcombine a bunch of these images, using offsets=wcs. My full param set is
input   =      fit_//@testlist  List of images to combine
output  =             testadd4  List of output images
(headers=                     ) List of header files (optional)
(bpmasks=                     ) List of bad pixel masks (optional)
(rejmask=                     ) List of rejection masks (optional)
(nrejmas=                     ) List of number rejected masks (optional)
(expmask=                     ) List of exposure masks (optional)
(sigmas =                     ) List of sigma images (optional)
(logfile=               STDOUT) Log file

(combine=               median) Type of combine operation
(reject =            avsigclip) Type of rejection
(project=                   no) Project highest dimension of input images?
(outtype=                 real) Output image pixel datatype
(outlimi=                     ) Output limits (x1 x2 y1 y2 ...)
(offsets=                  wcs) Input image offsets
(masktyp=                 none) Mask type
(maskval=                    0) Mask value
(blank  =                   0.) Value if there are no pixels

(scale  =                 none) Image scaling
(zero   =                 none) Image zero point offset
(weight =                 none) Image weights
(statsec=                     ) Image section for computing statistics
(expname=                     ) Image header exposure time keyword

(lthresh=                INDEF) Lower threshold
(hthresh=                INDEF) Upper threshold
(nlow   =                    1) minmax: Number of low pixels to reject
(nhigh  =                    1) minmax: Number of high pixels to reject
(nkeep  =                    1) Minimum to keep (pos) or maximum to reject (neg)
(mclip  =                  yes) Use median in sigma clipping algorithms?
(lsigma =                  2.5) Lower sigma clipping factor
(hsigma =                  2.5) Upper sigma clipping factor
(rdnoise=                   0.) ccdclip: CCD readout noise (electrons)
(gain   =                   1.) ccdclip: CCD gain (electrons/DN)
(snoise =                   0.) ccdclip: Sensitivity noise (fraction)
(sigscal=                  0.1) Tolerance for sigma clipping scaling corrections
(pclip  =                 -0.5) pclip: Percentile clipping parameter
(grow   =                   0.) Radius (pixels) for neighbor rejection
(mode   =                   ql)

The resulting image has a WCS problem. x and y are correct, but N goes diagonally up/right, and E goes diagonally down/left !!!! N and E are 180 degrees from each other. The header now says

CRVAL1  =      241.23971710972 /
CRVAL2  =      43.358557401931 /
CRPIX1  =     1188.00017818278 /
CRPIX2  =     3111.99993175194 /
CTYPE1  = 'RA---TAN'           /
CTYPE2  = 'DEC--TAN'           /
EQUINOX =                2000. /
WCSDIM  =                    2
CD1_1   =  -6.9046572469549E-5
CD1_2   =  6.90465776824204E-5
CD2_1   =  -1.6910818686302E-6
CD2_2   =  1.69108199630373E-6
LTM1_1  =                   1.
LTM2_2  =                   1.
WAT0_001= 'system=image'
WAT1_001= 'wtype=tan axtype=ra'
WAT2_001= 'wtype=tan axtype=dec'


The CRVALs are ok. The CD matrix is garbled. The CRPIX are wacky. So, I took a shot:
I set CRPIX2=CRPIX2-2048
I set CD2_2 to what was in CD1_2
I set CD1_2 to what was in CD2_2 * -1

and that works! A check against SDSS shows the coordinates are correct (or very close). It looks like a bug to me...

Is this a known bug in imcombine? I am using IRAFNET PC-IRAF Revision 2.13-BETA2 on a MacIntel running OS 10.4.9

Thanks
Roy

rrg wrote on Jun 19, 2007

The images that were used here were rotated (using IRAF rotate) and flipped (using imcopy[-*,*]) to get the orientation right. Following a colleague's suggestion (thanks Dale Kocevski!) I found that removing the LTV and LTM header keywords before running imcombine resulted in a correct final image.

This sort of solves my problem in an ugly way, but hopefully it points to the source of the error (if there is one) in imcombine.

Roy

Last post on Jun 19, 2007