Changeset 1857


Ignore:
Timestamp:
08/05/10 11:45:38 (14 years ago)
Author:
Malte Marquarding
Message:

auto_quotient is the first method to use @preserve_selection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r1856 r1857  
    2222    def wrap(obj, *args, **kw):
    2323        basesel = obj.get_selection()
    24         val = func(obj, *args, **kw)
    25         obj.set_selection(basesel)
     24        try:
     25            val = func(obj, *args, **kw)
     26        finally:
     27            obj.set_selection(basesel)
    2628        return val
    2729    return wrap
     
    14751477        for h in hist:
    14761478            if h.startswith("---"):
    1477                 out += "\n"+h
     1479                out = "\n".join([out, h])
    14781480            else:
    14791481                items = h.split("##")
     
    14861488                    s = i.split("=")
    14871489                    out += "\n   %s = %s" % (s[0], s[1])
    1488                 out += "\n"+"-"*80
     1490                out = "\n".join([out, "-"*80])
    14891491        if filename is not None:
    14901492            if filename is "":
     
    23632365
    23642366    @print_log_dec
     2367    @preserve_selection
    23652368    def auto_quotient(self, preserve=True, mode='paired', verify=False):
    23662369        """\
     
    23732376            preserve:       you can preserve (default) the continuum or
    23742377                            remove it.  The equations used are
     2378
    23752379                            preserve: Output = Toff * (on/off) - Toff
     2380
    23762381                            remove:   Output = Toff * (on/off) - Ton
    23772382
     
    23852390                            finds the closest off in time
    23862391
    2387         """
     2392        .. todo:: verify argument is not implemented
     2393
     2394        """
     2395        varlist = vars()
    23882396        modes = ["time", "paired"]
    23892397        if not mode in modes:
    23902398            msg = "please provide valid mode. Valid modes are %s" % (modes)
    23912399            raise ValueError(msg)
    2392         varlist = vars()
    23932400        s = None
    23942401        if mode.lower() == "paired":
    2395             basesel = self.get_selection()
    2396             sel = selector()+basesel
     2402            sel = self.get_selection()
    23972403            sel.set_query("SRCTYPE==1")
    23982404            self.set_selection(sel)
     
    24022408            ons = self.copy()
    24032409            s = scantable(self._math._quotient(ons, offs, preserve))
    2404             self.set_selection(basesel)
    24052410        elif mode.lower() == "time":
    24062411            s = scantable(self._math._auto_quotient(self, mode, preserve))
Note: See TracChangeset for help on using the changeset viewer.