source: sasview/sansview/perspectives/fitting/pagestate.py @ c81140c

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 c81140c was 7609f1a, checked in by Jae Cho <jhjcho@…>, 15 years ago

Added two more types of smear selections: Removed kill_focus on param box because it becomes very expensive with extensive model calculation

  • Property mode set to 100644
File size: 8.7 KB
RevLine 
[c77d859]1
2
[6f023e8]3import copy
[c77d859]4
[cfc0913]5class PageState(object):
[c77d859]6    """
7        Contains info to reconstruct a page
8    """
9    def __init__(self, parent,model=None, data=None):
10       
11        """
12            Initialization of the Panel
13        """
14        #TODO: remove this once the inheritence is cleaned up
15        ## Data member to store the dispersion object created
16        self._disp_obj_dict = {}
[cfc0913]17        ## reset True change the state of exsiting button
18        self.reset = False
[c77d859]19        #Data used for fitting
20        self.data = data
[c99a6c5]21        #engine type
22        self.engine_type = None
[c77d859]23        # flag to allow data2D plot
[cfc0913]24        self.enable2D = False
[c77d859]25        # model on which the fit would be performed
26        self.model = model
[0aeabc6]27        #if not hasattr(self.model, "_persistency_dict"):
28        #    self.model._persistency_dict = {}
29        #self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
[c77d859]30        #fit page manager
31        self.manager = None
32        #Store the parent of this panel parent
33        # For this application fitpanel is the parent
34        self.parent  = parent
35        # Event_owner is the owner of model event
36        self.event_owner = None
[c9a4377]37        ##page name
[cfc0913]38        self.page_name = ""
[c77d859]39        # Contains link between  model ,all its parameters, and panel organization
[cfc0913]40        self.parameters =[]
[c77d859]41        # Contains list of parameters that cannot be fitted and reference to
42        #panel objects
[cfc0913]43        self.fixed_param =[]
[c77d859]44        # Contains list of parameters with dispersity and reference to
45        #panel objects
[cfc0913]46        self.fittable_param =[]
[60132ef]47        ## orientation parameters
48        self.orientation_params=[]
[fc6ea43]49        ## orientation parmaters for gaussian dispersity
50        self.orientation_params_disp=[]
[3370922]51        ## smearer info
52        self.smearer=None
[7609f1a]53        self.smear_type = None
54        self.dq_l = None
55        self.dq_r = None
56
[c77d859]57        #list of dispersion paramaters
[cfc0913]58        self.disp_list =[]
[71f0373]59        if self.model !=None:
60            self.disp_list = self.model.getDispParamList()
[c477b31]61        self._disp_obj_dict={}
62        self.disp_cb_dict={}
[dad49a0]63        self.values=[]
64        self.weights=[]
65                   
[c77d859]66        #contains link between a model and selected parameters to fit
[cfc0913]67        self.param_toFit =[]
[a074145]68        ##dictionary of model type and model class
[cfc0913]69        self.model_list_box = None
[a074145]70        ## save the state of the context menu
71        self.saved_states={}
[240b9966]72        ## save selection of combobox
[3b9e023]73        self.formfactorcombobox = None
74        self.structurecombobox  = None
[240b9966]75        ## radio box to select type of model
76        self.shape_rbutton = False
77        self.shape_indep_rbutton = False
78        self.struct_rbutton = False
79        self.plugin_rbutton = False
[b787e68c]80        ## the indice of the current selection
81        self.disp_box = 0
[c77d859]82        ## Qrange
[cfc0913]83        ## Q range
84        self.qmin= 0.001
85        self.qmax= 0.1
86        self.npts = None
[240b9966]87        self.name=""
[cfc0913]88        ## enable smearering state
89        self.enable_smearer = False
[fc6ea43]90        self.disable_smearer = True
[7609f1a]91        self.pinhole_smearer = False
92        self.slit_smearer   = False
[cfc0913]93        ## disperity selection
94        self.enable_disp= False
[fc6ea43]95        self.disable_disp= True
[c477b31]96        ## plot 2D data
97        self.enable2D= False
[cfc0913]98        ## state of selected all check button
99        self.cb1 = False
[0aeabc6]100        ## store value of chisqr
101        self.tcChi= None
[240b9966]102   
[6f023e8]103    def clone(self):
104        model=None
105        if self.model !=None:
106            model = self.model.clone()
107       
[cfc0913]108        obj          = PageState( self.parent,model= model )
[6f023e8]109        obj.data = copy.deepcopy(self.data)
[dcf29d7]110        obj.model_list_box = copy.deepcopy(self.model_list_box)
[c99a6c5]111        obj.engine_type = copy.deepcopy(self.engine_type)
[240b9966]112       
113        obj.formfactorcombobox= self.formfactorcombobox
114        obj.structurecombobox  =self.structurecombobox 
115       
116        obj.shape_rbutton = self.shape_rbutton
117        obj.shape_indep_rbutton = self.shape_indep_rbutton
118        obj.struct_rbutton = self.struct_rbutton
119        obj.plugin_rbutton = self.plugin_rbutton
120       
[dcf29d7]121        obj.manager = self.manager
122        obj.event_owner = self.event_owner
[71f0373]123        obj.disp_list = copy.deepcopy(self.disp_list)
[fc6ea43]124       
[c477b31]125        obj.enable2D = copy.deepcopy(self.enable2D)
[cfc0913]126        obj.parameters = copy.deepcopy(self.parameters)
127        obj.fixed_param = copy.deepcopy(self.fixed_param)
128        obj.fittable_param = copy.deepcopy(self.fittable_param)
[60132ef]129        obj.orientation_params =  copy.deepcopy(self.orientation_params)
[fc6ea43]130        obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
[b787e68c]131        obj.enable_disp = copy.deepcopy(self.enable_disp)
[fc6ea43]132        obj.disable_disp = copy.deepcopy(self.disable_disp)
[0aeabc6]133        obj.tcChi = self.tcChi
134 
[c477b31]135        if len(self._disp_obj_dict)>0:
136            for k , v in self._disp_obj_dict.iteritems():
137                obj._disp_obj_dict[k]= v
[dad49a0]138        if len(self.disp_cb_dict)>0:
139            for k , v in self.disp_cb_dict.iteritems():
140                obj.disp_cb_dict[k]= v
[b421b1a]141               
[dad49a0]142        obj.values = copy.deepcopy(self.values)
143        obj.weights = copy.deepcopy(self.weights)
[b787e68c]144        obj.enable_smearer = copy.deepcopy(self.enable_smearer)
[fc6ea43]145        obj.disable_smearer = copy.deepcopy(self.disable_smearer)
[7609f1a]146        obj.pinhole_smearer = copy.deepcopy(self.pinhole_smearer)
147        obj.slit_smearer = copy.deepcopy(self.slit_smearer)
148        obj.smear_type = copy.deepcopy(self.smear_type)
149        obj.dq_l = copy.deepcopy(self.dq_l)
150        obj.dq_r = copy.deepcopy(self.dq_r)
151
[b421b1a]152       
[b787e68c]153        obj.disp_box = copy.deepcopy(self.disp_box)
154        obj.qmin = copy.deepcopy(self.qmin)
155        obj.qmax = copy.deepcopy(self.qmax)
156        obj.npts = copy.deepcopy(self.npts )
157        obj.cb1 = copy.deepcopy(self.cb1)
[3370922]158        obj.smearer = copy.deepcopy(self.smearer)
159       
[a074145]160        for name, state in self.saved_states.iteritems():
161            copy_name = copy.deepcopy(name)
162            copy_state = state.clone()
163            obj.saved_states[copy_name]= copy_state
[6f023e8]164        return obj
[c77d859]165
[240b9966]166     
167    def old__repr__(self):
168        """ output string for printing"""
169        rep = "\n\nState name: %s\n"%self.name
170        rep +="data : %s\n"% str(self.data)
171        rep += "Plotting Range: min: %s, max: %s, steps: %s\n"%(str(self.qmin),
172                                                str(self.qmax),str(self.npts))
173        rep +="model  : %s\n\n"% str(self.model)
174        rep +="number parameters(self.parameters): %s\n"%len(self.parameters)
175        for item in self.parameters:
176            rep += "parameter name: %s \n"%str(item[1])
177            rep += "value: %s\n"%str(item[2])
178            rep += "selected: %s\n"%str(item[0])
179            rep += "error displayed : %s \n"%str(item[4][0])
180            rep += "error value:%s \n"%str(item[4][1])
181            rep += "minimum displayed : %s \n"%str(item[5][0])
182            rep += "minimum value : %s \n"%str(item[5][1])
183            rep += "maximum displayed : %s \n"%str(item[6][0])
184            rep += "maximum value : %s \n"%str(item[6][1])
185            rep += "parameter unit: %s\n\n"%str(item[7])
186        rep +="number orientation parameters"
187        rep +="(self.orientation_params): %s\n"%len(self.orientation_params)
188        for item in self.orientation_params:
189            rep += "parameter name: %s \n"%str(item[1])
190            rep += "value: %s\n"%str(item[2])
191            rep += "selected: %s\n"%str(item[0])
192            rep += "error displayed : %s \n"%str(item[4][0])
193            rep += "error value:%s \n"%str(item[4][1])
194            rep += "minimum displayed : %s \n"%str(item[5][0])
195            rep += "minimum value : %s \n"%str(item[5][1])
196            rep += "maximum displayed : %s \n"%str(item[6][0])
197            rep += "maximum value : %s \n"%str(item[6][1])
198            rep += "parameter unit: %s\n\n"%str(item[7])
199        rep +="number dispersity parameters"
200        rep +="(self.orientation_params_disp): %s\n"%len(self.orientation_params_disp)
201        for item in self.orientation_params_disp:
202            rep += "parameter name: %s \n"%str(item[1])
203            rep += "value: %s\n"%str(item[2])
204            rep += "selected: %s\n"%str(item[0])
205            rep += "error displayed : %s \n"%str(item[4][0])
206            rep += "error value:%s \n"%str(item[4][1])
207            rep += "minimum displayed : %s \n"%str(item[5][0])
208            rep += "minimum value : %s \n"%str(item[5][1])
209            rep += "maximum displayed : %s \n"%str(item[6][0])
210            rep += "maximum value : %s \n"%str(item[6][1])
211            rep += "parameter unit: %s\n\n"%str(item[7])
212       
213        return rep
[71f0373]214
[cfc0913]215       
216       
[c77d859]217       
Note: See TracBrowser for help on using the repository browser.