Changeset a9e04aa in sasview for park_integration


Ignore:
Timestamp:
Sep 30, 2008 10:33:02 AM (16 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:
8bbab51
Parents:
3755d77
Message:

added fitting selection methods

Location:
park_integration
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • park_integration/AbstractFitEngine.py

    re71440c ra9e04aa  
    5050        self._model.details[self.name][1:] = r 
    5151    range = property(_getrange,_setrange) 
    52  
    53  
    54 class Model(object): 
     52     
     53class Model(park.Model): 
    5554    """ 
    5655        PARK wrapper for SANS models. 
     
    6059            @param sans_model: the sans model to wrap using park interface 
    6160        """ 
     61        park.Model.__init__(self, **kw) 
    6262        self.model = sans_model 
    6363        self.name = sans_model.name 
     
    108108    
    109109    
     110 
     111 
    110112class Data(object): 
    111113    """ Wrapper class  for SANS data """ 
     
    314316        if self.fitArrangeDict.has_key(Uid): 
    315317            del self.fitArrangeDict[Uid] 
    316  
     318             
     319    def select_problem_for_fit(self,Uid,value): 
     320        """ 
     321            select a couple of model and data at the Uid position in dictionary 
     322            and set in self.selected value to value 
     323            @param value: the value to allow fitting. can only have the value one or zero 
     324        """ 
     325        if self.fitArrangeDict.has_key(Uid): 
     326             self.fitArrangeDict[Uid].set_to_fit( value) 
     327    def get_problem_to_fit(self,Uid): 
     328        """ 
     329            return the self.selected value of the fit problem of Uid 
     330           @param Uid: the Uid of the problem 
     331        """ 
     332        if self.fitArrangeDict.has_key(Uid): 
     333             self.fitArrangeDict[Uid].get_to_fit() 
    317334     
    318335class FitArrange: 
     
    328345        self.model = None 
    329346        self.dList =[] 
     347        #self.selected  is zero when this fit problem is not schedule to fit  
     348        #self.selected is 1 when schedule to fit  
     349        self.selected = 0 
    330350         
    331351    def set_model(self,model): 
     
    359379        if data in self.dList: 
    360380            self.dList.remove(data) 
    361      
    362  
    363  
    364      
     381    def set_to_fit (self, value=0): 
     382        """ 
     383           set self.selected to 0 or 1  for other values raise an exception 
     384           @param value: integer between 0 or 1 
     385        """ 
     386        self.selected= value 
     387         
     388    def get_to_fit(self): 
     389        """ 
     390            @return self.selected value 
     391        """ 
     392        return self.selected 
     393     
     394 
     395 
     396     
  • park_integration/Fitting.py

    rca6d914 ra9e04aa  
    6969        self._engine.remove_Fit_Problem(Uid) 
    7070         
     71    def select_problem_for_fit(self,Uid,value): 
     72        """ 
     73            select a couple of model and data at the Uid position in dictionary 
     74            and set in self.selected value to value 
     75            @param value: the value to allow fitting. can only have the value one or zero 
     76        """ 
     77        self._engine.select_problem_for_fit(Uid,value) 
    7178         
     79    def get_problem_to_fit(self,Uid): 
     80        """ 
     81            return the self.selected value of the fit problem of Uid 
     82           @param Uid: the Uid of the problem 
     83        """ 
     84        return self._engine.get_problem_to_fit(Uid) 
  • park_integration/ParkFitting.py

    r916a15f ra9e04aa  
    5858        listmodel=[] 
    5959        i=0 
    60         for k,value in self.fitArrangeDict.iteritems(): 
    61             parkmodel = value.get_model() 
     60        fitproblems=[] 
     61        for id ,fproblem in self.fitArrangeDict.iteritems(): 
     62            if fproblem.get_to_fit()==1: 
     63                fitproblems.append(fproblem) 
     64                 
     65        if len(fitproblems)==0 :  
     66            raise RuntimeError, "No Assembly scheduled for Park fitting." 
     67            return 
     68        for item in fitproblems: 
     69            parkmodel = item.get_model() 
    6270            for p in parkmodel.parameterset: 
    6371                if p._getname()in self.paramList and not p.iscomputed(): 
     
    6674                
    6775            i+=1 
    68             Ldata=value.get_data() 
     76            Ldata=item.get_data() 
    6977            parkdata=self._concatenateData(Ldata) 
    7078             
  • park_integration/ScipyFitting.py

    re71440c ra9e04aa  
    6060        self.paramList=[] 
    6161    def fit(self,qmin=None, qmax=None): 
    62          # Protect against simultanous fitting attempts 
    63         if len(self.fitArrangeDict)>1:  
     62        # Protect against simultanous fitting attempts 
     63        #if len(self.fitArrangeDict)>1:  
     64        #    raise RuntimeError, "Scipy can't fit more than a single fit problem at a time." 
     65        # fitproblem contains first fitArrange object(one model and a list of data) 
     66        #list of fitproblem 
     67        fitproblem=[] 
     68        for id ,fproblem in self.fitArrangeDict.iteritems(): 
     69            print "ScipyFitting:fproblem.get_to_fit() ",fproblem.get_to_fit() 
     70            if fproblem.get_to_fit()==1: 
     71                fitproblem.append(fproblem) 
     72        if len(fitproblem)>1 :  
    6473            raise RuntimeError, "Scipy can't fit more than a single fit problem at a time." 
    65          
    66         # fitproblem contains first fitArrange object(one model and a list of data) 
    67         fitproblem=self.fitArrangeDict.values()[0] 
     74            return 
     75        elif len(fitproblem)==0 :  
     76            raise RuntimeError, "No Assembly scheduled for Scipy fitting." 
     77            return 
     78     
    6879        listdata=[] 
    69         model = fitproblem.get_model() 
    70         listdata = fitproblem.get_data() 
     80        model = fitproblem[0].get_model() 
     81        listdata = fitproblem[0].get_data() 
    7182        # Concatenate dList set (contains one or more data)before fitting 
    7283        data=self._concatenateData( listdata) 
Note: See TracChangeset for help on using the changeset viewer.