Changeset 2368
- Timestamp:
- 12/14/11 15:58:43 (13 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STGrid.cpp
r2365 r2368 289 289 gwgtArr.putStorage( wdata_p, deleteWgtG ) ; 290 290 Array<Float> gdataArr = real( gdataArrC ) ; 291 t0 = mathutil::gettimeofday_sec() ; 292 data_.resize( gdataArr.shape() ) ; 293 data_ = 0.0 ; 294 for ( Int ix = 0 ; ix < nx_ ; ix++ ) { 295 for ( Int iy = 0 ; iy < ny_ ; iy++ ) { 296 for ( Int ip = 0 ; ip < npol_ ; ip++ ) { 297 for ( Int ic = 0 ; ic < nchan_ ; ic++ ) { 298 IPosition pos( 4, ix, iy, ip, ic ) ; 299 IPosition gpos( 4, ix, iy, ip, ic ) ; 300 // IPosition gpos( 4, ix+convSupport_, iy+convSupport_, ip, ic ) ; 301 if ( gwgtArr( gpos ) > 0.0 ) 302 data_( pos ) = gdataArr( gpos ) / gwgtArr( gpos ) ; 303 } 304 } 305 } 306 } 307 t1 = mathutil::gettimeofday_sec() ; 308 os << "set data: elapsed time is " << t1-t0 << " sec." << LogIO::POST ; 291 setData( data_, gdataArr, gwgtArr ) ; 309 292 //Matrix<Double> sumWeight( IPosition( 2, npol_, nchan_ ), sumw_p, TAKE_OVER ) ; 310 293 delete sumw_p ; … … 313 296 // os << "gwgtArr = " << gwgtArr << LogIO::POST ; 314 297 // os << "data_ " << data_ << LogIO::POST ; 298 } 299 300 void STGrid::setData( Array<Float> &data, 301 Array<Float> &gdata, 302 Array<Float> &gwgt ) 303 { 304 LogIO os( LogOrigin("STGrid","setData",WHERE) ) ; 305 double t0, t1 ; 306 t0 = mathutil::gettimeofday_sec() ; 307 data.resize( gdata.shape() ) ; //data = 0.0 ; 308 uInt len = data.nelements() ; 309 Float *w0_p ; 310 const Float *w1_p, *w2_p ; 311 Bool b0, b1, b2 ; 312 Float *data_p = data.getStorage( b0 ) ; 313 const Float *gdata_p = gdata.getStorage( b1 ) ; 314 const Float *gwgt_p = gwgt.getStorage( b2 ) ; 315 w0_p = data_p ; 316 w1_p = gdata_p ; 317 w2_p = gwgt_p ; 318 for ( uInt i = 0 ; i < len ; i++ ) { 319 *w0_p = (*w2_p > 0.0) ? (*w1_p / *w2_p) : 0.0 ; 320 w0_p++ ; 321 w1_p++ ; 322 w2_p++ ; 323 } 324 data.putStorage( data_p, b0 ) ; 325 gdata.freeStorage( gdata_p, b1 ) ; 326 gwgt.freeStorage( gwgt_p, b2 ) ; 327 t1 = mathutil::gettimeofday_sec() ; 328 os << "setData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ; 315 329 } 316 330 … … 419 433 Table taborg( infile_ ) ; 420 434 if ( ifno == -1 ) { 421 LogIO os( LogOrigin("STGrid"," getData",WHERE) ) ;435 LogIO os( LogOrigin("STGrid","selectData",WHERE) ) ; 422 436 // os << LogIO::SEVERE 423 437 // << "Please set IFNO before actual gridding" … … 436 450 tab = taborg( node ) ; 437 451 if ( tab.nrow() == 0 ) { 438 LogIO os( LogOrigin("STGrid"," getData",WHERE) ) ;452 LogIO os( LogOrigin("STGrid","selectData",WHERE) ) ; 439 453 os << LogIO::SEVERE 440 454 << "No corresponding rows for given selection: IFNO " << ifno … … 523 537 Matrix<Double> &tint ) 524 538 { 539 LogIO os( LogOrigin("STGrid","getWeight",WHERE) ) ; 540 double t0, t1 ; 541 t0 = mathutil::gettimeofday_sec() ; 525 542 // resize 526 543 w.resize( nchan_, nrow_ ) ; 527 544 528 545 // set weight 529 w = 1.0 ;530 546 Bool warn = False ; 531 547 if ( wtype_.compare( "UNIFORM" ) == 0 ) { 532 // do nothing548 w = 1.0 ; 533 549 } 534 550 else if ( wtype_.compare( "TINT" ) == 0 ) { … … 536 552 for ( Int irow = 0 ; irow < nrow_ ; irow++ ) { 537 553 Float val = mean( tint.column( irow ) ) ; 538 w.column( irow ) = w.column( irow ) *val ;554 w.column( irow ) = val ; 539 555 } 540 556 } … … 545 561 for ( Int ichan = 0 ; ichan < nchan_ ; ichan++ ) { 546 562 Float val = mean( arr.column( ichan ) ) ; 547 w(ichan,irow) = w(ichan,irow)/ ( val * val ) ;563 w(ichan,irow) = 1.0 / ( val * val ) ; 548 564 } 549 565 } … … 556 572 for ( Int ichan = 0 ; ichan < nchan_ ; ichan++ ) { 557 573 Float temp = mean( arr.column( ichan ) ) ; 558 w(ichan,irow) = w(ichan,irow) *interval / ( temp * temp ) ;574 w(ichan,irow) = interval / ( temp * temp ) ; 559 575 } 560 576 } 561 577 } 562 578 else { 563 LogIO os( LogOrigin("STGrid", "getWeight", WHERE) ) ; 564 os << LogIO::WARN << "Unsupported weight type '" << wtype_ << "', apply UNIFORM weight" << LogIO::POST ; 579 //LogIO os( LogOrigin("STGrid", "getWeight", WHERE) ) ; 580 os << LogIO::WARN << "Unsupported weight type '" << wtype_ << "', apply UNIFORM weight" << LogIO::POST ; 581 w = 1.0 ; 565 582 } 566 583 567 584 if ( npol_ > 1 ) { 568 LogIO os( LogOrigin("STGrid", "getWeight", WHERE) ) ;585 //LogIO os( LogOrigin("STGrid", "getWeight", WHERE) ) ; 569 586 os << LogIO::WARN << "STGrid doesn't support assigning polarization-dependent weight. Use averaged weight over polarization." << LogIO::POST ; 570 587 } 588 t1 = mathutil::gettimeofday_sec() ; 589 os << "getWeight: elapsed time is " << t1-t0 << " sec" << LogIO::POST ; 571 590 } 572 591 … … 720 739 string STGrid::saveData( string outfile ) 721 740 { 741 LogIO os( LogOrigin("STGrid", "saveData", WHERE) ) ; 742 double t0, t1 ; 743 t0 = mathutil::gettimeofday_sec() ; 744 722 745 //Int polno = 0 ; 723 746 string outfile_ ; … … 734 757 outfile_ = outfile ; 735 758 } 736 CountedPtr<Scantable> ref( new Scantable( infile_, Table:: Memory) ) ;759 CountedPtr<Scantable> ref( new Scantable( infile_, Table::Plain ) ) ; 737 760 //cout << "ref->nchan()=" << ref->nchan() << endl ; 738 761 CountedPtr<Scantable> out( new Scantable( *ref, True ) ) ; … … 768 791 //cout << "outfile_=" << outfile_ << endl ; 769 792 out->makePersistent( outfile_ ) ; 793 794 t1 = mathutil::gettimeofday_sec() ; 795 os << "saveData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ; 770 796 771 797 return outfile_ ; -
trunk/src/STGrid.h
r2364 r2368 81 81 Double &ymax, 82 82 String ¢er ) ; 83 84 void setData( Array<Float> &data, 85 Array<Float> &gdata, 86 Array<Float> &gwgt ) ; 83 87 84 88 void getData( Cube<Float> &spectra,
Note:
See TracChangeset
for help on using the changeset viewer.