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


next up previous contents index
Next: tableindex - Constructor Up: table - Module Previous: tableiterator.done - Function


tableindex - Tool



Package utility
Module table


Postscript file available

Allows value based table access



Description
A tableindex makes it possible to find rows in a table based on their contents. When constructing the tableindex it has to be specified for which column or columns an index has to be built. Those columns will be loaded in memory and thereafter row numbers can be found in a fast way using a binary search.



Example
vis:=table("3C273XC1.MS");
vis.summary();
visinx:=tableindex(vis, "ANTENNA1");
rows:=visinx.rownrs(4);
rows:=visinx.rownrs(4,7);
This example builds an index for column ANTENNA1. The one but last line returns the row numbers (1-relative) of all rows with value 4 for ANTENNA1. There after these row numbers can, for example be used in getcell to read data. The last line is similar, but in this case the search interval 4-7 is given. So all rows with value 4, 5, 6, or 7 in ANTENNA1 are found. An optional 3rd and 4th argument can be given to tell if the interval is open or closed (i.e. if the boundaries are part of the interval). Note that for indices on floating point numbers it is best to use a search interval, because an exact match on such numbers usually fails.



Example
vis:=table("3C273XC1.MS");
vis.summary();
visinx:=tableindex(vis, "ANTENNA1 ANTENNA2");
rows:=visinx.rownrs([ANTENNA1=4, ANTENNA2=5);
rows:=visinx.rownrs([ANTENNA1=4, ANTENNA2=5), [ANTENNA1=4, ANTENNA2=8];
This example builds an index for column ANTENNA1 and ANTENNA2. Because multiple columns are used, the arguments for function rownrs have to be records now. So the one but last line returns the row numbers (1-relative) of all rows with value 4 for ANTENNA1 and 5 for ANTENNA2. The last line defines a search interval again. In this case the ordering of the columns in the index is important. It finds the rows of ANTENNA1=4 where ANTENNA2 is in the interval 5-8.

Normally a column used in a tableindex has to be a scalar column. However, if a single column is used that column can contain arrays. In such a case the rownrs function finds the rows where a value in its array matches the given search value.

If all key values in the index are unique, the function rownr can be used as well. It returns a single row number instead of a vector.

Constructors
tableindex Construct a tableindex
Functions
close Close the tableindex
done End the tableindex tool
isunique Are all key values in the index unique?
rownr Find the row number matching the search value
rownrs Find the row numbers matching search values
set Set table and columns to be indexed
setchanged Tell the index that columns have changed




next up previous contents index
Next: tableindex - Constructor Up: table - Module Previous: tableiterator.done - 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