NRAO Home > CASA > CASA Toolkit Reference Manual
table.calc - Function

3.2.1 TaQL expression with calc to calculate an expression on a table


Description

Get the result from the calculation of an expression on a table

The expression can be any expression that can be given in the WHERE clause of a SELECT expression (thus including subqueries). The given expression determines if the result is a scalar, a vector, or a record containing arrays. See the examples below.

Arguments





Inputs

expr

Expression string

allowed:

string

Default:

prefix

TaQL prefix for style and ordering etc ...check TaQL note 199 for usage

allowed:

string

Default:

using style base0, endincl, fortranorder

showtaql

Show the full taql command used

allowed:

bool

Default:

false

Returns
anyvariant

Example

 
 
 
tb.calc(’[select from ngc5921.ms  giving [mean(abs(DATA))]]’)  
 
find the mean of the abs of each row of the  DATA column of the MeasurementSet ngc5921.ms  
 
returns a (potentially enormous) record where a field contains the  
value of the expression for the row with that number. Note that it  
returns a record because for each row the expression results in an array.  
It should be clear that this example is useless. However, something  
like this could be useful for a column with (very) small arrays.  
 
tb.calc(’[select from ngc5921.ms.contsub giving  [ntrue(FLAG)]]’)  
 
 
returns for each row the number of flags set. The result is a vector,  
because for each row the expression results in a scalar.  
 
 
tb.calc(’sum([select from ngc5921.ms.contsub giving  [ntrue(FLAG)]])’)  
 
returns the total number of flags set in the table (in a single  
scalar).  
 
using subrow array  
tb.calc(’median([select from ngc5921.ms where ANTENNA1==3 && ANTENNA2==5 giving [abs(DATA[0,31])]])’)  
 
The above will find the median channel 31 and 0th pol of the requested  baseline formed with antennas 3 and 5.  
Note that the that the default casa order of arrays is fortran order ...pol axis is before channel axis  
 
tb.calc(’median([select from ngc5921.ms where ANTENNA1==3 && ANTENNA2==5 giving [abs(DATA[31, 0])]])’, prefix=’using style python’)  
 
Now the same is as the above but using the python style of axis ordering access  
 
 

__________________________________________________________________


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