Changeset 946 for trunk/python


Ignore:
Timestamp:
03/30/06 15:39:30 (19 years ago)
Author:
mar637
Message:

re-enabled average_pol; made use of selector class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r936 r946  
    22from asap import rcParams
    33from asap import print_log
     4from asap import selector
    45from numarray import ones,zeros
    56import sys
     
    175176
    176177        try:
    177             bsel = self._getselection()
    178             sel = asap._asap.Selector()
     178            bsel = self.get_selection()
     179            sel = selector()
    179180            if type(scanid) is str:
    180                 sel._setname()
    181                 self._setselection(sel)
     181                sel.set_name(scanid)
     182                self.set_selection(bsel+sel)
    182183                scopy = self._copy()
    183                 self._setselection(bsel)
     184                self.set_selection(bsel)
    184185                return scantable(scopy)
    185186            elif type(scanid) is int:
    186                 sel._setscans([scanid])
    187                 self._setselection(sel)
     187                sel.set_scans([scanid])
     188                self.set_selection(bsel+sel)
    188189                scopy = self._copy()
    189                 self._setselection(bsel)
     190                self.set_selection(bsel)
    190191                return scantable(scopy)
    191192            elif type(scanid) is list:
    192                 sel._setscans(scanid)
    193                 self._setselection(sel)
     193                sel.set_scans(scanid)
     194                self.set_selection(sel)
    194195                scopy = self._copy()
    195                 self._setselection(bsel)
     196                self.set_selection(bsel)
    196197                return scantable(scopy)
    197198            else:
     
    242243        else:
    243244            return info
     245
     246
     247    def get_selection(self):
     248        """
     249        """
     250        return selector(self._getselection())
     251
     252    def set_selection(self, selection):
     253        """
     254        """
     255        self._setselection(selection)
    244256
    245257    def set_cursor(self, beam=0, IF=0, pol=0):
     
    693705        elif isinstance(freqs, list) or isinstance(freqs,tuple):
    694706            if isinstance(freqs[-1], int) or isinstance(freqs[-1],float):
    695                 from asap._asap import selector
    696707                sel = selector()
    697708                savesel = self._getselection()
    698709                for i in xrange(len(freqs)):
    699                     sel._setifs([i])
     710                    sel.set_ifs([i])
    700711                    self._setselection(sel)
    701712                    self._setrestfreqs(freqs[i], unit)
     
    942953
    943954
    944 #     def average_pol(self, mask=None, weight='none', insitu=None):
    945 #         """
    946 #         Average the Polarisations together.
    947 #         The polarisation cursor of the output scan is set to 0
    948 #         Parameters:
    949 #             mask:        An optional mask defining the region, where the
    950 #                          averaging will be applied. The output will have all
    951 #                          specified points masked.
    952 #             weight:      Weighting scheme. 'none' (default), 'var' (1/var(spec)
    953 #                          weighted), or 'tsys' (1/Tsys**2 weighted)
    954 #             insitu:      if False a new scantable is returned.
    955 #                          Otherwise, the scaling is done in-situ
    956 #                          The default is taken from .asaprc (False)
    957 #         """
    958 #         if insitu is None: insitu = rcParams['insitu']
    959 #         self._math._setinsitu(insitu)
    960 #         varlist = vars()
    961 #
    962 #         if mask is None:
    963 #         mask = ()
    964 #         s = self._math._averagepol(self, mask, weight)
    965 #         s._add_history("average_pol",varlist)
    966 #         print_log()
    967 #         if insitu: self._assign(s)
    968 #         else: return scantable(s)
     955    def average_pol(self, mask=None, weight='none'):
     956        """
     957        Average the Polarisations together.
     958        Parameters:
     959            mask:        An optional mask defining the region, where the
     960                         averaging will be applied. The output will have all
     961                         specified points masked.
     962            weight:      Weighting scheme. 'none' (default), 'var' (1/var(spec)
     963                         weighted), or 'tsys' (1/Tsys**2 weighted)
     964        """
     965        varlist = vars()
     966        if mask is None:
     967            mask = ()
     968        s = self._math._averagepol(self, mask, weight)
     969        s._add_history("average_pol",varlist)
     970        print_log()
     971        return scantable(s)
    969972
    970973    def smooth(self, kernel="hanning", width=5.0, insitu=None):
Note: See TracChangeset for help on using the changeset viewer.