combFilter (version 1.13)
index
/acs/science/pipeline/lib/python/apsis/combFilter.py

# $Id: combFilter.py,v 1.13 2003/02/27 23:56:44 anderson Exp $
# ---------------------------------------------------------------------
# $Log: combFilter.py,v $
# Revision 1.13  2003/02/27 23:56:44  anderson
# undone the previous revision.  the addition of ramps filters to the
# delFilt list would have the effect of not producing catalogs for those
# filters.  This is likely not desirable behaviour.
#
# Revision 1.12  2003/02/27 20:57:58  jpb
# Added ramp filters to the delete list.
#
# Revision 1.11  2003/01/31 17:04:09  jpb
# Added multiplication of the detectionWeight image by edge masks, if
# found in the images directory.
#
# Revision 1.10  2002/09/13 15:33:15  anderson
# Revision to add new keywords PA_V3 and PA_FINAL to the list of
# copied keywords for the detectionImage header.
#
# Revision 1.9  2002/06/27 20:31:13  anderson
# update to include pyfits and numarray in the
# module message markup
#
# Revision 1.8  2002/06/20 21:07:44  anderson
# Revision to provide consistent filenames in messages with relative
# pathnames from the path described in the <root> element of each
# module message.  This was an update to this module's mkMsg method.
#
# Revision 1.7  2002/06/13 23:04:54  anderson
# added some robustness (try/except) to the deletion of the EXTEND keyword
# should pyfits ever decide to stop writing that keyword automatically
#
# Revision 1.6  2002/06/13 22:49:29  anderson
# Update to full implementation with pyfits and numarray.
#
# Revision 1.5  2002/05/29 22:02:19  jpb
# Allow a means for omitting images in specific filter from the produced
detectionImage.  This is done via the "delFilters=" optional flag to the
# constructor, which defaults to the "_delFiltsDef" list; as of this revision,
# the content of this default list is just 'G800L' (i.e., don't use grism
# images for the detectionImage) but may be expanded in future to contain
# narrow-band filters, ramps, or whatever filter that we may want to
# process up through drizzling but not use for detectionImage generation.
#
# Revision 1.4  2002/05/22 14:37:20  anderson
# Revision addresses Bugzilla bug #1303:
# the only MIME type for FITS files is image/x-fits.
#
# Revision 1.3  2002/05/16 18:46:12  anderson
# Bringing all apsis modules to a common rev level.
# K Anderson
#
# Revision 1.1.1.1  2002/05/03 17:39:34  anderson
# initial revision and release of the ACS Science pipeline, apsis
#
# ---------------------------------------------------------------------
# created by K Anderson 30-03-01
#
# This module provides the detectionImage class which provides methods to create
# a detection image from n filter images. A list of filter images is provided by
# Observation object (obs.sciImageList).  setpars() simply writes a dummy .inpar
# file for SExtractor which sets a high detection threshold (DETECT_THRESH) so
# that no sources are found.  Sextractor is run with the getStats() method after
# the dummy .inpar file is written to produce noise and background statistics
# which are used in the generation of the detetion image. These stats are
# produced by SExtractor when VERBOSE mode is either NORMAL or FULL. 
# Here it is run in NORMAL mode.
#
# - modified to use the new observation attribute sciImageList.
# K Anderson
# 22-05-01
#
# allows use of pyfits to make the output detection image via the mkIm() method 
# - jpb.

 
Modules
            
fUtil
numarray
numinclude
os
pUtil
popen2
pyfits
string
xmlUtil
 
Classes
            
detectionImage
 
class detectionImage
       class provides a detectionImage object with methods to create an
optimally combined (chi_square?) image from an observation's fits files.
The detection image is written to the observations Images directory.
 
   Methods defined here:
__init__(self, obs, delFilters=['G800L'])
 constructor gets an Observation object (obs) from the pipeline.
_fixHeader(self, fitsfile=None)
  Fix up the header of the detection Image (default).
optional parameter 'fitsfile' can be used to specify some other
image (notably, the detectionWeight image) for header fix.
_fixIrafHeader(self, fitsfile=None)
fix up the header of the detection Image.
_medFilterMaskedWgtIm(self, imname, medfiltsize=5)
 Method to median filter an image, intended to be the
detection weight image.  Default filter size is 5 pix.
It first makes a mask from the input image so that no input
zero pixels (which are specially flagged as having no weight)
become nonzero after filtering.
getStats(self)
Runs SExtractor with phoney pars to get noise and background stats. 
Now implement this using the Popen4 class, which sends both stdout
and stderr to the fromchild file object.  We suppress stdout from 
SExtractor by shunting stuff to /dev/null via the par file, so we
will only get stderr anyway, at least, in theory.  The Popen3 class
or rather, the factory function is uses, popen3, has proved
to be buggy at times, so this is an attempt to move away from it.
getinpar(self, param)
Returns value of input parameter given a parameter name
mkChi2Im(self)
Make the detection image using Numeric package, not IRAF.
This method creates the detection Image using the CHI^2 algorithm.
mkInvarIm(self)
Make the detection image using Numeric package, not IRAF.
This method creates a detection image using the inverse variance
algorithm.
mkIrafIm(self)
 make the detection image.  This method creates the detection 
Image using the CHI^2 algorithm.
mkMsg(self)
create and write module level message for this class.
Most of this is just compiling the info. meta is a dictionary
of lists where each list is a list of tuples describing the
tag lines for the particular section of the message.  This tuple 
format conforms to that used by the xmlMessage class which is
modeled on basic python argument passing, i.e. (key,*value,**attr).
mkWghtIm(self, doMedFilt=0, medfiltsize=5)
 Makes the weight image to be used by Sextractor when finding
sources in the (inverse variance-weighted) detection image.
The method for constructing the weight image follows analogously
to that used in making the (inverse-variance) detection image.
setinpar(self, param, value)
Sets value of input parameter given a parameter name and value
setpars(self)
 This method in this class generates a phoney (unimportant) .inpar file
to run sextractor and get out the background and noise stats.
writeXml(self)
Mark up the detection Image produced by this module.

Data and non-method functions defined here:
__doc__ = ' class provides a detectionImage object with me...tten to the observations Images directory.\n '
__module__ = 'combFilter'
 
Data
             __author__ = 'K. Anderson , J. Blakeslee'
__file__ = '/acs/science/pipeline/lib/python/apsis/combFilter.pyc'
__name__ = 'combFilter'
__version__ = '1.13'
__version_date__ = '2003/02/27 23:56:44'
_delFiltsDef = ['G800L']
iraf = <module 'pyraf.iraf' from '/usr/local/lib/python2.2/site-packages/pyraf/iraf.pyc'>
pyversion = '2.2 (#2, Feb 6 2002, 17:02:39) \n[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)]'
version = '2.2 (#2, Feb 6 2002, 17:02:39) \n[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)]'
 
Author
             K. Anderson <anderson@pha.jhu.edu>, J. Blakeslee