Changeset 2364


Ignore:
Timestamp:
12/08/11 18:31:00 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2816

Ready for Test: No

Interface Changes: Yes

What Interface Changed: see below

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): sdgrid task

Description: Describe your changes here...

  • setOption is renamed to setFunc
  • Implemented selection by SCANNO
  • Disabled to extend grid area for edge treatment
  • Added message for performance check


Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapgrid.py

    r2363 r2364  
    1919        self.gridder._setpollist( pollist )
    2020
     21    def setScanList( self, scanlist ):
     22        self.gridder._setscanlist( scanlist )
     23
    2124    def defineImage( self, nx=-1, ny=-1, cellx='', celly='', center='' ):
    2225        self.gridder._defineimage( nx, ny, cellx, celly, center )
    2326
    24     def setOption( self, convType='box', width=-1 ):
    25         self.gridder._setoption( convType, width )
     27    def setFunc( self, func='box', width=-1 ):
     28        self.gridder._setfunc( func, width )
    2629
    2730    def setWeight( self, weightType='uniform' ):
  • trunk/src/STGrid.cpp

    r2363 r2364  
    2222
    2323#include <Scantable.h>
     24#include <MathUtils.h>
     25
    2426#include "STGrid.h"
    2527
     
    7274void STGrid::setPolList( vector<unsigned int> pols )
    7375{
    74   //pollist_ = Vector<uInt>( pols ) ;
    7576  pollist_.assign( Vector<uInt>( pols ) ) ;
    7677  cout << "pollist_ = " << pollist_ << endl ;
     78}
     79
     80void STGrid::setScanList( vector<unsigned int> scans )
     81{
     82  scanlist_.assign( Vector<uInt>( scans ) ) ;
     83  cout << "scanlist_ = " << scanlist_ << endl ;
    7784}
    7885
     
    108115}
    109116 
    110 void STGrid::setOption( string convType,
    111                         int convSupport )
     117void STGrid::setFunc( string convType,
     118                      int convSupport )
    112119{
    113120  convType_ = String( convType ) ;
     
    154161  Matrix<uInt> rflag ;
    155162  Matrix<Float> weight ;
     163  double t0, t1 ;
     164  t0 = mathutil::gettimeofday_sec() ;
    156165  getData( spectra, direction, flagtra, rflag, weight ) ;
     166  t1 = mathutil::gettimeofday_sec() ;
     167  os << "getData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    157168  IPosition sshape = spectra.shape() ;
    158169  //os << "spectra.shape()=" << spectra.shape() << LogIO::POST ;
     
    164175  Cube<Int> flagI ;
    165176  Matrix<Int> rflagI ;
     177  t0 = mathutil::gettimeofday_sec() ;
    166178  toInt( &flagtra, &flagI ) ;
    167179  toInt( &rflag, &rflagI ) ;
     180  t1 = mathutil::gettimeofday_sec() ;
     181  os << "toInt: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    168182 
    169183  // grid parameter
     
    179193  // convolution kernel
    180194  Vector<Float> convFunc ;
     195  t0 = mathutil::gettimeofday_sec() ;
    181196  setConvFunc( convFunc ) ;
     197  t1 = mathutil::gettimeofday_sec() ;
     198  os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    182199  //cout << "convSupport=" << convSupport_ << endl ;
    183200  //cout << "convFunc=" << convFunc << endl ;
     
    185202  // world -> pixel
    186203  Matrix<Double> xypos( direction.shape(), 0.0 ) ;
     204  t0 = mathutil::gettimeofday_sec() ;
    187205  toPixel( direction, xypos ) ; 
     206  t1 = mathutil::gettimeofday_sec() ;
     207  os << "toPixel: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    188208 
    189209  // call ggridsd
     
    198218  Float *conv_p = convFunc.getStorage( deleteConv ) ;
    199219  // Extend grid plane with convSupport_
    200   //IPosition gshape( 4, nx_, ny_, npol, nchan ) ;
    201   Int gnx = nx_+convSupport_*2 ;
    202   Int gny = ny_+convSupport_*2 ;
     220  Int gnx = nx_ ;
     221  Int gny = ny_ ;
     222//   Int gnx = nx_+convSupport_*2 ;
     223//   Int gny = ny_+convSupport_*2 ;
    203224  IPosition gshape( 4, gnx, gny, npol_, nchan_ ) ;
    204225  Array<Complex> gdataArrC( gshape, 0.0 ) ;
     
    207228  Float *wdata_p = gwgtArr.getStorage( deleteWgtG ) ;
    208229  Int idopsf = 0 ;
    209   Int irow = -1 ;
    210230  Int *chanMap = new Int[nchan_] ;
    211231  {
     
    232252    }
    233253  }
     254  t0 = mathutil::gettimeofday_sec() ;
     255  Int irow = -1 ;
    234256  ggridsd( xypos_p,
    235257           data_p,
     
    254276           polMap,
    255277           sumw_p ) ;
     278  t1 = mathutil::gettimeofday_sec() ;
     279  os << "ggridsd: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    256280  xypos.putStorage( xypos_p, deletePos ) ;
    257281  dataC.freeStorage( data_p, deleteData ) ;
     
    265289  gwgtArr.putStorage( wdata_p, deleteWgtG ) ;
    266290  Array<Float> gdataArr = real( gdataArrC ) ;
     291  t0 = mathutil::gettimeofday_sec() ;
    267292  data_.resize( gdataArr.shape() ) ;
    268293  data_ = 0.0 ;
     
    272297        for ( Int ic = 0 ; ic < nchan_ ; ic++ ) {
    273298          IPosition pos( 4, ix, iy, ip, ic ) ;
    274           IPosition gpos( 4, ix+convSupport_, iy+convSupport_, ip, ic ) ;
     299          IPosition gpos( 4, ix, iy, ip, ic ) ;
     300//           IPosition gpos( 4, ix+convSupport_, iy+convSupport_, ip, ic ) ;
    275301          if ( gwgtArr( gpos ) > 0.0 )
    276302            data_( pos ) = gdataArr( gpos ) / gwgtArr( gpos ) ;
     
    279305    }
    280306  }
     307  t1 = mathutil::gettimeofday_sec() ;
     308  os << "set data: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    281309  //Matrix<Double> sumWeight( IPosition( 2, npol_, nchan_ ), sumw_p, TAKE_OVER ) ;
    282310  delete sumw_p ;
    283311  //cout << "sumWeight = " << sumWeight << endl ;
    284   //cout << "gdataArr = " << gdataArr << endl ;
    285   //cout << "gwgtArr = " << gwgtArr << endl ;
    286   //cout << "data_ " << data_ << endl ;
     312//   os << "gdataArr = " << gdataArr << LogIO::POST ;
     313//   os << "gwgtArr = " << gwgtArr << LogIO::POST ;
     314//   os << "data_ " << data_ << LogIO::POST ;
    287315}
    288316
     
    400428       << "IFNO is not given. Using default IFNO: " << ifno << LogIO::POST ;
    401429  }
    402   tab = taborg( taborg.col("IFNO") == ifno ) ;
     430//   tab = taborg( taborg.col("IFNO") == ifno ) ;
     431  TableExprNode node ;
     432  node = taborg.col("IFNO") == ifno ;
     433  if ( scanlist_.size() > 0 ) {
     434    node = node && taborg.col("SCANNO").in( scanlist_ ) ;
     435  }
     436  tab = taborg( node ) ;
    403437  if ( tab.nrow() == 0 ) {
    404438    LogIO os( LogOrigin("STGrid","getData",WHERE) ) ;
    405439    os << LogIO::SEVERE
    406        << "No corresponding rows for given IFNO: " << ifno
     440       << "No corresponding rows for given selection: IFNO" << ifno
     441       << "SCANNO " << scanlist_
    407442       << LogIO::EXCEPTION ;
    408443  }
     
    575610  // grid plane to avoid unexpected behavior on grid edge
    576611  Vector<Double> pixc( 2 ) ;
    577   //pixc(0) = Double( nx_-1 ) * 0.5 ;
    578   //pixc(1) = Double( ny_-1 ) * 0.5 ;
    579   pixc(0) = Double( nx_+2*convSupport_-1 ) * 0.5 ;
    580   pixc(1) = Double( ny_+2*convSupport_-1 ) * 0.5 ;
     612  pixc(0) = Double( nx_-1 ) * 0.5 ;
     613  pixc(1) = Double( ny_-1 ) * 0.5 ;
     614//   pixc(0) = Double( nx_+2*convSupport_-1 ) * 0.5 ;
     615//   pixc(1) = Double( ny_+2*convSupport_-1 ) * 0.5 ;
    581616  uInt nrow = world.shape()[1] ;
    582617  Vector<Double> cell( 2 ) ;
    583618  cell(0) = cellx_ ;
    584619  cell(1) = celly_ ;
    585   //ofstream ofs( "grid.dat", ios::out ) ;
    586620  for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
    587     //ofs << irow ;
    588621    for ( uInt i = 0 ; i < 2 ; i++ ) {
    589622      pixel( i, irow ) = pixc(i) + ( world(i, irow) - center_(i) ) / cell(i) ;
    590       //ofs << " " << world(i, irow) << " " << pixel(i, irow) ;
    591     }
    592     //ofs << endl ;
    593   }
    594   //ofs.close() ;
     623    }
     624  }
     625//   String gridfile = "grid."+convType_+"."+String::toString(convSupport_)+".dat" ;
     626//   ofstream ofs( gridfile.c_str(), ios::out ) ;
     627//   ofs << "center " << center_(0) << " " << pixc(0)
     628//       << " " << center_(1) << " " << pixc(1) << endl ;
     629//   for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
     630//     ofs << irow ;
     631//     for ( uInt i = 0 ; i < 2 ; i++ ) {
     632//       ofs << " " << world(i, irow) << " " << pixel(i, irow) ;
     633//     }
     634//     ofs << endl ;
     635//   }
     636//   ofs.close() ;
    595637}
    596638
  • trunk/src/STGrid.h

    r2362 r2364  
    5353  void setPolList( vector<unsigned int> pols ) ;
    5454
     55  void setScanList( vector<unsigned int> scans ) ;
     56
    5557  void defineImage( int nx=-1,
    5658                    int ny=-1,
     
    5860                    string scelly="",
    5961                    string scenter="" ) ;
    60   void setOption( string convtype="box",
    61                   int convsupport=-1 ) ;
     62  void setFunc( string convtype="box",
     63                int convsupport=-1 ) ;
    6264
    6365  void setWeight( const string wType="uniform" ) ;
     
    118120  Array<Float> data_ ;
    119121  Vector<uInt> pollist_ ;
     122  Vector<uInt> scanlist_ ;
    120123  String wtype_ ;
    121124
  • trunk/src/python_STGrid.cpp

    r2362 r2364  
    2323    .def("_setif", &STGrid::setIF)
    2424    .def("_setpollist", &STGrid::setPolList)
     25    .def("_setscanlist", &STGrid::setScanList)
    2526    .def("_defineimage", &STGrid::defineImage)
    26     .def("_setoption", &STGrid::setOption)
     27    .def("_setfunc", &STGrid::setFunc)
    2728    .def("_grid", &STGrid::grid)
    2829    .def("_setin", &STGrid::setFileIn)
Note: See TracChangeset for help on using the changeset viewer.