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

3.2.1 Make a table from a selection of rows


Description

Create a (reference) table containing a given subset of rows. It is, for instance, useful when a selection is done on another table containing the row numbers in the main table. It can be useful to apply the casapy function unique to those row numbers, otherwise the same row might be included multiple times (see example).

It is possible to give a name to the resulting table. If given, the resulting table is made persistent with that table name. Otherwise the table is transient and disappears when closed or when casapy exits.

The rownumbers function returns a vector containing the row number in the main table for each row in the selection table. Thus given a row number vector rownrs, the following is always true.

  rownrs == tb.selectrows(rownrs).rownumbers()

However, it is not true when selectrows is used on a selection table. because rownumbers does not return the row number in that selection table but in the main table.
It means that one has to take great care when using selectrows on a selection table.

Arguments





Inputs

rownrs

0-based Row Numbers

allowed:

intArray

Default:

name

Name of resulting table

allowed:

string

Default:

Returns
table

Example

 
 
# EXAMPLE NOT VERIFIED SINCE query IS BROKEN  
#   Do the query on the main table.  
  tb.open(’SOMENAME’)  
  scantable = tb.query(command)  
#   Get the column containing the 0-based row numbers in the BACKEND table.  
#   Make the row numbers unique.  NEED TO REPLACE GLISH unique FUNCTION HERE!  
  backrows = unique(scantable.getcol(’NS_GBT_BACKEND_ID’))  
#   Form the table subset of the BACKEND table containing those rows.  
  tb.close()  
  tb.open(’SOMENAME/GBT_BACKEND’)  
  scanback = tb.selectrows(backrows);  
#   Do something with that table.  
  print scanback.nrows();  
 
 
 
 

__________________________________________________________________


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