source: sasview/sansview/perspectives/fitting/fitproblem.py @ 018a0bd

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 018a0bd was 2f189dc, checked in by Gervaise Alina <gervyh@…>, 15 years ago

refactore fitpanel and removing the bug introduce while changing add fitpage use case

  • Property mode set to 100644
File size: 4.7 KB
RevLine 
[d89f09b]1
2class FitProblem:
3    """ 
4        FitProblem class allows to link a model with the new name created in _on_model,
5        a name theory created with that model  and the data fitted with the model.
6        FitProblem is mostly used  as value of the dictionary by fitting module.
7    """
8   
9    def __init__(self):
10       
11        """
[2140e68]12           contains information about data and model to fit
[d89f09b]13        """
[925a30e]14        ## data used for fitting
[2a8fac1]15        self.fit_data=None
[2140e68]16        ## the current model
17        self.model = None
[2f189dc]18        self.model_index = None
[925a30e]19        ## if 1 this fit problem will be selected to fit , if 0
20        ## it will not be selected for fit
[948add7]21        self.schedule=0
[925a30e]22        ##list containing parameter name and value
[8e81af0]23        self.list_param=[]
[925a30e]24        ## smear object to smear or not data1D
[08b9c6c8]25        self.smearer= None
[925a30e]26        ## same as fit_data but with more info for plotting
27        ## axis unit info and so on see plottables definition
[2a8fac1]28        self.plotted_data=None
[2140e68]29        ## fitting range
30        self.qmin = None
31        self.qmax = None
[08b9c6c8]32       
[9853ad0]33    def clone(self):
34        """
35            copy fitproblem
36        """
37        import copy 
[7c845cb]38        obj          = FitProblem()
39        model= None
40        if self.model!=None:
41            model = self.model.clone()
42        obj.model = model
[9853ad0]43        obj.fit_data = copy.deepcopy(self.fit_data)
44        obj.model = copy.deepcopy(self.model)
45        obj.schedule = copy.deepcopy(self.schedule)
46        obj.list_param = copy.deepcopy(self.list_param)
47        obj.smearer = copy.deepcopy(self.smearer)
48        obj.plotted_data = copy.deepcopy(self.plotted_data)
49        obj.qmin = copy.deepcopy(self.qmin)
50        obj.qmax = copy.deepcopy(self.qmax)
51       
52        return obj
53       
[925a30e]54       
[08b9c6c8]55    def set_smearer(self, smearer):
[925a30e]56        """
57          save reference of  smear object on fitdata
58          @param smear : smear object from DataLoader
59        """
[08b9c6c8]60        self.smearer= smearer
[925a30e]61       
[08b9c6c8]62    def get_smearer(self):
[925a30e]63        """
64            return smear object
65        """
[08b9c6c8]66        return self.smearer
67   
[bb18ef1]68    def save_model_name(self, name): 
69        self.name_per_page= name
70       
71       
72    def get_name(self):
73        return self.name_per_page
[08b9c6c8]74   
[2140e68]75    def set_model(self,model):
[d89f09b]76        """
77             associates each model with its new created name
78             @param model: model selected
79             @param name: name created for model
80        """
[2140e68]81        self.model= model
[bb18ef1]82       
[2140e68]83       
84    def get_model(self):
85        """ @return: saved model """
86        return self.model
87 
[2f189dc]88    def set_index(self, index):
89        """
90            set index of the model name
91        """
92        self.model_index = index
93       
94    def get_index(self):
95        """
96            get index of the model name
97        """
98        return self.model_index
99   
[2a8fac1]100    def add_plotted_data(self,data):
[d89f09b]101        """
102            save a copy of the data select to fit
103            @param data: data selected
104        """
[2a8fac1]105        self.plotted_data = data
[925a30e]106       
[2140e68]107
108    def get_plotted_data(self):
109        """ @return:  list of data dList"""
110        return self.plotted_data
111   
112   
[2a8fac1]113    def add_fit_data(self,data):
114        """
115            save a copy of the data select to fit
116            @param data: data selected
117        """
118        self.fit_data = data
[d89f09b]119           
[2140e68]120   
[2a8fac1]121    def get_fit_data(self):
122        return self.fit_data
123   
[d89f09b]124       
[2140e68]125    def set_model_param(self,name,value=None):
[d89f09b]126        """
[925a30e]127            Store the name and value of a parameter of this fitproblem's model
[d89f09b]128            @param name: name of the given parameter
129            @param value: value of that parameter
130        """
[8e81af0]131        self.list_param.append([name,value])
[925a30e]132       
133       
[00561739]134    def get_model_param(self):
135        """
[925a30e]136            @return list of couple of parameter name and value
[00561739]137        """
[8e81af0]138        return self.list_param
[d89f09b]139       
[925a30e]140       
[948add7]141    def schedule_tofit(self, schedule=0):
[3b19ac9]142        """
143             set schedule to true to decide if this fit  must be performed
144        """
145        self.schedule=schedule
[6bcdad1]146       
[2140e68]147       
[3b19ac9]148    def get_scheduled(self):
149        """ return true or false if a problem as being schedule for fitting"""
150        return self.schedule
[925a30e]151   
[2140e68]152
153    def set_range(self, qmin=None, qmax=None):
154        """
155            set fitting range
156        """
157        self.qmin = qmin
158        self.qmax = qmax
159       
160       
161    def get_range(self):
162        """
163            @return fitting range:
164        """
165        return self.qmin, self.qmax
[925a30e]166   
[9e27de9]167    def clear_model_param(self):
168        """
169        clear constraint info
170        """
[925a30e]171        self.list_param=[]
172       
[2140e68]173   
174   
[925a30e]175       
Note: See TracBrowser for help on using the repository browser.