Changeset 2384


Ignore:
Timestamp:
12/22/11 17:56:25 (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...

Updated call_ggridsd to be easy to call.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2383 r2384  
    3131
    3232namespace asap {
     33
     34// for performance check
     35double eToInt = 0.0 ;
     36double eGetWeight = 0.0 ;
    3337
    3438// constructor
     
    7781{
    7882  pollist_.assign( Vector<uInt>( pols ) ) ;
    79   cout << "pollist_ = " << pollist_ << endl ;
    8083}
    8184
     
    8386{
    8487  scanlist_.assign( Vector<uInt>( scans ) ) ;
    85   cout << "scanlist_ = " << scanlist_ << endl ;
    8688}
    8789
     
    9092  wtype_ = String( wType ) ;
    9193  wtype_.upcase() ;
    92   cout << "wtype_ = " << wtype_ << endl ;
    9394}
    9495
     
    153154                Double*);
    154155}
    155 void 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,
     156void STGrid::call_ggridsd( Array<Double> &xypos,
     157                           Array<Complex> &spectra,
     158                           Int &nvispol,
     159                           Int &nvischan,
     160                           Array<Int> &flagtra,
     161                           Array<Int> &flagrow,
     162                           Array<Float> &weight,
     163                           Int &nrow,
     164                           Int &irow,
     165                           Array<Complex> &gdata,
     166                           Array<Float> &gwgt,
     167                           Int &nx,
     168                           Int &ny,
     169                           Int &npol,
     170                           Int &nchan,
     171                           Int &support,
     172                           Int &sampling,
     173                           Vector<Float> &convFunc,
    173174                           Int *chanMap,
    174175                           Int *polMap )
     
    176177  // parameters for gridding
    177178  Int idopsf = 0 ;
    178   Int len = (*npol)*(*nchan) ;
     179  Int len = npol*nchan ;
    179180  Double *sumw_p = new Double[len] ;
    180181  {
     
    186187  }
    187188
     189  // prepare pointer
     190  Bool deletePos, deleteData, deleteWgt, deleteFlag, deleteFlagR, deleteConv, deleteDataG, deleteWgtG ;
     191  Double *xy_p = xypos.getStorage( deletePos ) ;
     192  const Complex *values_p = spectra.getStorage( deleteData ) ;
     193  const Int *flag_p = flagtra.getStorage( deleteFlag ) ;
     194  const Int *rflag_p = flagrow.getStorage( deleteFlagR ) ;
     195  const Float *wgt_p = weight.getStorage( deleteWgt ) ;
     196  Complex *grid_p = gdata.getStorage( deleteDataG ) ;
     197  Float *wgrid_p = gwgt.getStorage( deleteWgtG ) ;
     198  Float *conv_p = convFunc.getStorage( deleteConv ) ;
     199     
    188200  // call ggridsd
    189   ggridsd( xy,
    190            values,
    191            nvispol,
    192            nvischan,
     201  ggridsd( xy_p,
     202           values_p,
     203           &nvispol,
     204           &nvischan,
    193205           &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,
     206           flag_p,
     207           rflag_p,
     208           wgt_p,
     209           &nrow,
     210           &irow,
     211           grid_p,
     212           wgrid_p,
     213           &nx,
     214           &ny,
     215           &npol,
     216           &nchan,
     217           &support,
     218           &sampling,
     219           conv_p,
    208220           chanMap,
    209221           polMap,
     
    211223
    212224  // finalization
     225  xypos.putStorage( xy_p, deletePos ) ;
     226  spectra.freeStorage( values_p, deleteData ) ;
     227  flagtra.freeStorage( flag_p, deleteFlag ) ;
     228  flagrow.freeStorage( rflag_p, deleteFlagR ) ;
     229  weight.freeStorage( wgt_p, deleteWgt ) ;
     230  gdata.putStorage( grid_p, deleteDataG ) ;
     231  gwgt.putStorage( wgrid_p, deleteWgtG ) ;
     232  convFunc.putStorage( conv_p, deleteConv ) ;
    213233  delete sumw_p ;
    214234}
     
    223243void STGrid::grid()
    224244{
     245  LogIO os( LogOrigin("STGrid", "grid", WHERE) ) ;
     246
    225247  // data selection
    226248  selectData() ;
    227249  setupArray() ;
    228250
    229   if ( npol_ > 1 ) {
    230     LogIO os( LogOrigin("STGrid", "grid", WHERE) ) ;
    231     os << LogIO::WARN << "STGrid doesn't support assigning polarization-dependent weight. Use averaged weight over polarization." << LogIO::POST ;
    232   }
    233  
    234251  if ( wtype_.compare("UNIFORM") != 0 &&
    235252       wtype_.compare("TINT") != 0 &&
     
    241258  }
    242259
     260  // grid parameter
     261  os << LogIO::DEBUGGING ;
     262  os << "----------" << endl ;
     263  os << "Data selection summary" << endl ;
     264  os << "   ifno = " << ifno_ << endl ;
     265  os << "   pollist = " << pollist_ << endl ;
     266  os << "   scanlist = " << scanlist_ << endl ;
     267  os << "----------" << endl ;
     268  os << "Grid parameter summary" << endl ;
     269  os << "   (nx,ny) = (" << nx_ << "," << ny_ << ")" << endl ;
     270  os << "   (cellx,celly) = (" << cellx_ << "," << celly_ << ")" << endl ;
     271  os << "   center = " << center_ << endl ;
     272  os << "   weighting = " << wtype_ << endl ;
     273  os << "   convfunc = " << convType_ << "with support " << convSupport_ << endl ;
     274  os << "----------" << LogIO::POST ;
     275  os << LogIO::NORMAL ;
     276
    243277  Bool doAll = examine() ;
    244278
     
    264298  double t0, t1 ;
    265299
    266   // grid parameter
    267   os << LogIO::DEBUGGING ;
    268   os << "----------" << endl ;
    269   os << "Grid parameter summary" << endl ;
    270   os << "   (nx,ny) = (" << nx_ << "," << ny_ << ")" << endl ;
    271   os << "   (cellx,celly) = (" << cellx_ << "," << celly_ << ")" << endl ;
    272   os << "   center = " << center_ << endl ;
    273   os << "----------" << LogIO::POST ;
    274   os << LogIO::NORMAL ;
    275 
    276   // boolean for getStorage
    277   Bool deletePos, deleteData, deleteWgt, deleteFlag, deleteFlagR, deleteConv, deleteDataG, deleteWgtG ;
    278 
    279300  // convolution kernel
    280301  Vector<Float> convFunc ;
     
    283304  t1 = mathutil::gettimeofday_sec() ;
    284305  os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    285   //cout << "convSupport=" << convSupport_ << endl ;
    286   //cout << "convFunc=" << convFunc << endl ;
    287306
    288307  // grid data
     
    300319  Array<Float> gwgtArr( data_ ) ;
    301320
    302   // data storage
    303   Int irow = -1 ;
    304   IPosition cshape( 3, npol_, nchan_, nchunk_ ) ;
    305   IPosition mshape( 2, npol_, nchunk_ ) ;
    306   IPosition vshape( 1, nchunk_ ) ;
    307   IPosition dshape( 2, 2, nchunk_ ) ;
    308   IPosition wshape( 2, nchan_, nchunk_ ) ;
    309   Array<Complex> spectra( wshape ) ;
    310   Array<Int> flagtra( wshape ) ;
    311   Array<Int> rflag( vshape ) ;
    312   Array<Float> weight( wshape ) ;
    313   Array<Double> direction( dshape ) ;
    314   Array<Double> xypos( dshape ) ;
    315 
    316   spectraF_.resize( wshape ) ;
    317   flagtraUC_.resize( wshape ) ;
    318   rflagUI_.resize( vshape ) ;
    319 
    320321  // parameters for gridding
    321322  Int *chanMap = new Int[nchan_] ;
     
    329330  Int *polMap = new Int[1] ;
    330331  Int nvispol = 1 ;
     332  Int irow = -1 ;
    331333
    332334  // for performance check
    333   double eGetDataChunk = 0.0 ;
     335  double eGetData = 0.0 ;
    334336  double eToPixel = 0.0 ;
    335337  double eGGridSD = 0.0 ;
    336   double eToInt = 0.0 ;
     338  double eInitPol = 0.0 ;
    337339
    338340  for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) {
     341    t0 = mathutil::gettimeofday_sec() ;
    339342    initPol( ipol ) ;
     343    t1 = mathutil::gettimeofday_sec() ;
     344    eInitPol += t1-t0 ;
    340345   
    341346    polMap[0] = ipol ;
    342347
     348    os << "start pol" << ipol << LogIO::POST ;
     349
    343350    while( !pastEnd() ) {
     351      // data storage
     352      IPosition cshape( 3, npol_, nchan_, nchunk_ ) ;
     353      IPosition mshape( 2, npol_, nchunk_ ) ;
     354      IPosition vshape( 1, nchunk_ ) ;
     355      IPosition dshape( 2, 2, nchunk_ ) ;
     356      IPosition wshape( 2, nchan_, nchunk_ ) ;
     357      Array<Complex> spectra( wshape ) ;
     358      Array<Int> flagtra( wshape ) ;
     359      Array<Int> rflag( vshape ) ;
     360      Array<Float> weight( wshape ) ;
     361      Array<Double> direction( dshape ) ;
     362      Array<Double> xypos( dshape ) ;
     363     
     364      spectraF_.resize( wshape ) ;
     365      flagtraUC_.resize( wshape ) ;
     366      rflagUI_.resize( vshape ) ;
     367
    344368      // retrieve data
    345369      t0 = mathutil::gettimeofday_sec() ;
     
    347371      //os << "nrow = " << nrow << LogIO::POST ;
    348372      t1 = mathutil::gettimeofday_sec() ;
    349       eGetDataChunk += t1-t0 ;
    350       eToInt += subtime_ ;
     373      eGetData += t1-t0 ;
    351374     
    352375      // world -> pixel
     
    356379      eToPixel += t1-t0 ;
    357380   
    358       // prepare pointer
    359       Float *conv_p = convFunc.getStorage( deleteConv ) ;
    360       Complex *gdata_p = gdataArrC.getStorage( deleteDataG ) ;
    361       Float *wdata_p = gwgtArr.getStorage( deleteWgtG ) ;
    362       const Complex *data_p = spectra.getStorage( deleteData ) ;
    363       const Float *wgt_p = weight.getStorage( deleteWgt ) ;
    364       const Int *flag_p = flagtra.getStorage( deleteFlag ) ;
    365       const Int *rflag_p = rflag.getStorage( deleteFlagR ) ;
    366       Double *xypos_p = xypos.getStorage( deletePos ) ;
    367 
    368381      // call ggridsd
    369       irow = -1 ;
    370382      t0 = mathutil::gettimeofday_sec() ;
    371       call_ggridsd( xypos_p,
    372                     data_p,
    373                     //&npol_,
    374                     &nvispol,
    375                     &nchan_,
    376                     flag_p,
    377                     rflag_p,
    378                     wgt_p,
    379                     &nrow,
    380                     &irow,
    381                     gdata_p,
    382                     wdata_p,
    383                     &gnx,
    384                     &gny,
    385                     &npol_,
    386                     &nchan_,
    387                     &convSupport_,
    388                     &convSampling_,
    389                     conv_p,
     383      call_ggridsd( xypos,
     384                    spectra,
     385                    nvispol,
     386                    nchan_,
     387                    flagtra,
     388                    rflag,
     389                    weight,
     390                    nrow,
     391                    irow,
     392                    gdataArrC,
     393                    gwgtArr,
     394                    gnx,
     395                    gny,
     396                    npol_,
     397                    nchan_,
     398                    convSupport_,
     399                    convSampling_,
     400                    convFunc,
    390401                    chanMap,
    391402                    polMap ) ;
     
    393404      eGGridSD += t1-t0 ;
    394405
    395       // finalization
    396       convFunc.putStorage( conv_p, deleteConv ) ;
    397       gdataArrC.putStorage( gdata_p, deleteDataG ) ;
    398       gwgtArr.putStorage( wdata_p, deleteWgtG ) ;
    399       xypos.putStorage( xypos_p, deletePos ) ;
    400       spectra.freeStorage( data_p, deleteData ) ;
    401       weight.freeStorage( wgt_p, deleteWgt ) ;
    402       flagtra.freeStorage( flag_p, deleteFlag ) ;
    403       rflag.freeStorage( rflag_p, deleteFlagR ) ;
    404 
    405406    }
    406407
    407408    nprocessed_ = 0 ;
    408409  }
    409   os << "getDataChunk: elapsed time is " << eGetDataChunk << " sec." << LogIO::POST ;
     410  os << "initPol: elapsed time is " << eInitPol << " sec." << LogIO::POST ;
     411  os << "getData: elapsed time is " << eGetData-eToInt-eGetWeight << " sec." << LogIO::POST ;
    410412  os << "toPixel: elapsed time is " << eToPixel << " sec." << LogIO::POST ;
    411413  os << "ggridsd: elapsed time is " << eGGridSD << " sec." << LogIO::POST ;
    412414  os << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ;
     415  os << "getWeight: elapsed time is " << eGetWeight << " sec." << LogIO::POST ;
    413416 
    414417  delete polMap ;
     
    424427  LogIO os( LogOrigin("STGrid", "gridPerPol", WHERE) ) ;
    425428  double t0, t1 ;
    426 
    427   // grid parameter
    428   os << LogIO::DEBUGGING ;
    429   os << "----------" << endl ;
    430   os << "Grid parameter summary" << endl ;
    431   os << "   (nx,ny) = (" << nx_ << "," << ny_ << ")" << endl ;
    432   os << "   (cellx,celly) = (" << cellx_ << "," << celly_ << ")" << endl ;
    433   os << "   center = " << center_ << endl ;
    434   os << "----------" << LogIO::POST ;
    435   os << LogIO::NORMAL ;
    436429
    437430  // convolution kernel
     
    441434  t1 = mathutil::gettimeofday_sec() ;
    442435  os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    443   //cout << "convSupport=" << convSupport_ << endl ;
    444   //cout << "convFunc=" << convFunc << endl ;
    445436
    446437  // prepare grid data storage
     
    479470  }
    480471  Int *polMap = new Int[1] ;
     472
     473  // some parameters for ggridsd
    481474  Int nvispol = 1 ;
     475  Int irow = -1 ;
    482476 
    483477  // for performance check
     
    499493    t1 = mathutil::gettimeofday_sec() ;
    500494    eGetData += t1-t0 ;
    501    
    502     IPosition sshape = spectra.shape() ;
    503495   
    504496    // world -> pixel
     
    510502   
    511503    // call ggridsd
    512     Bool deletePos, deleteData, deleteWgt, deleteFlag, deleteFlagR, deleteConv, deleteDataG, deleteWgtG ;
    513     Double *xypos_p = xypos.getStorage( deletePos ) ;
    514     const Complex *data_p = spectra.getStorage( deleteData ) ;
    515     const Float *wgt_p = weight.getStorage( deleteWgt ) ;
    516     const Int *flag_p = flagtra.getStorage( deleteFlag ) ;
    517     const Int *rflag_p = rflag.getStorage( deleteFlagR ) ;
    518     Float *conv_p = convFunc.getStorage( deleteConv ) ;
    519     Complex *gdata_p = gdataArrC.getStorage( deleteDataG ) ;
    520     Float *wdata_p = gwgtArr.getStorage( deleteWgtG ) ;
    521504    polMap[0] = ipol ;
    522505    t0 = mathutil::gettimeofday_sec() ;
    523     Int irow = -1 ;
    524     call_ggridsd( xypos_p,
    525                   data_p,
    526                   &nvispol,
    527                   &nchan_,
    528                   flag_p,
    529                   rflag_p,
    530                   wgt_p,
    531                   &nrow_,
    532                   &irow,
    533                   gdata_p,
    534                   wdata_p,
    535                   &gnx,
    536                   &gny,
    537                   &npol_,
    538                   &nchan_,
    539                   &convSupport_,
    540                   &convSampling_,
    541                   conv_p,
     506    call_ggridsd( xypos,
     507                  spectra,
     508                  nvispol,
     509                  nchan_,
     510                  flagtra,
     511                  rflag,
     512                  weight,
     513                  nrow_,
     514                  irow,
     515                  gdataArrC,
     516                  gwgtArr,
     517                  gnx,
     518                  gny,
     519                  npol_,
     520                  nchan_,
     521                  convSupport_,
     522                  convSampling_,
     523                  convFunc,
    542524                  chanMap,
    543525                  polMap ) ;
    544526    t1 = mathutil::gettimeofday_sec() ;
    545     os << "ggridsd: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    546     xypos.putStorage( xypos_p, deletePos ) ;
    547     spectra.freeStorage( data_p, deleteData ) ;
    548     weight.freeStorage( wgt_p, deleteWgt ) ;
    549     flagtra.freeStorage( flag_p, deleteFlag ) ;
    550     rflag.freeStorage( rflag_p, deleteFlagR ) ;
    551     convFunc.putStorage( conv_p, deleteConv ) ;
    552     gdataArrC.putStorage( gdata_p, deleteDataG ) ;
    553     gwgtArr.putStorage( wdata_p, deleteWgtG ) ;
    554   }
    555 
     527    eGGridSD += t1-t0 ;
     528  }
    556529  os << "initPol: elapsed time is " << eInitPol << " sec." << LogIO::POST ;
    557   os << "getData: elapsed time is " << eGetData << " sec." << LogIO::POST ;
     530  os << "getData: elapsed time is " << eGetData-eToInt-eGetWeight << " sec." << LogIO::POST ;
     531  os << "toPixel: elapsed time is " << eToPixel << " sec." << LogIO::POST ;
     532  os << "ggridsd: elapsed time is " << eGGridSD << " sec." << LogIO::POST ;
     533  os << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ;
     534  os << "getWeight: elapsed time is " << eGetWeight << " sec." << LogIO::POST ;
     535
    558536  // delete maps
    559537  delete polMap ;
     
    804782    tsys = tsysTemp[0] ;
    805783  }
    806 
     784 
     785  double t0,t1 ;
     786  t0 = mathutil::gettimeofday_sec() ;
    807787  getWeight( weight, tsys, tint ) ;
     788  t1 = mathutil::gettimeofday_sec() ;
     789  eGetWeight += t1-t0 ;
    808790}
    809791
     
    827809  toInt( rflagUI, rflag ) ;
    828810  t1 = mathutil::gettimeofday_sec() ;
     811  eToInt += t1-t0 ;
    829812  //os << "toInt: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    830813}
     
    848831  toInt( rflagUI_, rflag ) ;
    849832  t1 = mathutil::gettimeofday_sec() ;
    850   subtime_ = t1 - t0 ;
     833  eToInt = t1 - t0 ;
    851834 
    852835  return nrow ;
     
    893876    tsys = tsysTemp[0] ;
    894877 
     878  double t0,t1 ;
     879  t0 = mathutil::gettimeofday_sec() ;
    895880  getWeight( weight, tsys, tint ) ;
     881  t1 = mathutil::gettimeofday_sec() ;
     882  eGetWeight += t1-t0 ;
    896883
    897884  nprocessed_ += nrow ;
     
    949936{
    950937  LogIO os( LogOrigin("STGrid","getWeight",WHERE) ) ;
    951   //os << "start getWeight" << LogIO::POST ;
    952   double t0, t1 ;
    953   t0 = mathutil::gettimeofday_sec() ;
     938
    954939  // 2011/12/22 TN
    955940  // w (weight) and tsys share storage
     
    10181003    w = 1.0 ;
    10191004  }
    1020 
    1021   t1 = mathutil::gettimeofday_sec() ;
    1022   //os << "getWeight: elapsed time is " << t1-t0 << " sec" << LogIO::POST ;
    1023   subtime_ += t1-t0 ;
    10241005}
    10251006
  • trunk/src/STGrid.h

    r2383 r2384  
    131131  void attach( Table &tab ) ;
    132132
    133   void call_ggridsd( Double* xy,
    134                      const Complex* values,
    135                      Int* nvispol,
    136                      Int* nvischan,
    137                      const Int* flag,
    138                      const Int* rflag,
    139                      const Float* weight,
    140                      Int* nrow,
    141                      Int* irow,
    142                      Complex* grid,
    143                      Float* wgrid,
    144                      Int* nx,
    145                      Int* ny,
    146                      Int * npol,
    147                      Int * nchan,
    148                      Int* support,
    149                      Int* sampling,
    150                      Float* convFunc,
     133  void call_ggridsd( Array<Double> &xy,
     134                     Array<Complex> &values,
     135                     Int &nvispol,
     136                     Int &nvischan,
     137                     Array<Int> &flag,
     138                     Array<Int> &rflag,
     139                     Array<Float> &weight,
     140                     Int &nrow,
     141                     Int &irow,
     142                     Array<Complex> &grid,
     143                     Array<Float> &wgrid,
     144                     Int &nx,
     145                     Int &ny,
     146                     Int &npol,
     147                     Int &nchan,
     148                     Int &support,
     149                     Int &sampling,
     150                     Vector<Float> &convFunc,
    151151                     Int *chanMap,
    152152                     Int *polMap ) ;
     
    190190  Array<uInt> rflagUI_ ;
    191191
    192   double subtime_ ;
    193192};
    194193}
Note: See TracChangeset for help on using the changeset viewer.