Changeset 2686


Ignore:
Timestamp:
11/15/12 23:28:32 (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: run sdgrid task with plot=True

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Fix for plotter failure.


Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapgrid.py

    r2680 r2686  
    306306        storg = rcParams['scantable.storage']
    307307        rcParams['scantable.storage'] = 'disk'
    308         plotter = _SDGridPlotter( self.infile, self.outfile, self.ifno )
     308        [nx,ny] = self.gridder._get_resultant_map_size()
     309        [cellx,celly] = self.gridder._get_resultant_cell_size()
     310        plotter = _SDGridPlotter( self.infile, self.outfile, self.ifno,
     311                                  nx=nx, ny=ny, cellx=cellx, celly=celly )
    309312        plotter.plot( chan=plotchan, pol=plotpol, plotobs=plotobs, plotgrid=plotgrid )
    310313        # back to original setup
     
    376379
    377380class _SDGridPlotter:
    378     def __init__( self, infile, outfile=None, ifno=-1 ):
     381    def __init__( self, infile, outfile=None, ifno=-1, nx=-1, ny=-1, cellx=0.0, celly=0.0 ):
    379382        if isinstance( infile, str ):
    380383            self.infile = [infile]
     
    384387        if self.outfile is None:
    385388            self.outfile = self.infile[0].rstrip('/')+'.grid'
    386         self.nx = -1
    387         self.ny = -1
     389        self.nx = nx
     390        self.ny = ny if ny > 0 else nx
    388391        self.nchan = 0
    389392        self.npol = 0
    390393        self.pollist = []
    391         self.cellx = 0.0
    392         self.celly = 0.0
     394        self.cellx = cellx
     395        self.celly = celly if celly > 0.0 else cellx
    393396        self.center = [0.0,0.0]
    394397        self.nonzero = [[0.0],[0.0]]
     
    414417        #print 'nrow=',nrow
    415418
    416         idx = 1
    417         d0 = s.get_direction( 0 ).split()[-2]
    418         d = s.get_direction(self.npol*idx)
    419         while( d is not None \
    420                and d.split()[-2] != d0):
    421             idx += 1
     419        if self.nx <= 0 or self.ny <= 0:
     420            idx = 1
     421            d0 = s.get_direction( 0 ).split()[-2]
    422422            d = s.get_direction(self.npol*idx)
     423            while( d is not None \
     424                   and d.split()[-2] != d0):
     425                idx += 1
     426                d = s.get_direction(self.npol*idx)
    423427       
    424         self.nx = idx
    425         self.ny = nrow / (self.npol * idx )
    426         #print 'nx,ny=',self.nx,self.ny
     428            self.nx = idx
     429            self.ny = nrow / (self.npol * idx )
     430            #print 'nx,ny=',self.nx,self.ny
    427431
    428432        self.blc = s.get_directionval( 0 )
     
    430434        #print self.blc
    431435        #print self.trc
    432         if nrow > 1:
    433             incrx = s.get_directionval( self.npol )
    434             incry = s.get_directionval( self.nx*self.npol )
    435         else:
    436             incrx = [0.0,0.0]
    437             incry = [0.0,0.0]
    438         self.cellx = abs( self.blc[0] - incrx[0] )
    439         self.celly = abs( self.blc[1] - incry[1] )
    440         #print 'cellx,celly=',self.cellx,self.celly
     436
     437        if self.cellx <= 0.0 or self.celly <= 0.0:
     438            if nrow > 1:
     439                incrx = s.get_directionval( self.npol )
     440                incry = s.get_directionval( self.nx*self.npol )
     441            else:
     442                incrx = [0.0,0.0]
     443                incry = [0.0,0.0]
     444            self.cellx = abs( self.blc[0] - incrx[0] )
     445            self.celly = abs( self.blc[1] - incry[1] )
     446            #print 'cellx,celly=',self.cellx,self.celly
    441447
    442448    def plot( self, chan=-1, pol=-1, plotobs=False, plotgrid=False ):
  • trunk/src/STGrid.cpp

    r2684 r2686  
    20842084}
    20852085
     2086vector<int> STGrid::getResultantMapSize()
     2087{
     2088  vector<int> r(2);
     2089  r[0] = nx_;
     2090  r[1] = ny_;
     2091  return r;
     2092}
     2093
     2094vector<double> STGrid::getResultantCellSize()
     2095{
     2096  vector<double> r(2);
     2097  r[0] = cellx_;
     2098  r[1] = celly_;
     2099  return r;
     2100}
     2101
    20862102// STGrid2
    20872103STGrid2::STGrid2()
  • trunk/src/STGrid.h

    r2671 r2686  
    7777  // support function to know how grid function looks like
    7878  vector<float> getConvFunc();
     79
     80  // for plotting
     81  vector<int> getResultantMapSize();
     82  vector<double> getResultantCellSize();
    7983
    8084//private:
  • trunk/src/python_STGrid.cpp

    r2671 r2686  
    4343    .def("_save", &STGrid::saveData)
    4444    .def("_getfunc", &STGrid::getConvFunc)
     45    .def("_get_resultant_map_size", &STGrid::getResultantMapSize)
     46    .def("_get_resultant_cell_size", &STGrid::getResultantCellSize)
    4547    ;
    4648
Note: See TracChangeset for help on using the changeset viewer.