Package gavo :: Package utils :: Module fitstools :: Class WCSAxis
[frames] | no frames]

Class WCSAxis

source code

object --+
         |
        WCSAxis

represents a single 1D WCS axis and allows easy metadata discovery.

You'll usually use the fromHeader constructor.

The idea of using this rather than astropy.wcs or similar is that this is simple and robust. It doesn't know many of the finer points of WCS, though, and in particular it's 1D only.

However, for the purposes of cutouts it probably should do for the overwhelming majority of non-spatial FITS axes.

The default pixel coordinates are handled in the FITS sense here, i.e., the first pixel has the index 1. Three are methods that have pix0 in their names; these assume 0-based arrays. All the transforms return Nones unchanged.

To retrieve the metadata shoved in, use the name, crval, crpix, cdelt, ctype, cunit, and axisLength attributes.

Instance Methods
 
__init__(self, name, crval, crpix, cdelt, ctype='UNKNOWN', cunit='', axisLength=1)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
pixToPhys(self, pixCoo)
returns the physical value for a 1-based pixel coordinate.
source code
 
pix0ToPhys(self, pix0Coo)
returns the physical value for a 0-based pixel coordinate.
source code
 
physToPix(self, physCoo)
returns a 1-based pixel coordinate for a physical value.
source code
 
physToPix0(self, physCoo)
returns a 0-based pixel coordinate for a physical value.
source code
 
getLimits(self)
returns the minimal and maximal physical values this axis takes within the image.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
fromHeader(cls, header, axisIndex, forceSeparable=False)
returns a WCSAxis for the specified axis in header.
source code
Properties

Inherited from object: __class__

Method Details

__init__(self, name, crval, crpix, cdelt, ctype='UNKNOWN', cunit='', axisLength=1)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

fromHeader(cls, header, axisIndex, forceSeparable=False)
Class Method

source code 

returns a WCSAxis for the specified axis in header.

If the axis is mentioned in a transformation matrix (CD or PC), a ValueError is raised; this is strictly for 1D coordinates.

The axisIndex is 1-based; to get a transform for the axis described by CTYPE1, pass 1 here.