source: sasview/sansview/perspectives/fitting/pagestate.py @ 784e2fa

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 784e2fa 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
Line 
1
2
3import copy
4
5class PageState(object):
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 = {}
17        ## reset True change the state of exsiting button
18        self.reset = False
19        #Data used for fitting
20        self.data = data
21        #engine type
22        self.engine_type = None
23        # flag to allow data2D plot
24        self.enable2D = False
25        # model on which the fit would be performed
26        self.model = model
27        #if not hasattr(self.model, "_persistency_dict"):
28        #    self.model._persistency_dict = {}
29        #self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
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
37        ##page name
38        self.page_name = ""
39        # Contains link between  model ,all its parameters, and panel organization
40        self.parameters =[]
41        # Contains list of parameters that cannot be fitted and reference to
42        #panel objects
43        self.fixed_param =[]
44        # Contains list of parameters with dispersity and reference to
45        #panel objects
46        self.fittable_param =[]
47        ## orientation parameters
48        self.orientation_params=[]
49        ## orientation parmaters for gaussian dispersity
50        self.orientation_params_disp=[]
51        ## smearer info
52        self.smearer=None
53        self.smear_type = None
54        self.dq_l = None
55        self.dq_r = None
56
57        #list of dispersion paramaters
58        self.disp_list =[]
59        if self.model !=None:
60            self.disp_list = self.model.getDispParamList()
61        self._disp_obj_dict={}
62        self.disp_cb_dict={}
63        self.values=[]
64        self.weights=[]
65                   
66        #contains link between a model and selected parameters to fit
67        self.param_toFit =[]
68        ##dictionary of model type and model class
69        self.model_list_box = None
70        ## save the state of the context menu
71        self.saved_states={}
72        ## save selection of combobox
73        self.formfactorcombobox = None
74        self.structurecombobox  = None
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
80        ## the indice of the current selection
81        self.disp_box = 0
82        ## Qrange
83        ## Q range
84        self.qmin= 0.001
85        self.qmax= 0.1
86        self.npts = None
87        self.name=""
88        ## enable smearering state
89        self.enable_smearer = False
90        self.disable_smearer = True
91        self.pinhole_smearer = False
92        self.slit_smearer   = False
93        ## disperity selection
94        self.enable_disp= False
95        self.disable_disp= True
96        ## plot 2D data
97        self.enable2D= False
98        ## state of selected all check button
99        self.cb1 = False
100        ## store value of chisqr
101        self.tcChi= None
102   
103    def clone(self):
104        model=None
105        if self.model !=None:
106            model = self.model.clone()
107       
108        obj          = PageState( self.parent,model= model )
109        obj.data = copy.deepcopy(self.data)
110        obj.model_list_box = copy.deepcopy(self.model_list_box)
111        obj.engine_type = copy.deepcopy(self.engine_type)
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       
121        obj.manager = self.manager
122        obj.event_owner = self.event_owner
123        obj.disp_list = copy.deepcopy(self.disp_list)
124       
125        obj.enable2D = copy.deepcopy(self.enable2D)
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)
129        obj.orientation_params =  copy.deepcopy(self.orientation_params)
130        obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
131        obj.enable_disp = copy.deepcopy(self.enable_disp)
132        obj.disable_disp = copy.deepcopy(self.disable_disp)
133        obj.tcChi = self.tcChi
134 
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
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
141               
142        obj.values = copy.deepcopy(self.values)
143        obj.weights = copy.deepcopy(self.weights)
144        obj.enable_smearer = copy.deepcopy(self.enable_smearer)
145        obj.disable_smearer = copy.deepcopy(self.disable_smearer)
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
152       
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)
158        obj.smearer = copy.deepcopy(self.smearer)
159       
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
164        return obj
165
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
214
215       
216       
217       
Note: See TracBrowser for help on using the repository browser.