Previous topic

HSTWCS Examples

Next topic

UPDATEWCS

This Page

User Interface: altwcs

The functions in this module manage alternate WCS’s in a header.

stwcs.wcsutil.altwcs.archiveWCS(fname, ext, wcskey=' ', wcsname=' ', reusekey=False)

Copy the primary WCS to the header as an alternate WCS with wcskey and name WCSNAME. It loops over all extensions in ‘ext’

Parameters :
 

fname: string or pyfits.HDUList :

a file name or a file object

ext: an int, a tuple, string, or list of integers or tuples (e.g.(‘sci’,1)) :

fits extensions to work with If a string is provided, it should specify the EXTNAME of extensions with WCSs to be archived

wcskey: string “A”-“Z” or ” “ :

if ” ”: get next available key if wcsname is also ” ” or try to get a key from WCSNAME value

wcsname: string :

Name of alternate WCS description

reusekey: boolean :

if True - overwrites a WCS with the same key

See also

wcsutil.restoreWCS
Copy an alternate WCS to the primary WCS

Examples

Copy the primary WCS of an in memory headrlet object to an alternate WCS with key ‘T’

>>> hlet=headerlet.createHeaderlet('junk.fits', 'hdr1.fits')
>>> altwcs.wcskeys(hlet[1].header)
['A']
>>> altwcs.archiveWCS(hlet, ext=[('SIPWCS',1),('SIPWCS',2)], wcskey='T')
>>> altwcs.wcskeys(hlet[1].header)
['A', 'T']
stwcs.wcsutil.altwcs.restoreWCS(f, ext, wcskey=' ', wcsname=' ')

Copy a WCS with key “WCSKEY” to the primary WCS

Reads in a WCS defined with wcskey and saves it as the primary WCS. Goes sequentially through the list of extensions in ext. Alternatively uses ‘fromext’ and ‘toext’.

Parameters :
 

f: string or pyfits.HDUList object :

a file name or a file object

ext: an int, a tuple, string, or list of integers or tuples (e.g.(‘sci’,1)) :

fits extensions to work with If a string is provided, it should specify the EXTNAME of extensions with WCSs to be archived

wcskey: a charater :

“A”-“Z” - Used for one of 26 alternate WCS definitions. or ” ” - find a key from WCSNAMe value

wcsname: string (optional) :

if given and wcskey is ” ”, will try to restore by WCSNAME value

See also

archiveWCS, restore_from_to

stwcs.wcsutil.altwcs.deleteWCS(fname, ext, wcskey=' ', wcsname=' ')

Delete an alternate WCS defined with wcskey. If wcskey is ” ” try to get a key from WCSNAME.

Parameters :
 

fname: sting or a pyfits.HDUList object :

ext: an int, a tuple, string, or list of integers or tuples (e.g.(‘sci’,1)) :

fits extensions to work with If a string is provided, it should specify the EXTNAME of extensions with WCSs to be archived

wcskey: one of ‘A’-‘Z’ or ” “ :

wcsname: string :

Name of alternate WCS description

stwcs.wcsutil.altwcs.wcsnames(fobj, ext=None)

Returns a dictionary of wcskey: WCSNAME pairs

Parameters :
 

fobj: string, pyfits.HDUList or pyfits.Header :

fits file name, pyfits file object or pyfits header

ext: int or None :

extension number if None, fobj must be a header

stwcs.wcsutil.altwcs.wcskeys(fobj, ext=None)

Returns a list of characters used in the header for alternate WCS description with WCSNAME keyword

Parameters :
 

fobj: string, pyfits.HDUList or pyfits.Header :

fits file name, pyfits file object or pyfits header

ext: int or None :

extension number if None, fobj must be a header

stwcs.wcsutil.altwcs.available_wcskeys(fobj, ext=None)

Returns a list of characters which are not used in the header with WCSNAME keyword. Any of them can be used to save a new WCS.

Parameters :
 

fobj: string, pyfits.HDUList or pyfits.Header :

fits file name, pyfits file object or pyfits header

ext: int or None :

extension number if None, fobj must be a header

stwcs.wcsutil.altwcs.next_wcskey(fobj, ext=None)

Returns next available character to be used for an alternate WCS

Parameters :
 

fobj: string, pyfits.HDUList or pyfits.Header :

fits file name, pyfits file object or pyfits header

ext: int or None :

extension number if None, fobj must be a header

stwcs.wcsutil.altwcs.getKeyFromName(header, wcsname)

If WCSNAME is found in header, return its key, else return None. This is used to update an alternate WCS repeatedly and not generate new keys every time.

Parameters :
 

header: pyfits.Header :

wcsname: str :

Value of WCSNAME