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)¶ Deprecated since version 1.6.0: The archiveWCS function is deprecated and may be removed in a future version. Use archive_wcs instead.
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
astropy.io.fits.HDUList
) – file name or a file object - ext (int, tuple, str, 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 (bool) – if True - overwrites a WCS with the same key
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']
See also
wcsutil.restoreWCS()
- Copy an alternate WCS to the primary WCS
- fname (string or
-
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 (str or
astropy.io.fits.HDUList
) – file name or a file object - ext (int, tuple, str, 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 (str) – “A”-“Z” - Used for one of 26 alternate WCS definitions. or ” ” - find a key from WCSNAMe value
- wcsname (str) – (optional) if given and wcskey is ” “, will try to restore by WCSNAME value
See also
archiveWCS()
,restore_from_to()
- f (str or
-
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 (str or a
astropy.io.fits.HDUList
) – - ext (int, tuple, str, 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 (str) – one of ‘A’-‘Z’ or ” “
- wcsname (str) – Name of alternate WCS description
- fname (str or a
-
stwcs.wcsutil.altwcs.
wcsnames
(fobj, ext=None, include_primary=True)¶ Returns a dictionary of wcskey: WCSNAME pairs
Parameters: - fobj (stri,
astropy.io.fits.HDUList
orastropy.io.fits.Header
) – fits file name, fits file object or fits header - ext (int or None) – extension number if None, fobj must be a header
- fobj (stri,
-
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 (str,
astropy.io.fits.HDUList
orastropy.io.fits.Header
) – fits file name, fits file object or fits header - ext (int or None) – extension number if None, fobj must be a header
- fobj (str,
-
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 (str,
astropy.io.fits.HDUList
orastropy.io.fits.Header
) – fits file name, fits file object or fits header - ext (int or None) – extension number if None, fobj must be a header
- fobj (str,
-
stwcs.wcsutil.altwcs.
next_wcskey
(fobj, ext=None)¶ Returns next available character to be used for an alternate WCS
Parameters: - fobj (str,
astropy.io.fits.HDUList
orastropy.io.fits.Header
) – fits file name, fits file object or fits header - ext (int or None) – extension number if None, fobj must be a header
- fobj (str,
-
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 (
astropy.io.fits.Header
) – - wcsname (str) – value of WCSNAME
- header (