Changeset 2360 for trunk/python
- Timestamp:
- 12/06/11 13:13:24 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapgrid.py
r2358 r2360 13 13 self.gridder._setin( infile ) 14 14 15 def setPolList( self, pollist ): 16 self.gridder._setpollist( pollist ) 17 15 18 def defineImage( self, nx=-1, ny=-1, cellx='', celly='', center='' ): 16 19 self.gridder._defineimage( nx, ny, cellx, celly, center ) … … 25 28 self.outfile = self.gridder._save( outfile ) 26 29 27 def plot( self, plotchan=-1 ):30 def plot( self, plotchan=-1, plotpol=-1 ): 28 31 plotter = _SDGridPlotter( self.infile, self.outfile ) 29 plotter.plot( chan=plotchan )32 plotter.plot( chan=plotchan, pol=plotpol ) 30 33 31 34 class _SDGridPlotter: … … 41 44 self.ny = -1 42 45 self.nchan = 0 46 self.npol = 0 47 self.pollist = [] 43 48 self.cellx = 0.0 44 49 self.celly = 0.0 … … 57 62 del s 58 63 59 idx = spectra.nonzero()[1]60 #self.nonzero = self.pointing.take( idx, axis=1 )61 62 64 s = scantable( self.outfile, average=False ) 63 self.grid = numpy.array( s.get_directionval() ).transpose()64 dirstring = s.get_direction()65 65 nrow = s.nrow() 66 spectra = []66 pols = numpy.ones( nrow, dtype=int ) 67 67 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 70 83 71 84 idx = 0 … … 73 86 while ( dirstring[idx].split()[-1] == d0 ): 74 87 idx += 1 75 76 88 self.ny = idx 77 self.nx = nrow / idx 89 self.nx = nrow / (self.npol * idx ) 90 #print 'nx,ny=',self.nx,self.ny 78 91 79 92 self.cellx = abs( self.grid[0][0] - self.grid[0][1] ) 80 93 self.celly = abs( self.grid[1][0] - self.grid[1][self.ny] ) 94 #print 'cellx,celly=',self.cellx,self.celly 81 95 82 self.data = spectra.reshape( (self.n chan,self.nx,self.ny) )96 self.data = spectra.reshape( (self.npol,self.nchan,self.nx,self.ny) ) 83 97 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) 85 107 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' 88 110 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) 91 114 pl.figure(10) 92 115 pl.clf() 93 116 pl.plot(self.grid[0],self.grid[1],'.',color='blue') 94 117 pl.plot(self.pointing[0],self.pointing[1],'.',color='red') 95 #pl.plot(self.nonzero[0],self.nonzero[1],'o',color='green')96 118 extent=[self.grid[0].min()-0.5*self.cellx, 97 119 self.grid[0].max()+0.5*self.cellx,
Note:
See TracChangeset
for help on using the changeset viewer.