void assignCTScanField(NewCalTable& ct, String msName,
Bool doField, Bool doScan, Bool doObs) {
// TBD: verify msName is present and is an MS
// Arrange to iterate only on SCAN (and SPW?)
Table mstab(msName,Table::Old);
// How many scans in total?
ROTableVector<Int> allscansTV(mstab,"SCAN_NUMBER");
TableVector<Int> allscansTV(mstab,"SCAN_NUMBER");
Vector<Int> allscans=allscansTV.makeVector();
Int nScan=genSort(allscans,Sort::Ascending,(Sort::QuickSort | Sort::NoDuplicates));
// cout << "Found " << nScan << " scans in " << msName << "." << endl;
Vector<Int> scanlist(nScan,-1);
Vector<Double> timelo(nScan,DBL_MIN);
Vector<Double> timehi(nScan,DBL_MAX);
Vector<Int> fieldlist(nScan,-1);
TableIterator mstiter(mstab,cols);
// Get time boundares and fields for each scan
while (!mstiter.pastEnd()) {
Table thistab(mstiter.table());
Int scan=ROTableVector<Int>(thistab,"SCAN_NUMBER")(0);
Int scan=TableVector<Int>(thistab,"SCAN_NUMBER")(0);
fieldlist(iscan)=ROTableVector<Int>(thistab,"FIELD_ID")(0);
obslist(iscan)=ROTableVector<Int>(thistab,"OBSERVATION_ID")(0);
fieldlist(iscan)=TableVector<Int>(thistab,"FIELD_ID")(0);
obslist(iscan)=TableVector<Int>(thistab,"OBSERVATION_ID")(0);
Vector<Double> times=ROTableVector<Double>(thistab,"TIME").makeVector();
Vector<Double> times=TableVector<Double>(thistab,"TIME").makeVector();
timelo(iscan)=min(times)-1e-5;
timehi(iscan)=max(times)+1e-5;
// Ensure time orderliness