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

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 e65050e was 3b9e023, checked in by Gervaise Alina <gervyh@…>, 15 years ago

working on save dispersity

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