This module implements headerlets.
A headerlet serves as a mechanism for encapsulating WCS information which can be used to update the WCS solution of an image. The idea came up first from the desire for passing improved astrometric solutions for HST data and provide those solutions in a manner that would not require getting entirely new images from the archive when only the WCS information has been updated.
A Headerlet class Ref: http://mediawiki.stsci.edu/mediawiki/index.php/Telescopedia:Headerlets
Parameters : | |
---|---|
fobj: string :
mode: string, optional :
logging: boolean :
logmode: ‘w’ or ‘a’ :
|
Copy this headerlet as an alternate WCS to fobj
Parameters : | |
---|---|
fobj: string, HDUList :
attach: boolean :
wcskey: string :
wcsname: string :
|
Copy this headerlet as a primary WCS to fobj
Parameters : | |
---|---|
fobj: string, HDUList :
attach: boolean :
archive: boolean (default is True) :
force: boolean (default is False) :
|
Attach Headerlet as an HeaderletHDU to a science file
Parameters : | |
---|---|
fobj: string, HDUList :
archive: string :
|
Notes
The algorithm used by this method: - verify headerlet can be applied to this file (based on DESTIM) - verify that HDRNAME is unique for this file - attach as HeaderletHDU to fobj - update wcscorr
Builds the DISTNAME for dest based on reference file names.
Verify the headerlet file is a valid fits file and has the required Primary Header keywords
Prints a summary of this headerlet The summary includes:
HDRNAME WCSNAME DISTNAME SIPNAME NPOLFILE D2IMFILE
Parameters : | |
---|---|
columns: list :
pad: int :
maxwidth: int :
output: string (optional) :
clobber: bool :
quiet: bool :
|
Returns a summary of this headerlet as a dictionary
Parameters : | |
---|---|
columns: list :
|
|
Returns : | |
summary: dict :
|
Write this headerlet to a file
Parameters : | |
---|---|
fname: string :
destim: string (optional) :
hdrname: string (optional) :
clobber: boolean :
|
verifies that the headerlet can be applied to the observation
DESTIM in the primary header of the headerlet must match ROOTNAME of the science file (or the name of the destination file)
Verifies that the headerlet can be applied to the observation
Reports whether or not this file already has a headerlet with this HDRNAME.
Verifies that the headerlet can be applied to the observation
Determines whether or not the file specifies the same distortion model/reference files.
A non-standard extension HDU for encapsulating Headerlets in a file. These HDUs have an extension type of HDRLET and their EXTNAME is derived from the Headerlet’s HDRNAME.
The data itself is a FITS file embedded within the HDU data. The file name is derived from the HDRNAME keyword, and should be in the form <HDRNAME>_hdr.fits. If the COMPRESS keyword evaluates to True, the tar file is compressed with gzip compression.
The structure of this HDU is the same as that proposed for the ‘FITS’ extension type proposed here: http://listmgr.cv.nrao.edu/pipermail/fitsbits/2002-April/thread.html
The Headerlet contained in the HDU’s data can be accessed by the headerlet attribute.
Creates a new HeaderletHDU from a given Headerlet object.
Parameters : | |
---|---|
headerlet : Headerlet
compress : bool, optional
|
|
Returns : | |
hlet : HeaderletHDU
|
Return the encapsulated headerlet as a Headerlet object.
This is similar to the hdulist property inherited from the FitsHDU class, though the hdulist property returns a normal HDUList object.
Apply headerlet to a science observation as an alternate WCS
Parameters : | |
---|---|
filename: string :
hdrlet: string :
attach: boolean :
wcskey: string :
wcsname: string :
logging: boolean :
logmode: ‘a’ or ‘w’ : |
Apply headerlet ‘hdrfile’ to a science observation ‘destfile’ as the primary WCS
Parameters : | |
---|---|
filename: string :
hdrlet: string :
attach: boolean :
archive: boolean :
force: boolean :
logging: boolean :
logmode: ‘w’ or ‘a’ :
|
Save a WCS as a headerlet extension and write it out to a file.
This function will create a headerlet, attach it as an extension to the science image (if it has not already been archived) then, optionally, write out the headerlet to a separate headerlet file.
Either wcsname or wcskey must be provided, if both are given, they must match a valid WCS Updates wcscorr if necessary.
Parameters : | |
---|---|
filename: string or HDUList :
hdrname: string :
sciext: string :
wcsname: string :
wcskey: one of A...Z or ” ” or “PRIMARY” :
destim: string :
sipname: string or None (default) :
npolfile: string or None (default) :
d2imfile: string :
author: string :
descrip: string :
history: filename, string or list of strings :
logging: boolean :
logmode: ‘w’ or ‘a’ :
|
Attach Headerlet as an HeaderletHDU to a science file
Parameters : | |
---|---|
filename: string, HDUList :
hdrlet: string or Headerlet object :
logging: boolean :
logmode: ‘a’ or ‘w’ : |
Create a headerlet from a WCS in a science file If both wcskey and wcsname are given they should match, if not raise an Exception
Parameters : | |
---|---|
filename: string or HDUList :
sciext: string or python list (default: ‘SCI’) :
hdrname: string :
destim: string or None :
wcskey: char (A...Z) or ” ” or “PRIMARY” or None :
wcsname: string or None :
sipname: string or None (default) :
npolfile: string or None (default) :
d2imfile: string :
author: string :
descrip: string :
history: filename, string or list of strings :
logging: boolean :
logmode: ‘w’ or ‘a’ :
|
|
Returns : | |
Headerlet object : |
Deletes HeaderletHDU(s) from a science file
Parameters : | |
---|---|
filename: string or HDUList :
hdrname: string or None :
hdrext: int, tuple or None :
distname: string or None :
logging: boolean :
logmode: ‘a’ or ‘w’ : |
Notes
One of hdrname, hdrext or distname should be given. If hdrname is given - delete a HeaderletHDU with a name HDRNAME from fobj. If hdrext is given - delete HeaderletHDU in extension. If distname is given - deletes all HeaderletHDUs with a specific distortion model from fobj. Updates wcscorr
Finds a headerlet extension in a science file and writes it out as a headerlet FITS file.
If both hdrname and extnum are given they should match, if not raise an Exception
Parameters : | |
---|---|
filename: string or HDUList or Python list :
output: string :
extnum: int :
hdrname: string :
clobber: bool :
logging: boolean :
|
Returns all HeaderletHDU extensions in a science file that matches the inputs specified by the user. If no hdrext, hdrname or distname are specified, this function will return a list of all HeaderletHDU objects.
Parameters : | |
---|---|
fobj: string, pyfits.HDUList :
hdrext: int, tuple or None :
hdrname: string :
distname: string :
strict: bool [Default: True] :
logging: boolean :
logmode: ‘w’ or ‘a’ :
|
|
Returns : | |
hdrlets: list :
|
Returns a list of specified keywords from all HeaderletHDU extensions in a science file.
Parameters : | |
---|---|
fobj: string, pyfits.HDUList : kw: str :
|
returns the value of ROOTNAME or DESTIM
Print a summary of all HeaderletHDUs in a science file to STDOUT, and optionally to a text file The summary includes:
HDRLET_ext_number HDRNAME WCSNAME DISTNAME SIPNAME NPOLFILE D2IMFILE
Parameters : | |
---|---|
filename: string or HDUList :
columns: list :
pad: int :
maxwidth: int :
output: string (optional) :
clobber: bool :
quiet: bool :
|
Initialize logging for a function
Parameters : | |
---|---|
funcname: string :
level: int, or bool, or string :
mode: ‘w’ or ‘a’ :
|
Compares the WCS solution of 2 files.
Parameters : | |
---|---|
scifile: string :
file2: string :
scikey: string :
file2key: string :
logging: boolean :
|
Notes
These can be 2 science observations or 2 headerlets or a science observation and a headerlet. The two files have the same WCS solution if the following are the same:
Interprets the input as either a filename of a file that needs to be opened or a PyFITS object.
Parameters : | |
---|---|
fname: string, pyfits.HDUList :
mode: string :
|
|
Returns : | |
fobj: pyfits.HDUList :
fname: string :
close_fobj: bool :
|
Print out summary dictionary to STDOUT, and possibly an output file
Restores all HeaderletHDUs with a given distortion model as alternate WCSs and a primary
Parameters : | |
---|---|
filename: string or HDUList :
distname: string :
primary: int or string or None :
archive: boolean (default True) :
logging: boolean :
logmode: ‘a’ or ‘w’ : |
Restores a headerlet as a primary WCS
Parameters : | |
---|---|
filename: string or HDUList :
hdrname: string :
hdrext: int or tuple :
archive: boolean (default: True) :
force: boolean (default:False) :
logging: boolean :
logmode: ‘a’ or ‘w’ : |
Update the reference files name in the primary header of ‘dest’ using values from ‘source’
Parameters : | |
---|---|
source: pyfits.Header : dest: pyfits.Header : |
Verifies that no other HeaderletHDU extension has the specified hdrname.
Parameters : | |
---|---|
fobj: string, pyfits.HDUList :
hdrname: string :
|
|
Returns : | |
unique: bool :
|
Save a WCS as a headerlet FITS file.
This function will create a headerlet, write out the headerlet to a separate headerlet file, then, optionally, attach it as an extension to the science image (if it has not already been archived)
Either wcsname or wcskey must be provided; if both are given, they must match a valid WCS.
Updates wcscorr if necessary.
Parameters : | |
---|---|
filename: string or HDUList or Python list :
hdrname: string :
output: string or None :
sciext: string :
wcsname: string :
wcskey: one of A...Z or ” ” or “PRIMARY” :
destim: string :
sipname: string or None (default) :
npolfile: string or None (default) :
d2imfile: string :
author: string :
descrip: string :
history: filename, string or list of strings :
attach: bool :
clobber: bool :
logging: boolean :
|