Package pydrizzle :: Module buildasn
[hide private]
[frames] | no frames]

Module buildasn

source code

buildasn.py - Module to generate an ACS-style association
table from all matching files from the current working directory.

This module will also recognize shiftfiles should they be specified
and add the offsets to the ASN table.

W.J. Hack 9 April 2001
    *** INITIAL VERSION

W.J Hack 24 April 2001
    Version 0.1b - Modified to support FITS version 0.4.2

W.J Hack, 1 May 2001
    Version 0.2  - Computes delta from given shifts file and header info

WJH, 20 Nov 2001:
    Version 0.3 - Added ROTATION column to default ASN table created.

WJH, 4 Dec 2001:
    Added help() function and printing of Version number.

WJH, 21 Jan 2002:
    Fixed bugs in writing out ASN table with default columns.
    Also added check to insure that files are found to build ASN table.

WJH, 8 Mar 2002:
    Added MEMPRSNT column and converted to use PyFITS v0.6.2 and numarray.

WJH, 12 June 2002 (0.5a):
    Changed 'pyfits.version' to 'pyfits.__version__' to keep up with PyFITS.

WJH, 20 Aug 2002 (0.6):
    Revised interface to accept wild-card specification and @files as well
        as filename partial (such as 'crj' or '440w').

WJH, 3 Dec 2002 (0.6a):
    Simplified interface to 'readShiftFile' for use with 'updateasn'; it now
    returns a dictionary without requiring it be pre-defined.

WJH, 3 Dec 2002 (0.6b):
    Blank lines in shiftfiles will now work.

WJH, 11 Apr 2003 (0.7):
    Support new shiftfile convention, as well as optional SCALE column.

WJH, 3 Jun 2003 (0.7a):
    Added logic to ignore blank lines in shift file.

WJH, 25 Aug 2003 (0.8)
    Updated to support numarray 0.6 using the new format letter codes.

CJH, 13 Jul 2004 (0.9)
    Updated to support input of simple python list as linename input.

CJH, 02 Aug 2004 (0.9a)
    Added support to find files for having 2 columns of filenames in an @inputlist
    file.  This is used by Multidrizzle to implement the use of IVM files.
WJH/CJH, 28 Sept 2004 (0.9.2)
    Added support to findFiles for comma separated string input.  Also corrected
    a bug in the processing of @files in which rstrip() was not being applied to
    the filenames leaving a trailing newline character.
WJH, 15 Nov 2004 (0.9.3)
    Moved 'readShiftFile' to 'fileutil.py' so it would not need to import
        'buildasn'. Instead, we use 'from fileutil import readShiftFile' here
WJH, 20 Dec 2004 (0.9.4)
    Added 'writeAsnDict' to output the ASN table dictionary read in using
    'readAsnTable' to a file.
WJH, 11 May 2005 (0.9.5)
    Modified to append reference WCS extension if given in shiftfile.
WJH, 28 June 2005 (0.9.5a)
    New 'order' keyword in dictionary from reading the shift file now used
        to index files.


Version: 0.9.5a (28-June-2005)

Functions [hide private]
 
buildAsnTable(asnroot, suffix=None, shiftfile=None, verbose='no')
Create an association table from all specified files in the current directory.
source code
 
_findFiles(inlist)
Builds list of all files which contain suffix.
source code
 
_findSuffix(fname) source code
 
_updateKeyword(key, inhdr, outhdr, default='UNKNOWN')
Safely updates keyword key in outhdr from value in inhdr.
source code
 
_findRefFile(sdict, flist)
Function which identifies the image from an association which serves as the reference, zero-offset position.
source code
 
_computeDeltaShifts(sdict, ref_file, flist)
Function which subtracts commanded offsets from headers from total offsets found in sdict.
source code
 
_buildTableRows(filelist, shiftdict, dthprod)
Create dictionary with each entry corresponding to a list of values for each column.
source code
 
_buildNewRootname(filename, extn=None, suffix=None)
Build rootname for a new file.
source code
 
_makeTableHDU(data)
Create new_table object for ASN table, including definitions for optional Offset/Rotation columns.
source code
 
_buildAsnPrimary(fasn, output, img1, frame=None, refimage=None)
Creates complete Primary header for ASN table based on template.
source code
 
makeTableDict(asndict)
Read in the dictionary created by 'readAsnTable' for an existing ASN table and convert it to the internal data dictionary used by 'makeTableHDU'.
source code
 
