Changeset 7bd6cfae in sasview


Ignore:
Timestamp:
Oct 3, 2011 5:21:52 AM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
63dc6e5
Parents:
5425990
Message:

working on display plot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fittingview/src/sans/perspectives/fitting/fitting.py

    r029e4d3 r7bd6cfae  
    732732                        name = str(element[1]) 
    733733                        pars.append(name) 
    734                     for fitproblem in  value.get_fit_problem(): 
     734                    fitproblem_list = value.values() 
     735                    fitproblem_list.sort() 
     736                    for fitproblem in  fitproblem_list: 
    735737                        if sim_fitter is None: 
    736738                            fitter = Fit(self._fit_engine)   
     
    967969                if item[0] != None and item[1] != None: 
    968970                    listOfConstraint.append((item[0],item[1])) 
    969         for param in model.getParamList(): 
    970             if param not in pars: 
    971                 if param not in batch_inputs.keys(): 
    972                     batch_inputs[param] = [] 
    973                 if param not in model.non_fittable: 
    974                     batch_inputs[param].append(model.getParam(param)) 
    975971        new_model = model#deepcopy(model) 
    976972        fitter.set_model(new_model, fit_id, pars, constraints=listOfConstraint) 
     
    978974                        qmax=qmax) 
    979975        fitter.select_problem_for_fit(id=fit_id, value=1) 
    980         #fill batch result information 
    981         if "Data" not in batch_outputs.keys(): 
    982             batch_outputs["Data"] = [] 
    983         batch_outputs["Data"].append(data.name) 
    984         for key, value in data.meta_data.iteritems(): 
    985             if key not in batch_inputs.keys(): 
    986                 batch_inputs[key] = [] 
    987             batch_inputs[key].append(value) 
    988         param = "temperature" 
    989         if hasattr(data.sample, param): 
    990             if param not in  batch_inputs.keys(): 
    991                  batch_inputs[param] = [] 
    992             batch_inputs[param].append(data.sample.temperature) 
     976        
    993977     
    994978    def _onSelect(self,event): 
     
    10461030                if res is None: 
    10471031                    null_value = numpy.nan 
    1048                     batch_outputs["Chi2"].append(null_value) 
     1032                    from sans.guiframe.data_processor import BatchCell 
     1033                    cell = BatchCell() 
     1034                    cell.label = null_value 
     1035                    cell.value = null_value 
     1036                    batch_outputs["Chi2"].append(cell) 
    10491037                    for index  in range(len(pars)): 
    10501038                        batch_outputs[pars[index]].append(null_value) 
     
    10521040                        batch_inputs["error on %s" % pars[index]].append(item) 
    10531041                else: 
    1054                     batch_outputs["Chi2"].append(res.fitness) 
     1042                    from sans.guiframe.data_processor import BatchCell 
     1043                    cell = BatchCell() 
     1044                    cell.label = res.fitness 
     1045                    cell.value = res.fitness 
     1046                    batch_outputs["Chi2"].append(cell) 
    10551047                    for index  in range(len(pars)): 
    10561048                        batch_outputs[pars[index]].append(res.pvec[index]) 
     
    10601052            self.page_finder[pid].set_result(result=batch_outputs)    
    10611053            
    1062             """ 
    1063             draw_model(self, model, page_id, data=None, smearer=None, 
    1064                    enable1D=True, enable2D=False, 
    1065                    state=None, 
    1066                    toggle_mode_on=False, 
    1067                    qmin=None, qmax=None,  
    1068                    update_chisqr=True, weight=None): 
    1069             """ 
    10701054            for pid in page_id: 
    10711055                cpage = self.fit_panel.get_page_by_id(pid) 
     
    10891073                                      update_chisqr=False,  
    10901074                                      weight=weight) 
     1075        #get theory data and residuals of each data then send all values 
     1076        # to the grid   
     1077        wx.CallAfter(self.on_set_batch_result, page_id, pars, batch_outputs,  
     1078                batch_inputs) 
    10911079                     
    1092             self.parent.on_set_batch_result(data_outputs=batch_outputs,  
     1080    def on_set_batch_result(self, page_id, pars, batch_outputs, batch_inputs): 
     1081        """ 
     1082        """ 
     1083        for pid in page_id: 
     1084            fitproblem_list = self.page_finder[pid].values() 
     1085            fitproblem_list.sort() 
     1086            index = 0 
     1087            for fitproblem in fitproblem_list: 
     1088                residuals =  fitproblem.get_residuals() 
     1089                theory_data = fitproblem.get_theory_data() 
     1090                data = fitproblem.get_fit_data() 
     1091                model = fitproblem.get_model() 
     1092                 #fill batch result information 
     1093                if "Data" not in batch_outputs.keys(): 
     1094                    batch_outputs["Data"] = [] 
     1095                from sans.guiframe.data_processor import BatchCell 
     1096                cell = BatchCell() 
     1097                cell.label = data.name 
     1098                cell.value = index 
     1099                cell.object = [data, theory_data] 
     1100                 
     1101                for param in model.getParamList(): 
     1102                    if param not in pars: 
     1103                        if param not in batch_inputs.keys(): 
     1104                            batch_inputs[param] = [] 
     1105                        if param not in model.non_fittable: 
     1106                            batch_inputs[param].append(model.getParam(param)) 
     1107                batch_outputs["Data"].append(cell) 
     1108                for key, value in data.meta_data.iteritems(): 
     1109                    if key not in batch_inputs.keys(): 
     1110                        batch_inputs[key] = [] 
     1111                    batch_inputs[key].append(value) 
     1112                param = "temperature" 
     1113                if hasattr(data.sample, param): 
     1114                    if param not in  batch_inputs.keys(): 
     1115                         batch_inputs[param] = [] 
     1116                    batch_inputs[param].append(data.sample.temperature) 
     1117                # associate residuals plot 
     1118                batch_outputs["Chi2"][index].object = residuals 
     1119           
     1120        self.parent.on_set_batch_result(data_outputs=batch_outputs,  
    10931121                                            data_inputs=batch_inputs, 
    10941122                                            plugin_name=self.sub_menu) 
     
    11511179                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    11521180            except ValueError: 
     1181                raise 
    11531182                self._update_fit_button(page_id) 
    11541183                msg = "Single Fitting did not converge!!!" 
     
    11561185                                                      type="stop")) 
    11571186            except: 
     1187                raise 
    11581188                self._update_fit_button(page_id) 
    11591189                msg = "Single Fit completed but Following" 
Note: See TracChangeset for help on using the changeset viewer.