NRAO Home > CASA > CASA Toolkit Reference Manual
image.calcmask - Function

1.1.1 Image mask calculator


Description

This method is used to create a new pixel mask via a Boolean LEL expression. This gives you much more scope than the simple set and putregion functions. Both float and complex valued images are supported.

See http://casa.nrao.edu/aips2_docs/notes/223/index.shtml which describes the the syntax and functionality of LEL in detail. Also in this document is a description of ways to escape image names that contain certain non-alphanumeric characters so they are compatible with LEL syntax.

If the expression is not a scalar, the shapes and coordinates of the image and expression must conform. If the expression is a scalar then the entire pixel mask will be set to that value.

By default (argument name) the name of a new pixel mask is made up for you. However, if you specify a pixel mask name (use function summary or maskhandler to see the mask names) then it is used. If the pixel mask already exists, it is overwritten.

You can specify whether the new pixel mask should be the default mask or not. By default, it is made the default pixel mask !

Arguments





Inputs

mask

Mask to use. See help par.mask. Default is none.

allowed:

string

Default:

name

Mask name. Default is auto new name.

allowed:

string

Default:

asdefault

Make specified mask the default mask?

allowed:

bool

Default:

true

Returns
bool

Example

 
 
"""  
#  
print "\t----\t calcmask Ex 1 \t----"  
ia.maketestimage(’zz’, overwrite=true)  
subim = ia.subimage()                # Make "another" image  
ia.calcmask(’T’)                     # Specify ’True’ mask as a string  
ia.calcmask(’zz>0’)                  # Mask of zz ignored  
ia.calcmask(’mask(zz) && zz>0’)      # Mask of zz included  
ia.calcmask(subim.name(true)+’>min(’+subim.name(true)+’)’) # Use tool names  
ia.calcmask(’zz>min(zz:nomask)’)  # Mask of zz not used in scalar function  
subim.done()  
ia.close()  
#  
"""  
 
 
The first calcmask example is the equivalent of {\cf  
ia.set(pixelmask=1)}.  It sets the entire mask to True.  
 
The second example creates a new \pixelmask\ which is True when  
the pixel values in image {\sff zz} are greater than 0.  
 
Now for some subtlety.  Read carefully !  Any LEL expression can be  
thought of as having a value and a mask.  Usually the value is Float and  
the mask Boolean.  In this case, because the expression is Boolean  
itself, the value is also Boolean.  The expression mask would just be  
the mask of {\sff zz}.  Now what {\stfaf calcmask} does is create a mask  
from the expression value (which is Boolean) and discards the expression  
mask.  Therefore, the resulting mask is independent of any mask  
that {\sff zz} might have.  
 
If you wish the mask of the expression be honoured as well,  
then you can do as in the third example.   It says the output \pixelmask\  
will be True if the current \pixelmask\ of {\sff zz} is True and the expression  
value is True.  
 
The fourth example is like the second, except that we use the pixel  
values associated with the on-the-fly {\stf subim} Image tool  disk file.  Note one further  
subtlety here.  When the scalar function {\cf min} evaluates a value  
from {\cf subim.name()}, which in this case is just {\cf zz}, the default  
mask of {\cf subim.name()} {\it will} be used.  All the scalar  
functions look at the mask.  If you didn’t want the mask to be used  
you can use the special {\cf :nomask} syntax shown in the final  
example.  
 

__________________________________________________________________


More information about CASA may be found at the CASA web page

Copyright 2016 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