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

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 f5348253 was ba1f0b2, checked in by Jae Cho <jhjcho@…>, 14 years ago

fixed 2D smear draw updating

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