User Interface: altwcs
The functions in this module manage alternate WCS’s in a header.
- stwcs.wcsutil.altwcs.archive_wcs(fname, ext, wcskey=None, wcsname=None, mode=<ArchiveMode.NO_CONFLICT: 0>)
Copy the primary WCS to the header as an alternate WCS with the specified
wcskeyand namewcsname. It loops over all extensions in ‘ext’.- Parameters:
fname (string or
astropy.io.fits.HDUList) – File name or aastropy.io.fits.HDUListwhose primary WCS need to be archived.ext (int, tuple, str, or list of integers or tuples (e.g.('sci',1))) –
Specifies FITS extensions whose primary WCS should be archived.
If a string is provided, it should specify the EXTNAME of extensions with WCSs to be archived
wcskey ({'A'-'Z'}, None, optional) – When
wcskeyisNone, andwcsnameis notNoneand an alternate WCS exist with the same name aswcsname, the key of this alernate WCS will be used forwcskey. Ifwcsnameis unique, the next available key will be used. Ifwcskeyis a letter'A'-'Z', the primary WCS will be archived to the indicated key. If an alternate WCS with the specified key already exist an exception will be raisen unless mode includes either flagArchiveMode.OVERWRITE_KEYorArchiveMode.QUIET_ABORT.wcsname (str, None, optional) –
Name of alternate WCS description. If
None, the WCS name will be initially set to the name of the primary WCS if available. If primary WCS does not have'WCSNAME'set and providedwcskeyis notNoneand a WCS with this key already exists in the header, the name of this alternate WCS will be used. I this alternate WCS does not have'WCSNAME'set and provided, a default WCS name will be used.Note
An exception will be raisen if an alternate WCS with provided name already exists in image’s headers unless
modeincludesArchiveMode.AUTO_RENAMEflag in which casewcsnamewill be automatically adjusted to be unique.mode (int, optional) –
An integer mask containing one or more flags from
ArchiveMode:NO_CONFLICT: Archive only when provided WCS key or name do not conflict with existing alternate WCS or when existing alternate WCS is identical to the primary WCS being archived.AUTO_RENAME: Rename primary WCS if same name is already used by an alternate WCS (in order to keep alternate WCS names unique).OVERWRITE_KEY: Overwrite an existing alternate WCS with the same key aswcskey.QUIET_ABORT: Stop archiving and quit if conflicts exists without raising exceptions.
- Returns:
wcs_id – Returns effective WCS key and name used for the archived WCS. If archival failed due to conflicts, and
modewas set toArchiveMode.QUIET_ABORTa tuple of(None, None)will be returned.- Return type:
- 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 objectext (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
archive_wcs,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 (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
- stwcs.wcsutil.altwcs.wcsnames(fobj, ext=None, include_primary=True)
Returns a dictionary of wcskey: WCSNAME pairs
- Parameters:
fobj (stri,
astropy.io.fits.HDUListorastropy.io.fits.Header) – fits file name, fits file object or fits headerext (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 (str,
astropy.io.fits.HDUListorastropy.io.fits.Header) – fits file name, fits file object or fits headerext (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 (str,
astropy.io.fits.HDUListorastropy.io.fits.Header) – fits file name, fits file object or fits headerext (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 (str,
astropy.io.fits.HDUListorastropy.io.fits.Header) – fits file name, fits file object or fits headerext (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 (
astropy.io.fits.Header)wcsname (str) – value of WCSNAME