Changeset 2381


Ignore:
Timestamp:
12/21/11 20:07:23 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2816

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...

Defined STGrid::call_ggridsd.
Defined some temporary data storage.
Some test code is inserted but commented out so far.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2380 r2381  
    153153                Double*);
    154154}
     155void STGrid::call_ggridsd( Double* xy,
     156                           const Complex* values,
     157                           Int* nvispol,
     158                           Int* nvischan,
     159                           const Int* flag,
     160                           const Int* rflag,
     161                           const Float* weight,
     162                           Int* nrow,
     163                           Int* irow,
     164                           Complex* grid,
     165                           Float* wgrid,
     166                           Int* nx,
     167                           Int* ny,
     168                           Int * npol,
     169                           Int * nchan,
     170                           Int* support,
     171                           Int* sampling,
     172                           Float* convFunc,
     173                           Int *chanMap,
     174                           Int *polMap )
     175{
     176  // parameters for gridding
     177  Int idopsf = 0 ;
     178  Int len = (*npol)*(*nchan) ;
     179  Double *sumw_p = new Double[len] ;
     180  {
     181    Double *work_p = sumw_p ;
     182    for ( Int i = 0 ; i < len ; i++ ) {
     183      *work_p = 0.0 ;
     184      work_p++ ;
     185    }
     186  }
     187
     188  // call ggridsd
     189  ggridsd( xy,
     190           values,
     191           nvispol,
     192           nvischan,
     193           &idopsf,
     194           flag,
     195           rflag,
     196           weight,
     197           nrow,
     198           irow,
     199           grid,
     200           wgrid,
     201           nx,
     202           ny,
     203           npol,
     204           nchan,
     205           support,
     206           sampling,
     207           convFunc,
     208           chanMap,
     209           polMap,
     210           sumw_p ) ;
     211
     212  // finalization
     213  delete sumw_p ;
     214}
     215
    155216void STGrid::gridPerRow()
    156217{
     
    204265  Array<Double> direction( dshape ) ;
    205266  Array<Int> flagtra( cshape ) ;
    206   //Array<Int> rflag( mshape ) ;
    207267  Array<Int> rflag( vshape ) ;
    208268  Array<Float> weight( wshape ) ;
    209269  Array<Double> xypos( dshape ) ;
    210270
     271  spectraF_.resize( cshape ) ;
     272  flagtraUC_.resize( cshape ) ;
     273  rflagUI_.resize( vshape ) ;
     274
    211275  // parameters for gridding
    212   Int idopsf = 0 ;
    213276  Int *chanMap = new Int[nchan_] ;
    214277  {
     
    227290    }
    228291  }
    229   Double *sumw_p = new Double[npol_*nchan_] ;
    230   {
    231     Double *work_p = sumw_p ;
    232     for ( Int i = 0 ; i < npol_*nchan_ ; i++ ) {
    233       *work_p = 0.0 ;
    234       work_p++ ;
    235     }
    236   }
    237292
    238293  // for performance check
     
    240295  double eToPixel = 0.0 ;
    241296  double eGGridSD = 0.0 ;
     297  double eToInt = 0.0 ;
    242298
    243299  // prepare pointer
     
    258314    t1 = mathutil::gettimeofday_sec() ;
    259315    eGetDataChunk += t1-t0 ;
     316    eToInt += subtime_ ;
    260317   
    261318    // world -> pixel
     
    268325    irow = -1 ;
    269326    t0 = mathutil::gettimeofday_sec() ;
    270     ggridsd( xypos_p,
    271              data_p,
    272              &npol_,
    273              &nchan_,
    274              &idopsf,
    275              flag_p,
    276              rflag_p,
    277              wgt_p,
    278              &nrow,
    279              &irow,
    280              gdata_p,
    281              wdata_p,
    282              &gnx,
    283              &gny,
    284              &npol_,
    285              &nchan_,
    286              &convSupport_,
    287              &convSampling_,
    288              conv_p,
    289              chanMap,
    290              polMap,
    291              sumw_p ) ;
     327    call_ggridsd( xypos_p,
     328                  data_p,
     329                  &npol_,
     330                  &nchan_,
     331                  flag_p,
     332                  rflag_p,
     333                  wgt_p,
     334                  &nrow,
     335                  &irow,
     336                  gdata_p,
     337                  wdata_p,
     338                  &gnx,
     339                  &gny,
     340                  &npol_,
     341                  &nchan_,
     342                  &convSupport_,
     343                  &convSampling_,
     344                  conv_p,
     345                  chanMap,
     346                  polMap ) ;
    292347    t1 = mathutil::gettimeofday_sec() ;
    293348    eGGridSD += t1-t0 ;
     
    297352  os << "toPixel: elapsed time is " << eToPixel << " sec." << LogIO::POST ;
    298353  os << "ggridsd: elapsed time is " << eGGridSD << " sec." << LogIO::POST ;
    299 
     354  os << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ;
    300355
    301356  // finalization
     
    310365  delete polMap ;
    311366  delete chanMap ;
    312   delete sumw_p ;
    313367
    314368  // set data
     
    358412  nchunk_ = 100 ;
    359413  Bool b = nchunk_ >= nrow_ ;
     414  nchunk_ = min( nchunk_, nrow_ ) ;
    360415  return b ;
    361416}
     
    363418void STGrid::gridAll()
    364419{
    365   LogIO os( LogOrigin("STGrid", "grid", WHERE) ) ;
     420  LogIO os( LogOrigin("STGrid", "gridAll", WHERE) ) ;
    366421
    367422  // retrieve data
     
    433488  Complex *gdata_p = gdataArrC.getStorage( deleteDataG ) ;
    434489  Float *wdata_p = gwgtArr.getStorage( deleteWgtG ) ;
    435   Int idopsf = 0 ;
    436490  Int *chanMap = new Int[nchan_] ;
    437491  {
     
    450504    }
    451505  }
    452   Double *sumw_p = new Double[npol_*nchan_] ;
    453   {
    454     Double *work_p = sumw_p ;
    455     for ( Int i = 0 ; i < npol_*nchan_ ; i++ ) {
    456       *work_p = 0.0 ;
    457       work_p++ ;
    458     }
    459   }
    460506  t0 = mathutil::gettimeofday_sec() ;
    461507  Int irow = -1 ;
    462   ggridsd( xypos_p,
    463            data_p,
    464            &npol_,
    465            &nchan_,
    466            &idopsf,
    467            flag_p,
    468            rflag_p,
    469            wgt_p,
    470            &nrow_,
    471            &irow,
    472            gdata_p,
    473            wdata_p,
    474            &gnx,
    475            &gny,
    476            &npol_,
    477            &nchan_,
    478            &convSupport_,
    479            &convSampling_,
    480            conv_p,
    481            chanMap,
    482            polMap,
    483            sumw_p ) ;
     508  call_ggridsd( xypos_p,
     509                data_p,
     510                &npol_,
     511                &nchan_,
     512                flag_p,
     513                rflag_p,
     514                wgt_p,
     515                &nrow_,
     516                &irow,
     517                gdata_p,
     518                wdata_p,
     519                &gnx,
     520                &gny,
     521                &npol_,
     522                &nchan_,
     523                &convSupport_,
     524                &convSampling_,
     525                conv_p,
     526                chanMap,
     527                polMap ) ;
    484528  t1 = mathutil::gettimeofday_sec() ;
    485529  os << "ggridsd: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     
    496540  setData( gdataArrC, gwgtArr ) ;
    497541  //Matrix<Double> sumWeight( IPosition( 2, npol_, nchan_ ), sumw_p, TAKE_OVER ) ;
    498   delete sumw_p ;
    499542  //cout << "sumWeight = " << sumWeight << endl ;
    500543//   os << "gdataArr = " << gdataArr << LogIO::POST ;
     
    689732  tsysCol_.attach( tab_, "TSYS" ) ;
    690733  intervalCol_.attach( tab_, "INTERVAL" ) ;
     734//   Vector<String> colnames( 6 ) ;
     735//   colnames[0] = "SPECTRA" ;
     736//   colnames[1] = "FLAGTRA" ;
     737//   colnames[2] = "DIRECTION" ;
     738//   colnames[3] = "FLAGROW" ;
     739//   colnames[4] = "TSYS" ;
     740//   colnames[5] = "INTERVAL" ;
     741//   row_ = ROTableRow( tab_, colnames ) ;
     742//   const TableRecord &rec = row_.record() ;
     743//   spectraRF_.attachToRecord( rec, colnames[0] ) ;
     744//   flagtraRF_.attachToRecord( rec, colnames[1] ) ;
     745//   directionRF_.attachToRecord( rec, colnames[2] ) ;
     746//   flagRowRF_.attachToRecord( rec, colnames[3] ) ;
     747//   tsysRF_.attachToRecord( rec, colnames[4] ) ;
     748//   intervalRF_.attachToRecord( rec, colnames[5] ) ;
    691749}
    692750
     
    811869                          Array<Float> &weight )
    812870{
    813   Array<Float> spFloat( spectra.shape() ) ;
    814   Array<uChar> fluChar( flagtra.shape() ) ;
    815   Array<uInt> fruInt( rflag.shape() ) ;
    816   Int nrow = getDataChunk( spFloat, direction, fluChar, fruInt, weight ) ;
    817   convertArray( spectra, spFloat ) ;
    818   convertArray( flagtra, fluChar ) ;
    819   convertArray( rflag, fruInt ) ;
    820 
     871  Int nrow = getDataChunk( spectraF_, direction, flagtraUC_, rflagUI_, weight ) ;
     872  double t0, t1 ;
     873  t0 = mathutil::gettimeofday_sec() ;
     874  convertArray( spectra, spectraF_ ) ;
     875  convertArray( flagtra, flagtraUC_ ) ;
     876  convertArray( rflag, rflagUI_ ) ;
     877  t1 = mathutil::gettimeofday_sec() ;
     878  subtime_ = t1 - t0 ;
     879 
    821880  return nrow ;
    822881}
     
    831890  Int nrow = min( spectra.shape()[2], nrow_-nprocessed_ ) ;
    832891  Array<Float> tsys( spectra.shape() ) ;
    833   //Array<Double> tint( rflag.shape() ) ;
    834892  Array<Double> tint( IPosition(2,spectra.shape()[0],spectra.shape()[2]) ) ;
    835893  IPosition m( 2, 0, 2 ) ;
     
    845903  Double *wti_p = ti_p ;
    846904  Int offset = nprocessed_ * npol_ ;
     905  Int start = offset ;
     906  Int end = start + nrow * npol_ ;
    847907  for ( Int irow = 0 ; irow < npol_ * nrow ; irow++ ) {
    848908    Array<Float> spSlice = spi.array() ;
     
    869929  }
    870930  tint.putStorage( ti_p, bti ) ;
    871 
    872931  for ( Int irow = 0 ; irow < nrow ; irow += npol_ ) {
    873932    uInt idx = rows_[offset+irow] ;
     
    882941  }
    883942  rflag.putStorage( fr_p, bfr ) ;
     943//   Bool bti, bfr ;
     944//   Double *ti_p = tint.getStorage( bti ) ;
     945//   Double *wti_p = ti_p ;
     946//   uInt *fr_p = rflag.getStorage( bfr ) ;
     947//   uInt *wfr_p = fr_p - 1 ;
     948//   Int start = nprocessed_ * npol_ ;
     949//   Int end = start + nrow * npol_ ;
     950//   for ( Int irow = start ; irow < end ; irow++ ) {
     951//     uInt idx = rows_[irow] ;
     952//     row_.get( idx ) ;
     953//     // SPECTRA
     954// //     os << "spi.array().shape()=" << spi.array().shape() << LogIO::POST ;
     955// //     os << "(*spectraRF_).shape()=" << (*spectraRF_).shape() << LogIO::POST ;
     956//     spi.array() = *spectraRF_ ;
     957   
     958//     // FLAGTRA
     959//     fli.array() = *flagtraRF_ ;
     960
     961//     // INTERVAL
     962//     *wti_p = *intervalRF_ ;
     963
     964//     // TSYS
     965// //     os << "tsi.array().shape()=" << tsi.array().shape() << LogIO::POST ;
     966// //     os << "(*tsysRF_).shape()=" << (*tsysRF_).shape() << LogIO::POST ;
     967// //     os << "(*tsysRF_).nelements()=" << (*tsysRF_).nelements() << LogIO::POST ;
     968//     if ( (*tsysRF_).nelements() == (uInt)nchan_ )
     969//       tsi.array() = *tsysRF_ ;
     970//     else
     971//       tsi.array() = *((*tsysRF_).data()) ;
     972
     973//     // DIRECTION and FLAGROW
     974//     Int mod = irow % npol_ ;
     975//     if ( mod == 0 ) {
     976// //       os << "di.array().shape()=" << di.array().shape() << LogIO::POST ;
     977// //       os << "(*directionRF_).shape()=" << (*directionRF_).shape() << LogIO::POST ;
     978//       di.array() = *directionRF_ ;
     979//       wfr_p++ ;
     980//       *wfr_p = *flagRowRF_ ;
     981//     }
     982//     else {
     983//       *wfr_p += *flagRowRF_ ;
     984//     }
     985   
     986//     // increment
     987//     spi.next() ;
     988//     fli.next() ;
     989//     tsi.next() ;
     990//     di.next() ;
     991//     *wti_p++ ;
     992//   }
     993//   tint.putStorage( ti_p, bti ) ;
     994//   rflag.putStorage( fr_p, bfr ) ;
    884995
    885996  getWeight( weight, tsys, tint ) ;
  • trunk/src/STGrid.h

    r2379 r2381  
    1919
    2020#include <casa/BasicSL/String.h>
     21#include <casa/Arrays/Array.h>
    2122#include <casa/Arrays/Vector.h>
    22 #include <casa/Arrays/Matrix.h>
    23 #include <casa/Arrays/Cube.h>
    24 // #include <casa/Arrays/ArrayMath.h>
    25 // #include <casa/Inputs/Input.h>
    26 // #include <casa/Quanta/Quantum.h>
    27 // #include <casa/Quanta/QuantumHolder.h>
    28 // #include <casa/Utilities/CountedPtr.h>
     23#include <casa/Containers/RecordField.h>
    2924
    3025#include <tables/Tables/Table.h>
    3126#include <tables/Tables/ScalarColumn.h>
    3227#include <tables/Tables/ArrayColumn.h>
     28//#include <tables/Tables/TableRow.h>
    3329
    3430// #include <measures/Measures/MDirection.h>
     
    137133  void attach() ;
    138134
     135  void call_ggridsd( Double* xy,
     136                     const Complex* values,
     137                     Int* nvispol,
     138                     Int* nvischan,
     139                     const Int* flag,
     140                     const Int* rflag,
     141                     const Float* weight,
     142                     Int* nrow,
     143                     Int* irow,
     144                     Complex* grid,
     145                     Float* wgrid,
     146                     Int* nx,
     147                     Int* ny,
     148                     Int * npol,
     149                     Int * nchan,
     150                     Int* support,
     151                     Int* sampling,
     152                     Float* convFunc,
     153                     Int *chanMap,
     154                     Int *polMap ) ;
     155
    139156
    140157  String infile_ ;
     
    164181  ROArrayColumn<Float> tsysCol_ ;
    165182  ROScalarColumn<Double> intervalCol_ ;
     183//   ROTableRow row_ ;
     184//   RORecordFieldPtr< Array<Float> > spectraRF_ ;
     185//   RORecordFieldPtr< Array<uChar> > flagtraRF_ ;
     186//   RORecordFieldPtr< Array<Double> > directionRF_ ;
     187//   RORecordFieldPtr<uInt> flagRowRF_ ;
     188//   RORecordFieldPtr< Array<Float> > tsysRF_ ;
     189//   RORecordFieldPtr<Double> intervalRF_ ;
    166190  Int nprocessed_ ;
    167191  Vector<uInt> rows_ ;
    168192  Int nchunk_ ;
     193
     194  Array<Float> spectraF_ ;
     195  Array<uChar> flagtraUC_ ;
     196  Array<uInt> rflagUI_ ;
     197
     198  double subtime_ ;
    169199};
    170200}
Note: See TracChangeset for help on using the changeset viewer.