Association File Interpretation¶
Association files serve as FITS tables which relate a set of input files to the generation of calibrated or combined products.
A module which provides utilities for reading, writing, creating and updating association tables and shift files.
author: | Warren Hack, Nadia Dencheva |
---|---|
version: | ‘0.1 (2008-01-03)’ |
-
class
stsci.tools.asnutil.
ASNMember
(xoff=0.0, yoff=0.0, rot=0.0, xshift=0.0, yshift=0.0, scale=1.0, dshift=False, abshift=False, refimage='', shift_frame='', shift_units='pixels', row=0)¶ A dictionary like object representing a member of an association table. It looks like this:
'j8bt06nzq': {'abshift': False, 'dshift': True, 'refimage': 'j8bt06010_shifts_asn.fits[wcs]', 'rot': 359.99829, 'row': 1, 'scale': 1.000165, 'shift_frame': 'input', 'shift_units': 'pixels', 'xoff': 0.0, 'xshift': 0.4091132, 'yoff': 0.0, 'yshift': -0.56702018}
If abshift is True, shifts, rotation and scale refer to absolute shifts. If dshift is True, they are delta shifts.
-
class
stsci.tools.asnutil.
ASNTable
(inlist=None, output=None, shiftfile=None)¶ A dictionary like object which represents an association table. An ASNTable object looks like this:
{'members': {'j8bt06nyq': {'abshift': False, 'dshift': True, 'refimage': 'j8bt06010_shifts_asn.fits[wcs]', 'rot': 0.0, 'row': 0, 'scale': 1.0, 'shift_frame': 'input', 'shift_units': 'pixels', 'xoff': 0.0, 'xshift': 0.0, 'yoff': 0.0, 'yshift': 0.0}, 'j8bt06nzq': {'abshift': False, 'dshift': True, 'refimage': 'j8bt06010_shifts_asn.fits[wcs]', 'rot': 359.99829, 'row': 1, 'scale': 1.000165, 'shift_frame': 'input', 'shift_units': 'pixels', 'xoff': 0.0, 'xshift': 0.4091132, 'yoff': 0.0, 'yshift': -0.56702018}}, 'order': ['j8bt06nyq', 'j8bt06nzq'], 'output': 'j8bt06nyq'}
Examples
Creating an ASNTable object from 3 filenames and a shift file would be done using:
>>> asnt=ASNTable([fname1,fname2, fname3], shiftfile='shifts.txt')
The ASNTable object would have the ‘members’ and ‘order’ in the association table populated based on infiles and shiftfile.
This creates a blank association table from the ASNTable object:
>>> asnt.create()
-
buildPrimary
(fasn, output=None)¶
-
create
(shiftfile=None)¶
-
update
([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
write
(output=None)¶ Write association table to a file.
-
-
class
stsci.tools.asnutil.
ShiftFile
(filename='', form='delta', frame=None, units='pixels', order=None, refimage=None, **kw)¶ A shift file has the following format (name, Xsh, Ysh, Rot, Scale):
# frame: output # refimage: tweak_wcs.fits[wcs] # form: delta # units: pixels j8bt06nyq_flt.fits 0.0 0.0 0.0 1.0 j8bt06nzq_flt.fits 0.4091132 -0.5670202 359.9983 1.000165
This object creates a dict like object representing a shift file used by Pydrizzle and Mirashift.
-
readShiftFile
(filename)¶ Reads a shift file from disk and populates a dictionary.
-
verifyShiftFile
()¶ Verifies that reference file exists.
-
writeShiftFile
(filename='shifts.txt')¶ Writes a shift file object to a file on disk using the convention for shift file format.
-
-
stsci.tools.asnutil.
readASNTable
(fname, output=None, prodonly=False)¶ Given a fits filename repesenting an association table reads in the table as a dictionary which can be used by pydrizzle and multidrizzle.
An association table is a FITS binary table with 2 required columns: ‘MEMNAME’, ‘MEMTYPE’. It checks ‘MEMPRSNT’ column and removes all files for which its value is ‘no’.
Parameters: - fname (str) – name of association table
- output (str) – name of output product - if not specified by the user, the first PROD-DTH name is used if present, if not, the first PROD-RPT name is used if present, if not, the rootname of the input association table is used.
- prodonly (bool) – what files should be considered as input if True - select only MEMTYPE=PROD* as input if False - select only MEMTYPE=EXP as input
Returns: asndict – A dictionary-like object with all the association information.
Return type: Examples
An association table can be read from a file using the following commands:
>>> from stsci.tools import asnutil >>> asntab = asnutil.readASNTable('j8bt06010_shifts_asn.fits', prodonly=False)
The asntab object can now be passed to other code to provide relationships between input and output images defined by the association table.