source: sasview/sansview/perspectives/fitting/fitproblem.py @ 027e8f2

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 027e8f2 was 7c845cb, checked in by Gervaise Alina <gervyh@…>, 16 years ago

open and closing page and simpage update

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