source: sasview/fittingview/src/sans/perspectives/fitting/fitproblem.py @ 9905d79

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 9905d79 was 49c69de, checked in by Gervaise Alina <gervyh@…>, 13 years ago

move perspective from sansview to fittingview

  • Property mode set to 100644
File size: 6.4 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
[cc31608]15        #list of data  in case of batch mode
16        self.data_list = []
17        #dictionary of data id and location to corresponding fitproblem
18        self.fitproblem_pointers = {}
[6bbeacd4]19        self.theory_data = None
[2140e68]20        ## the current model
21        self.model = None
[2f189dc]22        self.model_index = None
[925a30e]23        ## if 1 this fit problem will be selected to fit , if 0
24        ## it will not be selected for fit
[6bbeacd4]25        self.schedule = 0
[925a30e]26        ##list containing parameter name and value
[6bbeacd4]27        self.list_param = []
[925a30e]28        ## smear object to smear or not data1D
[6bbeacd4]29        self.smearer = None
30        self.fit_tab_caption = ''
[2140e68]31        ## fitting range
32        self.qmin = None
33        self.qmax = None
[cc31608]34        self.result = []
[08b9c6c8]35       
[ba1f0b2]36        # 1D or 2D
37        self.enable2D = False
38       
[9853ad0]39    def clone(self):
40        """
[5062bbf]41        copy fitproblem
[9853ad0]42        """
[e88ebfd]43       
[7c845cb]44        obj          = FitProblem()
45        model= None
46        if self.model!=None:
47            model = self.model.clone()
48        obj.model = model
[9853ad0]49        obj.fit_data = copy.deepcopy(self.fit_data)
[6bbeacd4]50        obj.theory_data = copy.deepcopy(self.theory_data)
[9853ad0]51        obj.model = copy.deepcopy(self.model)
52        obj.schedule = copy.deepcopy(self.schedule)
53        obj.list_param = copy.deepcopy(self.list_param)
54        obj.smearer = copy.deepcopy(self.smearer)
55        obj.plotted_data = copy.deepcopy(self.plotted_data)
56        obj.qmin = copy.deepcopy(self.qmin)
57        obj.qmax = copy.deepcopy(self.qmax)
[ba1f0b2]58        obj.enable2D = copy.deepcopy(self.enable2D)
[9853ad0]59        return obj
60       
[08b9c6c8]61    def set_smearer(self, smearer):
[925a30e]62        """
[5062bbf]63        save reference of  smear object on fitdata
64       
65        :param smear: smear object from DataLoader
66       
[925a30e]67        """
[08b9c6c8]68        self.smearer= smearer
[925a30e]69       
[08b9c6c8]70    def get_smearer(self):
[925a30e]71        """
[5062bbf]72        return smear object
[925a30e]73        """
[08b9c6c8]74        return self.smearer
75   
[5062bbf]76    def save_model_name(self, name):
77        """
78        """ 
[bb18ef1]79        self.name_per_page= name
80       
81    def get_name(self):
[5062bbf]82        """
83        """
[bb18ef1]84        return self.name_per_page
[08b9c6c8]85   
[2140e68]86    def set_model(self,model):
[d89f09b]87        """
[5062bbf]88        associates each model with its new created name
89       
90        :param model: model selected
91        :param name: name created for model
92       
[d89f09b]93        """
[2140e68]94        self.model= model
[bb18ef1]95       
[2140e68]96    def get_model(self):
[5062bbf]97        """
98        :return: saved model
99       
100        """
[2140e68]101        return self.model
102 
[2f189dc]103    def set_index(self, index):
104        """
[5062bbf]105        set index of the model name
[2f189dc]106        """
107        self.model_index = index
108       
109    def get_index(self):
110        """
[5062bbf]111        get index of the model name
[2f189dc]112        """
113        return self.model_index
114   
[6bbeacd4]115    def set_theory_data(self, data):
[d89f09b]116        """
[5062bbf]117        save a copy of the data select to fit
118       
119        :param data: data selected
120       
[d89f09b]121        """
[e88ebfd]122        self.theory_data = copy.deepcopy(data)
[ba1f0b2]123       
124    def set_enable2D(self, enable2D):
125        """
126        """
127        self.enable2D = enable2D
128         
[6bbeacd4]129    def get_theory_data(self):
[5062bbf]130        """
131        :return: list of data dList
132       
133        """
[6bbeacd4]134        return self.theory_data
[5062bbf]135
[6bbeacd4]136    def set_fit_data(self,data):
[2a8fac1]137        """
[5062bbf]138        save a copy of the data select to fit
139       
140        :param data: data selected
141       
[2a8fac1]142        """
143        self.fit_data = data
[d89f09b]144           
[2a8fac1]145    def get_fit_data(self):
[5062bbf]146        """
147        """
[2a8fac1]148        return self.fit_data
149   
[cc31608]150    def set_fit_data_list(self, data_list):
151        """
152        save a copy of a list of data
153       
154        :param data_list: list of data
155       
156        """
157        self.data_list = data_list
158           
159    def get_fit_data_list(self):
160        """
161        """
162        return self.data_list
163   
[2140e68]164    def set_model_param(self,name,value=None):
[d89f09b]165        """
[5062bbf]166        Store the name and value of a parameter of this fitproblem's model
167       
168        :param name: name of the given parameter
169        :param value: value of that parameter
170       
[d89f09b]171        """
[8e81af0]172        self.list_param.append([name,value])
[925a30e]173       
[00561739]174    def get_model_param(self):
175        """
[5062bbf]176        return list of couple of parameter name and value
[00561739]177        """
[8e81af0]178        return self.list_param
[d89f09b]179       
[948add7]180    def schedule_tofit(self, schedule=0):
[3b19ac9]181        """
[5062bbf]182        set schedule to true to decide if this fit  must be performed
[3b19ac9]183        """
184        self.schedule=schedule
[6bcdad1]185       
[3b19ac9]186    def get_scheduled(self):
[5062bbf]187        """
188        return true or false if a problem as being schedule for fitting
189        """
[3b19ac9]190        return self.schedule
[925a30e]191   
[2140e68]192    def set_range(self, qmin=None, qmax=None):
193        """
[5062bbf]194        set fitting range
[2140e68]195        """
196        self.qmin = qmin
197        self.qmax = qmax
198       
199    def get_range(self):
200        """
[5062bbf]201        :return: fitting range
202       
[2140e68]203        """
204        return self.qmin, self.qmax
[925a30e]205   
[9e27de9]206    def clear_model_param(self):
207        """
208        clear constraint info
209        """
[925a30e]210        self.list_param=[]
[6bbeacd4]211       
212    def set_fit_tab_caption(self, caption):
213        """
214        """
215        self.fit_tab_caption = str(caption)
216       
217    def get_fit_tab_caption(self):
218        """
219        """
220        return self.fit_tab_caption
[ba1f0b2]221   
222    def get_enable2D(self):
223        """
224        """
225        return self.enable2D
[cc31608]226   
227    def get_pointer_to_fitproblem(self):
228        """
229        return dictionary of id of fitproblem
230        """
231        return self.fitproblem_pointers
232   
233    def set_pointer_to_fitproblem(self, data_id, page_id):
234        """
235        """
236        self.fitproblem_pointers[data_id] = page_id
237       
238    def set_result(self, result):
239        """
240        set a list of result
241        """
242        self.result = result
243       
244    def get_result(self):
245        """
246        get result
247        """
248        return self.result
249       
[5062bbf]250   
Note: See TracBrowser for help on using the repository browser.