Changeset 2398 for trunk


Ignore:
Timestamp:
01/11/12 16:58:41 (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...

Reorganization of procedure:

  • Dropped STGrid::gridPerPol
  • Broker is created per input table
  • STGrid::examine is redefined as STGrid::updateChunkShape
Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2397 r2398  
    439439  os << LogIO::NORMAL ;
    440440
    441   Bool doAll = examine() ;
    442 
    443   if ( doAll )
    444     gridPerPol() ;
    445   else if ( doclip_ )
     441  if ( doclip_ )
    446442    gridPerRowWithClipping() ;
    447443  else
    448444    gridPerRow() ;
    449 
    450 }
    451 
    452 Bool STGrid::examine()
     445}
     446
     447void STGrid::updateChunkShape()
    453448{
    454449  // TODO: nchunk_ must be determined from nchan_, npol_, and (nx_,ny_)
    455450  //       by considering data size to be allocated for ggridsd input/output
    456451  nchunk_ = 400 ;
    457   Bool b = nchunk_ >= nrow_ ;
    458452  nchunk_ = min( nchunk_, nrow_ ) ;
    459453  vshape_ = IPosition( 1, nchunk_ ) ;
    460454  wshape_ = IPosition( 2, nchan_, nchunk_ ) ;
    461455  dshape_ = IPosition( 2, 2, nchunk_ ) ;
    462   return b ;
    463456}
    464457
     
    655648  double eInitPol = 0.0 ;
    656649
    657   Broker broker = Broker(produceChunk, consumeChunk);
    658650  for ( uInt ifile = 0 ; ifile < nfile_ ; ifile++ ) {
    659651    initTable( ifile ) ;
    660652
    661653    os << "start table " << ifile << ": " << infileList_[ifile] << LogIO::POST ;   
     654    Broker broker = Broker(produceChunk, consumeChunk);
    662655    for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) {
    663656      t0 = mathutil::gettimeofday_sec() ;
     
    780773  data_.resize( gshape ) ;
    781774  data_ = 0.0 ;
    782   //STCommonData common = STCommonData(gshape, data_);
    783775  STCommonDataWithClipping common = STCommonDataWithClipping( gshape,
    784776                                                              pshape,
     
    806798  double eInitPol = 0.0 ;
    807799
    808   //Broker broker = Broker(produceChunk, consumeChunk);
    809   Broker broker = Broker(produceChunk, consumeChunkWithClipping);
    810800  for ( uInt ifile = 0 ; ifile < nfile_ ; ifile++ ) {
    811801    initTable( ifile ) ;
    812802
    813803    os << "start table " << ifile << ": " << infileList_[ifile] << LogIO::POST ;   
     804    Broker broker = Broker(produceChunk, consumeChunkWithClipping);
    814805    for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) {
    815806      t0 = mathutil::gettimeofday_sec() ;
     
    818809      eInitPol += t1-t0 ;
    819810     
    820       //STContext context(this, common, ipol);
    821811      STContextWithClipping context(this, common, ipol);
    822812     
     
    832822          break;
    833823        }
    834         //consumeChunk(&context);
    835824        consumeChunkWithClipping(&context);
    836825      }
     
    963952}
    964953
    965 void STGrid::gridPerPol()
    966 {
    967   LogIO os( LogOrigin("STGrid", "gridPerPol", WHERE) ) ;
    968   double t0, t1 ;
    969 
    970   // convolution kernel
    971   Vector<Float> convFunc ;
    972   t0 = mathutil::gettimeofday_sec() ;
    973   setConvFunc( convFunc ) ;
    974   t1 = mathutil::gettimeofday_sec() ;
    975   os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    976 
    977   // prepare grid data storage
    978   Int gnx = nx_ ;
    979   Int gny = ny_ ;
    980 //   // Extend grid plane with convSupport_
    981 //   Int gnx = nx_+convSupport_*2 ;
    982 //   Int gny = ny_+convSupport_*2 ;
    983   IPosition gshape( 4, gnx, gny, npol_, nchan_ ) ;
    984   Array<Complex> gdataArrC( gshape, 0.0 ) ;
    985   //Array<Float> gwgtArr( gshape, 0.0 ) ;
    986   // 2011/12/20 TN
    987   // data_ and weight array shares storage
    988   data_.resize( gshape ) ;
    989   data_ = 0.0 ;
    990   Array<Float> gwgtArr( data_ ) ;
    991 
    992   // maps
    993   Int *chanMap = new Int[nchan_] ;
    994   {
    995     Int *work_p = chanMap ;
    996     for ( Int i = 0 ; i < nchan_ ; i++ ) {
    997       *work_p = i ;
    998       work_p++ ;
    999     }
    1000   }
    1001   Int polMap[1] ;
    1002 
    1003   // some parameters for ggridsd
    1004   Int nvispol = 1 ;
    1005   Int irow = -1 ;
    1006  
    1007   // for performance check
    1008   double eInitPol = 0.0 ;
    1009   double eGetData = 0.0 ;
    1010   double eToPixel = 0.0 ;
    1011   double eGGridSD = 0.0 ;
    1012   double eToInt = 0.0 ;
    1013 
    1014   for ( uInt ifile = 0 ; ifile < nfile_ ; ifile++ ) {
    1015     initTable( ifile ) ;
    1016 
    1017     os << "start table " << ifile << ": " << infileList_[ifile] << LogIO::POST ;   
    1018     // to read data from the table
    1019     IPosition mshape( 2, nchan_, nrow_ ) ;
    1020     IPosition dshape( 2, 2, nrow_ ) ;
    1021     Array<Complex> spectra( mshape ) ;
    1022     Array<Double> direction( dshape ) ;
    1023     Array<Int> flagtra( mshape ) ;
    1024     Array<Int> rflag( IPosition(1,nrow_) ) ;
    1025     Array<Float> weight( mshape ) ;
    1026     Array<Double> xypos( dshape ) ;
    1027 
    1028     for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) {
    1029       t0 = mathutil::gettimeofday_sec() ;
    1030       initPol( ipol ) ;
    1031       t1 = mathutil::gettimeofday_sec() ;
    1032       eInitPol += t1-t0 ;
    1033      
    1034       os << "start pol " << ipol << LogIO::POST ;
    1035      
    1036       // retrieve data
    1037       t0 = mathutil::gettimeofday_sec() ;
    1038       getDataPerPol( spectra, direction, flagtra, rflag, weight ) ;
    1039       t1 = mathutil::gettimeofday_sec() ;
    1040       eGetData += t1-t0 ;
    1041      
    1042       // world -> pixel
    1043       t0 = mathutil::gettimeofday_sec() ;
    1044       toPixel( direction, xypos ) ; 
    1045       t1 = mathutil::gettimeofday_sec() ;
    1046       eToPixel += t1-t0 ;
    1047      
    1048       // call ggridsd
    1049       polMap[0] = ipol ;
    1050       t0 = mathutil::gettimeofday_sec() ;
    1051       call_ggridsd( xypos,
    1052                     spectra,
    1053                     nvispol,
    1054                     nchan_,
    1055                     flagtra,
    1056                     rflag,
    1057                     weight,
    1058                     nrow_,
    1059                     irow,
    1060                     gdataArrC,
    1061                     gwgtArr,
    1062                     gnx,
    1063                     gny,
    1064                     npol_,
    1065                     nchan_,
    1066                     convSupport_,
    1067                     convSampling_,
    1068                     convFunc,
    1069                     chanMap,
    1070                     polMap ) ;
    1071       t1 = mathutil::gettimeofday_sec() ;
    1072       eGGridSD += t1-t0 ;
    1073 
    1074       os << "end pol " << ipol << LogIO::POST ;
    1075 
    1076     }
    1077     os << "end table " << ifile << LogIO::POST ;   
    1078   }
    1079   os << "initPol: elapsed time is " << eInitPol << " sec." << LogIO::POST ;
    1080   os << "getData: elapsed time is " << eGetData-eToInt-eGetWeight << " sec." << LogIO::POST ;
    1081   os << "toPixel: elapsed time is " << eToPixel << " sec." << LogIO::POST ;
    1082   os << "ggridsd: elapsed time is " << eGGridSD << " sec." << LogIO::POST ;
    1083   os << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ;
    1084   os << "getWeight: elapsed time is " << eGetWeight << " sec." << LogIO::POST ;
    1085 
    1086   // delete maps
    1087   delete chanMap ;
    1088 
    1089   setData( gdataArrC, gwgtArr ) ;
    1090 //   os << "gdataArr = " << gdataArr << LogIO::POST ;
    1091 //   os << "gwgtArr = " << gwgtArr << LogIO::POST ;
    1092 //   os << "data_ " << data_ << LogIO::POST ;
    1093 }
    1094 
    1095954void STGrid::initPol( Int ipol )
    1096955{
     
    1110969  tab_ = tableList_[idx] ;
    1111970  nrow_ = rows_[idx] ;
     971  updateChunkShape() ;
    1112972}
    1113973
     
    13491209}
    13501210
    1351 void STGrid::getDataPerPol( Array<Float> &spectra,
    1352                             Array<Double> &direction,
    1353                             Array<uChar> &flagtra,
    1354                             Array<uInt> &rflag,
    1355                             Array<Float> &weight )
    1356 {
    1357   LogIO os( LogOrigin("STGrid","getDataPerPol",WHERE) ) ;
    1358 
    1359   // 2011/12/22 TN
    1360   // weight and tsys shares its storage
    1361   Array<Float> tsys( weight ) ;
    1362   Array<Double> tint( rflag.shape() ) ;
    1363 
    1364   Vector<uInt> rflagVec( rflag ) ;
    1365   Vector<Double> tintVec( tint ) ;
    1366 
    1367   spectraCol_.getColumn( spectra ) ;
    1368   flagtraCol_.getColumn( flagtra ) ;
    1369   flagRowCol_.getColumn( rflagVec ) ;
    1370   directionCol_.getColumn( direction ) ;
    1371   intervalCol_.getColumn( tintVec ) ;
    1372   Vector<Float> tsysTemp = tsysCol_( 0 ) ;
    1373   if ( tsysTemp.nelements() == (uInt)nchan_ ) {
    1374     tsysCol_.getColumn( tsys ) ;
    1375   }
    1376   else {
    1377     tsys = tsysTemp[0] ;
    1378   }
    1379  
    1380   double t0,t1 ;
    1381   t0 = mathutil::gettimeofday_sec() ;
    1382   getWeight( weight, tsys, tint ) ;
    1383   t1 = mathutil::gettimeofday_sec() ;
    1384   eGetWeight += t1-t0 ;
    1385 }
    1386 
    1387 void STGrid::getDataPerPol( Array<Complex> &spectra,
    1388                             Array<Double> &direction,
    1389                             Array<Int> &flagtra,
    1390                             Array<Int> &rflag,
    1391                             Array<Float> &weight )
    1392 {
    1393   LogIO os( LogOrigin("STGrid","getDataPerPol",WHERE) ) ;
    1394   double t0, t1 ;
    1395 
    1396   Array<uChar> flagUC( flagtra.shape() ) ;
    1397   Array<uInt> rflagUI( rflag.shape() ) ;
    1398   Array<Float> spectraF( spectra.shape() ) ;
    1399   getDataPerPol( spectraF, direction, flagUC, rflagUI, weight ) ;
    1400 
    1401   convertArray( spectra, spectraF ) ;
    1402   t0 = mathutil::gettimeofday_sec() ;
    1403   toInt( flagUC, flagtra ) ;
    1404   toInt( rflagUI, rflag ) ;
    1405   t1 = mathutil::gettimeofday_sec() ;
    1406   eToInt += t1-t0 ;
    1407   //os << "toInt: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    1408 }
    1409 
    14101211Int STGrid::getDataChunk(
    14111212                         IPosition const &wshape,
     
    15561357  for ( uInt i = 0 ; i < nfile_ ; i++ ) {
    15571358    rows_[i] = tableList_[i].nrow() / npolOrg_ ;
    1558     if ( nrow_ < rows_[i] )
    1559       nrow_ = rows_[i] ;
     1359    //if ( nrow_ < rows_[i] )
     1360    //  nrow_ = rows_[i] ;
    15601361  }
    15611362  flagtraCol_.attach( tableList_[0], "FLAGTRA" ) ;
     
    16991500  world.freeStorage( w_p, bw ) ;
    17001501  pixel.putStorage( p_p, bp ) ; 
    1701 //   String gridfile = "grid."+convType_+"."+String::toString(convSupport_)+".dat" ;
    1702 //   ofstream ofs( gridfile.c_str(), ios::out ) ;
    1703 //   ofs << "center " << center_(0) << " " << pixc(0)
    1704 //       << " " << center_(1) << " " << pixc(1) << endl ;
    1705 //   for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
    1706 //     ofs << irow ;
    1707 //     for ( uInt i = 0 ; i < 2 ; i++ ) {
    1708 //       ofs << " " << world(i, irow) << " " << pixel(i, irow) ;
    1709 //     }
    1710 //     ofs << endl ;
    1711 //   }
    1712 //   ofs.close() ;
    17131502}
    17141503
  • trunk/src/STGrid.h

    r2396 r2398  
    2828
    2929#include "concurrent.h"
    30 //#include <tables/Tables/TableRow.h>
    31 
    32 // #include <measures/Measures/MDirection.h>
    33 
    34 // #include "Scantable.h"
    3530
    3631using namespace std ;
     
    7873  void gridPerRow() ;
    7974  void gridPerRowWithClipping() ;
    80   void gridPerPol() ;
    8175
    8276  // clipping
     
    108102                Array<Float> &gwgt ) ;
    109103 
    110   void getDataPerPol( Array<Complex> &spectra,
    111                       Array<Double> &direction,
    112                       Array<Int> &flagtra,
    113                       Array<Int> &rflag,
    114                       Array<Float> &weight ) ;
    115   void getDataPerPol( Array<Float> &spectra,
    116                       Array<Double> &direction,
    117                       Array<uChar> &flagtra,
    118                       Array<uInt> &rflag,
    119                       Array<Float> &weight ) ;
    120104  Int getDataChunk( IPosition const &wshape,
    121105                    IPosition const &vshape,
     
    154138  void prepareTable( Table &tab, String &name ) ;
    155139
    156 //   Bool pastEnd() ;
    157 
    158140  void selectData() ;
    159141  void setupArray() ;
    160142
    161   Bool examine() ;
     143  void updateChunkShape() ;
    162144  void attach( Table &tab ) ;
    163145
Note: See TracChangeset for help on using the changeset viewer.