Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: table.selectrows - Function Up: table - Tool Previous: table.query - Function


table.calc - Function



Package utility
Module table
Tool table


Calculate an expression on a table


Synopsis
calc(expr)


Description
Get the result from the calculation of an expression on a table. using a CALC command given to the tablecommand function. 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

expr in Expression string
    Allowed: String


Returns
record, vector, or scalar


Example
  t:=table("3C273XC1.MS");
  t.calc ('DATA+1');
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.
  t:=table("3C273XC1.MS");
  t.calc ('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.
  t:=table("3C273XC1.MS");
  t.calc ('sum([select from $1 giving [ntrue(FLAG)]])');
returns the total number of flags set in the table (in a single scalar). It is the same as
  sum(t.calc ('ntrue(FLAG)'));
The latter is easier to write, but sends (much) more data over the glish bus.



See Also
tablecommand





next up previous contents index
Next: table.selectrows - Function Up: table - Tool Previous: table.query - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15