NRAO Home > CASA > CASA Toolkit Reference Manual
##### image.calc - Function

1.1.1 Image calculator

Description

This function is used to evaluate a mathematical expression involving CASA images, assigning the result to the current (already existing) image. Both float and complex valued images are supported, although the image which results from the calculation must have the same type of pixel values as the image already attached to the tool. That is, one cannot create a complex valued image using this method if the associated ia tool is currently attached to a float valued image. It complements the imagecalc function which returns a newly constructed on-the-fly image tool. See note 223 which describes the the syntax and functionality in detail.

If the expression, supplied via the pixels argument, is not a scalar, the shapes and coordinates of the image and expression must conform.

If the image (that associated with the tool) has a pixel mask, then only pixels for which that mask is good will be changed. See the function maskhandler for managing image pixel masks.

Note that when multiple image are used in the expression, there is no garauntee about which of those images will be used to create the header of the output image. Therefore, one may have to modify the output header as needed if the input headers differ.

See the related functions set and putregion.

Arguments

 Inputs pixels LEL expression allowed: string Default: verbose Emit possibly useful messages. allowed: bool Default: True
Returns
bool

Example

"""
#
print "\t----\t calc Ex 1 \t----"
ia.maketestimage(’aF’, overwrite=true)
ia.calc(’min(aF, (min(aF)+max(aF))/2)’)
ia.calc(’1.0’)
ia.close()
#
"""

The first example shows that there are 2 {\cf min} functions.  One with a
single argument returning the minimum value of that image.  The other
with 2 arguments returning an image containing ‘‘aF’’ data clipped at
the value of the 2nd argument.   The second example sets all good
pixels to unity.

"""
#
print "\t----\t calc Ex 2 \t----"
ia.close()
ia.maketestimage(’aF’, overwrite=true)       # image files
ia.close()
ia.maketestimage(’bF’, overwrite=true)       # for use
ia.close()
ia.maketestimage(’aC’, overwrite=true)       # in
ia.close()
ia.maketestimage()
ia.close()
#
"""

This shows a mixed type expression.  The real part of the complex image
‘‘aC’’  is used in an expression that otherwise uses Float type.

__________________________________________________________________