[AstroPy] pywcs issue

Michael Droettboom mdroe at stsci.edu
Thu Mar 24 12:18:43 EDT 2011


The WCS is not guaranteed to be defined outside of the image.  Particularly with SIN projections, it is often the case that the results are invalid when outside of the image.  wcslib (and pywcs) does not do any sanity checks for this.

Mike
________________________________________
From: astropy-bounces at scipy.org [astropy-bounces at scipy.org] on behalf of Yogesh Wadadekar [yogesh at ncra.tifr.res.in]
Sent: Wednesday, March 23, 2011 9:23 AM
To: astropy at scipy.org
Cc: ishan.07 at iist.ac.in
Subject: [AstroPy] pywcs issue

I am trying to use pywcs for analysis of some FIRST survey radio data.
When I run the simple python test script (pasted at the bottom of
this email) below on the FITS file:

00525+00130Z.fits

Note that the FITS file above has minimal WCS related headers extracted
from the original FIRST data.

It is available at:

http://www.ncra.tifr.res.in/~yogesh/00525+00130Z.fits

I get strange results. The output of the script is:

project at yogesh:~$ python test.py
running pywcs version:1.10-4.7
Image:  00525+00130Z.fits
Input ra and dec:
12.742937       0.263592
Ra and dec after conversion via wcs_sky2pix and wcs_pix2sky:
[ 12.742937]    [ 0.263592]
Input ra and dec:
192.983075      -0.1740946
Ra and dec after conversion via wcs_sky2pix and wcs_pix2sky:
[ 13.26637025]  [ 0.25923741]

For  a RA/Dec lying within the image, the sky --> pix ---> sky conversion
gives correct results, but for a position ~180 degrees away, wcs_sky2pix
returns x,y within the image. wcs_pix2sky happily converts this x,y to a
grossly incorrect RA,Dec.

I am completely perplexed about what is going on here.

Yogesh

Yogesh Wadadekar                         Tel: 91 20 25719238
National Centre for Radio Astrophysics   e-mail: yogesh at ncra.tifr.res.in
Post Bag 3, Ganeshkhind
Pune 411007, India

------------------------------------------------------------------------
#!/usr/bin/env python

import pywcs,pyfits

print 'running pywcs version:'+pywcs.__version__

image = '00525+00130Z.fits'
print 'Image: ',image

header = pyfits.getheader(image)
wcs= pywcs.WCS(header)

x, y = wcs.wcs_sky2pix(12.742937,0.263592,1)
ra, dec = wcs.wcs_pix2sky(x, y,1)
print 'Input ra and dec:\n',12.742937,'\t',0.263592,'\nRa and dec after
conversion via wcs_sky2pix and wcs_pix2sky:\n',ra,'\t',dec

# Now repeat with ra,dec pair for a position well outside the image
x, y = wcs.wcs_sky2pix(192.983075,-0.1740946,1)
ra, dec = wcs.wcs_pix2sky(x, y,1)
print 'Input ra and dec:\n',192.983075,'\t', -0.1740946,'\nRa and dec
after conversion via wcs_sky2pix and wcs_pix2sky:\n',ra,'\t',dec
_______________________________________________
AstroPy mailing list
AstroPy at scipy.org
http://mail.scipy.org/mailman/listinfo/astropy



More information about the AstroPy mailing list