Changeset 2459 for branches/hpc33/python


Ignore:
Timestamp:
04/09/12 18:49:51 (13 years ago)
Author:
Kana Sugimoto
Message:

merged Takeshi's fix to asapgrid and STGrid class form trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/hpc33/python/asapgrid.py

    r2397 r2459  
    105105        numerical value and unit, e.g. '0.5arcmin', or numerical value.
    106106        If those values are specified as numerical value, their units
    107         will be assumed to 'arcmin'. If which of those is not specified,
     107        will be assumed to 'arcsec'. If which of those is not specified,
    108108        it will be set to the same value as the other. If none of them
    109109        are specified, it will be determined from map extent and number
     
    130130        """
    131131        if not isinstance( cellx, str ):
    132             cellx = '%sarcmin'%(cellx)
     132            cellx = '%sarcsec'%(cellx)
    133133        if not isinstance( celly, str ):
    134             celly = '%sarcmin'%(celly)
     134            celly = '%sarcsec'%(celly)
    135135        self.gridder._defineimage( nx, ny, cellx, celly, center )
    136136
     
    145145           'box': 1 pixel
    146146           'sf': 3 pixels
    147            'gauss': 3 pixels (width is used as HWHM)
     147           'gauss': 1 pixel (width is used as HWHM)
    148148
    149149        func -- Function type ('box', 'sf', 'gauss').
     
    265265        idx = 0
    266266        d0 = s.get_direction( 0 ).split()[-1]
    267         while ( s.get_direction(self.npol*idx).split()[-1] == d0 ): 
     267        while ( s.get_direction(self.npol*idx) is not None \
     268                and s.get_direction(self.npol*idx).split()[-1] == d0 ):
    268269            idx += 1
    269270       
     
    276277        #print self.blc
    277278        #print self.trc
    278         incrx = s.get_directionval( self.npol )
    279         incry = s.get_directionval( self.nx*self.npol )
     279        if nrow > 1:
     280            incrx = s.get_directionval( self.npol )
     281            incry = s.get_directionval( self.nx*self.npol )
     282        else:
     283            incrx = [0.0,0.0]
     284            incry = [0.0,0.0]
    280285        self.cellx = abs( self.blc[0] - incrx[0] )
    281286        self.celly = abs( self.blc[1] - incry[1] )
     
    287292        else:
    288293            opt = 'pol %s'%(pol)
    289         if chan < 0:
     294        if type(chan) is list:
     295            opt += ', averaged over channel %s-%s'%(chan[0],chan[1])
     296        elif chan < 0:
    290297            opt += ', averaged over channel'
    291298        else:
    292299            opt += ', channel %s'%(chan)
    293         data = self.getData( chan, pol )
     300        data = self.getData( chan, pol )
     301        data = numpy.fliplr( data )
    294302        title = 'Gridded Image (%s)'%(opt)
    295303        pl.figure(10)
     
    319327                    #print irow
    320328        # show image
    321         extent=[self.blc[0]-0.5*self.cellx,
    322                 self.trc[0]+0.5*self.cellx,
     329        extent=[self.trc[0]+0.5*self.cellx,
     330                self.blc[0]-0.5*self.cellx,
    323331                self.blc[1]-0.5*self.celly,
    324332                self.trc[1]+0.5*self.celly]
     333        deccorr = 1.0/numpy.cos(0.5*(self.blc[1]+self.trc[1]))
    325334        pl.imshow(data,extent=extent,origin='lower',interpolation='nearest')
    326335        pl.colorbar()
    327336        pl.xlabel('R.A. [rad]')
    328337        pl.ylabel('Dec. [rad]')
     338        ax = pl.axes()
     339        ax.set_aspect(deccorr)
    329340        pl.title( title )
    330341
     
    359370
    360371    def getData( self, chan=-1, pol=-1 ):
    361         if chan == -1:
     372        if type(chan) == list:
     373            spectra = self.__chanAverage(start=chan[0],end=chan[1])
     374        elif chan == -1:
    362375            spectra = self.__chanAverage()
    363376        else:
     
    370383        return retval
    371384
    372     def __chanAverage( self ):
     385    def __chanAverage( self, start=-1, end=-1 ):
    373386        s = scantable( self.outfile, average=False )
    374387        nrow = s.nrow()
     
    376389        irow = 0
    377390        sp = [0 for i in xrange(self.nchan)]
     391        if start < 0:
     392            start = 0
     393        if end < 0:
     394            end = self.nchan
    378395        for i in xrange(nrow/self.npol):
    379396            for ip in xrange(self.npol):
    380                 sp = s._getspectrum( irow )
     397                sp = s._getspectrum( irow )[start:end]
    381398                spectra[ip,i] = numpy.mean( sp )
    382399                irow += 1
     400           
    383401        return spectra
    384402
Note: See TracChangeset for help on using the changeset viewer.