- Timestamp:
- 12/22/11 17:56:25 (13 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STGrid.cpp
r2383 r2384 31 31 32 32 namespace asap { 33 34 // for performance check 35 double eToInt = 0.0 ; 36 double eGetWeight = 0.0 ; 33 37 34 38 // constructor … … 77 81 { 78 82 pollist_.assign( Vector<uInt>( pols ) ) ; 79 cout << "pollist_ = " << pollist_ << endl ;80 83 } 81 84 … … 83 86 { 84 87 scanlist_.assign( Vector<uInt>( scans ) ) ; 85 cout << "scanlist_ = " << scanlist_ << endl ;86 88 } 87 89 … … 90 92 wtype_ = String( wType ) ; 91 93 wtype_.upcase() ; 92 cout << "wtype_ = " << wtype_ << endl ;93 94 } 94 95 … … 153 154 Double*); 154 155 } 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,156 void 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, 173 174 Int *chanMap, 174 175 Int *polMap ) … … 176 177 // parameters for gridding 177 178 Int idopsf = 0 ; 178 Int len = (*npol)*(*nchan);179 Int len = npol*nchan ; 179 180 Double *sumw_p = new Double[len] ; 180 181 { … … 186 187 } 187 188 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 188 200 // call ggridsd 189 ggridsd( xy ,190 values ,191 nvispol,192 nvischan,201 ggridsd( xy_p, 202 values_p, 203 &nvispol, 204 &nvischan, 193 205 &idopsf, 194 flag ,195 rflag ,196 w eight,197 nrow,198 irow,199 grid ,200 wgrid ,201 nx,202 ny,203 npol,204 nchan,205 support,206 sampling,207 conv Func,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, 208 220 chanMap, 209 221 polMap, … … 211 223 212 224 // 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 ) ; 213 233 delete sumw_p ; 214 234 } … … 223 243 void STGrid::grid() 224 244 { 245 LogIO os( LogOrigin("STGrid", "grid", WHERE) ) ; 246 225 247 // data selection 226 248 selectData() ; 227 249 setupArray() ; 228 250 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 234 251 if ( wtype_.compare("UNIFORM") != 0 && 235 252 wtype_.compare("TINT") != 0 && … … 241 258 } 242 259 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 243 277 Bool doAll = examine() ; 244 278 … … 264 298 double t0, t1 ; 265 299 266 // grid parameter267 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 getStorage277 Bool deletePos, deleteData, deleteWgt, deleteFlag, deleteFlagR, deleteConv, deleteDataG, deleteWgtG ;278 279 300 // convolution kernel 280 301 Vector<Float> convFunc ; … … 283 304 t1 = mathutil::gettimeofday_sec() ; 284 305 os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ; 285 //cout << "convSupport=" << convSupport_ << endl ;286 //cout << "convFunc=" << convFunc << endl ;287 306 288 307 // grid data … … 300 319 Array<Float> gwgtArr( data_ ) ; 301 320 302 // data storage303 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 320 321 // parameters for gridding 321 322 Int *chanMap = new Int[nchan_] ; … … 329 330 Int *polMap = new Int[1] ; 330 331 Int nvispol = 1 ; 332 Int irow = -1 ; 331 333 332 334 // for performance check 333 double eGetData Chunk= 0.0 ;335 double eGetData = 0.0 ; 334 336 double eToPixel = 0.0 ; 335 337 double eGGridSD = 0.0 ; 336 double e ToInt= 0.0 ;338 double eInitPol = 0.0 ; 337 339 338 340 for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) { 341 t0 = mathutil::gettimeofday_sec() ; 339 342 initPol( ipol ) ; 343 t1 = mathutil::gettimeofday_sec() ; 344 eInitPol += t1-t0 ; 340 345 341 346 polMap[0] = ipol ; 342 347 348 os << "start pol" << ipol << LogIO::POST ; 349 343 350 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 344 368 // retrieve data 345 369 t0 = mathutil::gettimeofday_sec() ; … … 347 371 //os << "nrow = " << nrow << LogIO::POST ; 348 372 t1 = mathutil::gettimeofday_sec() ; 349 eGetDataChunk += t1-t0 ; 350 eToInt += subtime_ ; 373 eGetData += t1-t0 ; 351 374 352 375 // world -> pixel … … 356 379 eToPixel += t1-t0 ; 357 380 358 // prepare pointer359 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 368 381 // call ggridsd 369 irow = -1 ;370 382 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, 390 401 chanMap, 391 402 polMap ) ; … … 393 404 eGGridSD += t1-t0 ; 394 405 395 // finalization396 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 405 406 } 406 407 407 408 nprocessed_ = 0 ; 408 409 } 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 ; 410 412 os << "toPixel: elapsed time is " << eToPixel << " sec." << LogIO::POST ; 411 413 os << "ggridsd: elapsed time is " << eGGridSD << " sec." << LogIO::POST ; 412 414 os << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ; 415 os << "getWeight: elapsed time is " << eGetWeight << " sec." << LogIO::POST ; 413 416 414 417 delete polMap ; … … 424 427 LogIO os( LogOrigin("STGrid", "gridPerPol", WHERE) ) ; 425 428 double t0, t1 ; 426 427 // grid parameter428 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 ;436 429 437 430 // convolution kernel … … 441 434 t1 = mathutil::gettimeofday_sec() ; 442 435 os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ; 443 //cout << "convSupport=" << convSupport_ << endl ;444 //cout << "convFunc=" << convFunc << endl ;445 436 446 437 // prepare grid data storage … … 479 470 } 480 471 Int *polMap = new Int[1] ; 472 473 // some parameters for ggridsd 481 474 Int nvispol = 1 ; 475 Int irow = -1 ; 482 476 483 477 // for performance check … … 499 493 t1 = mathutil::gettimeofday_sec() ; 500 494 eGetData += t1-t0 ; 501 502 IPosition sshape = spectra.shape() ;503 495 504 496 // world -> pixel … … 510 502 511 503 // 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 ) ;521 504 polMap[0] = ipol ; 522 505 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, 542 524 chanMap, 543 525 polMap ) ; 544 526 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 } 556 529 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 558 536 // delete maps 559 537 delete polMap ; … … 804 782 tsys = tsysTemp[0] ; 805 783 } 806 784 785 double t0,t1 ; 786 t0 = mathutil::gettimeofday_sec() ; 807 787 getWeight( weight, tsys, tint ) ; 788 t1 = mathutil::gettimeofday_sec() ; 789 eGetWeight += t1-t0 ; 808 790 } 809 791 … … 827 809 toInt( rflagUI, rflag ) ; 828 810 t1 = mathutil::gettimeofday_sec() ; 811 eToInt += t1-t0 ; 829 812 //os << "toInt: elapsed time is " << t1-t0 << " sec." << LogIO::POST ; 830 813 } … … 848 831 toInt( rflagUI_, rflag ) ; 849 832 t1 = mathutil::gettimeofday_sec() ; 850 subtime_= t1 - t0 ;833 eToInt = t1 - t0 ; 851 834 852 835 return nrow ; … … 893 876 tsys = tsysTemp[0] ; 894 877 878 double t0,t1 ; 879 t0 = mathutil::gettimeofday_sec() ; 895 880 getWeight( weight, tsys, tint ) ; 881 t1 = mathutil::gettimeofday_sec() ; 882 eGetWeight += t1-t0 ; 896 883 897 884 nprocessed_ += nrow ; … … 949 936 { 950 937 LogIO os( LogOrigin("STGrid","getWeight",WHERE) ) ; 951 //os << "start getWeight" << LogIO::POST ; 952 double t0, t1 ; 953 t0 = mathutil::gettimeofday_sec() ; 938 954 939 // 2011/12/22 TN 955 940 // w (weight) and tsys share storage … … 1018 1003 w = 1.0 ; 1019 1004 } 1020 1021 t1 = mathutil::gettimeofday_sec() ;1022 //os << "getWeight: elapsed time is " << t1-t0 << " sec" << LogIO::POST ;1023 subtime_ += t1-t0 ;1024 1005 } 1025 1006 -
trunk/src/STGrid.h
r2383 r2384 131 131 void attach( Table &tab ) ; 132 132 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, 151 151 Int *chanMap, 152 152 Int *polMap ) ; … … 190 190 Array<uInt> rflagUI_ ; 191 191 192 double subtime_ ;193 192 }; 194 193 }
Note:
See TracChangeset
for help on using the changeset viewer.