Changeset 1099 for trunk/python


Ignore:
Timestamp:
08/01/06 12:31:39 (18 years ago)
Author:
mar637
Message:

moved average_channel into average_time as an addition weight

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r1093 r1099  
    794794            scanav:   True averages each scan separately
    795795                      False (default) averages all scans together,
    796             weight:   Weighting scheme. 'none', 'var' (1/var(spec)
    797                       weighted), 'tsys' (1/Tsys**2 weighted), 'tint'
    798                       (integration time weighted) or 'tintsys' (Tint/Tsys**2).
     796            weight:   Weighting scheme.
     797                      'none'     (mean no weight)
     798                      'var'      (1/var(spec) weighted)
     799                      'tsys'     (1/Tsys**2 weighted)
     800                      'tint'     (integration time weighted)
     801                      'tintsys'  (Tint/Tsys**2)
     802                      'median'   ( median averaging)
    799803                      The default is 'tint'
    800804            align:    align the spectra in velocity before averaging. It takes
     
    807811        if weight is None: weight = 'TINT'
    808812        if mask is None: mask = ()
    809         if scanav:
    810             scanav = "SCAN"
    811         else:
    812             scanav = "NONE"
     813        if scanav: scanav = "SCAN"
     814        else: scanav = "NONE"
    813815        scan = (self,)
    814816        try:
    815817          if align:
    816818              scan = (self.freq_align(insitu=False),)
    817           s = scantable(self._math._average(scan, mask, weight.upper(),
     819          s = None
     820          if weight.upper() == 'MEDIAN':
     821              s = scantable(self._math._averagechannel(scan[0], 'MEDIAN', scanav))
     822          else:
     823              s = scantable(self._math._average(scan, mask, weight.upper(),
    818824                        scanav))
    819825        except RuntimeError,msg:
     
    822828                return
    823829            else: raise
    824         s._add_history("average_time",varlist)
    825         print_log()
    826         return s
    827 
    828     def average_channel(self, mode="MEDIAN", scanav=False, align=False):
    829         """
    830         Return the (median) average of a scan.
    831         Note:
    832             in channels only - align if necessary
    833             the median Tsys is computed.
    834         Parameters:
    835             one scan or comma separated  scans
    836             mode:     type of average, default "MEDIAN"
    837             scanav:   True averages each scan separately
    838                       False (default) averages all scans together,
    839             align:    align the spectra in velocity before averaging. It takes
    840                       the time of the first spectrum as reference time.
    841         Example:
    842             # median average the scan
    843             newscan = scan.average_channel()
    844         """
    845         varlist = vars()
    846         if mode is None: mode = 'MEDIAN'
    847         scanav = "NONE"
    848         if scanav: scanav = "SCAN"
    849         scan = self
    850         try:
    851           if align:
    852               scan = self.freq_align(insitu=False)
    853           s = scantable(self._math._averagechannel(scan, mode, scanav))
    854         except RuntimeError,msg:
    855             if rcParams['verbose']:
    856                 print msg
    857                 return
    858             else: raise
    859         s._add_history("average_channel",varlist)
     830        s._add_history("average_time", varlist)
    860831        print_log()
    861832        return s
Note: See TracChangeset for help on using the changeset viewer.