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 | """ |
---|
6 | from sans.guitools.plottables import Data1D |
---|
7 | from Loader import Load |
---|
8 | from scipy import optimize |
---|
9 | from ScipyFitting import ScipyFit |
---|
10 | from ParkFitting import ParkFit |
---|
11 | |
---|
12 | |
---|
13 | class Fit: |
---|
14 | """ |
---|
15 | Wrap class that allows to select the fitting type.this class |
---|
16 | can be used as follow : |
---|
17 | |
---|
18 | from sans.fit.Fitting import Fit |
---|
19 | fitter= Fit() |
---|
20 | fitter.fit_engine('scipy') or fitter.fit_engine('park') |
---|
21 | engine = fitter.returnEngine() |
---|
22 | engine.set_data(data,Uid) |
---|
23 | engine.set_param( model,model.name, pars) |
---|
24 | engine.set_model(model,Uid) |
---|
25 | |
---|
26 | chisqr1, out1, cov1=engine.fit(pars,qmin,qmax) |
---|
27 | """ |
---|
28 | def __init__(self): |
---|
29 | """ |
---|
30 | self._engine will contain an instance of ScipyFit or ParkFit |
---|
31 | """ |
---|
32 | self._engine=None |
---|
33 | |
---|
34 | def fit_engine(self,word): |
---|
35 | """ |
---|
36 | Select the type of Fit |
---|
37 | @param word: the keyword to select the fit type |
---|
38 | @raise: if the user does not enter 'scipy' or 'park', |
---|
39 | a valueError is rase |
---|
40 | """ |
---|
41 | if word=="scipy": |
---|
42 | self._engine=ScipyFit() |
---|
43 | elif word=="park": |
---|
44 | self._engine=ParkFit() |
---|
45 | else: |
---|
46 | raise ValueError, "enter the keyword scipy or park" |
---|
47 | def returnEngine(self): |
---|
48 | """ @return self._engine""" |
---|
49 | return self._engine |
---|
50 | |
---|
51 | def fit(self,pars, qmin=None, qmax=None): |
---|
52 | """Perform the fit """ |
---|
53 | |
---|
54 | def set_model(self,model,Uid): |
---|
55 | """ Set model """ |
---|
56 | |
---|
57 | def set_data(self,data,Uid): |
---|
58 | """ Receive plottable and create a list of data to fit""" |
---|
59 | |
---|
60 | def get_model(self,Uid): |
---|
61 | """ return list of data""" |
---|
62 | |
---|
63 | def set_param(self,model,name, pars): |
---|
64 | """ Recieve a dictionary of parameter and save it """ |
---|
65 | |
---|
66 | def remove_data(self,Uid,data=None): |
---|
67 | """ remove one or all data""" |
---|
68 | |
---|
69 | def remove_model(self,Uid): |
---|
70 | """ remove model """ |
---|
71 | |
---|