Changeset dc613d6 in sasview for sansview


Ignore:
Timestamp:
Jun 15, 2011 5:44:29 PM (13 years ago)
Author:
Jae Cho <jhjcho@…>
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:
2446b66
Parents:
dfb6d38
Message:

fixed multi fitting

Location:
sansview/perspectives/fitting
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/fitpage.py

    r1180528 rdc613d6  
    952952        Allow to fit 
    953953        """ 
     954        if len(self.parent._manager.fit_thread_list)>0 and\ 
     955                    self.parent._manager._fit_engine != "park": 
     956            msg = "The FitEnging will be set to 'ParkMC'\n" 
     957            msg += " to fit with more than one data set..." 
     958            wx.MessageBox(msg, 'Info') 
     959            #wx.PostEvent(self._manager.parent, StatusEvent(status=\ 
     960            #                "Fitting: %s"%msg)) 
     961             
    954962        if self.data is None: 
    955963            msg = "Please get Data first..." 
     
    989997        self.qmin_x = float(self.qmin.GetValue()) 
    990998        self.qmax_x = float( self.qmax.GetValue()) 
    991         self._manager._reset_schedule_problem(value=0) 
     999        self._manager._reset_schedule_problem(value=0, uid=self.uid) 
    9921000        self._manager.schedule_for_fit(uid=self.uid,value=1, fitproblem =None)  
    9931001        self._manager.set_fit_range(uid=self.uid,qmin= self.qmin_x,  
     
    9951003         
    9961004        #single fit  
    997         self._manager.onFit() 
     1005        self._manager.onFit(uid=self.uid) 
    9981006        self.btFit.SetLabel("Stop") 
    9991007        self.bind_fit_button() 
  • sansview/perspectives/fitting/fitting.py

    rdfb6d38 rdc613d6  
    3434from sans.guiframe.plugin_base import PluginBase  
    3535 
    36 from .console import ConsoleUpdate 
     36#from .console import ConsoleUpdate 
    3737from .fitproblem import FitProblem 
    3838from .fitpanel import FitPanel 
     
    563563                                update_chisqr=update_chisqr) 
    564564             
    565     def onFit(self): 
     565    def onFit(self, uid=None): 
    566566        """ 
    567567        perform fit  
    568         """ 
     568         
     569        : param type: uid for single fit, None for simultaneous fit 
     570        """ 
     571        from sans.fit.Fitting import Fit 
    569572        from .fit_thread import FitThread 
     573        from .console import ConsoleUpdate 
    570574        ##  count the number of fitproblem schedule to fit  
     575        #if uid == None or self._fit_engine == "park": 
    571576        fitproblem_count = 0 
    572577        for value in self.page_finder.values(): 
     
    575580                 
    576581        ## if simultaneous fit change automatically the engine to park 
    577         if fitproblem_count > 1: 
     582        # scipy can not handle two thread running at the same time 
     583        if fitproblem_count > 1 or len(self.fit_thread_list)>0: 
    578584            self._on_change_engine(engine='park') 
    579585             
    580586        self.fitproblem_count = fitproblem_count   
    581            
    582         from sans.fit.Fitting import Fit 
     587 
    583588        fitter = Fit(self._fit_engine) 
    584          
    585589        if self._fit_engine == "park": 
    586590            engineType = "Simultaneous Fit" 
     
    592596        list_page_id = [] 
    593597        for page_id, value in self.page_finder.iteritems(): 
     598            # For simulfit (uid give with None), do for-loop 
     599            # if uid is specified (singlefit), do it only on the page. 
     600            if engineType == "Single Fit": 
     601                if page_id != uid: 
     602                    continue 
    594603            try: 
    595604                if value.get_scheduled() == 1: 
     
    651660                                    completefn=self._simul_fit_completed, 
    652661                                    ftol=self.ftol) 
     662 
    653663        self.fit_thread_list[current_page_id] = calc_fit 
    654664        time.sleep(0.3) 
     
    817827                    break 
    818828     
    819     def _reset_schedule_problem(self, value=0): 
     829    def _reset_schedule_problem(self, value=0, uid=None): 
    820830        """ 
    821831        unschedule or schedule all fitproblem to be fit 
    822832        """ 
    823         for page_id in self.page_finder.keys(): 
    824             self.page_finder[page_id].schedule_tofit(value) 
    825              
     833        # case that uid is not specified 
     834        if uid == None: 
     835            for page_id in self.page_finder.keys(): 
     836                self.page_finder[page_id].schedule_tofit(value) 
     837        # when uid is given 
     838        else: 
     839            self.page_finder[uid].schedule_tofit(value) 
     840                 
    826841    def _fit_helper(self, pars, value, fitproblem_id,fitter, title="Single Fit " ): 
    827842        """ 
     
    897912           
    898913        """   
     914        del self.fit_thread_list[page_id[0]] 
    899915        time.sleep(0.2)    
    900916        try: 
     
    917933                self._update_fit_button(page_id) 
    918934                return 
     935             
    919936            for uid in page_id: 
    920937                value = self.page_finder[uid]    
     
    962979         
    963980        """ 
     981        self.fit_thread_list = {} 
    964982        if page_id is None: 
    965983            page_id = [] 
     
    11141132        ## send the current engine type to fitpanel 
    11151133        self.fit_panel._on_engine_change(name=self._fit_engine) 
     1134 
    11161135        
    11171136    def _on_model_panel(self, evt): 
  • sansview/perspectives/fitting/simfitpage.py

    r4bd492f rdc613d6  
    5252        ##Font size 
    5353        self.SetWindowVariant(variant = FONT_VARIANT) 
    54         self.id = None 
     54        self.uid = None 
    5555        self.parent = parent 
    5656        ## store page_finder 
     
    6767        ## number of constraint 
    6868        self.nb_constraint= 0 
    69         self.id = wx.NewId() 
     69        self.uid = wx.NewId() 
    7070        ## draw page 
    7171        self.define_page_structure() 
     
    146146            for item in self.model_list: 
    147147                if item[0].GetValue(): 
    148                     self.manager.schedule_for_fit( value=1,fitproblem =item[1])  
    149             self.manager.onFit() 
     148                    self.manager.schedule_for_fit( value=1, fitproblem =item[1])  
     149            self.manager.onFit(None) 
    150150        else: 
    151151            msg= "Select at least one model to fit " 
Note: See TracChangeset for help on using the changeset viewer.