Changeset 2540 for branches/hpc33/src
- Timestamp:
- 05/21/12 11:43:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hpc33/src/STMath.cpp
r2539 r2540 83 83 const std::string& avmode) 84 84 { 85 //double t0, t1 ;86 //t0 = mathutil::gettimeofday_sec() ;85 // double t0, t1 ; 86 // t0 = mathutil::gettimeofday_sec() ; 87 87 88 88 LogIO os( LogOrigin( "STMath", "average()", WHERE ) ) ; … … 137 137 Vector<Bool> cmask(mask); 138 138 acc.setUserMask(cmask); 139 ROTableRow row(tout);139 // ROTableRow row(tout); 140 140 ROArrayColumn<Float> specCol, tsysCol; 141 141 ROArrayColumn<uChar> flagCol; … … 145 145 Vector<uInt> rowstodelete; 146 146 147 Block<String> cols(3); 147 // Block<String> cols(3); 148 vector<string> cols(3) ; 148 149 cols[0] = String("BEAMNO"); 149 150 cols[1] = String("IFNO"); … … 161 162 } 162 163 uInt outrowCount = 0; 163 TableIterator iter(baset, cols); 164 // use STIdxIterExAcc instead of TableIterator 165 STIdxIterExAcc iter( in[0], cols ) ; 166 // TableIterator iter(baset, cols); 164 167 // int count = 0 ; 165 168 while (!iter.pastEnd()) { 166 Table subt = iter.table(); 169 Vector<uInt> rows = iter.getRows( SHARE ) ; 170 if ( rows.nelements() == 0 ) { 171 iter.next() ; 172 continue ; 173 } 174 Vector<uInt> current = iter.current() ; 175 String srcname = iter.getSrcName() ; 176 //Table subt = iter.table(); 167 177 // copy the first row of this selection into the new table 168 178 tout.addRow(); 169 TableCopy::copyRows(tout, subt, outrowCount, 0, 1); 179 //TableCopy::copyRows(tout, subt, outrowCount, 0, 1); 180 TableCopy::copyRows(tout, baset, outrowCount, rows[0], 1); 170 181 // re-index to 0 171 182 if ( avmode != "SCAN" && avmode != "SOURCE" ) { 172 183 scanColOut.put(outrowCount, uInt(0)); 173 184 } 174 /* 175 ++outrowCount; 176 */ 185 177 186 // 2012/02/17 TN 178 187 // Since STGrid is implemented, average doesn't consider direction … … 214 223 // } 215 224 // outrowCount += rowNum ; 216 /*217 ++iter;218 }219 RowAccumulator acc(wtype);220 Vector<Bool> cmask(mask);221 acc.setUserMask(cmask);222 ROTableRow row(tout);223 ROArrayColumn<Float> specCol, tsysCol;224 ROArrayColumn<uChar> flagCol;225 ROScalarColumn<Double> mjdCol, intCol;226 ROScalarColumn<Int> scanIDCol;227 228 Vector<uInt> rowstodelete;229 */230 225 231 226 // merge loop … … 234 229 235 230 // in[0] is already selected by TableItertor 236 specCol.attach(subt,"SPECTRA"); 237 flagCol.attach(subt,"FLAGTRA"); 238 tsysCol.attach(subt,"TSYS"); 239 intCol.attach(subt,"INTERVAL"); 240 mjdCol.attach(subt,"TIME"); 231 // specCol.attach(subt,"SPECTRA"); 232 // flagCol.attach(subt,"FLAGTRA"); 233 // tsysCol.attach(subt,"TSYS"); 234 // intCol.attach(subt,"INTERVAL"); 235 // mjdCol.attach(subt,"TIME"); 236 specCol.attach(baset,"SPECTRA"); 237 flagCol.attach(baset,"FLAGTRA"); 238 tsysCol.attach(baset,"TSYS"); 239 intCol.attach(baset,"INTERVAL"); 240 mjdCol.attach(baset,"TIME"); 241 241 Vector<Float> spec,tsys; 242 242 Vector<uChar> flag; 243 243 Double inter,time; 244 for (uInt k = 0; k < subt.nrow(); ++k ) { 244 // for (uInt k = 0; k < subt.nrow(); ++k ) { 245 for (uInt l = 0; l < rows.nelements(); ++l ) { 246 uInt k = rows[l] ; 245 247 flagCol.get(k, flag); 246 248 Vector<Bool> bflag(flag.shape()); … … 266 268 acc.replaceNaN(); 267 269 268 // in[0] is already selected by TableIterator so that i t is not necessary to process269 // in[0] here270 // in[0] is already selected by TableIterator so that index is 271 // started from 1 270 272 //for ( int j=0; j < int(in.size()); ++j ) { 271 273 for ( int j=1; j < int(in.size()); ++j ) { 272 274 const Table& tin = in[j]->table(); 273 const TableRecord& rec = row.get(i);275 //const TableRecord& rec = row.get(i); 274 276 ROScalarColumn<Double> tmp(tin, "TIME"); 275 277 Double td;tmp.get(0,td); … … 277 279 #if 1 278 280 static char const*const colNames1[] = { "IFNO", "BEAMNO", "POLNO" }; 279 uInt const values1[] = { rec.asuInt("IFNO"), rec.asuInt("BEAMNO"), rec.asuInt("POLNO") }; 281 //uInt const values1[] = { rec.asuInt("IFNO"), rec.asuInt("BEAMNO"), rec.asuInt("POLNO") }; 282 uInt const values1[] = { current[1], current[0], current[2] }; 280 283 SingleTypeEqPredicate<uInt, 3> myPred(tin, colNames1, values1); 281 284 CustomTableExprNodeRep myNodeRep(tin, myPred); … … 284 287 Table basesubt = tin(myExpr); 285 288 #else 286 Table basesubt = tin( tin.col("BEAMNO") == Int(rec.asuInt("BEAMNO")) 287 && tin.col("IFNO") == Int(rec.asuInt("IFNO")) 288 && tin.col("POLNO") == Int(rec.asuInt("POLNO")) ); 289 // Table basesubt = tin( tin.col("BEAMNO") == Int(rec.asuInt("BEAMNO")) 290 // && tin.col("IFNO") == Int(rec.asuInt("IFNO")) 291 // && tin.col("POLNO") == Int(rec.asuInt("POLNO")) ); 292 Table basesubt = tin( tin.col("BEAMNO") == current[0] 293 && tin.col("IFNO") == current[1] 294 && tin.col("POLNO") == current[2] ); 289 295 #endif 290 //Table subt;296 Table subt; 291 297 if ( avmode == "SOURCE") { 292 subt = basesubt( basesubt.col("SRCNAME") == rec.asString("SRCNAME")); 298 // subt = basesubt( basesubt.col("SRCNAME") == rec.asString("SRCNAME")); 299 subt = basesubt( basesubt.col("SRCNAME") == srcname ); 300 293 301 } else if (avmode == "SCAN") { 294 subt = basesubt( basesubt.col("SRCNAME") == rec.asString("SRCNAME") 295 && basesubt.col("SCANNO") == Int(rec.asuInt("SCANNO")) ); 302 // subt = basesubt( basesubt.col("SRCNAME") == rec.asString("SRCNAME") 303 // && basesubt.col("SCANNO") == Int(rec.asuInt("SCANNO")) ); 304 subt = basesubt( basesubt.col("SRCNAME") == srcname 305 && basesubt.col("SCANNO") == current[4] ); 296 306 } else { 297 307 subt = basesubt; … … 327 337 intCol.attach(subt,"INTERVAL"); 328 338 mjdCol.attach(subt,"TIME"); 329 Vector<Float> spec,tsys;330 Vector<uChar> flag;331 Double inter,time;339 // Vector<Float> spec,tsys; 340 // Vector<uChar> flag; 341 // Double inter,time; 332 342 for (uInt k = 0; k < subt.nrow(); ++k ) { 333 343 flagCol.get(k, flag); … … 389 399 // merge with while loop for preparing out table 390 400 ++outrowCount; 391 ++iter ; 401 // ++iter ; 402 iter.next() ; 392 403 } 393 404 … … 400 411 } 401 412 402 //t1 = mathutil::gettimeofday_sec() ;403 //cout << "elapsed time for average(): " << t1-t0 << " sec" << endl ;413 // t1 = mathutil::gettimeofday_sec() ; 414 // cout << "elapsed time for average(): " << t1-t0 << " sec" << endl ; 404 415 405 416 return out;
Note:
See TracChangeset
for help on using the changeset viewer.