1 | ################################################################################ |
---|
2 | #This software was developed by the University of Tennessee as part of the |
---|
3 | #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
4 | #project funded by the US National Science Foundation. |
---|
5 | # |
---|
6 | #See the license text in license.txt |
---|
7 | # |
---|
8 | #copyright 2009, University of Tennessee |
---|
9 | ################################################################################ |
---|
10 | import copy |
---|
11 | from sans.models.qsmearing import smear_selection |
---|
12 | |
---|
13 | |
---|
14 | class FitProblemComponent(object): |
---|
15 | """ |
---|
16 | Inferface containing information to store data, model, range of data, etc... |
---|
17 | and retreive this information. This is an inferface |
---|
18 | for a fitProblem i.e relationship between data and model. |
---|
19 | """ |
---|
20 | def enable_smearing(self, flag=False): |
---|
21 | """ |
---|
22 | :param flag: bool.When flag is 1 get the computer smear value. When |
---|
23 | flag is 0 ingore smear value. |
---|
24 | """ |
---|
25 | def get_smearer(self): |
---|
26 | """ |
---|
27 | return smear object |
---|
28 | """ |
---|
29 | def save_model_name(self, name): |
---|
30 | """ |
---|
31 | """ |
---|
32 | def get_name(self): |
---|
33 | """ |
---|
34 | """ |
---|
35 | def set_model(self, model): |
---|
36 | """ |
---|
37 | associates each model with its new created name |
---|
38 | :param model: model selected |
---|
39 | :param name: name created for model |
---|
40 | """ |
---|
41 | def get_model(self): |
---|
42 | """ |
---|
43 | :return: saved model |
---|
44 | """ |
---|
45 | def set_residuals(self, residuals): |
---|
46 | """ |
---|
47 | save a copy of residual |
---|
48 | :param data: data selected |
---|
49 | """ |
---|
50 | def get_residuals(self): |
---|
51 | """ |
---|
52 | :return: residuals |
---|
53 | """ |
---|
54 | |
---|
55 | def set_theory_data(self, data): |
---|
56 | """ |
---|
57 | save a copy of the data select to fit |
---|
58 | :param data: data selected |
---|
59 | """ |
---|
60 | def get_theory_data(self): |
---|
61 | """ |
---|
62 | :return: list of data dList |
---|
63 | """ |
---|
64 | def set_fit_data(self, data): |
---|
65 | """ |
---|
66 | Store of list of data and create by create new fitproblem of each data |
---|
67 | id , if there was existing information about model, this information |
---|
68 | get copy to the new fitproblem |
---|
69 | :param data: list of data selected |
---|
70 | """ |
---|
71 | def get_fit_data(self): |
---|
72 | """ |
---|
73 | """ |
---|
74 | def set_model_param(self, name, value=None): |
---|
75 | """ |
---|
76 | Store the name and value of a parameter of this fitproblem's model |
---|
77 | :param name: name of the given parameter |
---|
78 | :param value: value of that parameter |
---|
79 | """ |
---|
80 | def set_param2fit(self, list): |
---|
81 | """ |
---|
82 | Store param names to fit (checked) |
---|
83 | :param list: list of the param names |
---|
84 | """ |
---|
85 | def get_param2fit(self): |
---|
86 | """ |
---|
87 | return the list param names to fit |
---|
88 | """ |
---|
89 | def get_model_param(self): |
---|
90 | """ |
---|
91 | return list of couple of parameter name and value |
---|
92 | """ |
---|
93 | def schedule_tofit(self, schedule=0): |
---|
94 | """ |
---|
95 | set schedule to true to decide if this fit must be performed |
---|
96 | """ |
---|
97 | def get_scheduled(self): |
---|
98 | """ |
---|
99 | return true or false if a problem as being schedule for fitting |
---|
100 | """ |
---|
101 | def set_range(self, qmin=None, qmax=None): |
---|
102 | """ |
---|
103 | set fitting range |
---|
104 | """ |
---|
105 | def get_range(self): |
---|
106 | """ |
---|
107 | :return: fitting range |
---|
108 | """ |
---|
109 | def set_weight(self, flag=None): |
---|
110 | """ |
---|
111 | set fitting range |
---|
112 | """ |
---|
113 | def get_weight(self): |
---|
114 | """ |
---|
115 | get fitting weight |
---|
116 | """ |
---|
117 | def clear_model_param(self): |
---|
118 | """ |
---|
119 | clear constraint info |
---|
120 | """ |
---|
121 | def set_fit_tab_caption(self, caption): |
---|
122 | """ |
---|
123 | store the caption of the page associated with object |
---|
124 | """ |
---|
125 | def get_fit_tab_caption(self): |
---|
126 | """ |
---|
127 | Return the caption of the page associated with object |
---|
128 | """ |
---|
129 | def set_graph_id(self, id): |
---|
130 | """ |
---|
131 | Set graph id (from data_group_id at the time the graph produced) |
---|
132 | """ |
---|
133 | def get_graph_id(self): |
---|
134 | """ |
---|
135 | Get graph_id |
---|
136 | """ |
---|
137 | def set_result(self, result): |
---|
138 | """ |
---|
139 | """ |
---|
140 | |
---|
141 | def get_result(self): |
---|
142 | """ |
---|
143 | get result |
---|
144 | """ |
---|
145 | |
---|
146 | |
---|
147 | class FitProblemDictionary(FitProblemComponent, dict): |
---|
148 | """ |
---|
149 | This module implements a dictionary of fitproblem objects |
---|
150 | """ |
---|
151 | def __init__(self): |
---|
152 | FitProblemComponent.__init__(self) |
---|
153 | dict.__init__(self) |
---|
154 | ## the current model |
---|
155 | self.model = None |
---|
156 | ## if 1 this fit problem will be selected to fit , if 0 |
---|
157 | ## it will not be selected for fit |
---|
158 | self.schedule = 0 |
---|
159 | ##list containing parameter name and value |
---|
160 | self.list_param = [] |
---|
161 | ## fitting range |
---|
162 | self.qmin = None |
---|
163 | self.qmax = None |
---|
164 | self.graph_id = None |
---|
165 | self._smear_on = False |
---|
166 | self.scheduled = 0 |
---|
167 | self.fit_tab_caption = '' |
---|
168 | self.nbr_residuals_computed = 0 |
---|
169 | self.batch_inputs = {} |
---|
170 | self.batch_outputs = {} |
---|
171 | |
---|
172 | |
---|
173 | def enable_smearing(self, flag=False, fid=None): |
---|
174 | """ |
---|
175 | :param flag: bool.When flag is 1 get the computer smear value. When |
---|
176 | flag is 0 ingore smear value. |
---|
177 | """ |
---|
178 | self._smear_on = flag |
---|
179 | if fid is None: |
---|
180 | for value in self.itervalues(): |
---|
181 | value.enable_smearing(flag) |
---|
182 | else: |
---|
183 | if fid in self.iterkeys(): |
---|
184 | self[fid].enable_smearing(flag) |
---|
185 | |
---|
186 | def set_smearer(self, smearer, fid=None): |
---|
187 | """ |
---|
188 | save reference of smear object on fitdata |
---|
189 | :param smear: smear object from DataLoader |
---|
190 | """ |
---|
191 | if fid is None: |
---|
192 | for value in self.itervalues(): |
---|
193 | value.set_smearer(smearer) |
---|
194 | else: |
---|
195 | if fid in self.iterkeys(): |
---|
196 | self[fid].set_smearer(smearer) |
---|
197 | |
---|
198 | def get_smearer(self, fid=None): |
---|
199 | """ |
---|
200 | return smear object |
---|
201 | """ |
---|
202 | if fid in self.iterkeys(): |
---|
203 | return self[fid].get_smearer() |
---|
204 | |
---|
205 | |
---|
206 | def save_model_name(self, name, fid=None): |
---|
207 | """ |
---|
208 | """ |
---|
209 | if fid is None: |
---|
210 | for value in self.itervalues(): |
---|
211 | value.save_model_name(name) |
---|
212 | else: |
---|
213 | if fid in self.iterkeys(): |
---|
214 | self[fid].save_model_name(name) |
---|
215 | |
---|
216 | def get_name(self, fid=None): |
---|
217 | """ |
---|
218 | """ |
---|
219 | result = [] |
---|
220 | if fid is None: |
---|
221 | for value in self.itervalues(): |
---|
222 | result.append(value.get_name()) |
---|
223 | else: |
---|
224 | if fid in self.iterkeys(): |
---|
225 | result.append(self[fid].get_name()) |
---|
226 | return result |
---|
227 | |
---|
228 | def set_model(self, model, fid=None): |
---|
229 | """ |
---|
230 | associates each model with its new created name |
---|
231 | :param model: model selected |
---|
232 | :param name: name created for model |
---|
233 | """ |
---|
234 | self.model = model |
---|
235 | if fid is None: |
---|
236 | for value in self.itervalues(): |
---|
237 | value.set_model(self.model) |
---|
238 | else: |
---|
239 | if fid in self.iterkeys(): |
---|
240 | self[fid].set_model(self.model) |
---|
241 | |
---|
242 | def get_model(self, fid): |
---|
243 | """ |
---|
244 | :return: saved model |
---|
245 | """ |
---|
246 | if fid in self.iterkeys(): |
---|
247 | return self[fid].get_model() |
---|
248 | |
---|
249 | def set_fit_tab_caption(self, caption): |
---|
250 | """ |
---|
251 | store the caption of the page associated with object |
---|
252 | """ |
---|
253 | self.fit_tab_caption = caption |
---|
254 | |
---|
255 | def get_fit_tab_caption(self): |
---|
256 | """ |
---|
257 | Return the caption of the page associated with object |
---|
258 | """ |
---|
259 | return self.fit_tab_caption |
---|
260 | |
---|
261 | def set_residuals(self, residuals, fid): |
---|
262 | """ |
---|
263 | save a copy of residual |
---|
264 | :param data: data selected |
---|
265 | """ |
---|
266 | if fid in self.iterkeys(): |
---|
267 | self[fid].set_residuals(residuals) |
---|
268 | |
---|
269 | def get_residuals(self, fid): |
---|
270 | """ |
---|
271 | :return: residuals |
---|
272 | """ |
---|
273 | if fid in self.iterkeys(): |
---|
274 | return self[fid].get_residuals() |
---|
275 | |
---|
276 | def set_theory_data(self, fid, data=None): |
---|
277 | """ |
---|
278 | save a copy of the data select to fit |
---|
279 | :param data: data selected |
---|
280 | """ |
---|
281 | if fid in self.iterkeys(): |
---|
282 | self[fid].set_theory_data(data) |
---|
283 | |
---|
284 | def get_theory_data(self, fid): |
---|
285 | """ |
---|
286 | :return: list of data dList |
---|
287 | """ |
---|
288 | if fid in self.iterkeys(): |
---|
289 | return self[fid].get_theory_data() |
---|
290 | |
---|
291 | def add_data(self, data): |
---|
292 | """ |
---|
293 | Add data to the current dictionary of fitproblem. if data id does not |
---|
294 | exist create a new fit problem. |
---|
295 | :note: only data changes in the fit problem |
---|
296 | """ |
---|
297 | if data.id not in self.iterkeys(): |
---|
298 | self[data.id] = FitProblem() |
---|
299 | self[data.id].set_fit_data(data) |
---|
300 | |
---|
301 | def set_fit_data(self, data): |
---|
302 | """ |
---|
303 | save a copy of the data select to fit |
---|
304 | :param data: data selected |
---|
305 | |
---|
306 | """ |
---|
307 | self.clear() |
---|
308 | if data is None: |
---|
309 | data = [] |
---|
310 | for d in data: |
---|
311 | if (d is not None): |
---|
312 | if (d.id not in self.iterkeys()): |
---|
313 | self[d.id] = FitProblem() |
---|
314 | self[d.id].set_fit_data(d) |
---|
315 | self[d.id].set_model(self.model) |
---|
316 | self[d.id].set_range(self.qmin, self.qmax) |
---|
317 | #self[d.id].set_smearer(self[d.id].get_smearer()) |
---|
318 | def get_fit_data(self, fid): |
---|
319 | """ |
---|
320 | |
---|
321 | return data for the given fitproblem id |
---|
322 | :param fid: is key representing a fitproblem. usually extract from data |
---|
323 | id |
---|
324 | """ |
---|
325 | if fid in self.iterkeys(): |
---|
326 | return self[fid].get_fit_data() |
---|
327 | |
---|
328 | def set_model_param(self, name, value=None, fid=None): |
---|
329 | """ |
---|
330 | Store the name and value of a parameter of this fitproblem's model |
---|
331 | :param name: name of the given parameter |
---|
332 | :param value: value of that parameter |
---|
333 | """ |
---|
334 | if fid is None: |
---|
335 | for value in self.itervalues(): |
---|
336 | value.set_model_param(name, value) |
---|
337 | else: |
---|
338 | if fid in self.iterkeys(): |
---|
339 | self[fid].set_model_param(name, value) |
---|
340 | |
---|
341 | def get_model_param(self, fid): |
---|
342 | """ |
---|
343 | return list of couple of parameter name and value |
---|
344 | """ |
---|
345 | if fid in self.iterkeys(): |
---|
346 | return self[fid].get_model_param() |
---|
347 | |
---|
348 | def set_param2fit(self, list): |
---|
349 | """ |
---|
350 | Store param names to fit (checked) |
---|
351 | :param list: list of the param names |
---|
352 | """ |
---|
353 | self.list_param2fit = list |
---|
354 | |
---|
355 | def get_param2fit(self): |
---|
356 | """ |
---|
357 | return the list param names to fit |
---|
358 | """ |
---|
359 | return self.list_param2fit |
---|
360 | |
---|
361 | def schedule_tofit(self, schedule=0): |
---|
362 | """ |
---|
363 | set schedule to true to decide if this fit must be performed |
---|
364 | """ |
---|
365 | self.scheduled = schedule |
---|
366 | for value in self.itervalues(): |
---|
367 | value.schedule_tofit(schedule) |
---|
368 | |
---|
369 | def get_scheduled(self): |
---|
370 | """ |
---|
371 | return true or false if a problem as being schedule for fitting |
---|
372 | """ |
---|
373 | return self.scheduled |
---|
374 | |
---|
375 | def set_range(self, qmin=None, qmax=None, fid=None): |
---|
376 | """ |
---|
377 | set fitting range |
---|
378 | """ |
---|
379 | self.qmin = qmin |
---|
380 | self.qmax = qmax |
---|
381 | if fid is None: |
---|
382 | for value in self.itervalues(): |
---|
383 | value.set_range(self.qmin, self.qmax) |
---|
384 | else: |
---|
385 | if fid in self.iterkeys(): |
---|
386 | self[fid].value.set_range(self.qmin, self.qmax) |
---|
387 | |
---|
388 | def get_range(self, fid): |
---|
389 | """ |
---|
390 | :return: fitting range |
---|
391 | """ |
---|
392 | if fid in self.iterkeys(): |
---|
393 | return self[fid].get_range() |
---|
394 | |
---|
395 | def set_weight(self, is2d, flag=None, fid=None): |
---|
396 | """ |
---|
397 | fit weight |
---|
398 | """ |
---|
399 | if fid is None: |
---|
400 | for value in self.itervalues(): |
---|
401 | value.set_weight(flag=flag, is2d=is2d) |
---|
402 | else: |
---|
403 | if fid in self.iterkeys(): |
---|
404 | self[fid].set_weight(flag=flag, is2d=is2d) |
---|
405 | |
---|
406 | def get_weight(self, fid=None): |
---|
407 | """ |
---|
408 | return fit weight |
---|
409 | """ |
---|
410 | if fid in self.iterkeys(): |
---|
411 | return self[fid].get_weight() |
---|
412 | |
---|
413 | def clear_model_param(self, fid=None): |
---|
414 | """ |
---|
415 | clear constraint info |
---|
416 | """ |
---|
417 | if fid is None: |
---|
418 | for value in self.itervalues(): |
---|
419 | value.clear_model_param() |
---|
420 | else: |
---|
421 | if fid in self.iterkeys(): |
---|
422 | self[fid].clear_model_param() |
---|
423 | |
---|
424 | def get_fit_problem(self): |
---|
425 | """ |
---|
426 | return fitproblem contained in this dictionary |
---|
427 | """ |
---|
428 | return self.itervalues() |
---|
429 | |
---|
430 | def set_result(self, result, fid): |
---|
431 | """ |
---|
432 | """ |
---|
433 | if fid in self.iterkeys(): |
---|
434 | self[fid].set_result(result) |
---|
435 | |
---|
436 | def set_batch_result(self, batch_inputs, batch_outputs): |
---|
437 | """ |
---|
438 | set a list of result |
---|
439 | """ |
---|
440 | self.batch_inputs = batch_inputs |
---|
441 | self.batch_outputs = batch_outputs |
---|
442 | |
---|
443 | def get_result(self, fid): |
---|
444 | """ |
---|
445 | get result |
---|
446 | """ |
---|
447 | if fid in self.iterkeys(): |
---|
448 | return self[fid].get_result() |
---|
449 | |
---|
450 | def get_batch_result(self): |
---|
451 | """ |
---|
452 | get result |
---|
453 | """ |
---|
454 | return self.batch_inputs, self.batch_outputs |
---|
455 | |
---|
456 | def set_graph_id(self, id): |
---|
457 | """ |
---|
458 | Set graph id (from data_group_id at the time the graph produced) |
---|
459 | """ |
---|
460 | self.graph_id = id |
---|
461 | |
---|
462 | def get_graph_id(self): |
---|
463 | """ |
---|
464 | Get graph_id |
---|
465 | """ |
---|
466 | return self.graph_id |
---|
467 | |
---|
468 | |
---|
469 | class FitProblem(FitProblemComponent): |
---|
470 | """ |
---|
471 | FitProblem class allows to link a model with the new name created in _on_model, |
---|
472 | a name theory created with that model and the data fitted with the model. |
---|
473 | FitProblem is mostly used as value of the dictionary by fitting module. |
---|
474 | """ |
---|
475 | def __init__(self): |
---|
476 | FitProblemComponent.__init__(self) |
---|
477 | """ |
---|
478 | contains information about data and model to fit |
---|
479 | """ |
---|
480 | ## data used for fitting |
---|
481 | self.fit_data = None |
---|
482 | self.theory_data = None |
---|
483 | self.residuals = None |
---|
484 | # original data: should not be modified |
---|
485 | self.original_data = None |
---|
486 | ## the current model |
---|
487 | self.model = None |
---|
488 | ## if 1 this fit problem will be selected to fit , if 0 |
---|
489 | ## it will not be selected for fit |
---|
490 | self.schedule = 0 |
---|
491 | ##list containing parameter name and value |
---|
492 | self.list_param = [] |
---|
493 | ## smear object to smear or not data1D |
---|
494 | self.smearer_computed = False |
---|
495 | self.smearer_enable = False |
---|
496 | self.smearer_computer_value = None |
---|
497 | ## fitting range |
---|
498 | self.qmin = None |
---|
499 | self.qmax = None |
---|
500 | # fit weight |
---|
501 | self.weight = None |
---|
502 | self.result = None |
---|
503 | |
---|
504 | |
---|
505 | def enable_smearing(self, flag=False): |
---|
506 | """ |
---|
507 | :param flag: bool.When flag is 1 get the computer smear value. When |
---|
508 | flag is 0 ingore smear value. |
---|
509 | """ |
---|
510 | self.smearer_enable = flag |
---|
511 | |
---|
512 | def set_smearer(self, smearer): |
---|
513 | """ |
---|
514 | save reference of smear object on fitdata |
---|
515 | |
---|
516 | :param smear: smear object from DataLoader |
---|
517 | |
---|
518 | """ |
---|
519 | self.smearer_computer_value = smearer |
---|
520 | |
---|
521 | def get_smearer(self): |
---|
522 | """ |
---|
523 | return smear object |
---|
524 | """ |
---|
525 | if not self.smearer_enable: |
---|
526 | return None |
---|
527 | if not self.smearer_computed: |
---|
528 | #smeari_selection should be call only once per fitproblem |
---|
529 | self.smearer_computer_value = smear_selection(self.fit_data, |
---|
530 | self.model) |
---|
531 | self.smearer_computed = True |
---|
532 | return self.smearer_computer_value |
---|
533 | |
---|
534 | def save_model_name(self, name): |
---|
535 | """ |
---|
536 | """ |
---|
537 | self.name_per_page= name |
---|
538 | |
---|
539 | def get_name(self): |
---|
540 | """ |
---|
541 | """ |
---|
542 | return self.name_per_page |
---|
543 | |
---|
544 | def set_model(self, model): |
---|
545 | """ |
---|
546 | associates each model with its new created name |
---|
547 | :param model: model selected |
---|
548 | :param name: name created for model |
---|
549 | """ |
---|
550 | self.model = model |
---|
551 | self.smearer_computer_value = smear_selection(self.fit_data, |
---|
552 | self.model) |
---|
553 | self.smearer_computed = True |
---|
554 | |
---|
555 | def get_model(self): |
---|
556 | """ |
---|
557 | :return: saved model |
---|
558 | """ |
---|
559 | return self.model |
---|
560 | |
---|
561 | def set_residuals(self, residuals): |
---|
562 | """ |
---|
563 | save a copy of residual |
---|
564 | :param data: data selected |
---|
565 | """ |
---|
566 | self.residuals = residuals |
---|
567 | |
---|
568 | def get_residuals(self): |
---|
569 | """ |
---|
570 | :return: residuals |
---|
571 | """ |
---|
572 | return self.residuals |
---|
573 | |
---|
574 | def set_theory_data(self, data): |
---|
575 | """ |
---|
576 | save a copy of the data select to fit |
---|
577 | |
---|
578 | :param data: data selected |
---|
579 | |
---|
580 | """ |
---|
581 | self.theory_data = copy.deepcopy(data) |
---|
582 | |
---|
583 | def get_theory_data(self): |
---|
584 | """ |
---|
585 | :return: theory generated with the current model and data of this class |
---|
586 | """ |
---|
587 | return self.theory_data |
---|
588 | |
---|
589 | def set_fit_data(self, data): |
---|
590 | """ |
---|
591 | Store data associated with this class |
---|
592 | :param data: list of data selected |
---|
593 | """ |
---|
594 | self.original_data = None |
---|
595 | self.fit_data = None |
---|
596 | # original data: should not be modified |
---|
597 | self.original_data = data |
---|
598 | # fit data: used for fit and can be modified for convenience |
---|
599 | self.fit_data = copy.deepcopy(data) |
---|
600 | self.smearer_computer_value = smear_selection(self.fit_data, |
---|
601 | self.model) |
---|
602 | self.smearer_computed = True |
---|
603 | self.result = None |
---|
604 | |
---|
605 | def get_fit_data(self): |
---|
606 | """ |
---|
607 | :return: data associate with this class |
---|
608 | """ |
---|
609 | return self.fit_data |
---|
610 | |
---|
611 | def get_origin_data(self): |
---|
612 | """ |
---|
613 | """ |
---|
614 | return self.original_data |
---|
615 | |
---|
616 | def set_weight(self, is2d, flag=None): |
---|
617 | """ |
---|
618 | Received flag and compute error on data. |
---|
619 | :param flag: flag to transform error of data. |
---|
620 | :param is2d: flag to distinguish 1D to 2D Data |
---|
621 | """ |
---|
622 | from .utils import get_weight |
---|
623 | # send original data for weighting |
---|
624 | self.weight = get_weight(data=self.original_data, is2d=is2d, flag=flag) |
---|
625 | if is2d: |
---|
626 | self.fit_data.err_data = self.weight |
---|
627 | else: |
---|
628 | self.fit_data.dy = self.weight |
---|
629 | |
---|
630 | def get_weight(self): |
---|
631 | """ |
---|
632 | returns weight array |
---|
633 | """ |
---|
634 | return self.weight |
---|
635 | |
---|
636 | def set_param2fit(self, list): |
---|
637 | """ |
---|
638 | Store param names to fit (checked) |
---|
639 | :param list: list of the param names |
---|
640 | """ |
---|
641 | self.list_param2fit = list |
---|
642 | |
---|
643 | def get_param2fit(self): |
---|
644 | """ |
---|
645 | return the list param names to fit |
---|
646 | """ |
---|
647 | return self.list_param2fit |
---|
648 | |
---|
649 | def set_model_param(self,name,value=None): |
---|
650 | """ |
---|
651 | Store the name and value of a parameter of this fitproblem's model |
---|
652 | :param name: name of the given parameter |
---|
653 | :param value: value of that parameter |
---|
654 | """ |
---|
655 | self.list_param.append([name,value]) |
---|
656 | |
---|
657 | def get_model_param(self): |
---|
658 | """ |
---|
659 | return list of couple of parameter name and value |
---|
660 | """ |
---|
661 | return self.list_param |
---|
662 | |
---|
663 | def schedule_tofit(self, schedule=0): |
---|
664 | """ |
---|
665 | set schedule to true to decide if this fit must be performed |
---|
666 | """ |
---|
667 | self.schedule = schedule |
---|
668 | |
---|
669 | def get_scheduled(self): |
---|
670 | """ |
---|
671 | return true or false if a problem as being schedule for fitting |
---|
672 | """ |
---|
673 | return self.schedule |
---|
674 | |
---|
675 | def set_range(self, qmin=None, qmax=None): |
---|
676 | """ |
---|
677 | set fitting range |
---|
678 | :param qmin: minimum value to consider for the fit range |
---|
679 | :param qmax: maximum value to consider for the fit range |
---|
680 | """ |
---|
681 | self.qmin = qmin |
---|
682 | self.qmax = qmax |
---|
683 | |
---|
684 | def get_range(self): |
---|
685 | """ |
---|
686 | :return: fitting range |
---|
687 | |
---|
688 | """ |
---|
689 | return self.qmin, self.qmax |
---|
690 | |
---|
691 | def clear_model_param(self): |
---|
692 | """ |
---|
693 | clear constraint info |
---|
694 | """ |
---|
695 | self.list_param = [] |
---|
696 | |
---|
697 | def set_fit_tab_caption(self, caption): |
---|
698 | """ |
---|
699 | """ |
---|
700 | self.fit_tab_caption = str(caption) |
---|
701 | |
---|
702 | def get_fit_tab_caption(self): |
---|
703 | """ |
---|
704 | """ |
---|
705 | return self.fit_tab_caption |
---|
706 | |
---|
707 | def set_graph_id(self, id): |
---|
708 | """ |
---|
709 | Set graph id (from data_group_id at the time the graph produced) |
---|
710 | """ |
---|
711 | self.graph_id = id |
---|
712 | |
---|
713 | def get_graph_id(self): |
---|
714 | """ |
---|
715 | Get graph_id |
---|
716 | """ |
---|
717 | return self.graph_id |
---|
718 | |
---|
719 | def set_result(self, result): |
---|
720 | """ |
---|
721 | """ |
---|
722 | self.result = result |
---|
723 | |
---|
724 | def get_result(self): |
---|
725 | """ |
---|
726 | get result |
---|
727 | """ |
---|
728 | return self.result |
---|