Changeset 2378 for trunk


Ignore:
Timestamp:
12/20/11 16:05:47 (13 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...

Preparation for gridding per row.

Speed up setData() by sharing storage for data_ and gridding weight.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2377 r2378  
    6060  userSupport_ = -1 ;
    6161  convSampling_ = 100 ;
     62  irow_ = 0 ;
    6263}
    6364
     
    150151                Double*);
    151152}
     153void STGrid::gridPerRow()
     154{
     155  LogIO os( LogOrigin("STGrid", "gridPerRow", WHERE) ) ;
     156  double t0, t1 ;
     157
     158  // grid parameter
     159  os << LogIO::DEBUGGING ;
     160  os << "----------" << endl ;
     161  os << "Grid parameter summary" << endl ;
     162  os << "   (nx,ny) = (" << nx_ << "," << ny_ << ")" << endl ;
     163  os << "   (cellx,celly) = (" << cellx_ << "," << celly_ << ")" << endl ;
     164  os << "   center = " << center_ << endl ;
     165  os << "----------" << LogIO::POST ;
     166  os << LogIO::NORMAL ;
     167
     168  // boolean for getStorage
     169  Bool deletePos, deleteData, deleteWgt, deleteFlag, deleteFlagR, deleteConv, deleteDataG, deleteWgtG ;
     170
     171  // convolution kernel
     172  Vector<Float> convFunc ;
     173  t0 = mathutil::gettimeofday_sec() ;
     174  setConvFunc( convFunc ) ;
     175  t1 = mathutil::gettimeofday_sec() ;
     176  os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     177  //cout << "convSupport=" << convSupport_ << endl ;
     178  //cout << "convFunc=" << convFunc << endl ;
     179  Float *conv_p = convFunc.getStorage( deleteConv ) ;
     180
     181  // Extend grid plane with convSupport_
     182  Int gnx = nx_ ;
     183  Int gny = ny_ ;
     184//   Int gnx = nx_+convSupport_*2 ;
     185//   Int gny = ny_+convSupport_*2 ;
     186  IPosition gshape( 4, gnx, gny, npol_, nchan_ ) ;
     187  Array<Complex> gdataArrC( gshape, 0.0 ) ;
     188  // 2011/12/20 TN
     189  // data_ and gwgtArr share storage
     190  data_.resize( gshape ) ;
     191  data_ = 0.0 ;
     192  Array<Float> gwgtArr( data_ ) ;
     193  //Array<Float> gwgtArr( gshape, 0.0 ) ;
     194  Complex *gdata_p = gdataArrC.getStorage( deleteDataG ) ;
     195  Float *wdata_p = gwgtArr.getStorage( deleteWgtG ) ;
     196
     197  // data selection
     198  selectData( tab_ ) ;
     199  setupArray( tab_ ) ;
     200
     201  // data storage
     202  IPosition mshape( 3, npol_, nchan_, 1 ) ;
     203  IPosition vshape( 2, npol_, 1 ) ;
     204  IPosition dshape( 2, 2, 1 ) ;
     205  Array<Complex> spectra( mshape ) ;
     206  Array<Double> direction( dshape ) ;
     207  Array<Int> flagtra( mshape ) ;
     208  Array<Int> rflag( vshape ) ;
     209  Array<Float> weight( vshape ) ;
     210  Array<Double> xypos( dshape ) ;
     211
     212  while( !pastEnd() ) {
     213    // retrieve data
     214    getDataChunk( spectra, direction, flagtra, rflag, weight ) ;
     215   
     216    // world -> pixel
     217    toPixel( direction, xypos ) ;
     218   
     219    // call ggridsd
     220  }
     221 
     222  // set data
     223  setData( gdataArrC, gwgtArr ) ;
     224}
     225
     226Bool STGrid::pastEnd()
     227{
     228  Bool b = irow_ >= nrow_ ;
     229  return b ;
     230}
     231
    152232void STGrid::grid()
    153233{
     
    214294  IPosition gshape( 4, gnx, gny, npol_, nchan_ ) ;
    215295  Array<Complex> gdataArrC( gshape, 0.0 ) ;
    216   Array<Float> gwgtArr( gshape, 0.0 ) ;
     296  //Array<Float> gwgtArr( gshape, 0.0 ) ;
     297  // 2011/12/20 TN
     298  // data_ and weight array shares storage
     299  data_.resize( gshape ) ;
     300  data_ = 0.0 ;
     301  Array<Float> gwgtArr( data_ ) ;
    217302  Complex *gdata_p = gdataArrC.getStorage( deleteDataG ) ;
    218303  Float *wdata_p = gwgtArr.getStorage( deleteWgtG ) ;
     
    278363  gdataArrC.putStorage( gdata_p, deleteDataG ) ;
    279364  gwgtArr.putStorage( wdata_p, deleteWgtG ) ;
    280   setData( data_, gdataArrC, gwgtArr ) ;
     365  setData( gdataArrC, gwgtArr ) ;
    281366  //Matrix<Double> sumWeight( IPosition( 2, npol_, nchan_ ), sumw_p, TAKE_OVER ) ;
    282367  delete sumw_p ;
     
    287372}
    288373
    289 void STGrid::setData( Array<Float> &data,
    290                       Array<Complex> &gdata,
     374void STGrid::setData( Array<Complex> &gdata,
    291375                      Array<Float> &gwgt )
    292376{
     377  // 2011/12/20 TN
     378  // gwgt and data_ share storage
    293379  LogIO os( LogOrigin("STGrid","setData",WHERE) ) ;
    294380  double t0, t1 ;
    295381  t0 = mathutil::gettimeofday_sec() ;
    296   data.resize( gdata.shape() ) ;
    297   uInt len = data.nelements() ;
    298   Float *w0_p ;
     382  //data.resize( gdata.shape() ) ;
     383  uInt len = data_.nelements() ;
    299384  const Complex *w1_p ;
    300   const Float *w2_p ;
     385  Float *w2_p ;
    301386  Bool b0, b1, b2 ;
    302   Float *data_p = data.getStorage( b0 ) ;
    303387  const Complex *gdata_p = gdata.getStorage( b1 ) ;
    304   const Float *gwgt_p = gwgt.getStorage( b2 ) ;
    305   w0_p = data_p ;
     388  Float *gwgt_p = data_.getStorage( b2 ) ;
    306389  w1_p = gdata_p ;
    307390  w2_p = gwgt_p ;
    308391  for ( uInt i = 0 ; i < len ; i++ ) {
    309     *w0_p = (*w2_p > 0.0) ? ((*w1_p).real() / *w2_p) : 0.0 ;
    310     w0_p++ ;
     392    //*w2_p = (*w2_p > 0.0) ? ((*w1_p).real() / *w2_p) : 0.0 ;
     393    if ( *w2_p > 0.0 ) *w2_p = (*w1_p).real() / *w2_p ;
    311394    w1_p++ ;
    312395    w2_p++ ;
    313396  }
    314   data.putStorage( data_p, b0 ) ;
    315397  gdata.freeStorage( gdata_p, b1 ) ;
    316   gwgt.freeStorage( gwgt_p, b2 ) ;
     398  data_.putStorage( gwgt_p, b2 ) ;
    317399  t1 = mathutil::gettimeofday_sec() ;
    318400  os << "setData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     
    586668  t1 = mathutil::gettimeofday_sec() ;
    587669  os << "toInt: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     670}
     671
     672void STGrid::getDataChunk( Array<Complex> &spectra,
     673                           Array<Double> &direction,
     674                           Array<Int> &flagtra,
     675                           Array<Int> &rflag,
     676                           Array<Float> &weight )
     677{
    588678}
    589679
  • trunk/src/STGrid.h

    r2375 r2378  
    6666
    6767  void grid() ;
     68  void gridPerRow() ;
    6869 
    6970  string saveData( string outfile="" ) ;
     
    8283                  String &center ) ;
    8384
    84   void setData( Array<Float> &data,
    85                 Array<Complex> &gdata,
     85  void setData( Array<Complex> &gdata,
    8686                Array<Float> &gwgt ) ;
    8787 
     88  void getData( Array<Complex> &spectra,
     89                Array<Double> &direction,
     90                Array<Int> &flagtra,
     91                Array<Int> &rflag,
     92                Array<Float> &weight ) ;
    8893  void getData( Array<Complex> &spectra,
    8994                Array<Double> &direction,
     
    9196                Array<uInt> &rflag,
    9297                Array<Float> &weight ) ;
    93   void getData( Array<Complex> &spectra,
    94                 Array<Double> &direction,
    95                 Array<Int> &flagtra,
    96                 Array<Int> &rflag,
    97                 Array<Float> &weight ) ;
     98  void getDataChunk( Array<Complex> &spectra,
     99                     Array<Double> &direction,
     100                     Array<Int> &flagtra,
     101                     Array<Int> &rflag,
     102                     Array<Float> &weight ) ;
    98103
    99104  void getWeight( Array<Float> &w,
     
    120125  void prepareTable( Table &tab, String &name ) ;
    121126
     127  Bool pastEnd() ;
     128
     129
    122130  String infile_ ;
    123131  Int ifno_ ;
     
    140148
    141149  Table tab_ ;
     150  Int irow_ ;
    142151};
    143152}
Note: See TracChangeset for help on using the changeset viewer.