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.

Methods

clear()

copy()

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**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]

values()

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()  

Methods

clear()

copy()

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**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]

values()

write([output])

Write association table to a file.

buildPrimary

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.

Methods

clear()

copy()

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

readShiftFile(filename)

Reads a shift file from disk and populates a dictionary.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**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]

values()

verifyShiftFile()

Verifies that reference file exists.

writeShiftFile([filename])

Writes a shift file object to a file on disk using the convention for shift file format.

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:
fnamestr

name of association table

outputstr

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.

prodonlybool

what files should be considered as input if True - select only MEMTYPE=PROD* as input if False - select only MEMTYPE=EXP as input

Returns:
asndictdict

A dictionary-like object with all the association information.

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.