starlink.Atl
module within PyAST provides a small number
of high level functions and classes that wrap up various other PyAST
calls to perform commonly required operations.
readfitswcs:
The header from the specified
PyFITS HDU is read, and an AST
FrameSet describing the WCS
information in the header is returned. None
is returned instead of a
FrameSet if WCS information cannot be read from the header. A string
identifying the scheme used to describe WCS information in the header
(the encoding) is also returned.
Synopsis:
(frameset,encoding) = starlink.Atl.readfitswcs( hdu )
hdu
pyfits.open()
. If the entire hdulist is supplied, rather than
an element of the hdulist, then the primary HDU (element zero) will be
used.frameset
None
if no WCS could be read.encoding
Example:
>>> import pyfits >>> import starlink.Atl as Atl >>> >>> hdulist = pyfits.open( 'test.fit' ) >>> frameset = Atl.readfitswcs( hdulist ) >>> if frameset == None: >>> print( "Cannot read WCS from test.fit" )
plotfitswcs:
Synopsis:
plot = starlink.Atl.plotfitswcs( axes, gbox, hdu, options="" )
axes
gbox
hdu
pyfits.open()
. If the entire hdulist is supplied, rather than
an element of the hdulist, then the primary HDU (element zero) will be
used.options
plot
Example:
>>> import pyfits >>> import starlink.Atl as Atl >>> import matplotlib.pyplot >>> >>> hdulist = pyfits.open( 'test.fit' ) >>> Atl.plotfitswcs( matplotlib.pyplot.figure().add_subplot(111), >>> [ 0.1, 0.1, 0.9, 0.9 ], hdulist ) >>> matplotlib.pyplot.show()
plotframeset:
Synopsis:
plot = starlink.Atl.plotframeset( axes, gbox, bbox, frameset, options="" )
axes
gbox
bbox
frameset
starlink.Atl.readfits
function. Its base Frame should be
2-dimensional.
options
plot
Example:
>>> import pyfits >>> import starlink.Atl as Atl >>> import matplotlib.pyplot >>> >>> hdulist = pyfits.open( 'test.fit' ) >>> frameset = starlink.Atl.readfitswcs( hdulist ) >>> if frameset != None: >>> naxis1 = hdulist[0].header['NAXIS1'] >>> naxis2 = hdulist[0].header['NAXIS2'] >>> Atl.plotframeset( matplotlib.pyplot.figure().add_subplot(111), >>> [ 0.1, 0.1, 0.9, 0.9 ], >>> [ 0.5, 0.5, naxis1+0.5, naxis2+0.5 ], frameset ) >>> matplotlib.pyplot.show()
writefitswcs:
The WCS information described by the supplied FrameSet is converted into a set of FITS header cards which are stored in the supplied PyFITS HDU (all cards in the header are first removed).
Synopsis:
nobj = starlink.Atl.writefitswcs( frameset, hdu, encoding="FITS-WCS" )
frameset
hdu
encoding
nobj
Example:
>>> import starlink.Atl as Atl >>> >>> (frameset,encoding) = Atl.readfitswcs( hdu1 ) >>> if Atl.writefitswcs( frameset, hdu2, encoding="FITS-AIPS" ) == 0: >>> if frameset == None: >>> print( "Cannot convert WCS to FITS-AIPS encoding" )
PyFITSAdapter:
When used as a FitsChan source, the PyFITSAdapter will allow the
FitsChan to read each of the cards in the associated PyFITS header,
thus allowing the cards to be copied into the FitsChan. This happens
when the newly created, empty FitsChan is used for the first time
(i.e. when any of its methods is invoked), and subsequently whenever
the FitsChan.readfits()
method is invoked.
When used as a FitsChan sink, the PyFITSAdapter will allow the
FitsChan to copy its own header cards into the PyFITS header. This
happens when the FitsChan is deleted or when the FitsChan.writefits()
method is invoked. If the PyFITSAdapter.clear property is true, then
the PyFITS header is first emptied of all existing headers, and the
contents of the FitsChan are then stored in the PyFITS header. If the
PyFITSAdapter.clear property is False, the original contents of the
PyFITS header are retained. In this case each FitsChan card replaces any
existing card that refers to the same keyword (if there is no card
for the keyword already in the PyFITS header, the FitsChan card will
be appended to the end of the header).
The class provides a public constructor, but no public methods.
Synopsis:
pyfitsadapter = starlink.Atl.PyFITSAdapter( hdu, clear=True )
hdu
hdulist
associated with a FITS file opened
using "pyfits.open()". If the entire hdulist is supplied, rather
than an element of the hdulist, then the primary HDU (element zero) will be
used.clear
Example:
>>> import pyfits >>> import starlink.Atl as Atl >>> import starlink.Ast as Ast >>> >>> hdulist = pyfits.open( 'test.fit' ) >>> adapter = Atl.PyFITSAdapter( hdulist[ 1 ] ) >>> fc = Ast.FitsChan( adapter, adapter ) >>> frameset = fc.read() >>> fc.writefits()
This example fills a FitsChan with the headers from the first extension in 'test.fit'. It then reads WCS information from the FitsChan. Since FitsChan reads are destructive, this causes all the WCS-related keywords to be deleted from the FitsChan. The remaining non-WCS keywords are then written out to the original PyAST header (the PyAST header is empted first). The net effect is to remove all WCS keywords from the PyAST header.