writeAsnDict(asndict, output=None)
writeAsnDict: ============= Write out a new ASN table using a dictionary in memory.
source code
 
help() source code
Variables [hide private]
  EXTLIST = ['_crj.fits', '_flt.fits', '_sfl.fits', '_cal.fits',...
  TABLE_DATA = {'units': None, 'frame': None, 'xsh': None, 'ysh'...
  _prihdr = pyfits.Header([pyfits.Card('SIMPLE', pyfits.TRUE, 'F...

Imports: os, re, types, copy, time, pyfits, N, readShiftFile, buildRootname, wcsutil


Function Details [hide private]

buildAsnTable(asnroot, suffix=None, shiftfile=None, verbose='no')

source code 
Create an association table from all specified files in
the current directory.  By default, it will include all 'crj' files.
The user may also specify their own list of files in different ways:
    as a file with a list of filenames using '@filename'
    using wild card specification of filenames, e.g. '*02t?q_flt* or '*f440w*'
    using part of a filename; such as 'f440w' or 'flt' or 'sfl'
    using a simple python list.

It would also add the columns XOFFSET, YOFFSET and ROTATION
and populate them with values from a shiftfile if one was specified
and can be read.

This function returns the name of the DITHER PRODUCT that was
created, then inserted into the ASN table. It will be
the rootname of asnroot with '_drz' appended, following the
general ACS pipeline filename conventions.

_findFiles(inlist)

source code 

Builds list of all files which contain suffix.

If a simple python list is supplied it will already be the list of files needed to build the ASN table.

_updateKeyword(key, inhdr, outhdr, default='UNKNOWN')

source code 

Safely updates keyword key in outhdr from value in inhdr. Uses value given by 'default' if keyword is not found in input header.

_findRefFile(sdict, flist)

source code 

Function which identifies the image from an association which serves as the reference, zero-offset position. It simply returns the filename for the image with the smallest total shift.

_computeDeltaShifts(sdict, ref_file, flist)

source code 

Function which subtracts commanded offsets from headers from total offsets found in sdict. Commanded offsets will always be relative to ref_file. <<OBSOLETE>>

_buildNewRootname(filename, extn=None, suffix=None)

source code 

Build rootname for a new file. Use 'extn' for new filename if given, otherwise does NOT append a suffix at all. Search for suffix if given.

Does NOT check to see if it exists already. Will ALWAYS return a new filename.

_buildAsnPrimary(fasn, output, img1, frame=None, refimage=None)

source code 

Creates complete Primary header for ASN table based on template. 'fasn' is the file handle of the newly opened ASN table file. Uses keyword values from 'img1' to update ASN header keywords.

writeAsnDict(asndict, output=None)

source code 

writeAsnDict:
=============
Write out a new ASN table using a dictionary in memory.
The input dictionary should be read in using 'readAsnTable',
and can be modified as needed before writing out the new table.

SYNTAX:
    buildasn.writeAsnDict(asndict,output=None)

PARAMETERS:
        asndict:    dictionary from 'readAsnTable
        output:     rootname or filename for output ASN file
    if output == None (default), product name from asndict will be
    used to define the output filename for the table.


Variables Details [hide private]

EXTLIST

Value:
['_crj.fits', '_flt.fits', '_sfl.fits', '_cal.fits', '_raw.fits', '.c0\
h', '.hhh', '.fits']

TABLE_DATA

Value:
{'units': None, 'frame': None, 'xsh': None, 'ysh': None, 'dx': None, '\
dy': None, 'rot': None, 'scl': None, 'name': None, 'mtype': None, 'mpr\
snt': None}

_prihdr

Value:
pyfits.Header([pyfits.Card('SIMPLE', pyfits.TRUE, 'Fits standard'), py\
fits.Card('BITPIX  ', 16, ' Bits per pixel'), pyfits.Card('NAXIS   ', \
0, ' Number of axes'), pyfits.Card('ORIGIN  ', 'NOAO-IRAF FITS Image K\
ernel July 1999', 'FITS file originator'), pyfits.Card('IRAF-TLM', '18\
:26:13 (27/03/2000)', ' Time of last modification'), pyfits.Card('EXTE\
ND  ', pyfits.TRUE, ' File may contain standard extensions'), pyfits.C\
ard('NEXTEND ', 1, ' Number of standard extensions'), pyfits.Card('DAT\
E    ', '2001-02-14T20:07:57', ' date this file was written (yyyy-mm-d\
...