Changeset 4c718654 in sasview for park_integration/ScipyFitting.py


Ignore:
Timestamp:
Jul 11, 2008 10:34:14 AM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
d4b0687
Parents:
03a20aa
Message:

Introduced abstract engine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • park_integration/ScipyFitting.py

    r4dd63eb r4c718654  
    77from Loader import Load 
    88from scipy import optimize 
    9  
     9from AbstractFitEngine import FitEngine, Parameter 
    1010 
    1111class FitArrange: 
     
    5656        self.dList=[] 
    5757             
    58 class ScipyFit: 
     58class ScipyFit(FitEngine): 
    5959    """  
    6060        ScipyFit performs the Fit.This class can be used as follow: 
     
    123123        return chisqr, out, cov 
    124124     
    125     def _concatenateData(self, listdata=[]): 
    126         """   
    127             _concatenateData method concatenates each fields of all data contains ins listdata. 
    128             @param listdata: list of data  
    129              
    130             @return xtemp, ytemp,dytemp:  x,y,dy respectively of data all combined 
    131                 if xi,yi,dyi of two or more data are the same the second appearance of xi,yi, 
    132                 dyi is ignored in the concatenation. 
    133                  
    134             @raise: if listdata is empty  will return None 
    135             @raise: if data in listdata don't contain dy field ,will create an error 
    136             during fitting 
    137         """ 
    138         if listdata==[]: 
    139             raise ValueError, " data list missing" 
    140         else: 
    141             xtemp=[] 
    142             ytemp=[] 
    143             dytemp=[] 
    144                 
    145             for data in listdata: 
    146                 for i in range(len(data.x)): 
    147                     if not data.x[i] in xtemp: 
    148                         xtemp.append(data.x[i]) 
    149                         
    150                     if not data.y[i] in ytemp: 
    151                         ytemp.append(data.y[i]) 
    152                     if data.dy and len(data.dy)>0:    
    153                         if not data.dy[i] in dytemp: 
    154                             dytemp.append(data.dy[i]) 
    155                     else: 
    156                         raise ValueError,"dy is missing will not be able to fit later on" 
    157             return xtemp, ytemp,dytemp 
    158          
    159125    def set_model(self,model,name,Uid,pars={}): 
    160126        """  
     
    222188        if self.fitArrangeList.has_key(Uid): 
    223189            del self.fitArrangeList[Uid] 
    224                  
    225  
    226 class Parameter: 
    227     """ 
    228         Class to handle model parameters 
    229     """ 
    230     def __init__(self, model, name, value=None): 
    231             self.model = model 
    232             self.name = name 
    233             if not value==None: 
    234                 self.model.setParam(self.name, value) 
    235             
    236     def set(self, value): 
    237         """ 
    238             Set the value of the parameter 
    239         """ 
    240         self.model.setParam(self.name, value) 
    241  
    242     def __call__(self): 
    243         """  
    244             Return the current value of the parameter 
    245         """ 
    246         return self.model.getParam(self.name) 
    247      
     190       
    248191def fitHelper(model, pars, x, y, err_y ,qmin=None, qmax=None): 
    249192    """ 
Note: See TracChangeset for help on using the changeset viewer.