- Timestamp:
- 09/30/09 17:56:00 (15 years ago)
- Location:
- branches/alma
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/selector.py
r1603 r1639 147 147 """ 148 148 self._setorder(order) 149 150 def set_rows(self, rows=[]): 151 """ 152 Set a sequence of row numbers (0-based). Power users Only! 153 NOTICE row numbers can be changed easily by sorting, 154 prior selection, etc. 155 Parameters: 156 rows: a list of integers. Default [] is to unset the selection. 157 """ 158 vec = _to_list(rows, int) 159 if isinstance(vec,list): 160 self._setrows(vec) 161 else: 162 raise TypeError('Unknown row number type. Use lists of integers.') 149 163 150 164 def get_scans(self): -
branches/alma/src/STSelector.cpp
r1603 r1639 116 116 } 117 117 118 void STSelector::setRows( const std::vector< int >& rows ) 119 { 120 rowselection_ = rows; 121 } 122 123 // Table STSelector::apply( const Table& tab ) 124 // { 125 // if ( empty() ) { 126 // return sort(tab); 127 // } 128 // TableExprNode query; 129 // intidmap::const_iterator it; 130 // for (it = intselections_.begin(); it != intselections_.end(); ++it) { 131 // TableExprNode theset(Vector<Int>( (*it).second )); 132 // if ( query.isNull() ) { 133 // query = tab.col((*it).first).in(theset); 134 // } else { 135 // query = tab.col((*it).first).in(theset) && query; 136 // } 137 // } 138 // stringidmap::const_iterator it1; 139 // for (it1 = stringselections_.begin(); it1 != stringselections_.end(); ++it1) { 140 // TableExprNode theset(mathutil::toVectorString( (*it1).second )); 141 // if ( query.isNull() ) { 142 // query = tab.col((*it1).first).in(theset); 143 // } else { 144 // query = tab.col((*it1).first).in(theset) && query; 145 // } 146 // } 147 // // add taql query 148 // if ( taql_.size() > 0 ) { 149 // Table tmpt = tab; 150 // std::string pytaql = "USING STYLE PYTHON " + taql_; 151 152 // if ( !query.isNull() ) { // taql and selection 153 // tmpt = tableCommand(pytaql, tab(query)); 154 // } else { // taql only 155 // tmpt = tableCommand(pytaql, tab); 156 // } 157 // return sort(tmpt); 158 // } else { 159 // if ( query.isNull() ) { 160 // return sort(tab); 161 // } else { 162 // return sort(tab(query)); 163 // } 164 // } 165 // } 118 166 Table STSelector::apply( const Table& tab ) 119 167 { 120 168 if ( empty() ) { 121 169 return sort(tab); 170 } 171 Table basetab = tab; 172 // Important!! Be sure to apply row selection first. 173 if (rowselection_.size() > 0){ 174 //Vector<Int> intrownrs(rowselection_); 175 Vector<uInt> rownrs( rowselection_.size() ); 176 convertArray(rownrs, Vector<Int> ( rowselection_ )); 177 basetab = tab( rownrs ); 178 ///TableExprNode theset(Vector<Int>( rowselection_ )); 179 ///query = tab.nodeRownr().in(theset); 122 180 } 123 181 TableExprNode query; … … 126 184 TableExprNode theset(Vector<Int>( (*it).second )); 127 185 if ( query.isNull() ) { 128 query = tab.col((*it).first).in(theset); 186 //query = tab.col((*it).first).in(theset); 187 query = basetab.col((*it).first).in(theset); 129 188 } else { 130 query = tab.col((*it).first).in(theset) && query; 189 //query = tab.col((*it).first).in(theset) && query; 190 query = basetab.col((*it).first).in(theset) && query; 131 191 } 132 192 } … … 135 195 TableExprNode theset(mathutil::toVectorString( (*it1).second )); 136 196 if ( query.isNull() ) { 137 query = tab.col((*it1).first).in(theset); 197 //query = tab.col((*it1).first).in(theset); 198 query = basetab.col((*it1).first).in(theset); 138 199 } else { 139 query = tab.col((*it1).first).in(theset) && query; 200 //query = tab.col((*it1).first).in(theset) && query; 201 query = basetab.col((*it1).first).in(theset) && query; 140 202 } 141 203 } 142 204 // add taql query 143 205 if ( taql_.size() > 0 ) { 144 Table tmpt = tab; 206 //Table tmpt = tab; 207 Table tmpt = basetab; 145 208 std::string pytaql = "USING STYLE PYTHON " + taql_; 146 209 147 210 if ( !query.isNull() ) { // taql and selection 148 tmpt = tableCommand(pytaql, tab(query)); 211 //tmpt = tableCommand(pytaql, tab(query)); 212 tmpt = tableCommand(pytaql, basetab(query)); 149 213 } else { // taql only 150 tmpt = tableCommand(pytaql, tab); 214 //tmpt = tableCommand(pytaql, tab); 215 tmpt = tableCommand(pytaql, basetab); 151 216 } 152 217 return sort(tmpt); 153 218 } else { 154 219 if ( query.isNull() ) { 155 return sort(tab); 220 //return sort(tab); 221 return sort(basetab); 156 222 } else { 157 return sort(tab(query)); 223 //return sort(tab(query)); 224 return sort(basetab(query)); 158 225 } 159 226 } … … 227 294 bool asap::STSelector::empty( ) const 228 295 { 229 return (intselections_.empty() && taql_.size() == 0 ); 296 //return (intselections_.empty() && taql_.size() == 0 ); 297 return (intselections_.empty() && taql_.size() == 0 && rowselection_.size() == 0); 230 298 } 231 299 -
branches/alma/src/STSelector.h
r939 r1639 48 48 49 49 void setSortOrder(const std::vector<std::string>& order); 50 void setRows(const std::vector<int>& rows); 50 51 51 52 std::vector<int> getScans() const; … … 86 87 casa::Block<casa::String> order_; 87 88 std::string taql_; 89 std::vector<int> rowselection_; 88 90 }; 89 91 -
branches/alma/src/python_STSelector.cpp
r939 r1639 41 41 .def("_settaql", &STSelector::setTaQL) 42 42 .def("_setorder", &STSelector::setSortOrder) 43 .def("_setrows", &STSelector::setRows) 43 44 .def("_empty", &STSelector::empty) 44 45 ;
Note:
See TracChangeset
for help on using the changeset viewer.