Ignore:
Timestamp:
12/20/04 15:53:55 (19 years ago)
Author:
kil064
Message:

add function 'stats'
function 'rms' -> 'stddev'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r126 r135  
    5050            self._vb = args[0]
    5151            return
    52 
    5352
    5453    def copy(self):
     
    109108        Example:
    110109            scan.set_selection(0,0,1)
    111             pol1rms = scan.rms(all=False) # returns rms for beam=0
     110            pol1sig = scan.stats(all=False) # returns std dev for beam=0
    112111                                         # if=0, pol=1
    113112        """
     
    135134        return i,j,k
    136135
    137     def rms(self,mask=None, all=True):
    138         """
    139         Determine the root mean square of the current beam/if/pol
     136    def stats(self, stat='stddev', mask=None, all=True):
     137        """
     138        Determine the specified statistic of the current beam/if/pol
    140139        Takes a 'mask' as an optional parameter to specify which
    141140        channels should be excluded.
    142141        Parameters:
    143             mask:    an optional mask specifying where the rms
     142            stat:    'min', 'max', 'sumsq', 'sum', 'mean'
     143                     'var', 'stddev', 'avdev', 'rms', 'median'
     144            mask:    an optional mask specifying where the statistic
    144145                     should be determined.
    145146            all:     optional flag to show all or a selected
     
    149150            scan.set_unit('channel')
    150151            msk = scan.create_mask([100,200],[500,600])
    151             scan.rms(mask=m)
    152         """
    153         from asap._asap import rms as _rms
     152            scan.stats(stat='mean', mask=m)
     153        """
     154        from asap._asap import stats as _stats
    154155        if mask == None:
    155156            mask = ones(self.nchan())
     
    163164                    for k in range(self.npol()):
    164165                        self.setpol(k)
    165                         rmsval = _rms(self,mask)
    166                         tmp.append(rmsval)
    167                         out += 'Beam[%d], IF[%d], Pol[%d] = %3.3f\n' % (i,j,k,rmsval)
    168             if self._vb:
    169                 print out
     166                        statVal = _stats(self,mask,stat)
     167                        tmp.append(statVal)
     168#                        out += 'Beam[%d], IF[%d], Pol[%d] = %3.3f\n' % (i,j,k,statVal)
     169#            if self._vb:
     170#                print out
    170171            return tmp
    171172
     
    174175            j = self.getif()
    175176            k = self.getpol()
    176             rmsval = _rms(self,mask)
    177             out = 'Beam[%d], IF[%d], Pol[%d] = %3.3f' % (i,j,k,rmsval)
    178             if self._vb:
    179                 print out
    180             return rmsval
     177            statVal = _stats(self,mask,stat)
     178#            out = 'Beam[%d], IF[%d], Pol[%d] = %3.3f' % (i,j,k,statVal)
     179#            if self._vb:
     180#                print out
     181            return statVal
     182
     183    def stddev(self,mask=None, all=True):
     184        """
     185        Determine the standard deviation of the current beam/if/pol
     186        Takes a 'mask' as an optional parameter to specify which
     187        channels should be excluded.
     188        Parameters:
     189            mask:    an optional mask specifying where the standard
     190                     deviation should be determined.
     191            all:     optional flag to show all or a selected
     192                     spectrum of Beam/IF/Pol
     193
     194        Example:
     195            scan.set_unit('channel')
     196            msk = scan.create_mask([100,200],[500,600])
     197            scan.stddev(mask=m)
     198        """
     199        return self.stats(stat='stddev',mask=mask, all=all);
    181200
    182201    def get_tsys(self, all=True):
     
    373392        Parameters:
    374393            what:     a choice of 'spectrum' (default) or 'tsys'
    375             col:      which out of Beams, IFs, Pols (default)
    376                       should be colour stacked
     394            col:      which out of Beams/IFs/Pols should be colour stacked
    377395            panel:    set up multiple panels, currently not working.
    378396        """
Note: See TracChangeset for help on using the changeset viewer.