Changeset 2560


Ignore:
Timestamp:
06/11/12 20:27:09 (13 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...

Minimize data copy in STMath::almacal


Location:
branches/hpc33/src
Files:
2 edited

Legend:

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

    r2559 r2560  
    39523952    CountedPtr<Scantable> out = getScantable( s, true ) ;
    39533953    Table t = s->table_( s->table_.col("SRCTYPE") == (Int)SrcType::PSOFF ) ;
    3954     TableCopy::copyRows( out->table(), t ) ;
     3954    //TableCopy::copyRows( out->table(), t ) ;
     3955    out->table_ = t ;
     3956    out->attach() ;
    39553957    insitu_ = insitu ;
    3956     Table ttab = out->table() ;
    3957     ROScalarColumn<Double> *timeCol = new ROScalarColumn<Double>( ttab, "TIME" ) ;
    3958     uInt nrow = timeCol->nrow() ;
    3959     Vector<Double> timeSep = timeCol->getColumn() ;
    3960     delete timeCol ;
    3961     for ( uInt i = nrow-2 ; i > 0 ; i-- ) {
    3962       timeSep[i] -= timeSep[i-1] ;
    3963     }
    3964     Vector<Double> interval = out->integrCol_.getColumn() ;
    3965     interval /= 86400.0 ;
    3966     uInt *newscan = new uInt[nrow] ;
    3967     Vector<uInt> newscanno( IPosition(1,nrow), newscan, TAKE_OVER ) ;
    3968     uInt *p = newscan ;
    3969     uInt newid = 0 ;
    3970     for ( uInt i = 0 ; i < nrow - 1 ; i++ ) {
    3971       *p = newid ;
    3972       double gap = 2.0 * timeSep[i+1] / ( interval[i] + interval[i+1] ) ;
    3973       //cout << "gap[" << i << "]=" << setw(5) << gap << endl ;
    3974       if ( gap > 1.1 ) {
    3975 //         cout << "detected gap between " << i << " and " << i+1 << endl ;
    3976         newid++ ;
    3977       }
    3978       p++ ;
    3979     }
    3980     *p = newid ;
    3981     out->scanCol_.putColumn( newscanno ) ;
    3982 //     double t2 = mathutil::gettimeofday_sec() ;
    3983     vector< CountedPtr<Scantable> > tmp( 1, out ) ;
    3984     CountedPtr<Scantable> aoff = average( tmp, masks, "TINT", "SCAN" ) ;
    3985 //     double t3 = mathutil::gettimeofday_sec() ;
    3986 //     cout << "aoff.nrow = " << aoff->nrow() << endl ;
     3958    CountedPtr<Scantable> aoff = averageWithinSession( out,
     3959                                                       masks,
     3960                                                       "TINT" ) ;
     3961//     Table ttab = out->table() ;
     3962//     ROScalarColumn<Double> *timeCol = new ROScalarColumn<Double>( ttab, "TIME" ) ;
     3963//     uInt nrow = timeCol->nrow() ;
     3964//     Vector<Double> timeSep = timeCol->getColumn() ;
     3965//     delete timeCol ;
     3966//     for ( uInt i = nrow-2 ; i > 0 ; i-- ) {
     3967//       timeSep[i] -= timeSep[i-1] ;
     3968//     }
     3969//     Vector<Double> interval = out->integrCol_.getColumn() ;
     3970//     interval /= 86400.0 ;
     3971//     uInt *newscan = new uInt[nrow] ;
     3972//     Vector<uInt> newscanno( IPosition(1,nrow), newscan, TAKE_OVER ) ;
     3973//     uInt *p = newscan ;
     3974//     uInt newid = 0 ;
     3975//     for ( uInt i = 0 ; i < nrow - 1 ; i++ ) {
     3976//       *p = newid ;
     3977//       double gap = 2.0 * timeSep[i+1] / ( interval[i] + interval[i+1] ) ;
     3978//       //cout << "gap[" << i << "]=" << setw(5) << gap << endl ;
     3979//       if ( gap > 1.1 ) {
     3980// //         cout << "detected gap between " << i << " and " << i+1 << endl ;
     3981//         newid++ ;
     3982//       }
     3983//       p++ ;
     3984//     }
     3985//     *p = newid ;
     3986//     out->scanCol_.putColumn( newscanno ) ;
     3987//     vector< CountedPtr<Scantable> > tmp( 1, out ) ;
     3988//     CountedPtr<Scantable> aoff = average( tmp, masks, "TINT", "SCAN" ) ;
    39873989//     t1 = mathutil::gettimeofday_sec() ;
    39883990//     cout << "elapsed time for off averaging: " << t1-t0 << " sec" << endl ;
    3989 //     cout << "   elapsed time for average(): " << t3-t2 << " sec" << endl ;
    39903991   
    39913992    // on scan
     
    39933994    s->table_ = s->table_( s->table_.col("SRCTYPE") == (Int)SrcType::PSON ) ;
    39943995    s->attach() ;
    3995     out->table().addRow( s->nrow()-out->nrow() ) ;
     3996    //out->table().addRow( s->nrow()-out->nrow() ) ;
     3997    out->table_ = out->originalTable_ ;
     3998    out->attach() ;
     3999    out->table().addRow( s->nrow() ) ;
    39964000    copyRows( out->table(), s->table(), 0, 0, s->nrow(), False ) ;
    39974001//     t1 = mathutil::gettimeofday_sec() ;
     
    55865590  }
    55875591}
     5592
     5593CountedPtr<Scantable> STMath::averageWithinSession( CountedPtr<Scantable> &s,
     5594                                                    vector<bool> &mask,
     5595                                                    string weight )
     5596{
     5597    Table ttab = s->table() ;
     5598    ROScalarColumn<Double> *timeCol = new ROScalarColumn<Double>( ttab, "TIME" ) ;
     5599    uInt nrow = timeCol->nrow() ;
     5600    Vector<Double> timeSep = timeCol->getColumn() ;
     5601    delete timeCol ;
     5602    for ( uInt i = nrow-2 ; i > 0 ; i-- ) {
     5603      timeSep[i] -= timeSep[i-1] ;
     5604    }
     5605    Vector<Double> interval = s->integrCol_.getColumn() ;
     5606    interval /= 86400.0 ;
     5607    uInt *newscan = new uInt[nrow] ;
     5608    Vector<uInt> newscanno( IPosition(1,nrow), newscan, TAKE_OVER ) ;
     5609    uInt *p = newscan ;
     5610    uInt newid = 0 ;
     5611    for ( uInt i = 0 ; i < nrow - 1 ; i++ ) {
     5612      *p = newid ;
     5613      double gap = 2.0 * timeSep[i+1] / ( interval[i] + interval[i+1] ) ;
     5614      //cout << "gap[" << i << "]=" << setw(5) << gap << endl ;
     5615      if ( gap > 1.1 ) {
     5616//         cout << "detected gap between " << i << " and " << i+1 << endl ;
     5617        newid++ ;
     5618      }
     5619      p++ ;
     5620    }
     5621    *p = newid ;
     5622    s->scanCol_.putColumn( newscanno ) ;
     5623//     double t2 = mathutil::gettimeofday_sec() ;
     5624    vector< CountedPtr<Scantable> > tmp( 1, s ) ;
     5625    CountedPtr<Scantable> a = average( tmp, mask, weight, "SCAN" ) ;
     5626//     double t3 = mathutil::gettimeofday_sec() ;
     5627//     cout << "a.nrow = " << a->nrow() << endl ;
     5628//     t1 = mathutil::gettimeofday_sec() ;
     5629//     cout << "   elapsed time for average(): " << t3-t2 << " sec" << endl ;
     5630    return a ;
     5631}
  • branches/hpc33/src/STMath.h

    r2551 r2560  
    448448                 casa::Bool copyFlagtra=true,
    449449                 casa::Bool copyTsys=true ) ;
     450  casa::CountedPtr<Scantable> averageWithinSession( casa::CountedPtr<Scantable> &s,
     451                                                    vector<bool> &mask,
     452                                                    string weight ) ;
    450453
    451454  bool insitu_;
Note: See TracChangeset for help on using the changeset viewer.