Changeset 1656 for branches/alma/src/Scantable.cpp
- Timestamp:
- 11/05/09 21:47:49 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/src/Scantable.cpp
r1616 r1656 109 109 { 110 110 initFactories(); 111 111 112 Table tab(name, Table::Update); 112 113 uInt version = tab.keywordSet().asuInt("VERSION"); … … 124 125 attach(); 125 126 } 127 /* 128 Scantable::Scantable(const std::string& name, Table::TableType ttype) : 129 type_(ttype) 130 { 131 initFactories(); 132 Table tab(name, Table::Update); 133 uInt version = tab.keywordSet().asuInt("VERSION"); 134 if (version != version_) { 135 throw(AipsError("Unsupported version of ASAP file.")); 136 } 137 if ( type_ == Table::Memory ) { 138 table_ = tab.copyToMemoryTable(generateName()); 139 } else { 140 table_ = tab; 141 } 142 143 attachSubtables(); 144 originalTable_ = table_; 145 attach(); 146 } 147 */ 126 148 127 149 Scantable::Scantable( const Scantable& other, bool clear ) … … 204 226 td.addColumn(ScalarColumnDesc<Int>("REFBEAMNO")); 205 227 228 td.addColumn(ScalarColumnDesc<uInt>("FLAGROW")); 229 206 230 td.addColumn(ScalarColumnDesc<Double>("TIME")); 207 231 TableMeasRefDesc measRef(MEpoch::UTC); // UTC as default … … 261 285 originalTable_ = table_; 262 286 } 263 264 287 265 288 void Scantable::attach() … … 289 312 mfocusidCol_.attach(table_, "FOCUS_ID"); 290 313 mmolidCol_.attach(table_, "MOLECULE_ID"); 314 315 //Add auxiliary column for row-based flagging (CAS-1433 Wataru Kawasaki) 316 attachAuxColumnDef(flagrowCol_, "FLAGROW", 0); 317 318 } 319 320 template<class T, class T2> 321 void Scantable::attachAuxColumnDef(ScalarColumn<T>& col, 322 const String& colName, 323 const T2& defValue) 324 { 325 try { 326 col.attach(table_, colName); 327 } catch (TableError& err) { 328 String errMesg = err.getMesg(); 329 if (errMesg == "Table column " + colName + " is unknown") { 330 table_.addColumn(ScalarColumnDesc<T>(colName)); 331 col.attach(table_, colName); 332 col.fillColumn(static_cast<T>(defValue)); 333 } else { 334 throw; 335 } 336 } catch (...) { 337 throw; 338 } 339 } 340 341 template<class T, class T2> 342 void Scantable::attachAuxColumnDef(ArrayColumn<T>& col, 343 const String& colName, 344 const Array<T2>& defValue) 345 { 346 try { 347 col.attach(table_, colName); 348 } catch (TableError& err) { 349 String errMesg = err.getMesg(); 350 if (errMesg == "Table column " + colName + " is unknown") { 351 table_.addColumn(ArrayColumnDesc<T>(colName)); 352 col.attach(table_, colName); 353 354 int size = 0; 355 ArrayIterator<T2>& it = defValue.begin(); 356 while (it != defValue.end()) { 357 ++size; 358 ++it; 359 } 360 IPosition ip(1, size); 361 Array<T>& arr(ip); 362 for (int i = 0; i < size; ++i) 363 arr[i] = static_cast<T>(defValue[i]); 364 365 col.fillColumn(arr); 366 } else { 367 throw; 368 } 369 } catch (...) { 370 throw; 371 } 291 372 } 292 373 … … 668 749 flagsCol_.put(i, flgs); 669 750 } 751 } 752 753 void Scantable::flagRow(const std::vector<uInt>& rows, bool unflag) 754 { 755 if ( selector_.empty() && (rows.size() == table_.nrow()) ) 756 throw(AipsError("Trying to flag whole scantable.")); 757 758 uInt rowflag = (unflag ? 0 : 1); 759 std::vector<uInt>::const_iterator it; 760 for (it = rows.begin(); it != rows.end(); ++it) 761 flagrowCol_.put(*it, rowflag); 670 762 } 671 763
Note: See TracChangeset
for help on using the changeset viewer.