Changeset f32d144 in sasview for fittingview/src/sans/perspectives/fitting/fitproblem.py
- Timestamp:
- Apr 27, 2012 2:20:33 PM (13 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f992a06
- Parents:
- 9e07bc4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/fitproblem.py
r7db52f1 rf32d144 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 """ 1 6 ################################################################################ 2 7 #This software was developed by the University of Tennessee as part of the 3 8 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 #project funded by the US National Science Foundation. 9 #project funded by the US National Science Foundation. 5 10 # 6 11 #See the license text in license.txt … … 8 13 #copyright 2009, University of Tennessee 9 14 ################################################################################ 10 import copy 15 import copy 11 16 from sans.models.qsmearing import smear_selection 12 13 17 14 18 class FitProblemComponent(object): 15 19 """ 16 20 Inferface containing information to store data, model, range of data, etc... 17 and retreive this information. This is an inferface 21 and retreive this information. This is an inferface 18 22 for a fitProblem i.e relationship between data and model. 19 23 """ … … 23 27 flag is 0 ingore smear value. 24 28 """ 29 25 30 def get_smearer(self): 26 31 """ … … 29 34 def save_model_name(self, name): 30 35 """ 31 """ 36 """ 37 32 38 def get_name(self): 33 39 """ 34 40 """ 41 35 42 def set_model(self, model): 36 """ 43 """ 37 44 associates each model with its new created name 38 45 :param model: model selected 39 46 :param name: name created for model 40 47 """ 48 41 49 def get_model(self): 42 50 """ 43 51 :return: saved model 44 52 """ 53 45 54 def set_residuals(self, residuals): 46 """ 55 """ 47 56 save a copy of residual 48 57 :param data: data selected 49 58 """ 59 50 60 def get_residuals(self): 51 61 """ … … 54 64 55 65 def set_theory_data(self, data): 56 """ 66 """ 57 67 save a copy of the data select to fit 58 68 :param data: data selected 59 69 """ 70 60 71 def get_theory_data(self): 61 72 """ 62 73 :return: list of data dList 63 74 """ 75 64 76 def set_fit_data(self, data): 65 """ 77 """ 66 78 Store of list of data and create by create new fitproblem of each data 67 79 id , if there was existing information about model, this information 68 80 get copy to the new fitproblem 69 81 :param data: list of data selected 70 """ 82 """ 83 71 84 def get_fit_data(self): 72 85 """ 73 86 """ 87 74 88 def set_model_param(self, name, value=None): 75 """ 89 """ 76 90 Store the name and value of a parameter of this fitproblem's model 77 91 :param name: name of the given parameter 78 92 :param value: value of that parameter 79 93 """ 94 80 95 def set_param2fit(self, list): 81 96 """ … … 83 98 :param list: list of the param names 84 99 """ 100 85 101 def get_param2fit(self): 86 102 """ 87 103 return the list param names to fit 88 104 """ 105 89 106 def get_model_param(self): 90 """ 107 """ 91 108 return list of couple of parameter name and value 92 109 """ 110 93 111 def schedule_tofit(self, schedule=0): 94 112 """ 95 113 set schedule to true to decide if this fit must be performed 96 114 """ 115 97 116 def get_scheduled(self): 98 117 """ 99 118 return true or false if a problem as being schedule for fitting 100 119 """ 120 101 121 def set_range(self, qmin=None, qmax=None): 102 122 """ 103 set fitting range 104 """ 123 set fitting range 124 """ 125 105 126 def get_range(self): 106 127 """ 107 128 :return: fitting range 108 129 """ 130 109 131 def set_weight(self, flag=None): 110 132 """ 111 set fitting range 112 """ 133 set fitting range 134 """ 135 113 136 def get_weight(self): 114 137 """ 115 138 get fitting weight 116 139 """ 140 117 141 def clear_model_param(self): 118 142 """ 119 143 clear constraint info 120 144 """ 145 121 146 def set_fit_tab_caption(self, caption): 122 147 """ 123 148 store the caption of the page associated with object 124 149 """ 150 125 151 def get_fit_tab_caption(self): 126 152 """ 127 153 Return the caption of the page associated with object 128 154 """ 155 129 156 def set_graph_id(self, id): 130 157 """ 131 158 Set graph id (from data_group_id at the time the graph produced) 132 159 """ 133 def get_graph_id(self): 160 161 def get_graph_id(self): 134 162 """ 135 163 Get graph_id 136 """ 164 """ 165 137 166 def set_result(self, result): 138 167 """ … … 141 170 def get_result(self): 142 171 """ 143 get result 144 """ 172 get result 173 """ 145 174 146 175 … … 154 183 ## the current model 155 184 self.model = None 156 ## if 1 this fit problem will be selected to fit , if 0 185 ## if 1 this fit problem will be selected to fit , if 0 157 186 ## it will not be selected for fit 158 187 self.schedule = 0 … … 169 198 self.batch_inputs = {} 170 199 self.batch_outputs = {} 171 172 200 173 201 def enable_smearing(self, flag=False, fid=None): … … 203 231 return self[fid].get_smearer() 204 232 205 206 233 def save_model_name(self, name, fid=None): 207 234 """ 208 """ 235 """ 209 236 if fid is None: 210 237 for value in self.itervalues(): … … 227 254 228 255 def set_model(self, model, fid=None): 229 """ 256 """ 230 257 associates each model with its new created name 231 258 :param model: model selected … … 260 287 261 288 def set_residuals(self, residuals, fid): 262 """ 289 """ 263 290 save a copy of residual 264 291 :param data: data selected … … 275 302 276 303 def set_theory_data(self, fid, data=None): 277 """ 304 """ 278 305 save a copy of the data select to fit 279 306 :param data: data selected … … 300 327 301 328 def set_fit_data(self, data): 302 """ 329 """ 303 330 save a copy of the data select to fit 304 331 :param data: data selected … … 315 342 self[d.id].set_model(self.model) 316 343 self[d.id].set_range(self.qmin, self.qmax) 317 #self[d.id].set_smearer(self[d.id].get_smearer())344 318 345 def get_fit_data(self, fid): 319 346 """ 320 321 347 return data for the given fitproblem id 322 348 :param fid: is key representing a fitproblem. usually extract from data … … 327 353 328 354 def set_model_param(self, name, value=None, fid=None): 329 """ 355 """ 330 356 Store the name and value of a parameter of this fitproblem's model 331 357 :param name: name of the given parameter … … 340 366 341 367 def get_model_param(self, fid): 342 """ 368 """ 343 369 return list of couple of parameter name and value 344 370 """ … … 356 382 """ 357 383 return the list param names to fit 358 """ 384 """ 359 385 return self.list_param2fit 360 386 … … 375 401 def set_range(self, qmin=None, qmax=None, fid=None): 376 402 """ 377 set fitting range 403 set fitting range 378 404 """ 379 405 self.qmin = qmin … … 393 419 return self[fid].get_range() 394 420 395 def set_weight(self, 421 def set_weight(self, is2d, flag=None, fid=None): 396 422 """ 397 423 fit weight … … 443 469 def get_result(self, fid): 444 470 """ 445 get result 446 """ 471 get result 472 """ 447 473 if fid in self.iterkeys(): 448 474 return self[fid].get_result() … … 450 476 def get_batch_result(self): 451 477 """ 452 get result 478 get result 453 479 """ 454 480 return self.batch_inputs, self.batch_outputs … … 460 486 self.graph_id = id 461 487 462 def get_graph_id(self): 488 def get_graph_id(self): 463 489 """ 464 490 Get graph_id 465 """ 491 """ 466 492 return self.graph_id 467 493 468 494 469 495 class FitProblem(FitProblemComponent): 470 """ 496 """ 471 497 FitProblem class allows to link a model with the new name created in _on_model, 472 498 a name theory created with that model and the data fitted with the model. … … 486 512 ## the current model 487 513 self.model = None 488 ## if 1 this fit problem will be selected to fit , if 0 514 ## if 1 this fit problem will be selected to fit , if 0 489 515 ## it will not be selected for fit 490 516 self.schedule = 0 … … 502 528 self.result = None 503 529 504 505 530 def enable_smearing(self, flag=False): 506 531 """ … … 534 559 def save_model_name(self, name): 535 560 """ 536 """ 537 self.name_per_page = name561 """ 562 self.name_per_page = name 538 563 539 564 def get_name(self): … … 543 568 544 569 def set_model(self, model): 545 """ 570 """ 546 571 associates each model with its new created name 547 572 :param model: model selected … … 560 585 561 586 def set_residuals(self, residuals): 562 """ 587 """ 563 588 save a copy of residual 564 589 :param data: data selected … … 573 598 574 599 def set_theory_data(self, data): 575 """ 600 """ 576 601 save a copy of the data select to fit 577 602 … … 588 613 589 614 def set_fit_data(self, data): 590 """ 615 """ 591 616 Store data associated with this class 592 617 :param data: list of data selected … … 644 669 """ 645 670 return the list param names to fit 646 """ 671 """ 647 672 return self.list_param2fit 648 673 649 def set_model_param(self, name,value=None):650 """ 674 def set_model_param(self, name, value=None): 675 """ 651 676 Store the name and value of a parameter of this fitproblem's model 652 677 :param name: name of the given parameter 653 678 :param value: value of that parameter 654 679 """ 655 self.list_param.append([name, value])680 self.list_param.append([name, value]) 656 681 657 682 def get_model_param(self): 658 """ 683 """ 659 684 return list of couple of parameter name and value 660 685 """ … … 707 732 def set_graph_id(self, id): 708 733 """ 709 Set graph id (from data_group_id at the time the graph produced) 734 Set graph id (from data_group_id at the time the graph produced) 710 735 """ 711 736 self.graph_id = id 712 737 713 def get_graph_id(self): 738 def get_graph_id(self): 714 739 """ 715 740 Get graph_id 716 """ 741 """ 717 742 return self.graph_id 718 743 … … 724 749 def get_result(self): 725 750 """ 726 get result 727 """ 751 get result 752 """ 728 753 return self.result
Note: See TracChangeset
for help on using the changeset viewer.