[AstroPy] wcs_world2pix giving wrong answer

Dave Lane dlane at ap.stmarys.ca
Fri Jan 15 12:54:10 EST 2016

(sorry for the blank subject earlier - hit send too early!)


I'm having trouble with 'wcs_world2pix' giving the wrong answers for 
pixel positions (off by about 10 pixels) compared to other software 
include including that interpreted by ds9 image display. The optical 
images were plate-solved by pinpoint (from dc3 dreams). I am getting the 

     WARNING: FITSFixedWarning: RADECSYS= 'FK5 ' / Equatorial coordinate 
     RADECSYS is non-standard, use RADESYSa. [astropy.wcs.wcs]

Any suggestions on how to proceed?

--- Dave


A code snipped is as follows:

import astropy.io.fits
from astropy import wcs
import numpy as np
from phot import aperphot,hms,dms
imagefile=imagelist[1]        # path to the image
hdulist = astropy.io.fits.open(imagefile)
w = wcs.WCS(hdulist['PRIMARY'].header)
world = np.array([[RAtarget, DECtarget]])
pix = w.wcs_world2pix(world,1)
print "Pixel Coordinates: ", pix[0,0], pix[0,1]
radec = w.wcs_pix2world(pix,1)
print "RADEC Coordinates: ", radec[0,0], radec[0,1]
observation=aperphot(imagefile, timekey=None, pos=[pix[0,0], pix[0,1]], 
dap=[10,15,20], resamp=2,retfull=False)
print "Aperture flux:", observation.phot
print "Background:   ", observation.bg

The pertinent header keys are:

RADECSYS= 'FK5     '           / Equatorial coordinate system
RA      = '20 57 22.20'        / [hms J2000] Target right ascension
DEC     = '+40 19 11.0'        / [dms +N J2000] Target declination
EQUINOX =               2000.0 / Equatorial coordinates are J2000
EPOCH   =               2000.0 / (incorrect but needed by old programs)
PA      =   1.29763632687E+000 / [deg, 0-360 CCW] Position angle of plate
CTYPE1  = 'RA---TAN'           / X-axis coordinate type
CRVAL1  =   3.14341739025E+002 / X-axis coordinate value
CRPIX1  =   7.68000000000E+002 / X-axis reference pixel
CDELT1  =  -2.59534986961E-004 / [deg/pixel] X-axis plate scale
CROTA1  =  -1.29763632687E+000 / [deg] Roll angle wrt X-axis
CTYPE2  = 'DEC--TAN'           / Y-axis coordinate type
CRVAL2  =   4.03127760707E+001 / Y-axis coordinate value
CRPIX2  =   7.68000000000E+002 / Y-axis reference pixel
CDELT2  =  -2.59455750274E-004 / [deg/pixel] Y-Axis Plate scale
CROTA2  =  -1.29763632687E+000 / [deg] Roll angle wrt Y-axis
CD1_1   =  -2.59468427764E-004 / Change in RA---TAN along X-Axis
CD1_2   =  -5.87565834781E-006 / Change in RA---TAN along Y-Axis
CD2_1   =   5.87745274898E-006 / Change in DEC--TAN along X-Axis
CD2_2   =  -2.59389211397E-004 / Change in DEC--TAN along Y-Axis
AstroPy mailing list
AstroPy at scipy.org

More information about the AstroPy mailing list