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 | ## data used for fitting |
---|
19 | self.fit_data=None |
---|
20 | ## list containing couple of model and its name |
---|
21 | self.model_list=[] |
---|
22 | ## if 1 this fit problem will be selected to fit , if 0 |
---|
23 | ## it will not be selected for fit |
---|
24 | self.schedule=0 |
---|
25 | ##list containing parameter name and value |
---|
26 | self.list_param=[] |
---|
27 | ## smear object to smear or not data1D |
---|
28 | self.smearer= None |
---|
29 | ## same as fit_data but with more info for plotting |
---|
30 | ## axis unit info and so on see plottables definition |
---|
31 | self.plotted_data=None |
---|
32 | |
---|
33 | |
---|
34 | def set_smearer(self, smearer): |
---|
35 | """ |
---|
36 | save reference of smear object on fitdata |
---|
37 | @param smear : smear object from DataLoader |
---|
38 | """ |
---|
39 | self.smearer= smearer |
---|
40 | |
---|
41 | def get_smearer(self): |
---|
42 | """ |
---|
43 | return smear object |
---|
44 | """ |
---|
45 | return self.smearer |
---|
46 | |
---|
47 | def save_model_name(self, name): |
---|
48 | self.name_per_page= name |
---|
49 | |
---|
50 | |
---|
51 | def get_name(self): |
---|
52 | return self.name_per_page |
---|
53 | |
---|
54 | def set_model(self,model,name): |
---|
55 | """ |
---|
56 | associates each model with its new created name |
---|
57 | @param model: model selected |
---|
58 | @param name: name created for model |
---|
59 | """ |
---|
60 | |
---|
61 | if len(self.model_list)>0 and name==None: |
---|
62 | self.model_list=[model,self.model_list[1]] |
---|
63 | else: |
---|
64 | self.model_list=[model,name] |
---|
65 | |
---|
66 | |
---|
67 | def add_plotted_data(self,data): |
---|
68 | """ |
---|
69 | save a copy of the data select to fit |
---|
70 | @param data: data selected |
---|
71 | """ |
---|
72 | self.plotted_data = data |
---|
73 | |
---|
74 | |
---|
75 | def add_fit_data(self,data): |
---|
76 | """ |
---|
77 | save a copy of the data select to fit |
---|
78 | @param data: data selected |
---|
79 | """ |
---|
80 | self.fit_data = data |
---|
81 | |
---|
82 | def get_model(self): |
---|
83 | """ @return: saved model """ |
---|
84 | return self.model_list |
---|
85 | |
---|
86 | def get_plotted_data(self): |
---|
87 | """ @return: list of data dList""" |
---|
88 | return self.plotted_data |
---|
89 | |
---|
90 | |
---|
91 | def get_fit_data(self): |
---|
92 | return self.fit_data |
---|
93 | |
---|
94 | |
---|
95 | def get_theory(self): |
---|
96 | """ @return the name of theory for plotting purpose""" |
---|
97 | return self.theory_name |
---|
98 | |
---|
99 | |
---|
100 | def set_theory(self,name): |
---|
101 | """ |
---|
102 | Set theory name |
---|
103 | @param name: name of the theory |
---|
104 | """ |
---|
105 | self.theory_name = name |
---|
106 | |
---|
107 | |
---|
108 | def set_model_param(self,name,value): |
---|
109 | """ |
---|
110 | Store the name and value of a parameter of this fitproblem's model |
---|
111 | @param name: name of the given parameter |
---|
112 | @param value: value of that parameter |
---|
113 | """ |
---|
114 | self.list_param.append([name,value]) |
---|
115 | |
---|
116 | |
---|
117 | def get_model_param(self): |
---|
118 | """ |
---|
119 | @return list of couple of parameter name and value |
---|
120 | """ |
---|
121 | return self.list_param |
---|
122 | |
---|
123 | |
---|
124 | def reset_model(self,model): |
---|
125 | """ |
---|
126 | reset a model when parameter has changed |
---|
127 | @param value: new model |
---|
128 | """ |
---|
129 | self.model_list[0]=model |
---|
130 | |
---|
131 | |
---|
132 | def schedule_tofit(self, schedule=0): |
---|
133 | """ |
---|
134 | set schedule to true to decide if this fit must be performed |
---|
135 | """ |
---|
136 | self.schedule=schedule |
---|
137 | |
---|
138 | def get_scheduled(self): |
---|
139 | """ return true or false if a problem as being schedule for fitting""" |
---|
140 | return self.schedule |
---|
141 | |
---|
142 | |
---|
143 | def clear_model_param(self): |
---|
144 | """ |
---|
145 | clear constraint info |
---|
146 | """ |
---|
147 | self.list_param=[] |
---|
148 | |
---|
149 | |
---|