Changeset 2638


Ignore:
Timestamp:
08/09/12 12:40:16 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: test_sdgrid

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

toPixel is redefined using DirectionCoordinate?.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2636 r2638  
    1717#include <casa/Utilities/CountedPtr.h>
    1818#include <casa/Logging/LogIO.h>
     19
     20#include <coordinates/Coordinates/DirectionCoordinate.h>
    1921
    2022#include <tables/Tables/Table.h>
     
    10841086//   os << "xmin=" << xmin << LogIO::POST ;
    10851087//   os << "center_=" << center_ << LogIO::POST ;
    1086   decCorr_ = 1.0 / cos( center_[1] ) ;
    10871088
    10881089  nx_ = nx ;
     
    11431144  cellx_ = qcellx.getValue( "rad" ) ;
    11441145  // DEC correction
    1145   cellx_ *= decCorr_ ;
     1146  cellx_ /= cos( center_[1] ) ;
    11461147  celly_ = qcelly.getValue( "rad" ) ;
    11471148  //os << "cellx_=" << cellx_ << ", celly_=" << celly_ << ", cos("<<center_(1)<<")=" << cos(center_(1)) << LogIO::POST ;
     
    15271528void STGrid::toPixel( Array<Double> &world, Array<Double> &pixel )
    15281529{
    1529   // gridding will be done on (nx_+2*convSupport_) x (ny_+2*convSupport_)
    1530   // grid plane to avoid unexpected behavior on grid edge
    1531   Block<Double> pixc( 2 ) ;
    1532   pixc[0] = Double( nx_-1 ) * 0.5 ;
    1533   pixc[1] = Double( ny_-1 ) * 0.5 ;
    1534 //   pixc[0] = Double( nx_+2*convSupport_-1 ) * 0.5 ;
    1535 //   pixc[1] = Double( ny_+2*convSupport_-1 ) * 0.5 ;
     1530  // using DirectionCoordinate
     1531  Matrix<Double> xform(2,2) ;
     1532  xform = 0.0 ;
     1533  xform.diagonal() = 1.0 ;
     1534  DirectionCoordinate coord( MDirection::J2000,
     1535                             Projection( Projection::SIN ),
     1536                             center_[0], center_[1],
     1537                             cellx_, celly_,
     1538                             xform,
     1539                             0.5*Double(nx_-1),
     1540                             0.5*Double(ny_-1) ) ;
    15361541  uInt nrow = world.shape()[1] ;
    15371542  Bool bw, bp ;
    1538   const Double *w_p = world.getStorage( bw ) ;
     1543  Double *w_p = world.getStorage( bw ) ;
    15391544  Double *p_p = pixel.getStorage( bp ) ;
    1540   const Double *ww_p = w_p ;
     1545  Double *ww_p = w_p ;
    15411546  Double *wp_p = p_p ;
     1547  IPosition vshape( 1, 2 ) ;
     1548  Vector<Double> _world, _pixel ;
    15421549  for ( uInt i = 0 ; i < nrow ; i++ ) {
    1543     *wp_p = pixc[0] + ( *ww_p - center_[0] ) / cellx_ ;
    1544     wp_p++ ;
    1545     ww_p++ ;
    1546     *wp_p = pixc[1] + ( *ww_p - center_[1] ) / celly_ ;
    1547     wp_p++ ;
    1548     ww_p++ ;
    1549   }
    1550   world.freeStorage( w_p, bw ) ;
    1551   pixel.putStorage( p_p, bp ) ; 
     1550    _world.takeStorage( vshape, ww_p, SHARE ) ;
     1551    _pixel.takeStorage( vshape, wp_p, SHARE ) ;
     1552    coord.toPixel( _pixel, _world ) ;
     1553    ww_p += 2 ;
     1554    wp_p += 2 ;
     1555  }
     1556  world.putStorage( w_p, bw ) ;
     1557  pixel.putStorage( p_p, bp ) ;
    15521558}
    15531559
  • trunk/src/STGrid.h

    r2631 r2638  
    226226  Double celly_ ;
    227227  Vector<Double> center_ ;
    228   Double decCorr_ ;
    229228  String convType_ ;
    230229  Int convSupport_ ;
Note: See TracChangeset for help on using the changeset viewer.