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.calc - Function Up: table - Tool Previous: table.toascii - Function


table.query - Function



Package utility
Module table
Tool table


Make a table from a query


Synopsis
query(query, name, sortlist, columns)


Description
Make a table from a query applied to the current table. The query is the qualification part of the tablecommand. It is also possible to specify column(s) and/or expressions to sort on and to specify the columns to be contained in the output table. See the example below. A new table tool is returned. The new (reference) table can be given a name and will then be written to disk. Note that the resulting table is just a reference to the original table. One can make a deep copy of the query result using the copy function (see example).

If the arguments query, sortlist, and columns are empty strings (their default values), the taqlwidget will be started (if a GUI is available) before the query function is executed. In that way it is possible to let the user form the query interactively.



Arguments

query in Query string
    Allowed: String
    Default: ''
name in Name of resulting reference table
    Allowed: String
    Default: ''
sortlist in Sort string (one or more expressions separated by commas)
    Allowed: String
    Default: ''
columns in List of column names separated by commas
    Allowed: String
    Default: ''


Returns
table tool


Example
  t:=table("3C273XC1.MS");
  subt:=t.query("SPECTRAL_WINDOW_ID==1",
                sortlist="ARRAY_ID", columns="TIME, DATA, UVW");
  print subt.ncols();
# 3
  t.close();
  subt.copy ("3C273XC1_spw1.MS", T);
  subt.close();

From the original table corresponding to the disk file 3C273XC1.MS, only rows with SPECTRAL_WINDOW_ID equal to 1 are selected and sorted by ARRAY_ID. Only the columns TIME DATA UVW are written. Thereafter a deep copy of the result is made. The table query command is equivalent to:

  subt:=tablecommand(paste('select TIME, DATA, UVW from 3C273XC1.MS',
                           'where SPECTRAL_WINDOW_ID==1',
                           'orderby ARRAY_ID'))
The sortlist argument can be used to sort in ascending or descending order (or a mix of them) on one or more columns. Default is ascending. It is also possible to remove duplicate values using the word NODUPLICATES at the beginning. E.g.:
  sortlist='TIME desc'
  sortlist='noduplicates ANTENNA1,ANTENNA2'
  sortlist='ANTENNA1 desc, ANTENNA2 asc'
  sortlist='desc ANTENNA1, ANTENNA2, TIME'



See Also
tablecommand





next up previous contents index
Next: table.calc - Function Up: table - Tool Previous: table.toascii - 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