Changeset 1656 for branches/alma/src


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


Location:
branches/alma/src
Files:
4 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
  • branches/alma/src/Scantable.h

    r1634 r1656  
    231231
    232232  /**
     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  /**
    233246   * Return a list of row numbers with respect to the original table.
    234247   * @return a list of unsigned ints
     
    447460  void regridChannel( int nchan, double dnu ) ;
    448461  void regridChannel( int nchan, double dnu, int irow ) ;
     462
    449463 
    450464private:
     
    523537  casa::ScalarColumn<casa::Float> paraCol_;
    524538  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_;
    526540  casa::ScalarColumn<casa::Int> rbeamCol_, srctCol_;
    527541  casa::ArrayColumn<casa::Float> specCol_, tsysCol_;
     
    544558  void initFactories();
    545559
     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>&);
    546576};
    547577
  • branches/alma/src/ScantableWrapper.h

    r1446 r1656  
    108108    { table_->flag(msk, unflag); }
    109109
     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
    110116  std::string getSourceName(int whichrow=0) const
    111117    { return table_->getSourceName(whichrow); }
  • branches/alma/src/python_Scantable.cpp

    r1446 r1656  
    105105    .def("get_antennaname", &ScantableWrapper::getAntennaName)
    106106    .def("_flag", &ScantableWrapper::flag)
     107    .def("_flag_row", &ScantableWrapper::flagRow)
     108    .def("_getflagrow", &ScantableWrapper::getFlagRow,
     109         (boost::python::arg("whichrow")=0) )
    107110    .def("_save",  &ScantableWrapper::makePersistent)
    108111    .def("_summary",  &ScantableWrapper::summary,
Note: See TracChangeset for help on using the changeset viewer.