[AstroPy] WCS world to pixel conversion with SIP correction?

David Berry d.berry at jach.hawaii.edu
Tue Jul 16 03:22:02 EDT 2013


It's not astropy, but you can do this using pyast
(http://dsberry.github.io/starlink/pyast.html) - a python wrapper for
the WCS library used by DS9. For example, the following reads the SIP
header, converts some pixel positions into (RA,Dec) and then converts
them back to pixel positions.

David


import pyfits
import starlink.Atl as Atl

# Read the FITS headers and get an AST FrameSet describing the
# full WCS.
hdulist = pyfits.open( "sip.fits" )
frameset,encoding = Atl.readfitswcs( hdulist )

# Transform some pixel positions into (RA,Dec) positions and display
them (in radians).
x = [ 30.0, 40.0, 50.0 ]
y = [ 10.0, 60.0, 100.0 ]
ra,dec = frameset.tran( [ x, y ] )
print( ra, dec )

# Transform them back to pixel positions.
x,y = frameset.tran( [ ra, dec ], False )
print( x, y )



On 16 July 2013 02:27, Leo Singer <lsinger at caltech.edu> wrote:
> Hello,
>
> I want to look up the pixel coordinates in a FITS image from the world coordinates (RA, Dec in ICRS), but the image has SIP distortion parameters. I noticed that the function WCS.wcs_world2pix does not perform the SIP transformation, and there is apparently no inverse function of WCS.all_pix2world.
>
> There is this open issue:
>
> Iterative implementation of wcs.all_world2pix
> https://github.com/astropy/astropy/issues/1066
>
> Am I perhaps looking in the wrong place? Is there a sequence of existing function calls to convert from pixel to world coordinates, including the distortion correction?
>
> Thanks,
> Leo Singer
> Graduate Student @ LIGO-Caltech
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy



More information about the AstroPy mailing list