Ignore:
Timestamp:
11/05/09 21:47:49 (15 years ago)
Author:
WataruKawasaki
Message:

New Development: Yes

JIRA Issue: Yes (CAS-1433)

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed: functionalities for row-based flagging added

Test Programs:

Put in Release Notes: No

Module(s): sdflag

Description: Added the following functionalities:

sd.scantable._flag_row()

  • to execute row-based flagging

sd.scantable._getflagrow()

  • to get row-based flagging info


File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/alma/src/Scantable.cpp

    r1616 r1656  
    109109{
    110110  initFactories();
     111
    111112  Table tab(name, Table::Update);
    112113  uInt version = tab.keywordSet().asuInt("VERSION");
     
    124125  attach();
    125126}
     127/*
     128Scantable::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*/
    126148
    127149Scantable::Scantable( const Scantable& other, bool clear )
     
    204226  td.addColumn(ScalarColumnDesc<Int>("REFBEAMNO"));
    205227
     228  td.addColumn(ScalarColumnDesc<uInt>("FLAGROW"));
     229
    206230  td.addColumn(ScalarColumnDesc<Double>("TIME"));
    207231  TableMeasRefDesc measRef(MEpoch::UTC); // UTC as default
     
    261285  originalTable_ = table_;
    262286}
    263 
    264287
    265288void Scantable::attach()
     
    289312  mfocusidCol_.attach(table_, "FOCUS_ID");
    290313  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
     320template<class T, class T2>
     321void 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
     341template<class T, class T2>
     342void 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  }
    291372}
    292373
     
    668749    flagsCol_.put(i, flgs);
    669750  }
     751}
     752
     753void 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);
    670762}
    671763
Note: See TracChangeset for help on using the changeset viewer.