Changeset 2540 for branches


Ignore:
Timestamp:
05/21/12 11:43:29 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Use STIdxIterExAcc instead of TableIterator?.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/hpc33/src/STMath.cpp

    r2539 r2540  
    8383                 const std::string& avmode)
    8484{
    85   //  double t0, t1 ;
    86   //  t0 = mathutil::gettimeofday_sec() ;
     85//    double t0, t1 ;
     86//    t0 = mathutil::gettimeofday_sec() ;
    8787
    8888  LogIO os( LogOrigin( "STMath", "average()", WHERE ) ) ;
     
    137137  Vector<Bool> cmask(mask);
    138138  acc.setUserMask(cmask);
    139   ROTableRow row(tout);
     139//   ROTableRow row(tout);
    140140  ROArrayColumn<Float> specCol, tsysCol;
    141141  ROArrayColumn<uChar> flagCol;
     
    145145  Vector<uInt> rowstodelete;
    146146
    147   Block<String> cols(3);
     147//   Block<String> cols(3);
     148  vector<string> cols(3) ;
    148149  cols[0] = String("BEAMNO");
    149150  cols[1] = String("IFNO");
     
    161162  }
    162163  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);
    164167//   int count = 0 ;
    165168  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();
    167177    // copy the first row of this selection into the new table
    168178    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);
    170181    // re-index to 0
    171182    if ( avmode != "SCAN" && avmode != "SOURCE" ) {
    172183      scanColOut.put(outrowCount, uInt(0));
    173184    }
    174     /*
    175     ++outrowCount;
    176     */
     185
    177186    // 2012/02/17 TN
    178187    // Since STGrid is implemented, average doesn't consider direction
     
    214223//     }
    215224//     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 */
    230225
    231226// merge loop
     
    234229
    235230    // 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");
    241241    Vector<Float> spec,tsys;
    242242    Vector<uChar> flag;
    243243    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] ;
    245247      flagCol.get(k, flag);
    246248      Vector<Bool> bflag(flag.shape());
     
    266268    acc.replaceNaN();
    267269
    268     // in[0] is already selected by TableIterator so that it is not necessary to process
    269     // in[0] here
     270    // in[0] is already selected by TableIterator so that index is
     271    // started from 1
    270272    //for ( int j=0; j < int(in.size()); ++j ) {
    271273    for ( int j=1; j < int(in.size()); ++j ) {
    272274      const Table& tin = in[j]->table();
    273       const TableRecord& rec = row.get(i);
     275      //const TableRecord& rec = row.get(i);
    274276      ROScalarColumn<Double> tmp(tin, "TIME");
    275277      Double td;tmp.get(0,td);
     
    277279#if 1
    278280      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] };
    280283      SingleTypeEqPredicate<uInt, 3> myPred(tin, colNames1, values1);
    281284      CustomTableExprNodeRep myNodeRep(tin, myPred);
     
    284287      Table basesubt = tin(myExpr);
    285288#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] );
    289295#endif
    290       //      Table subt;
     296      Table subt;
    291297      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
    293301      } 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] );
    296306      } else {
    297307        subt = basesubt;
     
    327337      intCol.attach(subt,"INTERVAL");
    328338      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;
    332342      for (uInt k = 0; k < subt.nrow(); ++k ) {
    333343        flagCol.get(k, flag);
     
    389399    // merge with while loop for preparing out table
    390400    ++outrowCount;
    391     ++iter ;
     401//     ++iter ;
     402    iter.next() ;
    392403  }
    393404
     
    400411  }
    401412
    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 ;
    404415
    405416  return out;
Note: See TracChangeset for help on using the changeset viewer.