source: sasview/sansview/perspectives/fitting/fitproblem.py @ c9636f7

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since c9636f7 was 925a30e, checked in by Gervaise Alina <gervyh@…>, 16 years ago

comments added to class

  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[d89f09b]1from sans.fit.AbstractFitEngine import Model
2
3class FitProblem:
4    """ 
5        FitProblem class allows to link a model with the new name created in _on_model,
6        a name theory created with that model  and the data fitted with the model.
7        FitProblem is mostly used  as value of the dictionary by fitting module.
8    """
9   
10    def __init__(self):
11       
12        """
13            @ self.data :is the data selected to perform the fit
14            @ self.theory_name: the name of the theory created with self.model
15            @ self.model_list:  is a list containing a model as first element
16            and its name assign example [lineModel, M0]
17        """
[925a30e]18        ## data used for fitting
[2a8fac1]19        self.fit_data=None
[925a30e]20        ## list containing couple of model and its name
[d89f09b]21        self.model_list=[]
[925a30e]22        ## if 1 this fit problem will be selected to fit , if 0
23        ## it will not be selected for fit
[948add7]24        self.schedule=0
[925a30e]25        ##list containing parameter name and value
[8e81af0]26        self.list_param=[]
[925a30e]27        ## smear object to smear or not data1D
[08b9c6c8]28        self.smearer= None
[925a30e]29        ## same as fit_data but with more info for plotting
30        ## axis unit info and so on see plottables definition
[2a8fac1]31        self.plotted_data=None
[08b9c6c8]32       
[925a30e]33       
[08b9c6c8]34    def set_smearer(self, smearer):
[925a30e]35        """
36          save reference of  smear object on fitdata
37          @param smear : smear object from DataLoader
38        """
[08b9c6c8]39        self.smearer= smearer
[925a30e]40       
[08b9c6c8]41    def get_smearer(self):
[925a30e]42        """
43            return smear object
44        """
[08b9c6c8]45        return self.smearer
46   
47   
[d89f09b]48    def set_model(self,model,name):
49        """
50             associates each model with its new created name
51             @param model: model selected
52             @param name: name created for model
53        """
54        self.model_list=[model,name]
55
56 
[2a8fac1]57    def add_plotted_data(self,data):
[d89f09b]58        """
59            save a copy of the data select to fit
60            @param data: data selected
61        """
[2a8fac1]62        self.plotted_data = data
[925a30e]63       
64       
[2a8fac1]65    def add_fit_data(self,data):
66        """
67            save a copy of the data select to fit
68            @param data: data selected
69        """
70        self.fit_data = data
[d89f09b]71           
72    def get_model(self):
73        """ @return: saved model """
74        return self.model_list
75     
[2a8fac1]76    def get_plotted_data(self):
[d89f09b]77        """ @return:  list of data dList"""
[2a8fac1]78        return self.plotted_data
79   
80   
81    def get_fit_data(self):
82        return self.fit_data
83   
84   
[d89f09b]85    def get_theory(self):
86        """ @return the name of theory for plotting purpose"""
87        return self.theory_name
88   
89   
90    def set_theory(self,name):
91        """
92            Set theory name
93            @param name: name of the theory
94        """
95        self.theory_name = name
96
97       
98    def set_model_param(self,name,value):
99        """
[925a30e]100            Store the name and value of a parameter of this fitproblem's model
[d89f09b]101            @param name: name of the given parameter
102            @param value: value of that parameter
103        """
[8e81af0]104        self.list_param.append([name,value])
[925a30e]105       
106       
[00561739]107    def get_model_param(self):
108        """
[925a30e]109            @return list of couple of parameter name and value
[00561739]110        """
[8e81af0]111        return self.list_param
[d89f09b]112       
[925a30e]113       
[d89f09b]114    def reset_model(self,model):
115        """
116            reset a model when parameter has changed
117            @param value: new model
118        """
119        self.model_list[0]=model
120       
[925a30e]121       
[948add7]122    def schedule_tofit(self, schedule=0):
[3b19ac9]123        """
124             set schedule to true to decide if this fit  must be performed
125        """
126        self.schedule=schedule
[6bcdad1]127       
[3b19ac9]128    def get_scheduled(self):
129        """ return true or false if a problem as being schedule for fitting"""
130        return self.schedule
[925a30e]131   
132   
[9e27de9]133    def clear_model_param(self):
134        """
135        clear constraint info
136        """
[925a30e]137        self.list_param=[]
138       
139       
Note: See TracBrowser for help on using the repository browser.