Ignore:
Timestamp:
05/22/12 10:17:06 (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...

More speedup of STMath::average().

  • Reduced number of call of RowAccumulator::replaceNaN().
  • Performance of RowAccumulator::add() is improved.


File:
1 edited

Legend:

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

    r2540 r2542  
    164164  // use STIdxIterExAcc instead of TableIterator
    165165  STIdxIterExAcc iter( in[0], cols ) ;
     166//   double t2 = 0 ;
     167//   double t3 = 0 ;
    166168//   TableIterator iter(baset, cols);
    167169//   int count = 0 ;
     
    229231
    230232    // in[0] is already selected by TableItertor
    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");
    236233    specCol.attach(baset,"SPECTRA");
    237234    flagCol.attach(baset,"FLAGTRA");
     
    258255      mjdCol.get(k, time);
    259256      // spectrum has to be added last to enable weighting by the other values                             
     257//       t2 = mathutil::gettimeofday_sec() ;
    260258      acc.add(spec, !bflag, tsys, inter, time);
    261     }
    262 
    263     // If there exists a channel at which all the input spectra are masked,                               
    264     // spec has 'nan' values for that channel and it may affect the following                             
    265     // processes. To avoid this, replacing 'nan' values in spec with                                       
    266     // weighted-mean of all spectra in the following line.                                                 
    267     // (done for CAS-2776, 2011/04/07 by Wataru Kawasaki)                                                 
    268     acc.replaceNaN();
     259//       t3 += mathutil::gettimeofday_sec() - t2 ;
     260     
     261    }
     262
    269263
    270264    // in[0] is already selected by TableIterator so that index is
     
    337331      intCol.attach(subt,"INTERVAL");
    338332      mjdCol.attach(subt,"TIME");
    339 //       Vector<Float> spec,tsys;
    340 //       Vector<uChar> flag;
    341 //       Double inter,time;
    342333      for (uInt k = 0; k < subt.nrow(); ++k ) {
    343334        flagCol.get(k, flag);
     
    354345        mjdCol.get(k, time);
    355346        // spectrum has to be added last to enable weighting by the other values
     347//         t2 = mathutil::gettimeofday_sec() ;
    356348        acc.add(spec, !bflag, tsys, inter, time);
    357       }
    358 
     349//         t3 += mathutil::gettimeofday_sec() - t2 ;
     350      }
     351
     352    }
     353    const Vector<Bool>& msk = acc.getMask();
     354    if ( allEQ(msk, False) ) {
     355      uint n = rowstodelete.nelements();
     356      rowstodelete.resize(n+1, True);
     357      rowstodelete[n] = i;
     358      continue;
     359    }
     360    //write out
     361    if (acc.state()) {
    359362      // If there exists a channel at which all the input spectra are masked,
    360363      // spec has 'nan' values for that channel and it may affect the following
     
    363366      // (done for CAS-2776, 2011/04/07 by Wataru Kawasaki)
    364367      acc.replaceNaN();
    365     }
    366     const Vector<Bool>& msk = acc.getMask();
    367     if ( allEQ(msk, False) ) {
    368       uint n = rowstodelete.nelements();
    369       rowstodelete.resize(n+1, True);
    370       rowstodelete[n] = i;
    371       continue;
    372     }
    373     //write out
    374     if (acc.state()) {
     368
    375369      Vector<uChar> flg(msk.shape());
    376370      convertArray(flg, !msk);
     
    413407//    t1 = mathutil::gettimeofday_sec() ;
    414408//    cout << "elapsed time for average(): " << t1-t0 << " sec" << endl ;
     409//    cout << "   elapsed time for acc.add(): " << t3 << " sec" << endl ;
    415410
    416411  return out;
Note: See TracChangeset for help on using the changeset viewer.