1 | from sans.fit.AbstractFitEngine import Model |
---|
2 | |
---|
3 | class FitProblem: |
---|
4 | """ |
---|
5 | FitProblem class allows to link a model with the new name created in _on_model, |
---|
6 | a name theory created with that model and the data fitted with the model. |
---|
7 | FitProblem is mostly used as value of the dictionary by fitting module. |
---|
8 | """ |
---|
9 | |
---|
10 | def __init__(self): |
---|
11 | |
---|
12 | """ |
---|
13 | @ self.data :is the data selected to perform the fit |
---|
14 | @ self.theory_name: the name of the theory created with self.model |
---|
15 | @ self.model_list: is a list containing a model as first element |
---|
16 | and its name assign example [lineModel, M0] |
---|
17 | """ |
---|
18 | self.data=None |
---|
19 | self.theory_name=None |
---|
20 | self.model_list=[] |
---|
21 | |
---|
22 | def set_model(self,model,name): |
---|
23 | """ |
---|
24 | associates each model with its new created name |
---|
25 | @param model: model selected |
---|
26 | @param name: name created for model |
---|
27 | """ |
---|
28 | self.model_list=[model,name] |
---|
29 | |
---|
30 | |
---|
31 | def add_data(self,data): |
---|
32 | """ |
---|
33 | save a copy of the data select to fit |
---|
34 | @param data: data selected |
---|
35 | """ |
---|
36 | self.data = data |
---|
37 | |
---|
38 | def get_model(self): |
---|
39 | """ @return: saved model """ |
---|
40 | return self.model_list |
---|
41 | |
---|
42 | def get_data(self): |
---|
43 | """ @return: list of data dList""" |
---|
44 | return self.data |
---|
45 | |
---|
46 | |
---|
47 | def get_theory(self): |
---|
48 | """ @return the name of theory for plotting purpose""" |
---|
49 | return self.theory_name |
---|
50 | |
---|
51 | |
---|
52 | def set_theory(self,name): |
---|
53 | """ |
---|
54 | Set theory name |
---|
55 | @param name: name of the theory |
---|
56 | """ |
---|
57 | self.theory_name = name |
---|
58 | |
---|
59 | |
---|
60 | def set_model_param(self,name,value): |
---|
61 | """ |
---|
62 | set the value of a given parameter of this model |
---|
63 | @param name: name of the given parameter |
---|
64 | @param value: value of that parameter |
---|
65 | """ |
---|
66 | |
---|
67 | self.model_list[0].setParam(name,value) |
---|
68 | |
---|
69 | |
---|
70 | def reset_model(self,model): |
---|
71 | """ |
---|
72 | reset a model when parameter has changed |
---|
73 | @param value: new model |
---|
74 | """ |
---|
75 | print "fitproblem : reset model" |
---|
76 | self.model_list[0]=model |
---|
77 | |
---|
78 | |
---|