1 | |
---|
2 | class FitProblem: |
---|
3 | """ |
---|
4 | FitProblem class allows to link a model with the new name created in _on_model, |
---|
5 | a name theory created with that model and the data fitted with the model. |
---|
6 | FitProblem is mostly used as value of the dictionary by fitting module. |
---|
7 | """ |
---|
8 | |
---|
9 | def __init__(self): |
---|
10 | |
---|
11 | """ |
---|
12 | contains information about data and model to fit |
---|
13 | """ |
---|
14 | ## data used for fitting |
---|
15 | self.fit_data=None |
---|
16 | ## the current model |
---|
17 | self.model = None |
---|
18 | ## if 1 this fit problem will be selected to fit , if 0 |
---|
19 | ## it will not be selected for fit |
---|
20 | self.schedule=0 |
---|
21 | ##list containing parameter name and value |
---|
22 | self.list_param=[] |
---|
23 | ## smear object to smear or not data1D |
---|
24 | self.smearer= None |
---|
25 | ## same as fit_data but with more info for plotting |
---|
26 | ## axis unit info and so on see plottables definition |
---|
27 | self.plotted_data=None |
---|
28 | ## fitting range |
---|
29 | self.qmin = None |
---|
30 | self.qmax = None |
---|
31 | |
---|
32 | def clone(self): |
---|
33 | """ |
---|
34 | copy fitproblem |
---|
35 | """ |
---|
36 | import copy |
---|
37 | obj = FitProblem( self.parent,model= model ) |
---|
38 | obj.fit_data = copy.deepcopy(self.fit_data) |
---|
39 | obj.model = copy.deepcopy(self.model) |
---|
40 | obj.schedule = copy.deepcopy(self.schedule) |
---|
41 | obj.list_param = copy.deepcopy(self.list_param) |
---|
42 | obj.smearer = copy.deepcopy(self.smearer) |
---|
43 | obj.plotted_data = copy.deepcopy(self.plotted_data) |
---|
44 | obj.qmin = copy.deepcopy(self.qmin) |
---|
45 | obj.qmax = copy.deepcopy(self.qmax) |
---|
46 | |
---|
47 | return obj |
---|
48 | |
---|
49 | |
---|
50 | def set_smearer(self, smearer): |
---|
51 | """ |
---|
52 | save reference of smear object on fitdata |
---|
53 | @param smear : smear object from DataLoader |
---|
54 | """ |
---|
55 | self.smearer= smearer |
---|
56 | |
---|
57 | def get_smearer(self): |
---|
58 | """ |
---|
59 | return smear object |
---|
60 | """ |
---|
61 | return self.smearer |
---|
62 | |
---|
63 | def save_model_name(self, name): |
---|
64 | self.name_per_page= name |
---|
65 | |
---|
66 | |
---|
67 | def get_name(self): |
---|
68 | return self.name_per_page |
---|
69 | |
---|
70 | def set_model(self,model): |
---|
71 | """ |
---|
72 | associates each model with its new created name |
---|
73 | @param model: model selected |
---|
74 | @param name: name created for model |
---|
75 | """ |
---|
76 | self.model= model |
---|
77 | |
---|
78 | |
---|
79 | def get_model(self): |
---|
80 | """ @return: saved model """ |
---|
81 | return self.model |
---|
82 | |
---|
83 | |
---|
84 | def add_plotted_data(self,data): |
---|
85 | """ |
---|
86 | save a copy of the data select to fit |
---|
87 | @param data: data selected |
---|
88 | """ |
---|
89 | self.plotted_data = data |
---|
90 | |
---|
91 | |
---|
92 | def get_plotted_data(self): |
---|
93 | """ @return: list of data dList""" |
---|
94 | return self.plotted_data |
---|
95 | |
---|
96 | |
---|
97 | def add_fit_data(self,data): |
---|
98 | """ |
---|
99 | save a copy of the data select to fit |
---|
100 | @param data: data selected |
---|
101 | """ |
---|
102 | self.fit_data = data |
---|
103 | |
---|
104 | |
---|
105 | def get_fit_data(self): |
---|
106 | return self.fit_data |
---|
107 | |
---|
108 | |
---|
109 | def set_model_param(self,name,value=None): |
---|
110 | """ |
---|
111 | Store the name and value of a parameter of this fitproblem's model |
---|
112 | @param name: name of the given parameter |
---|
113 | @param value: value of that parameter |
---|
114 | """ |
---|
115 | self.list_param.append([name,value]) |
---|
116 | |
---|
117 | |
---|
118 | def get_model_param(self): |
---|
119 | """ |
---|
120 | @return list of couple of parameter name and value |
---|
121 | """ |
---|
122 | return self.list_param |
---|
123 | |
---|
124 | |
---|
125 | def schedule_tofit(self, schedule=0): |
---|
126 | """ |
---|
127 | set schedule to true to decide if this fit must be performed |
---|
128 | """ |
---|
129 | self.schedule=schedule |
---|
130 | |
---|
131 | |
---|
132 | def get_scheduled(self): |
---|
133 | """ return true or false if a problem as being schedule for fitting""" |
---|
134 | return self.schedule |
---|
135 | |
---|
136 | |
---|
137 | def set_range(self, qmin=None, qmax=None): |
---|
138 | """ |
---|
139 | set fitting range |
---|
140 | """ |
---|
141 | self.qmin = qmin |
---|
142 | self.qmax = qmax |
---|
143 | |
---|
144 | |
---|
145 | def get_range(self): |
---|
146 | """ |
---|
147 | @return fitting range: |
---|
148 | """ |
---|
149 | return self.qmin, self.qmax |
---|
150 | |
---|
151 | def clear_model_param(self): |
---|
152 | """ |
---|
153 | clear constraint info |
---|
154 | """ |
---|
155 | self.list_param=[] |
---|
156 | |
---|
157 | |
---|
158 | |
---|
159 | |
---|