Ignore:
Timestamp:
09/01/06 10:45:58 (18 years ago)
Author:
mar637
Message:

small fix to _format_pars to test for length. Ticket #44 - fit can be saved as ASCII via fitter.store_fit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/Release2.1.0b/python/asapfitter.py

    r1228 r1230  
    156156        return
    157157
    158     def store_fit(self):
    159         """
    160         Store the fit parameters in the scantable.
     158    def store_fit(self, filename=None):
     159        """
     160        Save the fit parameters.
     161        Parameters:
     162            filename:    if specified save as an ASCII file, if None (default)
     163                         store it in the scnatable
    161164        """
    162165        if self.fitted and self.data is not None:
     
    170173            fit.setcomponents(self.components)
    171174            fit.setframeinfo(self.data._getcoordinfo())
    172             self.data._addfit(fit,self._fittedrow)
     175            if filename is not None:
     176                import os
     177                filename = os.path.expandvars(os.path.expanduser(filename))
     178                if os.path.exists(filename):
     179                    raise IOError("File '%s' exists." % filename)
     180                fit.save(filename)
     181            else:
     182                self.data._addfit(fit,self._fittedrow)
    173183
    174184    #def set_parameters(self, params, fixed=None, component=None):
     
    353363            for i in range(len(pars)):
    354364                fix = ""
    355                 if fixed[i]: fix = "(fixed)"
     365                if len(fixed) and fixed[i]: fix = "(fixed)"
    356366                if errors :
    357367                    out += '  p%d%s= %3.6f (%1.6f),' % (c,fix,pars[i], errors[i])
Note: See TracChangeset for help on using the changeset viewer.