Package pywcs :: Module _pywcs
[frames] | no frames]

Module _pywcs

The routines in this module implement the FITS World Coordinate System (WCS) standard which defines methods to be used for computing world coordinates from image pixel coordinates, and vice versa.

Note that pixel coordinates are always given and returned with a base of zero, to be consistent with Numpy and PyFITS indexing, not base one as the FITS standard.

The basic workflow is as follows:

  1. import pywcs
  2. Call the pywcs.WCS constructor with a PyFITS header object.
  3. Optionally, if the FITS file uses any deprecated or non-standard features, you may need to call one of the fix methods on the object.
  4. Convert coordinates using the pixel2world() or world2pixel() methods.

Short example:

   import numpy
   import pywcs
   import pyfits

   hdulist = pyfits.open("test.fits")

   # Parse the WCS keywords in the primary HDU
   wcs = pywcs.WCS(hdulist[0].header)

   # Print out the "name" of the WCS, as defined in the FITS header
   print wcs.name

   # Some interesting pixel coordinates
   pixcrd = numpy.array([[0,0],[24,38],[45,98]], numpy.float_)

   # Convert pixel coordinates to world coordinates
   world = wcs.pixel2world(pixcrd)
   print world