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

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 f932c02 was e88ebfd, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on guiframe

  • Property mode set to 100644
File size: 5.0 KB
RevLine 
[e88ebfd]1import copy 
[d89f09b]2
3class FitProblem:
4    """ 
[5062bbf]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.
[d89f09b]8    """
9    def __init__(self):
10        """
[5062bbf]11        contains information about data and model to fit
[d89f09b]12        """
[925a30e]13        ## data used for fitting
[6bbeacd4]14        self.fit_data = None
15        self.theory_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
[6bbeacd4]21        self.schedule = 0
[925a30e]22        ##list containing parameter name and value
[6bbeacd4]23        self.list_param = []
[925a30e]24        ## smear object to smear or not data1D
[6bbeacd4]25        self.smearer = None
26        self.fit_tab_caption = ''
[2140e68]27        ## fitting range
28        self.qmin = None
29        self.qmax = None
[08b9c6c8]30       
[9853ad0]31    def clone(self):
32        """
[5062bbf]33        copy fitproblem
[9853ad0]34        """
[e88ebfd]35       
[7c845cb]36        obj          = FitProblem()
37        model= None
38        if self.model!=None:
39            model = self.model.clone()
40        obj.model = model
[9853ad0]41        obj.fit_data = copy.deepcopy(self.fit_data)
[6bbeacd4]42        obj.theory_data = copy.deepcopy(self.theory_data)
[9853ad0]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        return obj
51       
[08b9c6c8]52    def set_smearer(self, smearer):
[925a30e]53        """
[5062bbf]54        save reference of  smear object on fitdata
55       
56        :param smear: smear object from DataLoader
57       
[925a30e]58        """
[08b9c6c8]59        self.smearer= smearer
[925a30e]60       
[08b9c6c8]61    def get_smearer(self):
[925a30e]62        """
[5062bbf]63        return smear object
[925a30e]64        """
[08b9c6c8]65        return self.smearer
66   
[5062bbf]67    def save_model_name(self, name):
68        """
69        """ 
[bb18ef1]70        self.name_per_page= name
71       
72    def get_name(self):
[5062bbf]73        """
74        """
[bb18ef1]75        return self.name_per_page
[08b9c6c8]76   
[2140e68]77    def set_model(self,model):
[d89f09b]78        """
[5062bbf]79        associates each model with its new created name
80       
81        :param model: model selected
82        :param name: name created for model
83       
[d89f09b]84        """
[2140e68]85        self.model= model
[bb18ef1]86       
[2140e68]87    def get_model(self):
[5062bbf]88        """
89        :return: saved model
90       
91        """
[2140e68]92        return self.model
93 
[2f189dc]94    def set_index(self, index):
95        """
[5062bbf]96        set index of the model name
[2f189dc]97        """
98        self.model_index = index
99       
100    def get_index(self):
101        """
[5062bbf]102        get index of the model name
[2f189dc]103        """
104        return self.model_index
105   
[6bbeacd4]106    def set_theory_data(self, data):
[d89f09b]107        """
[5062bbf]108        save a copy of the data select to fit
109       
110        :param data: data selected
111       
[d89f09b]112        """
[e88ebfd]113        self.theory_data = copy.deepcopy(data)
114     
[6bbeacd4]115    def get_theory_data(self):
[5062bbf]116        """
117        :return: list of data dList
118       
119        """
[6bbeacd4]120        return self.theory_data
[5062bbf]121
[6bbeacd4]122    def set_fit_data(self,data):
[2a8fac1]123        """
[5062bbf]124        save a copy of the data select to fit
125       
126        :param data: data selected
127       
[2a8fac1]128        """
129        self.fit_data = data
[d89f09b]130           
[2a8fac1]131    def get_fit_data(self):
[5062bbf]132        """
133        """
[2a8fac1]134        return self.fit_data
135   
[2140e68]136    def set_model_param(self,name,value=None):
[d89f09b]137        """
[5062bbf]138        Store the name and value of a parameter of this fitproblem's model
139       
140        :param name: name of the given parameter
141        :param value: value of that parameter
142       
[d89f09b]143        """
[8e81af0]144        self.list_param.append([name,value])
[925a30e]145       
[00561739]146    def get_model_param(self):
147        """
[5062bbf]148        return list of couple of parameter name and value
[00561739]149        """
[8e81af0]150        return self.list_param
[d89f09b]151       
[948add7]152    def schedule_tofit(self, schedule=0):
[3b19ac9]153        """
[5062bbf]154        set schedule to true to decide if this fit  must be performed
[3b19ac9]155        """
156        self.schedule=schedule
[6bcdad1]157       
[3b19ac9]158    def get_scheduled(self):
[5062bbf]159        """
160        return true or false if a problem as being schedule for fitting
161        """
[3b19ac9]162        return self.schedule
[925a30e]163   
[2140e68]164    def set_range(self, qmin=None, qmax=None):
165        """
[5062bbf]166        set fitting range
[2140e68]167        """
168        self.qmin = qmin
169        self.qmax = qmax
170       
171    def get_range(self):
172        """
[5062bbf]173        :return: fitting range
174       
[2140e68]175        """
176        return self.qmin, self.qmax
[925a30e]177   
[9e27de9]178    def clear_model_param(self):
179        """
180        clear constraint info
181        """
[925a30e]182        self.list_param=[]
[6bbeacd4]183       
184    def set_fit_tab_caption(self, caption):
185        """
186        """
187        self.fit_tab_caption = str(caption)
188       
189    def get_fit_tab_caption(self):
190        """
191        """
192        return self.fit_tab_caption
193   
[5062bbf]194   
Note: See TracBrowser for help on using the repository browser.