Changeset 393f0f3 in sasview


Ignore:
Timestamp:
Jan 26, 2010 11:09:19 AM (14 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:
693500a
Parents:
3c67340
Message:

revert previous commits asked by ga.

Location:
park_integration
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • park_integration/AbstractFitEngine.py

    r6d20b46 r393f0f3  
    11import logging, sys 
    2 import copy 
    3 from copy import deepcopy 
    42import park,numpy,math, copy 
    53from DataLoader.data_info import Data1D 
     
    8179        self.pars=[] 
    8280   
    83     def clone(self): 
    84         model = self.model.clone() 
    85         model.name = self.model.name 
    86         return Model(model) 
     81   
    8782    def getParams(self,fitparams): 
    8883        """ 
     
    120115        """ 
    121116        try: 
    122                 return self.model.evalDistribution(x) 
     117            return self.model.evalDistribution(x) 
    123118        except: 
    124                 raise 
     119            raise 
    125120 
    126121     
     
    342337         Sans Assembly class a class wrapper to be call in optimizer.leastsq method 
    343338    """ 
    344     def __init__(self,paramlist,model=None , data=None, curr_thread= None): 
    345         """ 
    346             @param model: the model wrapper for sans -model 
    347             @param data: the data wrapper for sans data 
    348         """ 
    349         self.model = model.clone() 
    350         self.data  = deepcopy(data) 
    351         self.paramlist = deepcopy(paramlist) 
     339    def __init__(self,paramlist,Model=None , Data=None, curr_thread= None): 
     340        """ 
     341            @param Model: the model wrapper fro sans -model 
     342            @param Data: the data wrapper for sans data 
     343        """ 
     344        self.model = Model 
     345        self.data  = Data 
     346        self.paramlist=paramlist 
    352347        self.curr_thread= curr_thread 
    353348        self.res=[] 
     
    462457        if model == None: 
    463458            raise ValueError, "AbstractFitEngine: Need to set model to fit" 
    464         #print "set_model",model.name 
    465         #new_model= deepcopy(model) 
    466         new_model = model.clone() 
    467         new_model.name = model.name 
    468         if not issubclass(new_model.__class__, Model): 
    469             new_model= Model(new_model) 
     459         
     460        new_model= model 
     461        if not issubclass(model.__class__, Model): 
     462            new_model= Model(model) 
    470463         
    471464        if len(constraints)>0: 
     
    513506            @param Uid: unique key corresponding to a fitArrange object with data 
    514507        """ 
    515         #print "set_data",data.__class__.__name__ 
    516508        if data.__class__.__name__=='Data2D': 
    517509            fitdata=FitData2D(sans_data2d=data, data=data.data, err_data= data.err_data) 
    518510        else: 
    519511            fitdata=FitData1D(x=data.x, y=data.y , dx= data.dx,dy=data.dy,smearer=smearer) 
    520          
     512        
    521513        fitdata.setFitRange(qmin=qmin,qmax=qmax) 
    522514        #A fitArrange is already created but contains model only at Uid 
     
    586578        """ 
    587579        self.model = model 
    588         self.model.name = model.name 
    589580         
    590581    def add_data(self,data): 
  • park_integration/Fitting.py

    r6d20b46 r393f0f3  
    2222        engine.set_param( model,model.name, pars) 
    2323        engine.set_model(model,Uid) 
    24         engine.select_problem_for_fit(Uid,value) 
     24         
    2525        chisqr1, out1, cov1=engine.fit(pars,qmin,qmax) 
    2626    """   
  • park_integration/ScipyFitting.py

    r6d20b46 r393f0f3  
    5656            with Uid as keys 
    5757        """ 
    58         self.fitArrangeDict = {} 
    59         self.paramList = [] 
     58        self.fitArrangeDict={} 
     59        self.paramList=[] 
    6060    #def fit(self, *args, **kw): 
    6161    #    return profile(self._fit, *args, **kw) 
    62     def createFunctor(self): 
    63         fitproblem=None 
    64         fit_count = 0  
    65         #print " self.fitArrangeDict", self.fitArrangeDict 
    66         for id, fproblem in self.fitArrangeDict.iteritems(): 
    67             if fproblem.get_to_fit() == 1: 
    68                 fitproblem = fproblem 
    69                 fit_count += 1 
    70         if fit_count > 1 :  
     62 
     63    def fit(self ,q=None,handler=None,curr_thread= None): 
     64        
     65        fitproblem=[] 
     66        for id ,fproblem in self.fitArrangeDict.iteritems(): 
     67            if fproblem.get_to_fit()==1: 
     68                fitproblem.append(fproblem) 
     69        if len(fitproblem)>1 :  
    7170            raise RuntimeError, "Scipy can't fit more than a single fit problem at a time." 
    7271            return 
    73         elif fit_count == 0 :  
     72        elif len(fitproblem)==0 :  
    7473            raise RuntimeError, "No Assembly scheduled for Scipy fitting." 
    7574            return 
    7675     
    77         listdata = [] 
    78         model = fitproblem.get_model().clone() 
    79         data = fitproblem.get_data() 
    80          
     76        listdata=[] 
     77        model = fitproblem[0].get_model() 
     78        listdata = fitproblem[0].get_data() 
    8179        # Concatenate dList set (contains one or more data)before fitting 
    8280        #data=self._concatenateData( listdata) 
    83         #data = listdata 
    84         #self.curr_thread= curr_thread 
     81        data=listdata 
     82        self.curr_thread= curr_thread 
    8583 
    8684        #try: 
    87         functor = SansAssembly(self.paramList, model, data)#, curr_thread= curr_thread) 
    88         return functor , model 
    89  
    90     def fit(self, q=None, handler=None, curr_thread=None): 
    91          
    92         functor , model = self.createFunctor() 
    93          
    94         out, cov_x, info, mesg, success = optimize.leastsq(functor, 
    95                                                 model.getParams(self.paramList),  
    96                                                 full_output=1, warning=True) 
     85        functor= SansAssembly(self.paramList,model,data, curr_thread= self.curr_thread) 
     86        out, cov_x, info, mesg, success = optimize.leastsq(functor,model.getParams(self.paramList), full_output=1, warning=True) 
    9787         
    9888        chisqr = functor.chisq(out) 
     
    10898                result.pvec = out 
    10999                result.success = success 
    110                 if q is not None: 
     100                if q !=None: 
    111101                    print "went here" 
    112102                    q.put(result) 
     
    115105                return result 
    116106        else:   
    117             raise ValueError, "SVD did not converge" + str(success) 
     107            raise ValueError, "SVD did not converge"+str(success) 
    118108        #except FitAbort: 
    119109            ## fit engine is stop 
Note: See TracChangeset for help on using the changeset viewer.