Changeset 1070 for trunk


Ignore:
Timestamp:
07/04/06 14:45:26 (18 years ago)
Author:
mar637
Message:

enhancement ticket #35. median scantable; also added get_column

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r1061 r1070  
    377377        return retval
    378378
     379    def _get_column(self, callback, row=-1):
     380        """
     381        """
     382        if row == -1:
     383            return [callback(i) for i in range(self.nrow())]
     384        else:
     385            if  0 <= row < self.nrow():
     386                return callback(row)
     387
    379388
    380389    def get_time(self, row=-1):
     
    387396            none
    388397        """
    389         out = []
    390         if row == -1:
    391             for i in range(self.nrow()):
    392                 out.append(self._gettime(i))
    393             return out
    394         else:
    395             if row < self.nrow():
    396                 return self._gettime(row)
     398        return self._get_column(self._gettime, row)
    397399
    398400    def get_sourcename(self, row=-1):
     
    405407            none
    406408        """
    407         out = []
    408         if row == -1:
    409             return [self._getsourcename(i) for i in range(self.nrow())]
    410         else:
    411             if  0 <= row < self.nrow():
    412                 return self._getsourcename(row)
     409        return self._get_column(self._getsourcename, row)
    413410
    414411    def get_elevation(self, row=-1):
     
    421418            none
    422419        """
    423         out = []
    424         if row == -1:
    425             return [self._getelevation(i) for i in range(self.nrow())]
    426         else:
    427             if  0 <= row < self.nrow():
    428                 return self._getelevation(row)
     420        return self._get_column(self._getelevation, row)
    429421
    430422    def get_azimuth(self, row=-1):
     
    437429            none
    438430        """
    439         out = []
    440         if row == -1:
    441             return [self._getazimuth(i) for i in range(self.nrow())]
    442         else:
    443             if  0 <= row < self.nrow():
    444                 return self._getazimuth(row)
     431        return self._get_column(self._getazimuth, row)
    445432
    446433    def get_parangle(self, row=-1):
     
    453440            none
    454441        """
    455         out = []
    456         if row == -1:
    457             return [self._getparangle(i) for i in range(self.nrow())]
    458         else:
    459             if  0 <= row < self.nrow():
    460                 return self._getparangle(row)
     442        return self._get_column(self._getparangle, row)
     443
     444    def get_direction(self, row=-1):
     445        """
     446        Get a list of Positions on the sky (direction) for the observations.
     447        Return a float for each integration in the scantable.
     448        Parameters:
     449            row:    row no of integration. Default -1 return all rows
     450        Example:
     451            none
     452        """
     453        return self._get_column(self._getdirection, row)
    461454
    462455    def set_unit(self, unit='channel'):
     
    756749    def average_time(self, mask=None, scanav=False, weight='tint', align=False):
    757750        """
    758         Return the (time) average of a scan, or apply it 'insitu'.
     751        Return the (time) weighted average of a scan.
    759752        Note:
    760             in channels only
    761             The cursor of the output scan is set to 0.
     753            in channels only - align if necessary
    762754        Parameters:
    763755            one scan or comma separated  scans
     
    795787            else: raise
    796788        s._add_history("average_time",varlist)
     789        print_log()
     790        return s
     791
     792    def average_channel(self, mode="MEDIAN", align=False):
     793        """
     794        Return the (median) average of a scan.
     795        Note:
     796            in channels only - align if necessary
     797            the mdeian Tsys is computed.
     798        Parameters:
     799            one scan or comma separated  scans
     800            mode:     type of average, default "MEDIAN"
     801            align:    align the spectra in velocity before averaging. It takes
     802                      the time of the first spectrum as reference time.
     803        Example:
     804            # mdeian average the scan
     805            newscan = scan.average_channel()
     806        """
     807        varlist = vars()
     808        if mode is None: mode = 'MEDIAN'
     809        scan = self
     810        try:
     811          if align:
     812              scan = self.freq_align(insitu=False)
     813          s = scantable(self._math._averagechannel(scan, mode))
     814        except RuntimeError,msg:
     815            if rcParams['verbose']:
     816                print msg
     817                return
     818            else: raise
     819        s._add_history("average_channel",varlist)
    797820        print_log()
    798821        return s
     
    12821305                            remove it.  The equations used are
    12831306                            preserve: Output = Toff * (on/off) - Toff
    1284                             remove:   Output = Tref * (on/off) - Ton
     1307                            remove:   Output = Toff * (on/off) - Ton
    12851308        """
    12861309        modes = ["time"]
     
    12891312            raise ValueError(msg)
    12901313        varlist = vars()
    1291         s = scantable(self._math._quotient(self, mode, preserve))
     1314        s = scantable(self._math._auto_quotient(self, mode, preserve))
    12921315        s._add_history("auto_quotient",varlist)
    12931316        print_log()
Note: See TracChangeset for help on using the changeset viewer.