Package pydrizzle :: Module makewcs
[hide private]
[frames] | no frames]

Module makewcs

source code


MAKEWCS.PY - Updated the WCS in an image header so that
            it matches the geometric distortion defined in an IDC table
            which is referenced in the image header.

License: http://www.stsci.edu/resources/software_hardware/pyraf/LICENSE

This version tries to implement a full updating of the WCS based on
information about the V2/V3 plane which is obtained from th IDCTAB and,
in the case of WFPC2, the OFFTAB.

The only parameters from the original WCS which are retained are
the CRVALs of the reference chip.

The original WCS are first copied to MCD1_1 etc before being updated.

:UPINCD History:
First try, Richard Hook, ST-ECF/STScI, August 2002.
Version 0.0.1 (WJH) - Obtain IDCTAB using PyDrizzle function.
Version 0.1 (WJH) - Added support for processing image lists.
                    Revised to base CD matrix on ORIENTAT, instead of PA_V3
                    Supports subarrays by shifting coefficients as needed.
Version 0.2 (WJH) - Implemented orientation computation based on PA_V3 using
                    Troll function from Colin to compute new ORIENTAT value.
Version 0.3 (WJH) - Supported filter dependent distortion models in IDCTAB
                    fixed bugs in applying Troll function to WCS.
Version 0.4 (WJH) - Updated to support use of 'defaultModel' for generic
                    cases: XREF/YREF defaults to image center and idctab
                    name defaults to None.
Version 0.5 (WJH) - Added support for WFPC2 OFFTAB updates, which updates
                    the CRVALs.  However, for WFPC2 data, the creation of
                    the backup values does not currently work.
:MAKEWCS History:
MAKEWCS V0.0 (RNH) - Created new version to implement more complete
                     WCS creation based on a reference tangent plane.

        V0.1 (RNH) - First working version for tests. May 20th 2004.
        V0.11 (RNH) - changed reference chip for ACS/WFC. May 26th 2004.
        V0.2 (WJH) - Removed all dependencies from IRAF and use new WCSObject
                    class for all WCS operations.
        V0.4 (WJH/CJH) - Corrected logic for looping of extension in FITS image.
        V0.5 (RNH) - Chip to chip CRVAL shifting logic change.
        V0.6 (CJH/WJH) - Added support for non-associated STIS data.
        V0.6.2 (WJH) - Added support for NICMOS data. This required
                        new versions of wcsutil and fileutil in PyDrizzle.
        V0.6.3 (WJH) - Modified to support new version of WCSUtil which correctly
                        sets up and uses archived WCS keywords.
        V0.7.0 (WJH) - Revised algorithm to work properly with subarray images.
                        Also, simplified keyword access using PyFITS object.
        V0.8.0 (CJH) - Modified to work with either numarray or numpy through
                        the use of the numerix interface layer.


Version: 1.1.7 (6 Jul 2010)

Functions [hide private]
 
run(input, quiet=True, restore=False, prepend='O', tddcorr=True)
makewcs - a task for updating an image header WCS to make it consistent with the distortion model and velocity aberration.
source code
 
restoreCD(image, prepend) source code
 
_update(image, idctab, nimsets, apply_tdd=False, quiet=None, instrument=None, prepend=None, nrchip=None, nrext=None) source code
 
diff_angles(a, b)
Perform angle subtraction a-b taking into account small-angle differences across 360degree line.
source code
 
readKeyword(hdr, keyword) source code
 
get_numsci(image)
Find the number of SCI extensions in the image.
source code
 
shift_coeffs(cx, cy, xs, ys, norder)
Shift reference position of coefficients to new center where (xs,ys) = old-reference-position - subarray/image center.
source code
 
getNrefchip(image, instrument='WFPC2')
This handles the fact that WFPC2 subarray observations may not include chip 3 which is the default reference chip for full observations.
source code
 
