- Timestamp:
- 11/05/09 21:47:49 (15 years ago)
- Location:
- branches/alma/src
- Files:
-
- 4 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 -
branches/alma/src/Scantable.h
r1634 r1656 231 231 232 232 /** 233 * Flag the data in a row-based manner. (CAS-1433 Wataru Kawasaki) 234 * param[in] rows list of row numbers to be flagged 235 */ 236 void flagRow( const std::vector<casa::uInt>& rows = std::vector<casa::uInt>(), bool unflag=false); 237 238 /** 239 * Get flagRow info at the specified row. If true, the whole data 240 * at the row should be flagged. 241 */ 242 bool getFlagRow(int whichrow) const 243 { return (flagrowCol_(whichrow) > 0); } 244 245 /** 233 246 * Return a list of row numbers with respect to the original table. 234 247 * @return a list of unsigned ints … … 447 460 void regridChannel( int nchan, double dnu ) ; 448 461 void regridChannel( int nchan, double dnu, int irow ) ; 462 449 463 450 464 private: … … 523 537 casa::ScalarColumn<casa::Float> paraCol_; 524 538 casa::ScalarColumn<casa::String> srcnCol_, fldnCol_; 525 casa::ScalarColumn<casa::uInt> scanCol_, beamCol_, ifCol_, polCol_, cycleCol_ ;539 casa::ScalarColumn<casa::uInt> scanCol_, beamCol_, ifCol_, polCol_, cycleCol_, flagrowCol_; 526 540 casa::ScalarColumn<casa::Int> rbeamCol_, srctCol_; 527 541 casa::ArrayColumn<casa::Float> specCol_, tsysCol_; … … 544 558 void initFactories(); 545 559 560 /** 561 * Add an auxiliary column to the main table and attach it to a 562 * cached column. Use for adding new columns that the original asap2 563 * tables do not have. 564 * @param[in] col reference to the cached column to be attached 565 * @param[in] colName column name in asap table 566 * @param[in] defValue default value to fill in the column 567 * 568 * 25/10/2009 Wataru Kawasaki 569 */ 570 template<class T, class T2> void attachAuxColumnDef(casa::ScalarColumn<T>&, 571 const casa::String&, 572 const T2&); 573 template<class T, class T2> void attachAuxColumnDef(casa::ArrayColumn<T>&, 574 const casa::String&, 575 const casa::Array<T2>&); 546 576 }; 547 577 -
branches/alma/src/ScantableWrapper.h
r1446 r1656 108 108 { table_->flag(msk, unflag); } 109 109 110 void flagRow(const std::vector<casa::uInt>& rows=std::vector<casa::uInt>(), bool unflag=false) 111 { table_->flagRow(rows, unflag); } 112 113 bool getFlagRow(int whichrow=0) const 114 { return table_->getFlagRow(whichrow); } 115 110 116 std::string getSourceName(int whichrow=0) const 111 117 { return table_->getSourceName(whichrow); } -
branches/alma/src/python_Scantable.cpp
r1446 r1656 105 105 .def("get_antennaname", &ScantableWrapper::getAntennaName) 106 106 .def("_flag", &ScantableWrapper::flag) 107 .def("_flag_row", &ScantableWrapper::flagRow) 108 .def("_getflagrow", &ScantableWrapper::getFlagRow, 109 (boost::python::arg("whichrow")=0) ) 107 110 .def("_save", &ScantableWrapper::makePersistent) 108 111 .def("_summary", &ScantableWrapper::summary,
Note:
See TracChangeset
for help on using the changeset viewer.