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