Changeset 634ca14 in sasview for park_integration/src/sans


Ignore:
Timestamp:
Oct 5, 2011 1:15:32 PM (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:
d91d2c9
Parents:
41661a0
Message:

making sure each result know it data and model

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

Legend:

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

    r1cff677 r634ca14  
    170170    a way to get residuals from data. 
    171171    """ 
    172     def __init__(self, x, y, dx=None, dy=None, smearer=None): 
     172    def __init__(self, x, y, dx=None, dy=None, smearer=None, data=None): 
    173173        """ 
    174174        :param smearer: is an object of class QSmearer or SlitSmearer 
     
    191191        """ 
    192192        Data1D.__init__(self, x=x, y=y, dx=dx, dy=dy) 
    193          
     193        self.sans_data = data 
    194194        self.smearer = smearer 
    195195        self._first_unsmeared_bin = None 
     
    309309        self.radius = 0 
    310310        self.res_err_data = [] 
     311        self.sans_data = sans_data2d 
    311312        self.set_data(sans_data2d) 
    312313 
     
    625626            fitdata = FitData1D(x=data.x, y=data.y , 
    626627                                 dx=data.dx, dy=data.dy, smearer=smearer) 
     628        fitdata.sans_data = data 
    627629        
    628630        fitdata.set_fit_range(qmin=qmin, qmax=qmax) 
  • park_integration/src/sans/fit/Fitting.py

    rcc83c649 r634ca14  
    5555                                ftol=ftol) 
    5656      
    57     def set_model(self, model, id, pars=[], constraints=[]): 
     57    def set_model(self, model, id, pars=[], constraints=[], data=None): 
    5858        """ 
    5959        store a model model to fit at the position id of the fit engine 
    6060        """ 
    61         self._engine.set_model(model, id, pars, constraints) 
     61        self._engine.set_model(model, id, pars, constraints, data=data) 
    6262    
    6363    def set_data(self, data, id, smearer=None, qmin=None, qmax=None): 
  • park_integration/src/sans/fit/ParkFitting.py

    r1cff677 r634ca14  
    2424from sans.fit.AbstractFitEngine import FitEngine 
    2525   
     26class SansFitResult(fitresult.FitResult): 
     27    def __init__(self, *args, **kwrds): 
     28        fitresult.FitResult.__init__(self, *args, **kwrds) 
     29        self.inputs = [] 
     30         
    2631class SansFitSimplex(FitSimplex): 
    2732    """ 
     
    5762        fitpars = [SansFitParameter(pars[i].name,pars[i].range,v, pars[i].model, pars[i].data) 
    5863                   for i,v in enumerate(result.x)] 
    59         res = fitresult.FitResult(fitpars, result.calls, result.fx) 
     64        res = SansFitResult(fitpars, result.calls, result.fx) 
     65        res.inputs = [(pars[i].model, pars[i].data) for i,v in enumerate(result.x)] 
    6066        # Compute the parameter uncertainties from the jacobian 
    6167        res.calc_cov(fitness) 
     
    384390        self.problem.all_results(result) 
    385391         
    386         #print "park------", self.problem.parts 
     392        #print "park------", result.inputs 
     393        #for (model, data) in result.inputs: 
     394        #    print model.name, data.name 
     395        #for p in result.parameters: 
     396        #    print "simul ----", p , p.__class__, p.model.name, p.data.name 
    387397    
    388398        if result != None: 
  • park_integration/src/sans/fit/ScipyFitting.py

    r82bff0b r634ca14  
    1414from sans.fit.AbstractFitEngine import SansAssembly 
    1515from sans.fit.AbstractFitEngine import FitAbort 
     16from sans.fit.AbstractFitEngine import Model 
    1617IS_MAC = True 
    1718if sys.platform.count("win32") > 0: 
     
    2223    Storing fit result 
    2324    """ 
    24     def __init__(self, model=None, param_list=None): 
     25    def __init__(self, model=None, param_list=None, data=None): 
    2526        self.calls = None 
    2627        self.fitness = None 
     
    3435        self.parameters = None 
    3536        self.is_mac = IS_MAC 
     37        if issubclass(model.__class__, Model): 
     38            model = model.model 
    3639        self.model = model 
     40        self.data = data 
    3741        self.param_list = param_list 
    3842        self.iterations = 0 
     43         
     44        self.inputs = [(self.model, self.data)] 
    3945      
    4046    def set_model(self, model): 
     
    139145        self._check_param_range(model) 
    140146         
    141         result = fitresult(model=model, param_list=self.param_list) 
     147        result = fitresult(model=model, data=data.sans_data, param_list=self.param_list) 
    142148        if handler is not None: 
    143149            handler.set_result(result=result) 
     
    182188            result.pvec = out 
    183189            result.success = success 
     190            print "scipy", result.inputs 
    184191            if q is not None: 
    185192                q.put(result) 
Note: See TracChangeset for help on using the changeset viewer.