Changeset 2669


Ignore:
Timestamp:
10/17/12 17:20:35 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-4429

Ready for Test: Yes

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...

Use DirectionCoordinate for conversion between world and pixel.


Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapgrid.py

    r2594 r2669  
    448448        #print 'nrow=',nrow
    449449
    450         idx = 0
    451         d0 = s.get_direction( 0 ).split()[-1]
    452         while ( s.get_direction(self.npol*idx) is not None \
    453                 and s.get_direction(self.npol*idx).split()[-1] == d0 ):
     450        idx = 1
     451        d0 = s.get_direction( 0 ).split()[-2]
     452        d = s.get_direction(self.npol*idx)
     453        while( d is not None \
     454               and d.split()[-2] != d0):
    454455            idx += 1
     456            d = s.get_direction(self.npol*idx)
    455457       
    456458        self.nx = idx
     
    484486            opt += ', channel %s'%(chan)
    485487        data = self.getData( chan, pol )
    486         data = numpy.fliplr( data )
     488        #data = numpy.fliplr( data )
    487489        title = 'Gridded Image (%s)'%(opt)
    488490        pl.figure(10)
     
    530532        if self.ifno < 0:
    531533            ifno = self.tablein.getif(0)
    532             print 'ifno=',ifno
     534            #print 'ifno=',ifno
    533535        else:
    534536            ifno = self.ifno
  • trunk/src/STGrid.cpp

    r2638 r2669  
    11431143  }
    11441144  cellx_ = qcellx.getValue( "rad" ) ;
    1145   // DEC correction
    1146   cellx_ /= cos( center_[1] ) ;
    11471145  celly_ = qcelly.getValue( "rad" ) ;
    11481146  //os << "cellx_=" << cellx_ << ", celly_=" << celly_ << ", cos("<<center_(1)<<")=" << cos(center_(1)) << LogIO::POST ;
     
    11561154      wy = 0.00290888 ;
    11571155    }
    1158     nx_ = Int( ceil( wx/cellx_ ) ) ;
     1156    nx_ = Int( ceil( wx/(cellx_/cos(center_[1])) ) ) ;
    11591157    ny_ = Int( ceil( wy/celly_ ) ) ;
    11601158  }
     1159
     1160  // create DirectionCoordinate
     1161  Matrix<Double> xform(2,2) ;
     1162  xform = 0.0 ;
     1163  xform.diagonal() = 1.0 ;
     1164  dircoord_ = new DirectionCoordinate(MDirection::J2000,
     1165                                      Projection( Projection::SIN ),
     1166                                      center_[0], center_[1],
     1167                                      -cellx_, celly_,
     1168                                      xform,
     1169                                      0.5*Double(nx_-1),
     1170                                      0.5*Double(ny_-1)) ;
    11611171}
    11621172
     
    15281538void STGrid::toPixel( Array<Double> &world, Array<Double> &pixel )
    15291539{
    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) ) ;
    15411540  uInt nrow = world.shape()[1] ;
    15421541  Bool bw, bp ;
     
    15501549    _world.takeStorage( vshape, ww_p, SHARE ) ;
    15511550    _pixel.takeStorage( vshape, wp_p, SHARE ) ;
    1552     coord.toPixel( _pixel, _world ) ;
     1551    dircoord_->toPixel( _pixel, _world ) ;
    15531552    ww_p += 2 ;
    15541553    wp_p += 2 ;
     
    16901689  cpix(1) = Double( ny_ - 1 ) * 0.5 ;
    16911690  Vector<Double> dir( 2 ) ;
     1691  Vector<Double> pix( 2 );
    16921692  ArrayColumn<Double> directionCol( tab, "DIRECTION" ) ;
    16931693  ArrayColumn<Float> spectraCol( tab, "SPECTRA" ) ;
     
    17041704  uInt scanno = 0 ;
    17051705  for ( Int iy = 0 ; iy < ny_ ; iy++ ) {
    1706     dir(1) = center_(1) - ( cpix(1) - (Double)iy ) * celly_ ;
     1706    pix(1) = (Double)(iy);
    17071707    for ( Int ix = 0 ; ix < nx_ ; ix++ ) {
    1708       dir(0) = center_(0) - ( cpix(0) - (Double)ix ) * cellx_ ;
     1708      pix(0) = (Double)(nx_-1-ix);
     1709      dircoord_->toWorld(dir,pix);
     1710      //os << "dir[" << ix << "," << iy << "]=" << dir << LogIO::POST;
    17091711      for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) {
    1710         offset = ix + iy * nx_ + ipol * nx_ * ny_ ;
     1712        offset = ix + nx_ * (iy + ipol * ny_) ;
    17111713        //os << "offset = " << offset << LogIO::POST ;
    17121714        sp_p = sp.getStorage( bsp ) ;
  • trunk/src/STGrid.h

    r2638 r2669  
    2222#include <casa/Arrays/Vector.h>
    2323#include <casa/Containers/RecordField.h>
     24#include <casa/Utilities/CountedPtr.h>
    2425
    2526#include <tables/Tables/Table.h>
    2627#include <tables/Tables/ScalarColumn.h>
    2728#include <tables/Tables/ArrayColumn.h>
     29
     30#include <coordinates/Coordinates/DirectionCoordinate.h>
    2831
    2932#include "ScantableWrapper.h"
     
    236239  Vector<uInt> rows_ ;
    237240  Int nchunk_ ;
     241  CountedPtr<DirectionCoordinate> dircoord_;
    238242
    239243  /////////////// gridPerRow variable
Note: See TracChangeset for help on using the changeset viewer.