Previous topic

DistortionLookupTable

Next topic

UnitConverter

This Page

Sip

class pywcs.Sip

The Sip class performs polynomial distortion correction using the SIP convention in both directions.

Shupe, D. L., M. Moshir, J. Li, D. Makovoz and R. Narron. 2005. “The SIP Convention for Representing Distortion in FITS Image Headers.” ADASS XIV.
  • a: double array[m+1][m+1]. The A_i_j polynomial for pixel to focal plane transformation. Its size must be (m + 1, m + 1) where m = A_ORDER.
  • b: double array[m+1][m+1]. The B_i_j polynomial for pixel to focal plane transformation. Its size must be (m + 1, m + 1) where m = B_ORDER.
  • ap: double array[m+1][m+1]. The AP_i_j polynomial for pixel to focal plane transformation. Its size must be (m + 1, m + 1) where m = AP_ORDER.
  • bp: double array[m+1][m+1]. The BP_i_j polynomial for pixel to focal plane transformation. Its size must be (m + 1, m + 1) where m = BP_ORDER.
  • crpix: double array[2]. The reference pixel.
a

double array[a_order+1][a_order+1]

The SIP A_i_j matrix used for pixel to focal plane transformation.

Its values may be changed in place, but it may not be resized, without creating a new Sip object.

a_order

int (read-only)

The order of the polynomial in the SIP A_i_j array (A_ORDER).

ap

double array[ap_order+1][ap_order+1]

The SIP AP_i_j matrix used for focal plane to pixel transformation. Its values may be changed in place, but it may not be resized, without creating a new Sip object.

ap_order

int (read-only)

The order of the polynomial in the SIP AP_i_j array (AP_ORDER). int array[naxis]

An array of four-digit type codes for each axis.

  • First digit (i.e. 1000s):
    • 0: Non-specific coordinate type.
    • 1: Stokes coordinate.
    • 2: Celestial coordinate (including CUBEFACE).
    • 3: Spectral coordinate.
  • Second digit (i.e. 100s):
    • 0: Linear axis.
    • 1: Quantized axis (STOKES, CUBEFACE).
    • 2: Non-linear celestial axis.
    • 3: Non-linear spectral axis.
    • 4: Logarithmic axis.
    • 5: Tabular axis.
  • Third digit (i.e. 10s):
    • 0: Group number, e.g. lookup table number
  • The fourth digit is used as a qualifier depending on the axis type.
    • For celestial axes:
      • 0: Longitude coordinate.
      • 1: Latitude coordinate.
      • 2: CUBEFACE number.
    • For lookup tables: the axis number in a multidimensional table.

CTYPEia in "4-3" form with unrecognized algorithm code will have its type set to -1 and generate an error.

b

double array[b_order+1][b_order+1]

The SIP B_i_j matrix used for pixel to focal plane transformation. Its values may be changed in place, but it may not be resized, without creating a new Sip object.

b_order

int (read-only)

The order of the polynomial in the SIP B_i_j array (B_ORDER).

bp

double array[bp_order+1][bp_order+1]

The SIP BP_i_j matrix used for focal plane to pixel transformation. Its values may be changed in place, but it may not be resized, without creating a new Sip object.

bp_order

int (read-only)

The order of the polynomial in the SIP BP_i_j array (BP_ORDER). double array[naxis][naxis]

The CDi_ja linear transformation matrix.

For historical compatibility, three alternate specifications of the linear transforations are available in wcslib. The canonical PCi_ja with CDELTia, and the deprecated CDi_ja and CROTAia keywords. Although the deprecated versions may not formally co-exist with PCi_ja, the approach here is simply to ignore them if given in conjunction with PCi_ja.

has_pc, has_cd and has_crota can be used to determine which of these alternatives are present in the header.

These alternate specifications of the linear transformation matrix are translated immediately to PCi_ja by set and are nowhere visible to the lower-level routines. In particular, set resets cdelt to unity if CDi_ja is present (and no PCi_ja). If no CROTAia is associated with the latitude axis, set reverts to a unity PCi_ja matrix.

crpix

double array[naxis]

Coordinate reference pixels (CRPIXja) for each pixel axis.

foc2pix

sip_foc2pix(foccrd, origin) -> double array[ncoord][nelem]

Convert focal plane coordinates to pixel coordinates using the SIP polynomial distortion convention.

  • foccrd: double array[ncoord][nelem]. Array of focal plane coordinates.
  • origin: int. Specifies the origin of pixel values. The Fortran and FITS standards use an origin of 1. Numpy and C use array indexing with origin at 0.

Returns an array of pixel coordinates.

Exceptions:

  • MemoryError: Memory allocation failed.
  • ValueError: Invalid coordinate transformation parameters.
pix2foc

sip_pix2foc(pixcrd, origin) -> double array[ncoord][nelem]

Convert pixel coordinates to focal plane coordinates using the SIP polynomial distortion convention.

  • pixcrd: double array[ncoord][nelem]. Array of pixel coordinates.
  • origin: int. Specifies the origin of pixel values. The Fortran and FITS standards use an origin of 1. Numpy and C use array indexing with origin at 0.

Returns an array of focal plane coordinates.

Exceptions:

  • MemoryError: Memory allocation failed.
  • ValueError: Invalid coordinate transformation parameters.