Source
xxxxxxxxxx
########################################################################3
# task_immath.py
#
# Copyright (C) 2008, 2009
# Associated Universities, Inc. Washington DC, USA.
#
# This script is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
#
# Correspondence concerning AIPS++ should be adressed as follows:
# Internet email: aips2-request@nrao.edu.
# Postal address: AIPS++ Project Office
# National Radio Astronomy Observatory
# 520 Edgemont Road
# Charlottesville, VA 22903-2475 USA
#
# <summary>
# CASA task for smoothing an image, by doing Forier-based convolution
# on a CASA image file.
# </summary>
#
# <reviewed reviwer="" date="" tests="" demos="">
# </reviewed
#
# <author>
# Shannon Jaeger, University of Calgary (image math)
# Takeshi Nakazato, National Radio Astronomy Obaservatory (polarization)
# </author>
#
# <prerequisite>
# </prerequisite>
#
# <etymology>
# immath stands for image mathematics
# </etymology>
#
# <synopsis>
# This task evaluates mathematical expressions involving existing
# image files. The results of the calculations are stored in the
# designated output file. Options are available to specify mathematical
# expression directly or pre-defined expression for calculation of
# spectral index image, and polarization intensity and position angle
# images are available. The image file names imbedded in the expression or
# specified in the imagename parameter for the pre-defined calculations may
# be CASA images or FITS images.
#
#
# NOTE: Index values for axes start at 0 for the box and chans
# parameters, but at 1 when used with the indexin function
# in expression. Use the imhead task to see the range of
# values for each axes.
#
#
# Keyword arguments:
# outfile -- The file where the results of the image calculations
# are stored. Overwriting an existing outfile is not permitted.
# Default: none; Example: outfile='results.im'
# mode -- mode for mathematical operation
# Default: evalexpr
# Options: 'evalexpr' : evalulate a mathematical expression defined in 'expr'
# 'spix' : spectalindex image
# 'pola' : polarization position angle image
# 'poli' : polarization intesity image
# mode expandable parameters
# expr -- (for mode='evalexpr') A mathematical expression, with image file names.
# Image file names MUST be enclosed in double quotes (")
# Default: none
# Examples:
# Make an image that is image1.im - image2.im
# expr=' ("image1.im" - "image2.im" )'
# Clip an image below a value (0.5 in this case)
# expr = ' iif("image1.im">=0.5, "image1.im", 0.0) '
# Note: iif (a, b, c) a is the boolian expression
# b is the value if true
# c is the value if false
# Take the rms value of two images
# expr = ' sqrt("image1.im" * "image1.im" + "image2.im" * "image2.im") '
# Note: No exponentiaion available?
# Build an image pixel by pixel from the minimum of (image2.im, 2*image1.im)
# expr='min("image2.im",2*max("image1.im"))'