Changeset 7db52f1 in sasview for park_integration/src


Ignore:
Timestamp:
Oct 12, 2011 11:40:24 AM (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:
7643ba2
Parents:
18253cd
Message:

now able to reset the model init param values in batch model

Location:
park_integration/src/sans/fit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • park_integration/src/sans/fit/AbstractFitEngine.py

    rd8661fb r7db52f1  
    459459        #import thread 
    460460        self.model.set_params(self.paramlist, params) 
    461          
     461        print "params", params 
    462462        self.true_res, theory = self.data.residuals(self.model.eval) 
    463463        self.theory = copy.deepcopy(theory) 
     
    548548        #Dictionnary of fitArrange element (fit problems) 
    549549        self.fit_arrange_dict = {} 
    550    
     550         
    551551    def set_model(self, model,  id,  pars=[], constraints=[], data=None): 
    552552        """ 
     
    611611                fitproblem.pars = pars 
    612612                self.fit_arrange_dict[id] = fitproblem 
    613                  
     613                vals = [] 
     614                for name in pars: 
     615                    vals.append(new_model.model.getParam(name)) 
     616                self.fit_arrange_dict[id].vals = vals 
    614617        else: 
    615618            raise ValueError, "park_integration:missing parameters" 
     
    698701        self.data_list = [] 
    699702        self.pars = [] 
     703        self.vals = [] 
    700704        #self.selected  is zero when this fit problem is not schedule to fit  
    701705        #self.selected is 1 when schedule to fit  
  • park_integration/src/sans/fit/Fitting.py

    r634ca14 r7db52f1  
    5050            raise ValueError, "enter the keyword scipy or park" 
    5151 
    52     def fit(self, q=None, handler=None, curr_thread=None, ftol=1.49012e-8): 
     52    def fit(self, q=None, handler=None,  
     53                        curr_thread=None,  
     54                        ftol=1.49012e-8, 
     55                        reset_flag=False): 
    5356        """Perform the fit """ 
    5457        return self._engine.fit(q, handler, curr_thread=curr_thread, 
    55                                 ftol=ftol) 
     58                                ftol=ftol, reset_flag=reset_flag) 
    5659      
    5760    def set_model(self, model, id, pars=[], constraints=[], data=None): 
  • park_integration/src/sans/fit/ParkFitting.py

    r444c900e r7db52f1  
    338338        self.param_list = [] 
    339339         
    340     def create_assembly(self, curr_thread): 
     340    def create_assembly(self, curr_thread, reset_flag=False): 
    341341        """ 
    342342        Extract sansmodel and sansdata from  
     
    358358        for item in fitproblems: 
    359359            parkmodel = item.get_model() 
     360            if reset_flag: 
     361                # reset the initial value; useful for batch 
     362                for name in item.pars: 
     363                    ind = item.pars.index(name) 
     364                    parkmodel.model.setParam(name, item.vals[ind]) 
     365             
    360366            for p in parkmodel.parameterset: 
    361367                ## does not allow status change for constraint parameters 
     
    374380         
    375381   
    376     def fit(self, q=None, handler=None, curr_thread=None, ftol=1.49012e-8): 
     382    def fit(self, q=None, handler=None, curr_thread=None,  
     383                                        ftol=1.49012e-8, reset_flag=False): 
    377384        """ 
    378385        Performs fit with park.fit module.It can  perform fit with one model 
     
    395402         
    396403        """ 
    397         self.create_assembly(curr_thread=curr_thread) 
     404        self.create_assembly(curr_thread=curr_thread, reset_flag=reset_flag) 
    398405        localfit = SansFitSimplex() 
    399406        localfit.ftol = ftol 
  • park_integration/src/sans/fit/ScipyFitting.py

    rd8661fb r7db52f1  
    5656    #    return profile(self._fit, *args, **kw) 
    5757 
    58     def fit(self, q=None, handler=None, curr_thread=None, ftol=1.49012e-8): 
     58    def fit(self, q=None, handler=None, curr_thread=None,  
     59            ftol=1.49012e-8, reset_flag=False): 
    5960        """ 
    6061        """ 
     
    7071            raise RuntimeError, "No Assembly scheduled for Scipy fitting." 
    7172            return 
    72      
     73        model = fitproblem[0].get_model() 
     74        if reset_flag: 
     75            # reset the initial value; useful for batch 
     76            for name in fitproblem[0].pars: 
     77                ind = fitproblem[0].pars.index(name) 
     78                model.model.setParam(name, fitproblem[0].vals[ind]) 
    7379        listdata = [] 
    74         model = fitproblem[0].get_model() 
    7580        listdata = fitproblem[0].get_data() 
    7681        # Concatenate dList set (contains one or more data)before fitting 
Note: See TracChangeset for help on using the changeset viewer.