astropy/astropy — Issue #107: Issue with positions outside sky
Author: astrofrog
Created: 2011-12-08 11:11:44+00:00
State: open
Labels: wcs

The following header defines a transformation such that some pixels in the image fall outside the sky

SIMPLE = T /
BITPIX = -32 /
NAXIS = 2 /
NAXIS1 = 2048 /
NAXIS2 = 2048 /
EXTEND = T /
BSCALE = 1.00000000000E+00 /
BZERO = 0.00000000000E+00 /
CDELT1 = -8.19629704013E-02 /
CRPIX1 = 1.02500000000E+03 /
CRVAL1 = 79.95701
CTYPE1 = 'RA---SIN' /
CDELT2 = 8.19629704013E-02 /
CRPIX2 = 1.02500000000E+03 /
CRVAL2 = -45.779
CTYPE2 = 'DEC--SIN' /
EPOCH = 2.00000000000E+03 /
PV2_1 = -0.755124458581295
PV2_2 = 0.209028857410973

When converting pixel positions outside the sky:

import pyfits

header = pyfits.Header()
header.fromTxtFile('header.hdr')

from astropy.wcs import WCS

wcs = WCS(header)
print wcs.wcs_pix2sky([[100.,500.]], 0) # outside sky
print wcs.wcs_pix2sky([[200.,200.]], 0) # outside sky
print wcs.wcs_pix2sky([[1000.,1000.]], 0)

The result is a normal value, and there is no indication that the pixel is outside the sky:

[[ 259.95701 -44.221 ]]
[[ 259.95701 -44.221 ]]
[[ 82.96101414 -47.72314271]]

Should the values not be returned e.g. as NaN values to indicate that they are not valid?