help() source code
Variables [hide private]
  yes = True
  no = False
  PARITY = {'HRC': [[-1.0, 0.0], [0.0, 1.0]], 'IR': [[-1.0, 0.0]...
  NUM_PER_EXTN = {'ACS': 3, 'NICMOS': 5, 'STIS': 3, 'WFC3': 3, '...
  _help_str = ' makewcs - a task for updating an image header WC...
  __package__ = 'pydrizzle'
  e = 2.71828182846
  pi = 3.14159265359

Imports: numerixenv, os, pyfits, drutil, models, mutil, fileutil, wcsutil, parseinput, N, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, copysign, cos, cosh, degrees, erf, erfc, exp, expm1, fabs, factorial, floor, fmod, frexp, fsum, gamma, hypot, isinf, isnan, ldexp, lgamma, log, log10, log1p, modf, pow, radians, sin, sinh, sqrt, tan, tanh, trunc


Function Details [hide private]

run(input, quiet=True, restore=False, prepend='O', tddcorr=True)

source code 
makewcs - a task for updating an image header WCS to make
      it consistent with the distortion model and velocity aberration.

This task will read in a distortion model from the IDCTAB and generate
a new WCS matrix based on the value of ORIENTAT.  It will support subarrays
by shifting the distortion coefficients to image reference position before
applying them to create the new WCS, including velocity aberration.
Original WCS values will be moved to an O* keywords (OCD1_1,...).
Currently, this task will only support ACS and WFPC2 observations.

Parameters
----------
input: str
    The filename(s) of image(s) to be updated given either as:
      * a single image with extension specified,
      * a substring common to all desired image names,
      * a wildcarded filename
      * '@file' where file is a file containing a list of images

quiet: bool
    turns off ALL reporting messages: 'yes' or 'no'(default)

prepend: char
    This parameter specifies what prefix letter should be used to
    create a new set of WCS keywords for recording the original values
    [Default: 'O']

restore: bool
    restore WCS for all input images to defaults if possible:
    'yes' or 'no'(default)

tddcorr: bool
    applies the time-dependent skew terms to the SIP coefficients
    written out to the header: 'yes' or True or, 'no' or False (default).

Notes
-----
This function can be run using the syntax:
    makewcs.run(image,quiet=no,prepend='O',restore=no,tddcorr=True)
An example of how this can be used is given as::

    >>> import makewcs
    >>> makewcs.run('raw') # This will update all _raw files in directory
    >>> makewcs.run('j8gl03igq_raw.fits[sci,1]')

get_numsci(image)

source code 
Find the number of SCI extensions in the image.
Input:
    image - name of single input image

shift_coeffs(cx, cy, xs, ys, norder)

source code 

Shift reference position of coefficients to new center where (xs,ys) = old-reference-position - subarray/image center. This will support creating coeffs files for drizzle which will be applied relative to the center of the image, rather than relative to the reference position of the chip.

Derived directly from PyDrizzle V3.3d.

getNrefchip(image, instrument='WFPC2')

source code 

This handles the fact that WFPC2 subarray observations may not include chip 3 which is the default reference chip for full observations. Also for subarrays chip 3 may not be the third extension in a MEF file. It is a kludge but this whole module is one big kludge. ND


Variables Details [hide private]

PARITY

Value:
{'HRC': [[-1.0, 0.0], [0.0, 1.0]],
 'IR': [[-1.0, 0.0], [0.0, 1.0]],
 'NICMOS': [[-1.0, 0.0], [0.0, 1.0]],
 'SBC': [[-1.0, 0.0], [0.0, 1.0]],
 'STIS': [[-1.0, 0.0], [0.0, 1.0]],
 'UVIS': [[-1.0, 0.0], [0.0, 1.0]],
 'WFC': [[1.0, 0.0], [0.0, -1.0]],
 'WFPC2': [[-1.0, 0.0], [0.0, 1.0]],
...

NUM_PER_EXTN

Value:
{'ACS': 3, 'NICMOS': 5, 'STIS': 3, 'WFC3': 3, 'WFPC2': 1}

_help_str

Value:
''' makewcs - a task for updating an image header WCS to make
      it consistent with the distortion model and velocity aberration.

This task will read in a distortion model from the IDCTAB and generate
a new WCS matrix based on the value of ORIENTAT.  It will support suba\
rrays
by shifting the distortion coefficients to image reference position be\
fore
...