source: sasview/park_integration/Fitting.py @ 3a848b2

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 3a848b2 was 393f0f3, checked in by Jae Cho <jhjcho@…>, 15 years ago

revert previous commits asked by ga.

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[792db7d5]1"""
2    @organization: Class Fit contains ScipyFit and ParkFit methods declaration
3    allows to create instance of type ScipyFit or ParkFit to perform either
4    a park fit or a scipy fit.
5"""
[d8a2e31]6
[7705306]7from scipy import optimize
8from ScipyFitting import ScipyFit
9from ParkFitting import ParkFit
10
11
12class Fit:
13    """
[792db7d5]14        Wrap class that allows to select the fitting type.this class
15        can be used as follow :
16       
17        from sans.fit.Fitting import Fit
18        fitter= Fit()
19        fitter.fit_engine('scipy') or fitter.fit_engine('park')
20        engine = fitter.returnEngine()
21        engine.set_data(data,Uid)
22        engine.set_param( model,model.name, pars)
23        engine.set_model(model,Uid)
[393f0f3]24       
[792db7d5]25        chisqr1, out1, cov1=engine.fit(pars,qmin,qmax)
[7705306]26    """ 
[93f0a586]27    def __init__(self, engine='scipy'):
[792db7d5]28        """
29            self._engine will contain an instance of ScipyFit or ParkFit
30        """
[20d30e9]31        self._engine = None
[93f0a586]32        self.set_engine(engine)
[7705306]33         
[20d30e9]34         
[93f0a586]35    def set_engine(self,word):
[7705306]36        """
37            Select the type of Fit
38            @param word: the keyword to select the fit type
[792db7d5]39            @raise: if the user does not enter 'scipy' or 'park',
40             a valueError is rase
[7705306]41        """
42        if word=="scipy":
43            self._engine=ScipyFit()
44        elif word=="park":
45            self._engine=ParkFit()
46        else:
47            raise ValueError, "enter the keyword scipy or park"
[ca6d914]48       
[20d30e9]49   
[7705306]50   
[fd6b789]51    def fit(self,q=None,handler=None, curr_thread=None):
[792db7d5]52        """Perform the fit """
[a6a7e8a]53        try:
[fd6b789]54            return self._engine.fit(q,handler, curr_thread= curr_thread)
[a6a7e8a]55        except:
56            raise
[20d30e9]57   
[d8a2e31]58   
[fd6b789]59    def set_model(self,model,Uid,pars=[],constraints=[]):
[20d30e9]60        """
61        store a model model to fit at the position Uid of the fit engine
62        """
[fd6b789]63        self._engine.set_model(model,Uid,pars,constraints)
[20d30e9]64   
[48882d1]65   
[20d30e9]66    def set_data(self,data,Uid,smearer=None,qmin=None, qmax=None):
67        """
68            Store data to fit at the psotion Uid of the fit engine
69            @param data: data to fit
70            @param smearer: smearerobject to smear data
71            @param qmin: the minimum q range to fit
72            @param qmax: the minimum q range to fit
73        """
74        self._engine.set_data(data,Uid,smearer,qmin, qmax)
75       
[ca6d914]76       
[7705306]77    def get_model(self,Uid):
78        """ return list of data"""
[4dd63eb]79        self._engine.get_model(Uid)
[9855699]80
[20d30e9]81
[4dd63eb]82    def remove_Fit_Problem(self,Uid):
83        """remove   fitarrange in Uid"""
84        self._engine.remove_Fit_Problem(Uid)
[ca6d914]85       
[20d30e9]86       
[a9e04aa]87    def select_problem_for_fit(self,Uid,value):
88        """
89            select a couple of model and data at the Uid position in dictionary
90            and set in self.selected value to value
91            @param value: the value to allow fitting. can only have the value one or zero
92        """
93        self._engine.select_problem_for_fit(Uid,value)
[ca6d914]94       
[20d30e9]95       
[a9e04aa]96    def get_problem_to_fit(self,Uid):
97        """
98            return the self.selected value of the fit problem of Uid
99           @param Uid: the Uid of the problem
100        """
101        return self._engine.get_problem_to_fit(Uid)
Note: See TracBrowser for help on using the repository browser.