- Timestamp:
- 01/11/12 16:58:41 (13 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STGrid.cpp
r2397 r2398 439 439 os << LogIO::NORMAL ; 440 440 441 Bool doAll = examine() ; 442 443 if ( doAll ) 444 gridPerPol() ; 445 else if ( doclip_ ) 441 if ( doclip_ ) 446 442 gridPerRowWithClipping() ; 447 443 else 448 444 gridPerRow() ; 449 450 } 451 452 Bool STGrid::examine() 445 } 446 447 void STGrid::updateChunkShape() 453 448 { 454 449 // TODO: nchunk_ must be determined from nchan_, npol_, and (nx_,ny_) 455 450 // by considering data size to be allocated for ggridsd input/output 456 451 nchunk_ = 400 ; 457 Bool b = nchunk_ >= nrow_ ;458 452 nchunk_ = min( nchunk_, nrow_ ) ; 459 453 vshape_ = IPosition( 1, nchunk_ ) ; 460 454 wshape_ = IPosition( 2, nchan_, nchunk_ ) ; 461 455 dshape_ = IPosition( 2, 2, nchunk_ ) ; 462 return b ;463 456 } 464 457 … … 655 648 double eInitPol = 0.0 ; 656 649 657 Broker broker = Broker(produceChunk, consumeChunk);658 650 for ( uInt ifile = 0 ; ifile < nfile_ ; ifile++ ) { 659 651 initTable( ifile ) ; 660 652 661 653 os << "start table " << ifile << ": " << infileList_[ifile] << LogIO::POST ; 654 Broker broker = Broker(produceChunk, consumeChunk); 662 655 for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) { 663 656 t0 = mathutil::gettimeofday_sec() ; … … 780 773 data_.resize( gshape ) ; 781 774 data_ = 0.0 ; 782 //STCommonData common = STCommonData(gshape, data_);783 775 STCommonDataWithClipping common = STCommonDataWithClipping( gshape, 784 776 pshape, … … 806 798 double eInitPol = 0.0 ; 807 799 808 //Broker broker = Broker(produceChunk, consumeChunk);809 Broker broker = Broker(produceChunk, consumeChunkWithClipping);810 800 for ( uInt ifile = 0 ; ifile < nfile_ ; ifile++ ) { 811 801 initTable( ifile ) ; 812 802 813 803 os << "start table " << ifile << ": " << infileList_[ifile] << LogIO::POST ; 804 Broker broker = Broker(produceChunk, consumeChunkWithClipping); 814 805 for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) { 815 806 t0 = mathutil::gettimeofday_sec() ; … … 818 809 eInitPol += t1-t0 ; 819 810 820 //STContext context(this, common, ipol);821 811 STContextWithClipping context(this, common, ipol); 822 812 … … 832 822 break; 833 823 } 834 //consumeChunk(&context);835 824 consumeChunkWithClipping(&context); 836 825 } … … 963 952 } 964 953 965 void STGrid::gridPerPol()966 {967 LogIO os( LogOrigin("STGrid", "gridPerPol", WHERE) ) ;968 double t0, t1 ;969 970 // convolution kernel971 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 storage978 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 TN987 // data_ and weight array shares storage988 data_.resize( gshape ) ;989 data_ = 0.0 ;990 Array<Float> gwgtArr( data_ ) ;991 992 // maps993 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 ggridsd1004 Int nvispol = 1 ;1005 Int irow = -1 ;1006 1007 // for performance check1008 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 table1019 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 data1037 t0 = mathutil::gettimeofday_sec() ;1038 getDataPerPol( spectra, direction, flagtra, rflag, weight ) ;1039 t1 = mathutil::gettimeofday_sec() ;1040 eGetData += t1-t0 ;1041 1042 // world -> pixel1043 t0 = mathutil::gettimeofday_sec() ;1044 toPixel( direction, xypos ) ;1045 t1 = mathutil::gettimeofday_sec() ;1046 eToPixel += t1-t0 ;1047 1048 // call ggridsd1049 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 maps1087 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 1095 954 void STGrid::initPol( Int ipol ) 1096 955 { … … 1110 969 tab_ = tableList_[idx] ; 1111 970 nrow_ = rows_[idx] ; 971 updateChunkShape() ; 1112 972 } 1113 973 … … 1349 1209 } 1350 1210 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 TN1360 // weight and tsys shares its storage1361 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 1410 1211 Int STGrid::getDataChunk( 1411 1212 IPosition const &wshape, … … 1556 1357 for ( uInt i = 0 ; i < nfile_ ; i++ ) { 1557 1358 rows_[i] = tableList_[i].nrow() / npolOrg_ ; 1558 if ( nrow_ < rows_[i] )1559 nrow_ = rows_[i] ;1359 //if ( nrow_ < rows_[i] ) 1360 // nrow_ = rows_[i] ; 1560 1361 } 1561 1362 flagtraCol_.attach( tableList_[0], "FLAGTRA" ) ; … … 1699 1500 world.freeStorage( w_p, bw ) ; 1700 1501 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() ;1713 1502 } 1714 1503 -
trunk/src/STGrid.h
r2396 r2398 28 28 29 29 #include "concurrent.h" 30 //#include <tables/Tables/TableRow.h>31 32 // #include <measures/Measures/MDirection.h>33 34 // #include "Scantable.h"35 30 36 31 using namespace std ; … … 78 73 void gridPerRow() ; 79 74 void gridPerRowWithClipping() ; 80 void gridPerPol() ;81 75 82 76 // clipping … … 108 102 Array<Float> &gwgt ) ; 109 103 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 ) ;120 104 Int getDataChunk( IPosition const &wshape, 121 105 IPosition const &vshape, … … 154 138 void prepareTable( Table &tab, String &name ) ; 155 139 156 // Bool pastEnd() ;157 158 140 void selectData() ; 159 141 void setupArray() ; 160 142 161 Bool examine() ;143 void updateChunkShape() ; 162 144 void attach( Table &tab ) ; 163 145
Note:
See TracChangeset
for help on using the changeset viewer.