nraonrao
 
 NRAO Home > CASA > CasaDocument
image.imagecalc - Function

1.1.1 Construct a CASA image via the image calculator
Description

This function is used to evaluate a mathematical expression involving existing image files, assigning the result to the newly created output image. The syntax of the expression supplied via the pixels argument (in what is called the Lattice Expression Language, or LEL) is explained in detail in note 223.

Any image files embedded in the expression may be native CASA or FITS (but not yet Miriad) image files. Look ?? for more information on foreign images.

If outfile is given, the image is written to the specified disk file. If outfile is unset, the on-the-fly Image tool returned by this function actually references all of the input files in the expression. So if you deleted any of the input image disk files, it would render this tool useless. When you destry this on-the-fly tool (with the done function), the reference connections are broken.

If you make a reference tool, the expression is re-evaluated every time you use it. So it takes no extra storage, but takes longer to access the pixel values (they must be recomputed).

Arguments





Inputs

outfile

Output image file name. Default is unset.

allowed:

string

Default:

pixels

LEL expression. Default is empty expression.

allowed:

string

Default:

overwrite

Overwrite (unprompted) pre-existing output file?

allowed:

bool

Default:

false

Returns
casaimage

Example

"""  
#  
print "\t----\t imagecalc Ex 1 \t----"  
ia.fromshape(’aF’,[10,10],overwrite=true)  
ia.fromshape(’bF’,[10,20,30],overwrite=true)  
myim= ia.imagecalc(outfile=’cF’, pixels=’aF + min(float(pi()), mean(bF))’,  
                   overwrite=true)  
myim.done()  
ia.close()  
#  
"""

Suppose aF and bF are image files with single precision data. They do not need to have conforming shapes and coordinates, because only the mean of bF is used. Note that pi is explicitly converted to single precision, because pi() results in a Double. If that was not done, the expression result would be a Double with the effect that all data of aF had to be converted to Double. So this expression first computes a scalar, the minimum of π and the mean of the image file bF. That scalar is then added to the value of each pixel in the image file aF. The resultant is put in the image file called cF to which access is provided via the image tool called myim.

If the expression is masked, that mask will be copied to the new image.

Example

"""  
#  
print "\t----\t imagecalc Ex 2 \t----"  
ia.fromshape(’aF’,[10,10],overwrite=true)  
myim=ia.imagecalc(’cF’, ’min(aF, (min(aF)+max(aF))/2)’, overwrite=true)  
myim.done()  
ia.close()  
#  
"""

This example shows that there are 2 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.

Example

"""  
#  
print "\t----\t imagecalc Ex 3 \t----"  
ia.fromshape(’aD’,[10,10],overwrite=true)  
ia.fromshape(’aF’,[10,10],overwrite=true)  
ia.fromshape(’bF’,[10,10],overwrite=true)  
ia.fromshape(’aC’,[10,10],overwrite=true)  
myim = ia.imagecalc(’eF’, ’sin(aD)+(aF*2)+min(bF)+real(aC)’, overwrite=true)  
myim.done()  
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. The result of the expression is written out to the disk file called eF.

Example

"""  
#  
print "\t----\t imagecalc Ex 4 \t----"  
ia.fromshape(’aD’,[10,10],overwrite=true)  
ia.fromshape(’aF’,[10,10],overwrite=true)  
ia.fromshape(’bF’,[10,10],overwrite=true)  
ia.fromshape(’aC’,[10,10],overwrite=true)  
myim = ia.imagecalc(pixels=’sin(aD)+(aF*2)+min(bF)+real(aC)’)  
myim.done()  
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. The result of the expression is not written out to disk in this case. It is evaluated each time it is needed.

Please send any comments or questions about CASA or AIPS++ to aips2-requests@nrao.edu

Copyright © 2007 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search

Updated daily during alpha development.