Changeset 2820 for trunk/src


Ignore:
Timestamp:
07/02/13 13:11:02 (11 years ago)
Author:
Malte Marquarding
Message:

Issue #293: added scantbale.drop_history and added extra parameters to scantable.history to allow selection of rows

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STHistory.cpp

    r2243 r2820  
    2020#include "STDefs.h"
    2121#include "STHistory.h"
    22 
     22#include "MathUtils.h"
    2323
    2424using namespace casa;
     
    8181{
    8282  const Table& t = other.table();
    83   addEntry(asap::SEPERATOR);
    84   TableCopy::copyRows(table_, t, table_.nrow(), 0, t.nrow());
    85   addEntry(asap::SEPERATOR);
     83  if (other.nrow() > 0) {
     84    addEntry(asap::SEPERATOR);
     85    TableCopy::copyRows(table_, t, table_.nrow(), 0, t.nrow());
     86    addEntry(asap::SEPERATOR);
     87  }
    8688
    8789}
    8890
    89 std::vector<std::string> asap::STHistory::getHistory( ) const
     91std::vector<std::string> asap::STHistory::getHistory( int nrow,
     92                                                      int start) const
    9093{
    91   std::vector<std::string> stlout;
    92   for (uInt i=0; i<table_.nrow(); ++i) {
    93     stlout.push_back(itemCol_(i));
     94  if (nrow < 0) {
     95    nrow = this->nrow();
    9496  }
    95   return stlout;
     97  AlwaysAssert(nrow <= this->nrow(), AipsError);
     98  Vector<String> rows;
     99  Slicer slice(IPosition(1, start), IPosition(1, nrow));
     100 
     101  rows = itemCol_.getColumnRange(slice);
     102  return mathutil::tovectorstring(rows);
    96103}
    97104
     105  void asap::STHistory::drop() {
     106    table_.removeRow(table_.rowNumbers());
     107  }
     108
    98109}
  • trunk/src/STHistory.h

    r1353 r2820  
    6262   * @return a vector of strings
    6363   */
    64   std::vector<std::string> getHistory( ) const;
     64  std::vector<std::string> getHistory(int nrow=-1, int start=0 ) const;
    6565
    6666  const casa::String& name() const { return name_; }
     67
     68  int nrow() const { return table_.nrow(); }
     69
     70
     71  void drop();
    6772
    6873private:
  • trunk/src/Scantable.h

    r2818 r2820  
    378378  void makePersistent(const std::string& filename);
    379379
    380   std::vector<std::string> getHistory() const
    381     { return historyTable_.getHistory(); };
     380  std::vector<std::string> getHistory(int nrow=-1, int start=0) const
     381    { return historyTable_.getHistory(nrow, start); }
     382
     383  uint historyLength()
     384  { return historyTable_.nrow(); }
     385 
     386  void dropHistory() { historyTable_.drop(); }
    382387
    383388  void addHistory(const std::string& hist) { historyTable_.addEntry(hist); }
  • trunk/src/ScantableWrapper.h

    r2818 r2820  
    242242  }
    243243
    244   std::vector<std::string> getHistory() const
    245     { return table_->getHistory(); }
     244  std::vector<std::string> getHistory(int nrow=-1, int start=0) const
     245    { return table_->getHistory(nrow, start); }
     246
     247  uint historyLength() {
     248    return table_->historyLength();
     249  }
     250
     251  void dropHistory() { table_->dropHistory(); }
    246252
    247253  void addHistory(const std::string& hist)
  • trunk/src/python_Scantable.cpp

    r2818 r2820  
    131131    .def("_gethistory", &ScantableWrapper::getHistory)
    132132    .def("_addhistory", &ScantableWrapper::addHistory)
     133    .def("drop_history", &ScantableWrapper::dropHistory)
     134    .def("_historylength", &ScantableWrapper::historyLength)
    133135    .def("_getselection", &ScantableWrapper::getSelection)
    134136    .def("_setselection", &ScantableWrapper::setSelection)
Note: See TracChangeset for help on using the changeset viewer.