Package astLib :: Module astWCS :: Class WCS
[hide private]
[frames] | no frames]

Class WCS

source code

This class provides methods for accessing information from the World Coordinate System (WCS) contained in the header of a FITS image. Conversions between pixel and WCS coordinates can also be performed.

To create a WCS object from a FITS file called "test.fits", simply:

WCS=astWCS.WCS("test.fits")

Likewise, to create a WCS object from the pyfits.header of "test.fits":

img=pyfits.open("test.fits") header=img[0].header WCS=astWCS.WCS(header, mode = "pyfits")

Instance Methods [hide private]
 
__init__(self, headerSource, extensionName=0, mode="image", zapKeywords=[])
Creates a WCS object using either the information contained in the header of the specified .fits image, or from a pyfits.header object.
source code
astWCS.WCS object
copy(self)
Copies the WCS object to a new object.
source code
 
updateFromHeader(self)
Updates the WCS object using information from WCS.header.
source code
list
getCentreWCSCoords(self)
Returns the RA and dec coordinates (in decimal degrees) at the centre of the WCS.
source code
list
getFullSizeSkyDeg(self)
Returns the width, height of the image according to the WCS in decimal degrees on the sky (i.e., with the projection taken into account).
source code
list
getHalfSizeDeg(self)
Returns the half-width, half-height of the image according to the WCS in RA and dec degrees.
source code
list
getImageMinMaxWCSCoords(self)
Returns the minimum, maximum WCS coords defined by the size of the parent image (as defined by the NAXIS keywords in the image header).
source code
list
wcs2pix(self, RADeg, decDeg)
Returns the pixel coordinates corresponding to the input WCS coordinates (given in decimal degrees).
source code
list
pix2wcs(self, x, y)
Returns the WCS coordinates corresponding to the input pixel coordinates.
source code
bool
coordsAreInImage(self, RADeg, decDeg)
Returns True if the given RA, dec coordinate is within the image boundaries.
source code
float
getRotationDeg(self)
Returns the rotation angle in degrees around the axis, North through East.
source code
int
isFlipped(self)
Returns 1 if image is reflected around axis, otherwise returns 0.
source code
float
getPixelSizeDeg(self)
Returns the pixel scale of the WCS.
source code
float
getXPixelSizeDeg(self)
Returns the pixel scale along the x-axis of the WCS in degrees.
source code
float
getYPixelSizeDeg(self)
Returns the pixel scale along the y-axis of the WCS in degrees.
source code
float
getEquinox(self)
Returns the equinox of the WCS.
source code
float
getEpoch(self)
Returns the epoch of the WCS.
source code
Method Details [hide private]

__init__(self, headerSource, extensionName=0, mode="image", zapKeywords=[])
(Constructor)

source code 

Creates a WCS object using either the information contained in the header of the specified .fits image, or from a pyfits.header object. Set mode = "pyfits" if the headerSource is a pyfits.header.

For some images from some archives, particular header keywords such as COMMENT or HISTORY may contain unprintable strings. If you encounter this, try setting zapKeywords = ['COMMENT', 'HISTORY'] (for example).

Parameters:
  • headerSource (string or pyfits.header) - filename of input .fits image, or a pyfits.header object
  • extensionName (int or string) - name or number of .fits extension in which image data is stored
  • mode (string) - set to "image" if headerSource is a .fits file name, or set to "pyfits" if headerSource is a pyfits.header object
  • zapKeywords (list)

Note: The meta data provided by headerSource is stored in WCS.header as a pyfits.header object.

copy(self)

source code 

Copies the WCS object to a new object.

Returns: astWCS.WCS object
WCS object

updateFromHeader(self)

source code 

Updates the WCS object using information from WCS.header. This routine should be called whenever changes are made to WCS keywords in WCS.header.

getCentreWCSCoords(self)

source code 

Returns the RA and dec coordinates (in decimal degrees) at the centre of the WCS.

Returns: list
coordinates in decimal degrees in format [RADeg, decDeg]

getFullSizeSkyDeg(self)

source code 

Returns the width, height of the image according to the WCS in decimal degrees on the sky (i.e., with the projection taken into account).

Returns: list
width and height of image in decimal degrees on the sky in format [width, height]

getHalfSizeDeg(self)

source code 

Returns the half-width, half-height of the image according to the WCS in RA and dec degrees.

Returns: list
half-width and half-height of image in R.A., dec. decimal degrees in format [half-width, half-height]

getImageMinMaxWCSCoords(self)

source code 

Returns the minimum, maximum WCS coords defined by the size of the parent image (as defined by the NAXIS keywords in the image header).

Returns: list
[minimum R.A., maximum R.A., minimum Dec., maximum Dec.]

wcs2pix(self, RADeg, decDeg)

source code 

Returns the pixel coordinates corresponding to the input WCS coordinates (given in decimal degrees). RADeg, decDeg can be single floats, or lists or numpy arrays.

Returns: list
pixel coordinates in format [x, y]

pix2wcs(self, x, y)

source code 

Returns the WCS coordinates corresponding to the input pixel coordinates.

Returns: list
WCS coordinates in format [RADeg, decDeg]

coordsAreInImage(self, RADeg, decDeg)

source code 

Returns True if the given RA, dec coordinate is within the image boundaries.

Returns: bool
True if coordinate within image, False if not.

getRotationDeg(self)

source code 

Returns the rotation angle in degrees around the axis, North through East.

Returns: float
rotation angle in degrees

isFlipped(self)

source code 

Returns 1 if image is reflected around axis, otherwise returns 0.

Returns: int
1 if image is flipped, 0 otherwise

getPixelSizeDeg(self)

source code 

Returns the pixel scale of the WCS. This is the average of the x, y pixel scales.

Returns: float
pixel size in decimal degrees

getXPixelSizeDeg(self)

source code 

Returns the pixel scale along the x-axis of the WCS in degrees.

Returns: float
pixel size in decimal degrees

getYPixelSizeDeg(self)

source code 

Returns the pixel scale along the y-axis of the WCS in degrees.

Returns: float
pixel size in decimal degrees

getEquinox(self)

source code 

Returns the equinox of the WCS.

Returns: float
equinox of the WCS

getEpoch(self)

source code 

Returns the epoch of the WCS.

Returns: float
epoch of the WCS