There has been a major misuse of opening an MS and refering to SORTED_TABLE table in general since eons (i'm at fault, much more than anybody else, in it as i kept copying the opening of an MS object by explicitly opening on the reference table)

My conclusion after understanding what MSiter does ...is to always use the ms object as is (one should not refer to the SORTED_TABLE explicitly...its a mistake) ... MSIter is smart to decide whether to sort or resort depeding on the order you gave and save a reference table (called SORTED_TABLE and this should be viewed as for the sole use of MSIter) )if it has write permission...and if the ms is readonly that reference is in memory and disappear when the object goes out of context

So if you have an ms named "mydata.ms"...this is how you would construct an MSIter...VisIter in read mode

myms=MeasurementSet("mydata.ms", TableLock::AutoNoReadLocking, Table::Old)

///say you have a function (domyselection) that will do selection on this and return you a reference ms on the original ms

const MeasurementSet& mssel=domyselection(myms);

///you want access your data in a given sort as such for example

Block<Int> sort(4);
sort[0] = MS::FIELD_ID;
sort[1] = MS::ARRAY_ID;
sort[2] = MS::DATA_DESC_ID;
sort[3] = MS::TIME;
timeinterval=0.0;

!ROVisibilityIterator myvisiter(mssel, sort, timeInterval);

////

You don't need to worry if the data was sorted before or not or if its going to waste time resorting ...if the SORTED_DATA exists and its the order you asked MSIter underlying VisIter will recognize it and use it...if not it will create a new sorted data reference table to have the sort order you requested. If the ms is readonly as in the example above ...it will be kept in memory as long as the VisIter/MSIter object is in context. If the MS was writable then it will store that sort order in the reference table called SORTED_DATA

-- KumarGolap - 2009-07-27
Topic revision: r2 - 2012-04-24, PatrickMurphy
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding NRAO Public Wiki? Send feedback