- Timestamp:
- 07/02/13 13:11:02 (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r2818 r2820 2067 2067 2068 2068 @asaplog_post_dec 2069 def history(self, filename=None ):2069 def history(self, filename=None, nrows=-1, start=0): 2070 2070 """\ 2071 2071 Print the history. Optionally to a file. … … 2076 2076 2077 2077 """ 2078 hist = list(self._gethistory()) 2078 n = self._historylength() 2079 if nrows == -1: 2080 nrows = n 2081 if start+nrows > n: 2082 nrows = nrows-start 2083 if n > 1000 and nrows == n: 2084 nrows = 1000 2085 start = n-1000 2086 asaplog.push("Warning: History has {0} entries. Displaying last " 2087 "1000".format(n)) 2088 hist = list(self._gethistory(nrows, start)) 2079 2089 out = "-"*80 2080 2090 for h in hist: 2081 if h.startswith("---"): 2082 out = "\n".join([out, h]) 2091 if not h.strip(): 2092 continue 2093 if h.find("---") >-1: 2094 continue 2083 2095 else: 2084 2096 items = h.split("##") … … 2093 2105 s = i.split("=") 2094 2106 out += "\n %s = %s" % (s[0], s[1]) 2095 out = "\n".join([out, " -"*80])2107 out = "\n".join([out, "*"*80]) 2096 2108 if filename is not None: 2097 2109 if filename is "": 2098 2110 filename = 'scantable_history.txt' 2099 import os2100 2111 filename = os.path.expandvars(os.path.expanduser(filename)) 2101 2112 if not os.path.isdir(filename): -
trunk/src/STHistory.cpp
r2243 r2820 20 20 #include "STDefs.h" 21 21 #include "STHistory.h" 22 22 #include "MathUtils.h" 23 23 24 24 using namespace casa; … … 81 81 { 82 82 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 } 86 88 87 89 } 88 90 89 std::vector<std::string> asap::STHistory::getHistory( ) const 91 std::vector<std::string> asap::STHistory::getHistory( int nrow, 92 int start) const 90 93 { 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(); 94 96 } 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); 96 103 } 97 104 105 void asap::STHistory::drop() { 106 table_.removeRow(table_.rowNumbers()); 107 } 108 98 109 } -
trunk/src/STHistory.h
r1353 r2820 62 62 * @return a vector of strings 63 63 */ 64 std::vector<std::string> getHistory( ) const;64 std::vector<std::string> getHistory(int nrow=-1, int start=0 ) const; 65 65 66 66 const casa::String& name() const { return name_; } 67 68 int nrow() const { return table_.nrow(); } 69 70 71 void drop(); 67 72 68 73 private: -
trunk/src/Scantable.h
r2818 r2820 378 378 void makePersistent(const std::string& filename); 379 379 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(); } 382 387 383 388 void addHistory(const std::string& hist) { historyTable_.addEntry(hist); } -
trunk/src/ScantableWrapper.h
r2818 r2820 242 242 } 243 243 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(); } 246 252 247 253 void addHistory(const std::string& hist) -
trunk/src/python_Scantable.cpp
r2818 r2820 131 131 .def("_gethistory", &ScantableWrapper::getHistory) 132 132 .def("_addhistory", &ScantableWrapper::addHistory) 133 .def("drop_history", &ScantableWrapper::dropHistory) 134 .def("_historylength", &ScantableWrapper::historyLength) 133 135 .def("_getselection", &ScantableWrapper::getSelection) 134 136 .def("_setselection", &ScantableWrapper::setSelection)
Note:
See TracChangeset
for help on using the changeset viewer.