Changeset 2371
- Timestamp:
- 12/15/11 17:14:29 (13 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STGrid.cpp
r2369 r2371 21 21 #include <measures/Measures/MDirection.h> 22 22 23 #include <Scantable.h>24 23 #include <MathUtils.h> 25 24 … … 305 304 double t0, t1 ; 306 305 t0 = mathutil::gettimeofday_sec() ; 307 data.resize( gdata.shape() ) ; //data = 0.0 ;306 data.resize( gdata.shape() ) ; 308 307 uInt len = data.nelements() ; 309 308 Float *w0_p ; … … 466 465 Table tab ; 467 466 selectData( tab ) ; 468 ROScalarColumn<uInt> polnoCol( tab, "POLNO" ) ; 469 Vector<uInt> pols = polnoCol.getColumn() ; 470 Vector<uInt> pollistOrg ; 471 uInt npolOrg = 0 ; 472 for ( uInt i = 0 ; i < pols.size() ; i++ ) { 473 if ( allNE( pollistOrg, pols[i] ) ) { 474 pollistOrg.resize( npolOrg+1, True ) ; 475 pollistOrg[npolOrg] = pols[i] ; 476 npolOrg++ ; 477 } 478 } 479 if ( pollist_.size() == 0 ) 480 pollist_ = pollistOrg ; 481 else { 482 Vector<uInt> newlist ; 483 uInt newsize = 0 ; 484 for ( uInt i = 0 ; i < pollist_.size() ; i++ ) { 485 if ( anyEQ( pols, pollist_[i] ) ) { 486 newlist.resize( newsize+1, True ) ; 487 newlist[newsize] = pollist_[i] ; 488 newsize++ ; 489 } 490 } 491 pollist_ = newlist ; 492 } 493 npol_ = pollist_.size() ; 494 ROArrayColumn<uChar> tmpCol( tab, "FLAGTRA" ) ; 495 nchan_ = tmpCol( 0 ).nelements() ; 496 nrow_ = tab.nrow() / npolOrg ; 467 updatePolList( tab ) ; 497 468 // cout << "npol_ = " << npol_ << endl ; 498 469 // cout << "nchan_ = " << nchan_ << endl ; … … 503 474 Cube<Float> tsys( npol_, nchan_, nrow_ ) ; 504 475 Matrix<Double> tint( npol_, nrow_ ) ; 476 // boolean for pointer access 477 Bool bsp, bfl, bfr, bts, bti ; 478 // pointer to the data 479 Float *sp_p = spectra.getStorage( bsp ) ; 480 uChar *fl_p = flagtra.getStorage( bfl ) ; 481 uInt *fr_p = rflag.getStorage( bfr ) ; 482 Float *ts_p = tsys.getStorage( bts ) ; 483 Double *ti_p = tint.getStorage( bti ) ; 484 // working pointer 485 Float *wsp_p = sp_p ; 486 uChar *wfl_p = fl_p ; 487 uInt *wfr_p = fr_p ; 488 Float *wts_p = ts_p ; 489 Double *wti_p = ti_p ; 490 uInt len = nchan_ * nrow_ ; 491 IPosition mshape( 2, nchan_, nrow_ ) ; 492 IPosition vshape( 1, nrow_ ) ; 505 493 for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) { 506 494 Table subt = tab( tab.col("POLNO") == pollist_[ipol] ) ; … … 511 499 ROArrayColumn<Float> tsysCol( subt, "TSYS" ) ; 512 500 ROScalarColumn<Double> tintCol( subt, "INTERVAL" ) ; 513 Matrix<Float> tmpF = spectra.yzPlane( ipol ) ;514 Matrix<uChar> tmpUC = flagtra.yzPlane( ipol) ;515 Vector<uInt> tmpUI = rflag.row( ipol) ;516 spectraCol.getColumn( tmpF) ;517 flagtraCol.getColumn( tmpUC) ;518 rflagCol.getColumn( tmpUI) ;501 Matrix<Float> spSlice( mshape, wsp_p, SHARE ) ; 502 Matrix<uChar> flSlice( mshape, wfl_p, SHARE ) ; 503 Vector<uInt> frSlice( vshape, wfr_p, SHARE ) ; 504 spectraCol.getColumn( spSlice ) ; 505 flagtraCol.getColumn( flSlice ) ; 506 rflagCol.getColumn( frSlice ) ; 519 507 if ( ipol == 0 ) 520 508 directionCol.getColumn( direction ) ; 521 Matrix<Float> tmpF2 = tsysCol.getColumn() ; 522 Vector<Double> tmpD = tint.row( ipol ) ; 523 if ( tmpF2.shape()(0) == nchan_ ) { 524 tsys.yzPlane( ipol ) = tmpF2 ; 509 Vector<Float> tmpF = tsysCol( 0 ) ; 510 Vector<Double> tmpD( vshape, wti_p, SHARE ) ; 511 Matrix<Float> tsSlice( mshape, wts_p, SHARE ) ; 512 if ( tmpF.nelements() == (uInt)nchan_ ) { 513 tsysCol.getColumn( tsSlice ) ; 525 514 } 526 515 else { 527 ts ys.yzPlane( ipol ) = tmpF2(0,0) ;516 tsSlice = tmpF( 0 ) ; 528 517 } 529 518 tintCol.getColumn( tmpD ) ; 530 } 519 520 wsp_p += len ; 521 wfl_p += len ; 522 wfr_p += nrow_ ; 523 wts_p += len ; 524 wti_p += nrow_ ; 525 } 526 spectra.putStorage( sp_p, bsp ) ; 527 flagtra.putStorage( fl_p, bfl ) ; 528 rflag.putStorage( fr_p, bfr ) ; 529 tsys.putStorage( ts_p, bts ) ; 530 tint.putStorage( ti_p, bti ) ; 531 531 532 532 getWeight( weight, tsys, tint ) ; 533 } 534 535 void STGrid::updatePolList( Table &tab ) 536 { 537 ROScalarColumn<uInt> polnoCol( tab, "POLNO" ) ; 538 Vector<uInt> pols = polnoCol.getColumn() ; 539 Vector<uInt> pollistOrg ; 540 uInt npolOrg = 0 ; 541 uInt polno ; 542 for ( uInt i = 0 ; i < polnoCol.nrow() ; i++ ) { 543 //polno = polnoCol( i ) ; 544 polno = pols( i ) ; 545 if ( allNE( pollistOrg, polno ) ) { 546 pollistOrg.resize( npolOrg+1, True ) ; 547 pollistOrg[npolOrg] = polno ; 548 npolOrg++ ; 549 } 550 } 551 if ( pollist_.size() == 0 ) 552 pollist_ = pollistOrg ; 553 else { 554 Vector<uInt> newlist ; 555 uInt newsize = 0 ; 556 for ( uInt i = 0 ; i < pollist_.size() ; i++ ) { 557 if ( anyEQ( pollistOrg, pollist_[i] ) ) { 558 newlist.resize( newsize+1, True ) ; 559 newlist[newsize] = pollist_[i] ; 560 newsize++ ; 561 } 562 } 563 pollist_.assign( newlist ) ; 564 } 565 npol_ = pollist_.size() ; 566 if ( npol_ == 0 ) { 567 LogIO os( LogOrigin("STGrid","updatePolList",WHERE) ) ; 568 os << LogIO::SEVERE << "Empty pollist" << LogIO::EXCEPTION ; 569 } 570 nrow_ = tab.nrow() / npolOrg ; 571 ROArrayColumn<uChar> tmpCol( tab, "FLAGTRA" ) ; 572 nchan_ = tmpCol( 0 ).nelements() ; 573 // LogIO os( LogOrigin("STGrid","updatePolList",WHERE) ) ; 574 // os << "npol_ = " << npol_ << "(" << pollist_ << ")" << endl 575 // << "nchan_ = " << nchan_ << endl 576 // << "nrow_ = " << nrow_ << LogIO::POST ; 533 577 } 534 578 … … 793 837 794 838 //Int polno = 0 ; 795 string outfile_ ;839 String outfile_ ; 796 840 if ( outfile.size() == 0 ) { 797 841 if ( infile_.lastchar() == '/' ) { … … 806 850 outfile_ = outfile ; 807 851 } 808 CountedPtr<Scantable> ref( new Scantable( infile_, Table::Plain ) ) ; 809 //cout << "ref->nchan()=" << ref->nchan() << endl ; 810 CountedPtr<Scantable> out( new Scantable( *ref, True ) ) ; 811 Table tab = out->table() ; 852 Table tab ; 853 prepareTable( tab, outfile_ ) ; 812 854 IPosition dshape = data_.shape() ; 813 855 Int nrow = nx_ * ny_ * npol_ ; … … 822 864 ScalarColumn<uInt> polnoCol( tab, "POLNO" ) ; 823 865 Int irow = 0 ; 866 Vector<Float> sp( nchan_ ) ; 867 Bool bsp, bdata ; 868 const Float *data_p = data_.getStorage( bdata ) ; 869 Float *wsp_p, *sp_p ; 870 const Float *wdata_p = data_p ; 871 long step = nx_ * ny_ * npol_ ; 872 long offset ; 824 873 for ( Int iy = 0 ; iy < ny_ ; iy++ ) { 874 dir(1) = center_(1) - ( cpix(1) - (Double)iy ) * celly_ ; 825 875 for ( Int ix = 0 ; ix < nx_ ; ix++ ) { 876 dir(0) = center_(0) - ( cpix(0) - (Double)ix ) * cellx_ ; 826 877 for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) { 827 IPosition start( 4, ix, iy, ipol, 0 ) ; 828 IPosition end( 4, ix, iy, ipol, nchan_-1 ) ; 829 IPosition inc( 4, 1, 1, 1, 1 ) ; 830 Vector<Float> sp = data_( start, end, inc ) ; 831 dir(0) = center_(0) - ( cpix(0) - (Double)ix ) * cellx_ ; 832 dir(1) = center_(1) - ( cpix(1) - (Double)iy ) * celly_ ; 878 offset = ix + iy * nx_ + ipol * nx_ * ny_ ; 879 //os << "offset = " << offset << LogIO::POST ; 880 sp_p = sp.getStorage( bsp ) ; 881 wsp_p = sp_p ; 882 wdata_p = data_p + offset ; 883 for ( Int ichan = 0 ; ichan < nchan_ ; ichan++ ) { 884 *wsp_p = *wdata_p ; 885 wsp_p++ ; 886 wdata_p += step ; 887 } 888 sp.putStorage( sp_p, bsp ) ; 833 889 spectraCol.put( irow, sp ) ; 834 890 directionCol.put( irow, dir ) ; … … 838 894 } 839 895 } 840 //cout << "outfile_=" << outfile_ << endl ; 841 out->makePersistent( outfile_ ) ; 896 data_.freeStorage( data_p, bdata ) ; 842 897 843 898 t1 = mathutil::gettimeofday_sec() ; … … 847 902 } 848 903 849 } 904 void STGrid::prepareTable( Table &tab, String &name ) 905 { 906 Table t( infile_, Table::Old ) ; 907 t.deepCopy( name, Table::New, False, t.endianFormat(), True ) ; 908 tab = Table( name, Table::Update ) ; 909 } 910 } -
trunk/src/STGrid.h
r2369 r2371 111 111 Double polMean( const Double *p ) ; 112 112 113 void updatePolList( Table &tab ) ; 114 115 void prepareTable( Table &tab, String &name ) ; 116 113 117 String infile_ ; 114 118 Int ifno_ ;
Note:
See TracChangeset
for help on using the changeset viewer.