Changeset 2359


Ignore:
Timestamp:
12/02/11 19:49:49 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2816

Ready for Test: No

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

  • Disabled debug message to stdout.
  • Total extent of the grid area will be determined to cover whole observed position.
  • number of pixels for ggridsd_ is (nx+convSupport*2,ny+convSupport+2) where (nx,ny) is output grid since ogridsd is defined such that convSupport pixels from the edge are ignored.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2356 r2359  
    147147 
    148148  // grid parameter
    149   cout << "----------" << endl ;
    150   cout << "Grid parameter summary" << endl ;
    151   cout << "   (nx,ny) = (" << nx_ << "," << ny_ << ")" << endl ;
    152   cout << "   (cellx,celly) = (" << cellx_ << "," << celly_ << ")" << endl ;
    153   cout << "   center = " << center_ << endl ;
    154   cout << "----------" << endl ;
     149//   cout << "----------" << endl ;
     150//   cout << "Grid parameter summary" << endl ;
     151//   cout << "   (nx,ny) = (" << nx_ << "," << ny_ << ")" << endl ;
     152//   cout << "   (cellx,celly) = (" << cellx_ << "," << celly_ << ")" << endl ;
     153//   cout << "   center = " << center_ << endl ;
     154//   cout << "----------" << endl ;
     155
     156  // convolution kernel
     157  Vector<Float> convFunc ;
     158  setConvFunc( convFunc ) ;
     159  //cout << "convSupport=" << convSupport_ << endl ;
     160  //cout << "convFunc=" << convFunc << endl ;
    155161
    156162  // world -> pixel
     
    162168  //cout << "min(xypos.row(1))=" << min(xypos.row(1)) << endl ;
    163169//   for ( Int irow = 0 ; irow < nrow ; irow++ ) {
    164 //     cout << irow << ": xypos=" << xypos.column( irow )
    165 //          << " data = " << spectra.column( irow ) << endl ;
     170//     if ( spectra.column( irow )(0) > 0.0 ) {
     171//       cout << irow << ": xypos=" << xypos.column( irow )
     172//            << " data = " << spectra.column( irow ) << endl ;
     173//     }
    166174//   }
    167175 
    168   // convolution kernel
    169   Vector<Float> convFunc ;
    170   setConvFunc( convFunc ) ;
    171   //cout << "convSupport=" << convSupport_ << endl ;
    172   //cout << "convFunc=" << convFunc << endl ;
    173 
    174176  // weighting factor
    175177  Matrix<Float> weight( IPosition( 2, nchan, nrow ), 1.0 ) ;
     
    186188  Float *conv_p = convFunc.getStorage( deleteConv ) ;
    187189  Int npol = 1 ;
    188   IPosition gshape( 4, nx_, ny_, npol, nchan ) ;
     190  // Extend grid plane with convSupport_
     191  //IPosition gshape( 4, nx_, ny_, npol, nchan ) ;
     192  Int gnx = nx_+convSupport_*2 ;
     193  Int gny = ny_+convSupport_*2 ;
     194  IPosition gshape( 4, gnx, gny, npol, nchan ) ;
    189195  Array<Complex> gdataArrC( gshape, 0.0 ) ;
    190196  Array<Float> gwgtArr( gshape, 0.0 ) ;
     
    229235           gdata_p,
    230236           wdata_p,
    231            &nx_,
    232            &ny_,
     237           //&nx_,
     238           //&ny_,
     239           &gnx,
     240           &gny,
    233241           &npol,
    234242           &nchan,
     
    250258  gwgtArr.putStorage( wdata_p, deleteWgtG ) ;
    251259  Array<Float> gdataArr = real( gdataArrC ) ;
    252   //Array<Float> gdataArrN( gdataArr.shape(), 0.0 ) ;
    253260  data_.resize( gdataArr.shape() ) ;
    254261  data_ = 0.0 ;
     
    258265        for ( Int ic = 0 ; ic < nchan ; ic++ ) {
    259266          IPosition pos( 4, ix, iy, ip, ic ) ;
    260           if ( gwgtArr( pos ) > 0.0 )
    261             //gdataArrN( pos ) = gdataArr( pos ) / gwgtArr( pos ) ;
    262             data_( pos ) = gdataArr( pos ) / gwgtArr( pos ) ;
     267          //if ( gwgtArr( pos ) > 0.0 )
     268          //  data_( pos ) = gdataArr( pos ) / gwgtArr( pos ) ;
     269          IPosition gpos( 4, ix+convSupport_, iy+convSupport_, ip, ic ) ;
     270          if ( gwgtArr( gpos ) > 0.0 )
     271            data_( pos ) = gdataArr( gpos ) / gwgtArr( gpos ) ;
    263272        }
    264273      }
     
    269278  //cout << "gdataArr = " << gdataArr << endl ;
    270279  //cout << "gwgtArr = " << gwgtArr << endl ;
    271   //cout << "gdataArr/gwgtArr = " << gdataArrN << endl ;
     280  //cout << "data_ " << data_ << endl ;
    272281}
    273282
     
    283292{
    284293  //cout << "nx=" << nx << ", ny=" << ny << endl ;
    285   Double wx = xmax - xmin ;
    286   Double wy = ymax - ymin ;
    287   // take some margin
     294
     295  // center position
     296  if ( center.size() == 0 ) {
     297    center_(0) = 0.5 * ( xmin + xmax ) ;
     298    center_(1) = 0.5 * ( ymin + ymax ) ;
     299  }
     300  else {
     301    String::size_type pos0 = center.find( " " ) ;
     302    if ( pos0 == String::npos ) {
     303      throw AipsError( "bad string format in parameter center" ) ;
     304    }
     305    String::size_type pos1 = center.find( " ", pos0+1 ) ;
     306    String typestr, xstr, ystr ;
     307    if ( pos1 != String::npos ) {
     308      typestr = center.substr( 0, pos0 ) ;
     309      xstr = center.substr( pos0+1, pos1-pos0 ) ;
     310      ystr = center.substr( pos1+1 ) ;
     311      // todo: convert to J2000 (or direction ref for DIRECTION column)
     312    }
     313    else {
     314      typestr = "J2000" ;
     315      xstr = center.substr( 0, pos0 ) ;
     316      ystr = center.substr( pos0+1 ) ;
     317    }
     318    QuantumHolder qh ;
     319    String err ;
     320    qh.fromString( err, xstr ) ;
     321    Quantum<Double> xcen = qh.asQuantumDouble() ;
     322    qh.fromString( err, ystr ) ;
     323    Quantum<Double> ycen = qh.asQuantumDouble() ;
     324    center_(0) = xcen.getValue( "rad" ) ;
     325    center_(1) = ycen.getValue( "rad" ) ;
     326  }
     327
     328
     329  //Double wx = xmax - xmin ;
     330  //Double wy = ymax - ymin ;
     331  Double wx = max( abs(xmax-center_(0)), abs(xmin-center_(0)) ) * 2 ;
     332  Double wy = max( abs(ymax-center_(1)), abs(ymin-center_(1)) ) * 2 ;
     333  // take 10% margin
    288334  wx *= 1.10 ;
    289335  wy *= 1.10 ;
     
    331377    nx_ = Int( ceil( wx/cellx_ ) ) ;
    332378    ny_ = Int( ceil( wy/celly_ ) ) ;
    333   }
    334 
    335   if ( center.size() == 0 ) {
    336     center_(0) = 0.5 * ( xmin + xmax ) ;
    337     center_(1) = 0.5 * ( ymin + ymax ) ;
    338   }
    339   else {
    340     String::size_type pos0 = center.find( " " ) ;
    341     if ( pos0 == String::npos ) {
    342       throw AipsError( "bad string format in parameter center" ) ;
    343     }
    344     String::size_type pos1 = center.find( " ", pos0+1 ) ;
    345     String typestr, xstr, ystr ;
    346     if ( pos1 != String::npos ) {
    347       typestr = center.substr( 0, pos0 ) ;
    348       xstr = center.substr( pos0+1, pos1-pos0 ) ;
    349       ystr = center.substr( pos1+1 ) ;
    350       // todo: convert to J2000 (or direction ref for DIRECTION column)
    351     }
    352     else {
    353       typestr = "J2000" ;
    354       xstr = center.substr( 0, pos0 ) ;
    355       ystr = center.substr( pos0+1 ) ;
    356     }
    357     QuantumHolder qh ;
    358     String err ;
    359     qh.fromString( err, xstr ) ;
    360     Quantum<Double> xcen = qh.asQuantumDouble() ;
    361     qh.fromString( err, ystr ) ;
    362     Quantum<Double> ycen = qh.asQuantumDouble() ;
    363     center_(0) = xcen.getValue( "rad" ) ;
    364     center_(1) = ycen.getValue( "rad" ) ;
    365379  }
    366380}
     
    419433void STGrid::toPixel( Matrix<Double> &world, Matrix<Double> &pixel )
    420434{
     435  // gridding will be done on (nx_+2*convSupport_) x (ny_+2*convSupport_)
     436  // grid plane to avoid unexpected behavior on grid edge
    421437  Vector<Double> pixc( 2 ) ;
    422   pixc(0) = Double( nx_-1 ) * 0.5 ;
    423   pixc(1) = Double( ny_-1 ) * 0.5 ;
     438  //pixc(0) = Double( nx_-1 ) * 0.5 ;
     439  //pixc(1) = Double( ny_-1 ) * 0.5 ;
     440  pixc(0) = Double( nx_+2*convSupport_-1 ) * 0.5 ;
     441  pixc(1) = Double( ny_+2*convSupport_-1 ) * 0.5 ;
    424442  uInt nrow = world.shape()[1] ;
    425443  Vector<Double> cell( 2 ) ;
     
    502520    gaussFunc( convFunc ) ;
    503521  }
    504   else if ( convType_ == "PB" )
     522  else if ( convType_ == "PB" ) {
     523    if ( convSupport_ < 0 )
     524      convSupport_ = 0 ;
    505525    pbFunc( convFunc ) ;
     526  }
    506527  else {
    507528    throw AipsError( "Unsupported convolution function" ) ;
Note: See TracChangeset for help on using the changeset viewer.