NRAO Home > CASA > CASA Task Reference Manual

0.1.63 imval

Requires:

Synopsis
Get the data value(s) and/or mask value in an image.

Arguments





Outputs

blc

Bottom-left corner of the bounding box that encloses the region being examined..

allowed:

any

Default:

variant

trc

top-right corner of the bounding box that encloses the region being examined.

allowed:

any

Default:

variant

axes

A listing of the axis index numbers and the data stored along that axis.

allowed:

any

Default:

variant

unit

The units the data values are stored and displayed in.

allowed:

any

Default:

variant

data

The pixel values found at the given point(s).

allowed:

any

Default:

variant

mask

The mask values found at the given point(s).

allowed:

any

Default:

variant

Inputs

imagename

Name of the input image

allowed:

string

Default:

region

Region selection. Default is to use the full image.

allowed:

any

Default:

variant

box

Rectangular region(s) to select in direction plane. Default is to use the entire direction plane.

allowed:

string

Default:

chans

Channels to use. Default is to use all channels.

allowed:

string

Default:

stokes

Stokes planes to use. Planes specified must be contiguous. Default is to use all Stokes planes.

allowed:

string

Default:

Returns
void

Example

 
     The data point(s) to be retrieved are those found in the specified  
     region, which may be:  
        1. A region file or text string, with the following caveat:  
           * If the specified region is complex (eg, a union or intersection of multiple regions,  
             only the first simple region in this set is used.  
           * If the region is not rectangular, then the rectangular region that circumscribes the  
             specified region (ie the bounding box) is used to retrieve values, since the returned  
             arrays must be rectangular. The resulting mask values in this case are the result of  
             anding the image mask values with the specified region mask values, eg  
             if a pixel falls outside the specified region but within the bounding box, its returned  
             mask value will be false even if its image mask value is true.  
        2. A region specified by a set of rectangular  
           pixel coordinates, the channel ranges and/or the Stokes.  
 
     For directed output, run as  
                    myoutput = imval()  
 
 
Keyword arguments:  
imagename -- Name of input image  
Default: none; Example: imagename=’ngc5921_task.im’  
        region -- Region selection. Default is to use the full image.  
                Example: region=’myimage.im.rgn’  
                         region=’region1’  
box --  Rectangular region to select in direction plane. Default is to use the entire direction plane.  
Default: ’’ (referencepixel values for the Directional coord);  
                Example: box=’10,10,50,50’  
                         box = ’10,10,30,30,35,35,50,50’ (two boxes)  
chans -- Channels to use. Default is to use all channels.  
stokes -- Stokes planes to use. Planes specified must be contiguous. Default is to use all Stokes planes.  
         Example: stokes=’IQUV’;  
                      stokes=’I,Q’  
 
      General procedure:  
 
         1.  Specify inputs, then  
 
         2.  myoutput = imval()  
               or specify inputs directly in calling sequence to task  
             myoutput = imsval(imagename=’image.im’, etc)  
 
         3.  myoutput[’KEYS’] will contain the result associated with any  
               of the keys given below  
 
        KEYS CURRENTLY AVAILABLE  
     blc          - absolute PIXEL coordinate of the bottom left corner of  
               the bounding box surrounding the selected region  
     trc          - the absolute PIXEL coordinate of the top right corner  
                       of the bounding box surrOunding the selected region  
        axes         - List the data stored in each axis of the data block.  
        unit         - unit of the returned data values.  
     data         - data value(s) found in the given region  
     mask         - mask value(s) found in the given region. See important  
                       note above regarding returned mask values for  
                       non-rectangular regions.  
 
        NOTE: The data returned is in the same order as it is internally  
        stored, typically RA, DEC, spectral, stokes. Also both the data  
        and mask values are returned as Python Numpy arrays, for more  
        information on how to manipulate them see  
             http://numpy.scipy.org/#array_interface  
 
 
Additional Examples  
# The value and mask value at a single point (5,17,2,Q)  
        imval( ’myImage’, box=’5,5,17,17’, chans=2, stokes=’Q’ )  
 
# Select and report on two box regions  
# box 1, bottom-left coord is 2,3 and top-right coord is 14,15  
# box 2, bottom-left coord is 30,31 and top-right coord is 42,43  
        # Note that only the boxes for the  
imval( ’myImage’, box=’2,3,14,15;30,31,42,43’ )  
 
# Select the same two box regions but only channels 4 and 5  
imval( ’myImage’, box=’2,3,14,15;30,31,42,43’, chan=’4~5’ )  
 
# Select all channels greater the 20 as well as channel 0.  
  # Then the mean and standard deviation are printed  
        # Note that the data returned is a Python numpy array which  
        # has built in operations such as min, max, and means as  
        # demonstrated here.  
results = imval( ’myImage’, chans=’>20;0’ )  
        imval_data=results[’data’]  
        mask=results[’mask’]  
        # holds the absolute coordinates of the associated pixels in imval_data  
        coords = results[’coords’]  
        print "Data max: ", imval_data.max(), "  mean is ", imval_data.mean()  
        swapped_data=imval_data.swapaxes(0,2)  
        swapped_mask=mask.swapaxes(0,2)  
        print "Data values for 21st channel: \n", swapped_data[0]  
        print "Mask values for 21st channel: \n", swapped_mask[0]  


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