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 | self.schedule='False' |
---|
22 | self.param_name= None |
---|
23 | self.param_value=None |
---|
24 | |
---|
25 | def set_model(self,model,name): |
---|
26 | """ |
---|
27 | associates each model with its new created name |
---|
28 | @param model: model selected |
---|
29 | @param name: name created for model |
---|
30 | """ |
---|
31 | self.model_list=[model,name] |
---|
32 | |
---|
33 | |
---|
34 | def add_data(self,data): |
---|
35 | """ |
---|
36 | save a copy of the data select to fit |
---|
37 | @param data: data selected |
---|
38 | """ |
---|
39 | self.data = data |
---|
40 | |
---|
41 | def get_model(self): |
---|
42 | """ @return: saved model """ |
---|
43 | print "fitproblem",self.model_list |
---|
44 | return self.model_list |
---|
45 | |
---|
46 | def get_data(self): |
---|
47 | """ @return: list of data dList""" |
---|
48 | return self.data |
---|
49 | |
---|
50 | |
---|
51 | def get_theory(self): |
---|
52 | """ @return the name of theory for plotting purpose""" |
---|
53 | return self.theory_name |
---|
54 | |
---|
55 | |
---|
56 | def set_theory(self,name): |
---|
57 | """ |
---|
58 | Set theory name |
---|
59 | @param name: name of the theory |
---|
60 | """ |
---|
61 | self.theory_name = name |
---|
62 | |
---|
63 | |
---|
64 | def set_model_param(self,name,value): |
---|
65 | """ |
---|
66 | set the value of a given parameter of this model |
---|
67 | @param name: name of the given parameter |
---|
68 | @param value: value of that parameter |
---|
69 | """ |
---|
70 | print "fitproblem",name,value |
---|
71 | #self.model_list[0].setParam(name,value) |
---|
72 | self.param_name = name |
---|
73 | self.param_value= value |
---|
74 | def get_model_param(self): |
---|
75 | """ |
---|
76 | set the value of a given parameter of this model |
---|
77 | @param name: name of the given parameter |
---|
78 | @param value: value of that parameter |
---|
79 | """ |
---|
80 | print self.param_name, self.param_value |
---|
81 | #self.model_list[0].setParam(name,value) |
---|
82 | return self.param_name, self.param_value |
---|
83 | |
---|
84 | def reset_model(self,model): |
---|
85 | """ |
---|
86 | reset a model when parameter has changed |
---|
87 | @param value: new model |
---|
88 | """ |
---|
89 | print "fitproblem : reset model" |
---|
90 | self.model_list[0]=model |
---|
91 | |
---|
92 | def schedule_tofit(self, schedule='False'): |
---|
93 | """ |
---|
94 | set schedule to true to decide if this fit must be performed |
---|
95 | """ |
---|
96 | self.schedule=schedule |
---|
97 | def get_scheduled(self): |
---|
98 | """ return true or false if a problem as being schedule for fitting""" |
---|
99 | return self.schedule |
---|
100 | |
---|
101 | |
---|