Ignore:
Timestamp:
12/06/11 13:13:24 (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: Added interface to select polarization

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Polarization selection support.
Default is all polarization components.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapgrid.py

    r2358 r2360  
    1313        self.gridder._setin( infile )
    1414
     15    def setPolList( self, pollist ):
     16        self.gridder._setpollist( pollist )
     17
    1518    def defineImage( self, nx=-1, ny=-1, cellx='', celly='', center='' ):
    1619        self.gridder._defineimage( nx, ny, cellx, celly, center )
     
    2528        self.outfile = self.gridder._save( outfile )
    2629
    27     def plot( self, plotchan=-1 ):
     30    def plot( self, plotchan=-1, plotpol=-1 ):
    2831        plotter = _SDGridPlotter( self.infile, self.outfile )
    29         plotter.plot( chan=plotchan )
     32        plotter.plot( chan=plotchan, pol=plotpol )
    3033       
    3134class _SDGridPlotter:
     
    4144        self.ny = -1
    4245        self.nchan = 0
     46        self.npol = 0
     47        self.pollist = []
    4348        self.cellx = 0.0
    4449        self.celly = 0.0
     
    5762        del s
    5863
    59         idx = spectra.nonzero()[1]
    60         #self.nonzero = self.pointing.take( idx, axis=1 )
    61        
    6264        s = scantable( self.outfile, average=False )
    63         self.grid = numpy.array( s.get_directionval() ).transpose()
    64         dirstring = s.get_direction()
    6565        nrow = s.nrow()
    66         spectra = []
     66        pols = numpy.ones( nrow, dtype=int )
    6767        for i in xrange(nrow):
    68             spectra.append( s._getspectrum( i ) )
    69         spectra = numpy.array( spectra ).transpose()
     68            pols[i] = s.getpol(i)
     69        self.pollist, indices = numpy.unique( pols, return_inverse=True )
     70        self.npol = len(self.pollist)
     71        self.pollist = self.pollist[indices[:self.npol]]
     72        #print 'pollist=',self.pollist
     73        #print 'npol=',self.npol
     74        #print 'nrow=',nrow
     75        dirstring = numpy.array(s.get_direction()).take(range(0,nrow,self.npol))
     76        self.grid = numpy.array( s.get_directionval() ).take(range(0,nrow,self.npol),axis=0).transpose()
     77        spectra = numpy.zeros( (self.npol,self.nchan,nrow/self.npol), dtype=float )
     78        irow = 0
     79        for i in xrange(nrow/self.npol):
     80            for ip in xrange(self.npol):
     81                spectra[ip,:,i] = s._getspectrum( irow )
     82                irow += 1
    7083
    7184        idx = 0
     
    7386        while ( dirstring[idx].split()[-1] == d0 ): 
    7487            idx += 1
    75 
    7688        self.ny = idx
    77         self.nx = nrow / idx
     89        self.nx = nrow / (self.npol * idx )
     90        #print 'nx,ny=',self.nx,self.ny
    7891       
    7992        self.cellx = abs( self.grid[0][0] - self.grid[0][1] )
    8093        self.celly = abs( self.grid[1][0] - self.grid[1][self.ny] )
     94        #print 'cellx,celly=',self.cellx,self.celly
    8195
    82         self.data = spectra.reshape( (self.nchan,self.nx,self.ny) )
     96        self.data = spectra.reshape( (self.npol,self.nchan,self.nx,self.ny) )
    8397
    84     def plot( self, chan=-1 ):
     98    def plot( self, chan=-1, pol=-1 ):
     99        if pol < 0:
     100            data = self.data.mean(axis=0)
     101            opt = 'averaged over pol'
     102        else:
     103            idx = self.pollist.tolist().index( pol )
     104            #print 'idx=',idx
     105            data = self.data[idx]
     106            opt = 'pol %s'%(pol)
    85107        if chan < 0:
    86             data = self.data.mean(axis=0)
    87             title = 'Gridded Image (averaged over channel)'
     108            data = data.mean(axis=0)
     109            opt += ', averaged over channel'
    88110        else:
    89             data = self.data[chan]
    90             title = 'Gridded Image (channel %s)'%(chan)
     111            data = data[chan]
     112            opt += ', channel %s'%(chan)
     113        title = 'Gridded Image (%s)'%(opt)
    91114        pl.figure(10)
    92115        pl.clf()
    93116        pl.plot(self.grid[0],self.grid[1],'.',color='blue')
    94117        pl.plot(self.pointing[0],self.pointing[1],'.',color='red')
    95         #pl.plot(self.nonzero[0],self.nonzero[1],'o',color='green')
    96118        extent=[self.grid[0].min()-0.5*self.cellx,
    97119                self.grid[0].max()+0.5*self.cellx,
Note: See TracChangeset for help on using the changeset viewer.