source: sasview/theoryview/perspectives/theory/pagestate.py @ 58c90ba

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

added new models

  • Property mode set to 100644
File size: 8.6 KB
RevLine 
[0277d084]1
2
3import copy
4
5class PageState(object):
6    """
[74755ff]7    Contains info to reconstruct a page
8   
[0277d084]9    """
10    def __init__(self, parent,model=None, data=None):
11       
12        """
[74755ff]13        Initialization of the Panel
14       
[0277d084]15        """
16        #TODO: remove this once the inheritence is cleaned up
17        ## Data member to store the dispersion object created
18        self._disp_obj_dict = {}
19        ## reset True change the state of exsiting button
20        self.reset = False
21        #Data used for fitting
22        self.data = data
23        #engine type
24        self.engine_type = None
25        # flag to allow data2D plot
26        self.enable2D = False
27        # model on which the fit would be performed
28        self.model = model
29        #if not hasattr(self.model, "_persistency_dict"):
30        #    self.model._persistency_dict = {}
31        #self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
32        #fit page manager
33        self.manager = None
34        #Store the parent of this panel parent
35        # For this application fitpanel is the parent
36        self.parent  = parent
37        # Event_owner is the owner of model event
38        self.event_owner = None
39        ##page name
40        self.page_name = ""
41        # Contains link between  model ,all its parameters, and panel organization
42        self.parameters =[]
[fb59ed9]43        # String parameter list that can not be fitted
44        self.str_parameters = []
[0277d084]45        # Contains list of parameters that cannot be fitted and reference to
46        #panel objects
47        self.fixed_param =[]
48        # Contains list of parameters with dispersity and reference to
49        #panel objects
50        self.fittable_param =[]
51        ## orientation parameters
52        self.orientation_params=[]
53        ## orientation parmaters for gaussian dispersity
54        self.orientation_params_disp=[]
55        ## smearer info
56        self.smearer=None
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=""
[4523b68]88        self.multi_factor = None
[0277d084]89        ## enable smearering state
90        self.enable_smearer = False
91        self.disable_smearer = True
92        ## disperity selection
93        self.enable_disp= False
94        self.disable_disp= True
95        ## plot 2D data
96        self.enable2D= False
97        ## state of selected all check button
98        self.cb1 = False
99        ## store value of chisqr
100        self.tcChi= None
101   
102    def clone(self):
[74755ff]103        """
104        """
[0277d084]105        model=None
106        if self.model !=None:
107            model = self.model.clone()
108       
109        obj          = PageState( self.parent,model= model )
110        obj.data = copy.deepcopy(self.data)
111        obj.model_list_box = copy.deepcopy(self.model_list_box)
112        obj.engine_type = copy.deepcopy(self.engine_type)
113       
114        obj.formfactorcombobox= self.formfactorcombobox
115        obj.structurecombobox  =self.structurecombobox 
116       
117        obj.shape_rbutton = self.shape_rbutton
118        obj.shape_indep_rbutton = self.shape_indep_rbutton
119        obj.struct_rbutton = self.struct_rbutton
120        obj.plugin_rbutton = self.plugin_rbutton
121       
122        obj.manager = self.manager
123        obj.event_owner = self.event_owner
124        obj.disp_list = copy.deepcopy(self.disp_list)
125       
126        obj.enable2D = copy.deepcopy(self.enable2D)
127        obj.parameters = copy.deepcopy(self.parameters)
[fb59ed9]128        obj.str_parameters = copy.deepcopy(self.str_parameters)
[0277d084]129        obj.fixed_param = copy.deepcopy(self.fixed_param)
130        obj.fittable_param = copy.deepcopy(self.fittable_param)
131        obj.orientation_params =  copy.deepcopy(self.orientation_params)
132        obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
133        obj.enable_disp = copy.deepcopy(self.enable_disp)
134        obj.disable_disp = copy.deepcopy(self.disable_disp)
135        obj.tcChi = self.tcChi
136 
137        if len(self._disp_obj_dict)>0:
138            for k , v in self._disp_obj_dict.iteritems():
139                obj._disp_obj_dict[k]= v
140        if len(self.disp_cb_dict)>0:
141            for k , v in self.disp_cb_dict.iteritems():
142                obj.disp_cb_dict[k]= v
143               
144        obj.values = copy.deepcopy(self.values)
145        obj.weights = copy.deepcopy(self.weights)
146        obj.enable_smearer = copy.deepcopy(self.enable_smearer)
147        obj.disable_smearer = copy.deepcopy(self.disable_smearer)
148       
149        obj.disp_box = copy.deepcopy(self.disp_box)
150        obj.qmin = copy.deepcopy(self.qmin)
151        obj.qmax = copy.deepcopy(self.qmax)
[4523b68]152        obj.multi_factor = copy.deepcopy(self.multi_factor)
[0277d084]153        obj.npts = copy.deepcopy(self.npts )
154        obj.cb1 = copy.deepcopy(self.cb1)
155        obj.smearer = copy.deepcopy(self.smearer)
156       
157        for name, state in self.saved_states.iteritems():
158            copy_name = copy.deepcopy(name)
159            copy_state = state.clone()
160            obj.saved_states[copy_name]= copy_state
161        return obj
162
163     
164    def old__repr__(self):
[74755ff]165        """
166        output string for printing
167       
168        """
[0277d084]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])
[fb59ed9]186        rep += "number str_parameters(self.str_parameters): %s\n"%len(self.str_parameters)
[0277d084]187        rep +="number orientation parameters"
188        rep +="(self.orientation_params): %s\n"%len(self.orientation_params)
189        for item in self.orientation_params:
190            rep += "parameter name: %s \n"%str(item[1])
191            rep += "value: %s\n"%str(item[2])
192            rep += "selected: %s\n"%str(item[0])
193            rep += "error displayed : %s \n"%str(item[4][0])
194            rep += "error value:%s \n"%str(item[4][1])
195            rep += "minimum displayed : %s \n"%str(item[5][0])
196            rep += "minimum value : %s \n"%str(item[5][1])
197            rep += "maximum displayed : %s \n"%str(item[6][0])
198            rep += "maximum value : %s \n"%str(item[6][1])
199            rep += "parameter unit: %s\n\n"%str(item[7])
200        rep +="number dispersity parameters"
201        rep +="(self.orientation_params_disp): %s\n"%len(self.orientation_params_disp)
202        for item in self.orientation_params_disp:
203            rep += "parameter name: %s \n"%str(item[1])
204            rep += "value: %s\n"%str(item[2])
205            rep += "selected: %s\n"%str(item[0])
206            rep += "error displayed : %s \n"%str(item[4][0])
207            rep += "error value:%s \n"%str(item[4][1])
208            rep += "minimum displayed : %s \n"%str(item[5][0])
209            rep += "minimum value : %s \n"%str(item[5][1])
210            rep += "maximum displayed : %s \n"%str(item[6][0])
211            rep += "maximum value : %s \n"%str(item[6][1])
212            rep += "parameter unit: %s\n\n"%str(item[7])
213        return rep
[74755ff]214 
Note: See TracBrowser for help on using the repository browser.