Changeset 1061 for trunk/python


Ignore:
Timestamp:
06/08/06 13:59:51 (19 years ago)
Author:
mar637
Message:

Added feature Ticket #42; The user can now plot the fits adn reject them.

Location:
trunk/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapfitter.py

    r1039 r1061  
    322322                fix = ""
    323323                if fixed[i]: fix = "(fixed)"
    324                 out += '  p%d%s= %3.3f,' % (c,fix,pars[i])
     324                out += '  p%d%s= %3.6f,' % (c,fix,pars[i])
    325325                c+=1
    326326            out = out[:-1]  # remove trailing ','
     
    491491        print_log()
    492492
    493     def auto_fit(self, insitu=None):
     493    def auto_fit(self, insitu=None, plot=False):
    494494        """
    495495        Return a scan where the function is applied to all rows for
     
    521521            self.fit()
    522522            x = self.get_parameters()
     523            if plot:
     524                self.plot(residual=True)
     525                x = raw_input("Accept fit ([y]/n): ")
     526                if x.upper() == 'N':
     527                    continue
    523528            scan._setspectrum(self.fitter.getresidual(), r)
     529        if plot:
     530            self._p.unmap()
     531            self._p = None
    524532        print_log()
    525533        return scan
  • trunk/python/scantable.py

    r1033 r1061  
    10331033
    10341034
    1035     def poly_baseline(self, mask=None, order=0, insitu=None):
     1035    def poly_baseline(self, mask=None, order=0, plot=False, insitu=None):
    10361036        """
    10371037        Return a scan which has been baselined (all rows) by a polynomial.
     
    10401040            mask:       an optional mask
    10411041            order:      the order of the polynomial (default is 0)
     1042            plot:       plot the fit and the residual. In this each
     1043                        indivual fit has to be approved, by typing 'y'
     1044                        or 'n'
    10421045            insitu:     if False a new scantable is returned.
    10431046                        Otherwise, the scaling is done in-situ
    10441047                        The default is taken from .asaprc (False)
    1045             allaxes:    If True (default) apply to all spectra. Otherwise
    1046                         apply only to the selected (beam/pol/if)spectra only
    1047                         The default is taken from .asaprc (True if none)
    10481048        Example:
    10491049            # return a scan baselined by a third order polynomial,
     
    10601060        f.set_scan(self, mask)
    10611061        f.set_function(poly=order)
    1062         s = f.auto_fit(insitu)
     1062        s = f.auto_fit(insitu, plot=plot)
    10631063        s._add_history("poly_baseline", varlist)
    10641064        print_log()
     
    10671067
    10681068    def auto_poly_baseline(self, mask=[], edge=(0,0), order=0,
    1069                            threshold=3, insitu=None):
     1069                           threshold=3, plot=False, insitu=None):
    10701070        """
    10711071        Return a scan which has been baselined (all rows) by a polynomial.
     
    10861086                        keep it large as only strong lines affect the
    10871087                        baseline solution.
     1088            plot:       plot the fit and the residual. In this each
     1089                        indivual fit has to be approved, by typing 'y'
     1090                        or 'n'
    10881091            insitu:     if False a new scantable is returned.
    10891092                        Otherwise, the scaling is done in-situ
     
    11551158            f.fit()
    11561159            x = f.get_parameters()
     1160            if plot:
     1161                f.plot(residual=True)
     1162                x = raw_input("Accept fit ( [y]/n ): ")
     1163                if x.upper() == 'N':
     1164                    continue
    11571165            workscan._setspectrum(f.fitter.getresidual(), r)
    1158         workscan._add_history("poly_baseline", varlist)
     1166        if plot:
     1167            f._p.unmap()
     1168            f._p = None
     1169        workscan._add_history("auto_poly_baseline", varlist)
    11591170        if insitu:
    11601171            self._assign(workscan)
Note: See TracChangeset for help on using the changeset viewer.