[d89f09b] | 1 | import os,os.path, re |
---|
| 2 | import sys, wx, logging |
---|
[0550752] | 3 | import string, numpy, math |
---|
[d89f09b] | 4 | |
---|
[3b19ac9] | 5 | from copy import deepcopy |
---|
[dc317d1] | 6 | from danse.common.plottools.plottables import Data1D, Theory1D,Data2D |
---|
[6f73a08] | 7 | from danse.common.plottools.PlotPanel import PlotPanel |
---|
[d89f09b] | 8 | from sans.guicomm.events import NewPlotEvent, StatusEvent |
---|
[32d802f] | 9 | from sans.guicomm.events import EVT_SLICER_PANEL,EVT_MODEL2D_PANEL |
---|
[568e1a5] | 10 | |
---|
[6f73a08] | 11 | from sans.fit.AbstractFitEngine import Model,Data,FitData1D,FitData2D |
---|
[d89f09b] | 12 | from fitproblem import FitProblem |
---|
| 13 | from fitpanel import FitPanel |
---|
[e9b4cc4] | 14 | from fit_thread import FitThread |
---|
[2dbb681] | 15 | import models,modelpage |
---|
[e1a310f] | 16 | import fitpage1D,fitpage2D |
---|
[dabb633] | 17 | import park |
---|
[d250f7d] | 18 | DEFAULT_BEAM = 0.005 |
---|
[cfc68540] | 19 | DEFAULT_QMIN = 0.0 |
---|
| 20 | DEFAULT_QMAX = 0.15 |
---|
| 21 | DEFAULT_NPTS = 40 |
---|
[e9b4cc4] | 22 | import time |
---|
| 23 | import thread |
---|
| 24 | print "main",thread.get_ident() |
---|
| 25 | |
---|
[d89f09b] | 26 | class Plugin: |
---|
| 27 | """ |
---|
[dabb633] | 28 | Fitting plugin is used to perform fit |
---|
[d89f09b] | 29 | """ |
---|
| 30 | def __init__(self): |
---|
| 31 | ## Plug-in name |
---|
| 32 | self.sub_menu = "Fitting" |
---|
| 33 | |
---|
| 34 | ## Reference to the parent window |
---|
| 35 | self.parent = None |
---|
| 36 | self.menu_mng = models.ModelManager() |
---|
| 37 | ## List of panels for the simulation perspective (names) |
---|
| 38 | self.perspective = [] |
---|
[568e1a5] | 39 | self.mypanels=[] |
---|
[e9b4cc4] | 40 | self.calc_thread = None |
---|
| 41 | self.done = False |
---|
[d89f09b] | 42 | # Start with a good default |
---|
| 43 | self.elapsed = 0.022 |
---|
| 44 | self.fitter = None |
---|
| 45 | |
---|
| 46 | #Flag to let the plug-in know that it is running standalone |
---|
| 47 | self.standalone=True |
---|
| 48 | ## Fit engine |
---|
[3b19ac9] | 49 | self._fit_engine = 'scipy' |
---|
[b2c3225] | 50 | self.enable_model2D=False |
---|
[d89f09b] | 51 | # Log startup |
---|
| 52 | logging.info("Fitting plug-in started") |
---|
[32d802f] | 53 | # model 2D view |
---|
| 54 | self.model2D_id=None |
---|
[d89f09b] | 55 | |
---|
| 56 | def populate_menu(self, id, owner): |
---|
| 57 | """ |
---|
| 58 | Create a menu for the Fitting plug-in |
---|
| 59 | @param id: id to create a menu |
---|
| 60 | @param owner: owner of menu |
---|
| 61 | @ return : list of information to populate the main menu |
---|
| 62 | """ |
---|
[32d802f] | 63 | self.parent.Bind(EVT_MODEL2D_PANEL, self._on_model2D_show) |
---|
[d89f09b] | 64 | #Menu for fitting |
---|
| 65 | self.menu1 = wx.Menu() |
---|
| 66 | id1 = wx.NewId() |
---|
| 67 | self.menu1.Append(id1, '&Show fit panel') |
---|
| 68 | wx.EVT_MENU(owner, id1, self.on_perspective) |
---|
[3b19ac9] | 69 | id3 = wx.NewId() |
---|
[442895f] | 70 | self.menu1.AppendCheckItem(id3, "park") |
---|
[e5af88b] | 71 | |
---|
[3b19ac9] | 72 | wx.EVT_MENU(owner, id3, self._onset_engine) |
---|
[d89f09b] | 73 | |
---|
| 74 | #menu for model |
---|
| 75 | menu2 = wx.Menu() |
---|
[f39511b] | 76 | |
---|
[d89f09b] | 77 | self.menu_mng.populate_menu(menu2, owner) |
---|
| 78 | id2 = wx.NewId() |
---|
| 79 | owner.Bind(models.EVT_MODEL,self._on_model_menu) |
---|
[2dbb681] | 80 | #owner.Bind(modelpage.EVT_MODEL,self._on_model_menu) |
---|
[d89f09b] | 81 | self.fit_panel.set_owner(owner) |
---|
| 82 | self.fit_panel.set_model_list(self.menu_mng.get_model_list()) |
---|
[bcd6d51] | 83 | owner.Bind(fitpage1D.EVT_MODEL_BOX,self._on_model_panel) |
---|
[e1a310f] | 84 | owner.Bind(fitpage2D.EVT_MODEL_BOX,self._on_model_panel) |
---|
[3b19ac9] | 85 | #create menubar items |
---|
[d89f09b] | 86 | return [(id, self.menu1, "Fitting"),(id2, menu2, "Model")] |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | def help(self, evt): |
---|
| 90 | """ |
---|
| 91 | Show a general help dialog. |
---|
| 92 | TODO: replace the text with a nice image |
---|
| 93 | """ |
---|
[d7d143b0] | 94 | from helpDialog import HelpWindow |
---|
| 95 | dialog = HelpWindow(None, -1, 'HelpWindow') |
---|
| 96 | if dialog.ShowModal() == wx.ID_OK: |
---|
| 97 | pass |
---|
| 98 | dialog.Destroy() |
---|
| 99 | |
---|
[d89f09b] | 100 | |
---|
| 101 | def get_context_menu(self, graph=None): |
---|
| 102 | """ |
---|
| 103 | Get the context menu items available for P(r) |
---|
| 104 | @param graph: the Graph object to which we attach the context menu |
---|
| 105 | @return: a list of menu items with call-back function |
---|
| 106 | """ |
---|
| 107 | self.graph=graph |
---|
| 108 | for item in graph.plottables: |
---|
[693ab78] | 109 | if item.__class__.__name__ is "Data2D": |
---|
[2dbb681] | 110 | return [["Select data for Fitting",\ |
---|
| 111 | "Dialog with fitting parameters ", self._onSelect]] |
---|
[6f73a08] | 112 | else: |
---|
[693ab78] | 113 | if item.name==graph.selected_plottable and\ |
---|
| 114 | item.__class__.__name__ is "Data1D": |
---|
[2dbb681] | 115 | return [["Select data for Fitting", \ |
---|
| 116 | "Dialog with fitting parameters ", self._onSelect]] |
---|
[d89f09b] | 117 | return [] |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | def get_panels(self, parent): |
---|
| 121 | """ |
---|
| 122 | Create and return a list of panel objects |
---|
| 123 | """ |
---|
| 124 | self.parent = parent |
---|
| 125 | # Creation of the fit panel |
---|
| 126 | self.fit_panel = FitPanel(self.parent, -1) |
---|
| 127 | #Set the manager forthe main panel |
---|
| 128 | self.fit_panel.set_manager(self) |
---|
| 129 | # List of windows used for the perspective |
---|
| 130 | self.perspective = [] |
---|
| 131 | self.perspective.append(self.fit_panel.window_name) |
---|
| 132 | # take care of saving data, model and page associated with each other |
---|
[3b19ac9] | 133 | self.page_finder = {} |
---|
| 134 | #index number to create random model name |
---|
| 135 | self.index_model = 0 |
---|
[32673ac] | 136 | self.parent.Bind(EVT_SLICER_PANEL, self._on_slicer_event) |
---|
[888e62c] | 137 | |
---|
[32d802f] | 138 | |
---|
[3b19ac9] | 139 | #create the fitting panel |
---|
[568e1a5] | 140 | #return [self.fit_panel] |
---|
[32673ac] | 141 | |
---|
[568e1a5] | 142 | self.mypanels.append(self.fit_panel) |
---|
| 143 | return self.mypanels |
---|
[888e62c] | 144 | |
---|
| 145 | |
---|
[32d802f] | 146 | def _on_model2D_show(self, event ): |
---|
| 147 | print "model2D get the id ", event.id |
---|
[888e62c] | 148 | |
---|
| 149 | |
---|
[568e1a5] | 150 | def _on_slicer_event(self, event): |
---|
[32673ac] | 151 | print "fitting:slicer event ", event.panel |
---|
[888e62c] | 152 | if event.panel!=None: |
---|
| 153 | new_panel = event.panel |
---|
| 154 | # Set group ID if available |
---|
| 155 | event_id = self.parent.popup_panel(new_panel) |
---|
| 156 | self.menu1.Append(event_id, new_panel.window_caption, |
---|
| 157 | "Show %s plot panel" % new_panel.window_caption) |
---|
| 158 | # Set UID to allow us to reference the panel later |
---|
| 159 | new_panel.uid = event_id |
---|
| 160 | new_panel |
---|
| 161 | self.mypanels.append(new_panel) |
---|
[568e1a5] | 162 | return |
---|
[d23544dc] | 163 | def _on_show_panel(self, event): |
---|
| 164 | print "_on_show_panel: fitting" |
---|
[d89f09b] | 165 | |
---|
| 166 | def get_perspective(self): |
---|
| 167 | """ |
---|
| 168 | Get the list of panel names for this perspective |
---|
| 169 | """ |
---|
| 170 | return self.perspective |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | def on_perspective(self, event): |
---|
| 174 | """ |
---|
| 175 | Call back function for the perspective menu item. |
---|
| 176 | We notify the parent window that the perspective |
---|
| 177 | has changed. |
---|
| 178 | """ |
---|
| 179 | self.parent.set_perspective(self.perspective) |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | def post_init(self): |
---|
| 183 | """ |
---|
| 184 | Post initialization call back to close the loose ends |
---|
| 185 | [Somehow openGL needs this call] |
---|
| 186 | """ |
---|
| 187 | self.parent.set_perspective(self.perspective) |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | def _onSelect(self,event): |
---|
| 191 | """ |
---|
| 192 | when Select data to fit a new page is created .Its reference is |
---|
| 193 | added to self.page_finder |
---|
| 194 | """ |
---|
| 195 | self.panel = event.GetEventObject() |
---|
| 196 | for item in self.panel.graph.plottables: |
---|
[693ab78] | 197 | if item.name == self.panel.graph.selected_plottable or\ |
---|
| 198 | item.__class__.__name__ is "Data2D": |
---|
[3b19ac9] | 199 | #find a name for the page created for notebook |
---|
[d89f09b] | 200 | try: |
---|
[6bcdad1] | 201 | page, model_name = self.fit_panel.add_fit_page(item) |
---|
[3b19ac9] | 202 | # add data associated to the page created |
---|
[bcd6d51] | 203 | |
---|
[6f73a08] | 204 | if page !=None: |
---|
| 205 | #create a fitproblem storing all link to data,model,page creation |
---|
| 206 | self.page_finder[page]= FitProblem() |
---|
[6bcdad1] | 207 | self.page_finder[page].save_model_name(model_name) |
---|
[bcd6d51] | 208 | self.page_finder[page].add_data(item) |
---|
[d89f09b] | 209 | except: |
---|
[68dada4] | 210 | raise |
---|
[6f73a08] | 211 | wx.PostEvent(self.parent, StatusEvent(status="Creating Fit page: %s"\ |
---|
| 212 | %sys.exc_value)) |
---|
[948add7] | 213 | def schedule_for_fit(self,value=0,fitproblem =None): |
---|
| 214 | """ |
---|
| 215 | |
---|
| 216 | """ |
---|
| 217 | if fitproblem !=None: |
---|
| 218 | fitproblem.schedule_tofit(value) |
---|
| 219 | else: |
---|
| 220 | current_pg=self.fit_panel.get_current_page() |
---|
| 221 | for page, val in self.page_finder.iteritems(): |
---|
| 222 | if page ==current_pg : |
---|
| 223 | val.schedule_tofit(value) |
---|
| 224 | break |
---|
| 225 | |
---|
[d89f09b] | 226 | |
---|
| 227 | def get_page_finder(self): |
---|
| 228 | """ @return self.page_finder used also by simfitpage.py""" |
---|
| 229 | return self.page_finder |
---|
| 230 | |
---|
| 231 | |
---|
[3b19ac9] | 232 | def set_page_finder(self,modelname,names,values): |
---|
[d89f09b] | 233 | """ |
---|
| 234 | Used by simfitpage.py to reset a parameter given the string constrainst. |
---|
| 235 | @param modelname: the name ot the model for with the parameter has to reset |
---|
| 236 | @param value: can be a string in this case. |
---|
[3b19ac9] | 237 | @param names: the paramter name |
---|
[d89f09b] | 238 | @note: expecting park used for fit. |
---|
| 239 | """ |
---|
[94999eb] | 240 | sim_page=self.fit_panel.get_page(1) |
---|
[d89f09b] | 241 | for page, value in self.page_finder.iteritems(): |
---|
| 242 | if page != sim_page: |
---|
| 243 | list=value.get_model() |
---|
| 244 | model=list[0] |
---|
[bcd6d51] | 245 | #print "fitting",model.name,modelname |
---|
[d89f09b] | 246 | if model.name== modelname: |
---|
[3b19ac9] | 247 | value.set_model_param(names,values) |
---|
[d89f09b] | 248 | break |
---|
| 249 | |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | def split_string(self,item): |
---|
| 253 | """ |
---|
[3b19ac9] | 254 | receive a word containing dot and split it. used to split parameterset |
---|
| 255 | name into model name and parameter name example: |
---|
| 256 | paramaterset (item) = M1.A |
---|
| 257 | @return model_name =M1 , parameter name =A |
---|
[d89f09b] | 258 | """ |
---|
| 259 | if string.find(item,".")!=-1: |
---|
| 260 | param_names= re.split("\.",item) |
---|
| 261 | model_name=param_names[0] |
---|
| 262 | param_name=param_names[1] |
---|
| 263 | return model_name,param_name |
---|
| 264 | |
---|
[e9b4cc4] | 265 | |
---|
[4af20b4] | 266 | def _single_fit_completed(self,result,pars,cpage,qmin,qmax,elapsed, |
---|
| 267 | ymin=None, ymax=None, xmin=None, xmax=None): |
---|
[d89f09b] | 268 | """ |
---|
[3b19ac9] | 269 | Display fit result on one page of the notebook. |
---|
| 270 | @param result: result of fit |
---|
| 271 | @param pars: list of names of parameters fitted |
---|
| 272 | @param current_pg: the page where information will be displayed |
---|
| 273 | @param qmin: the minimum value of x to replot the model |
---|
| 274 | @param qmax: the maximum value of x to replot model |
---|
[d89f09b] | 275 | |
---|
| 276 | """ |
---|
[89032bf] | 277 | #print "single fit ", pars,result.pvec,result.stderr,result.fitness |
---|
[e9b4cc4] | 278 | #self.done = True |
---|
| 279 | #wx.PostEvent(self.parent, StatusEvent(status="Fitting Completed: %g" % elapsed)) |
---|
[d89f09b] | 280 | try: |
---|
| 281 | for page, value in self.page_finder.iteritems(): |
---|
[948add7] | 282 | if page==cpage : |
---|
[6f73a08] | 283 | #fitdata = value.get_data() |
---|
[d89f09b] | 284 | list = value.get_model() |
---|
| 285 | model= list[0] |
---|
| 286 | break |
---|
| 287 | i = 0 |
---|
[89032bf] | 288 | #print "fitting: single fit pars ", pars |
---|
[d89f09b] | 289 | for name in pars: |
---|
| 290 | if result.pvec.__class__==numpy.float64: |
---|
[1b07935d] | 291 | model.setParam(name,result.pvec) |
---|
[d89f09b] | 292 | else: |
---|
[1b07935d] | 293 | model.setParam(name,result.pvec[i]) |
---|
[442895f] | 294 | # print "fitting: single fit", name, result.pvec[i] |
---|
[d89f09b] | 295 | i += 1 |
---|
[26bf293] | 296 | print "fitting result : chisqr",result.fitness |
---|
| 297 | print "fitting result : pvec",result.pvec |
---|
| 298 | print "fitting result : stderr",result.stderr |
---|
[4af20b4] | 299 | print "qmin qmax xmin xmax ymin , ymax",qmin, qmax,xmin, xmax ,ymin, ymax |
---|
[442895f] | 300 | |
---|
[948add7] | 301 | cpage.onsetValues(result.fitness, result.pvec,result.stderr) |
---|
[4af20b4] | 302 | self.plot_helper(currpage=cpage,qmin=qmin,qmax=qmax, |
---|
| 303 | ymin=ymin, ymax=ymax, |
---|
| 304 | xmin=xmin, xmax=xmax,title="Fitted model 2D ") |
---|
[d89f09b] | 305 | except: |
---|
[89032bf] | 306 | #raise |
---|
[060b857] | 307 | wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) |
---|
[d89f09b] | 308 | |
---|
| 309 | |
---|
[e9b4cc4] | 310 | def _simul_fit_completed(self,result,qmin,qmax, elapsed,pars=None,cpage=None, ymin=None, ymax=None): |
---|
[d89f09b] | 311 | """ |
---|
| 312 | Parameter estimation completed, |
---|
| 313 | display the results to the user |
---|
| 314 | @param alpha: estimated best alpha |
---|
| 315 | @param elapsed: computation time |
---|
| 316 | """ |
---|
[e9b4cc4] | 317 | wx.PostEvent(self.parent, StatusEvent(status="Fitting Completed: %g" % elapsed)) |
---|
[d89f09b] | 318 | try: |
---|
| 319 | for page, value in self.page_finder.iteritems(): |
---|
[948add7] | 320 | if value.get_scheduled()==1: |
---|
[6f73a08] | 321 | #fitdata = value.get_data() |
---|
[3b19ac9] | 322 | list = value.get_model() |
---|
| 323 | model= list[0] |
---|
| 324 | |
---|
| 325 | small_out = [] |
---|
| 326 | small_cov = [] |
---|
| 327 | i = 0 |
---|
| 328 | #Separate result in to data corresponding to each page |
---|
| 329 | for p in result.parameters: |
---|
| 330 | model_name,param_name = self.split_string(p.name) |
---|
| 331 | if model.name == model_name: |
---|
| 332 | small_out.append(p.value ) |
---|
[26bf293] | 333 | small_cov.append(p.stderr) |
---|
[3b19ac9] | 334 | model.setParam(param_name,p.value) |
---|
| 335 | # Display result on each page |
---|
| 336 | page.onsetValues(result.fitness, small_out,small_cov) |
---|
| 337 | #Replot model |
---|
[9d31a8b] | 338 | self.plot_helper(currpage= page,qmin= qmin,qmax= qmax,ymin=ymin, ymax=ymax) |
---|
[d89f09b] | 339 | except: |
---|
| 340 | wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) |
---|
| 341 | |
---|
[e9b4cc4] | 342 | |
---|
[4af20b4] | 343 | def _on_single_fit(self,id=None,qmin=None, qmax=None,ymin=None, ymax=None,xmin=None,xmax=None): |
---|
[d89f09b] | 344 | """ |
---|
| 345 | perform fit for the current page and return chisqr,out and cov |
---|
| 346 | @param engineName: type of fit to be performed |
---|
| 347 | @param id: unique id corresponding to a fit problem(model, set of data) |
---|
| 348 | @param model: model to fit |
---|
| 349 | |
---|
| 350 | """ |
---|
[948add7] | 351 | #print "in single fitting" |
---|
[d89f09b] | 352 | #set an engine to perform fit |
---|
| 353 | from sans.fit.Fitting import Fit |
---|
| 354 | self.fitter= Fit(self._fit_engine) |
---|
[3b19ac9] | 355 | #Setting an id to store model and data in fit engine |
---|
[d89f09b] | 356 | if id==None: |
---|
[17fc6f8] | 357 | self.id=0 |
---|
| 358 | else: |
---|
| 359 | self.id = id |
---|
[948add7] | 360 | page_fitted=None |
---|
| 361 | fit_problem=None |
---|
[3b19ac9] | 362 | #Get information (model , data) related to the page on |
---|
| 363 | #with the fit will be perform |
---|
[57f3320] | 364 | #current_pg=self.fit_panel.get_current_page() |
---|
| 365 | #simul_pg=self.fit_panel.get_page(0) |
---|
[948add7] | 366 | |
---|
[d89f09b] | 367 | for page, value in self.page_finder.iteritems(): |
---|
[948add7] | 368 | if value.get_scheduled() ==1 : |
---|
[9d31a8b] | 369 | metadata = value.get_data() |
---|
[d89f09b] | 370 | list=value.get_model() |
---|
| 371 | model=list[0] |
---|
[08b9c6c8] | 372 | smearer= value.get_smearer() |
---|
[26bf293] | 373 | print "single fit", model, smearer |
---|
[3b19ac9] | 374 | #Create list of parameters for fitting used |
---|
[d89f09b] | 375 | pars=[] |
---|
| 376 | templist=[] |
---|
| 377 | try: |
---|
[948add7] | 378 | #templist=current_pg.get_param_list() |
---|
| 379 | templist=page.get_param_list() |
---|
| 380 | for element in templist: |
---|
| 381 | pars.append(str(element[0].GetLabelText())) |
---|
| 382 | pars.sort() |
---|
[89032bf] | 383 | #print "single fit start pars:", pars |
---|
[948add7] | 384 | #Do the single fit |
---|
[3b19ac9] | 385 | self.fitter.set_model(Model(model), self.id, pars) |
---|
[888e62c] | 386 | #print "args...:",metadata,self.id,smearer,qmin,qmax,ymin,ymax |
---|
[17fc6f8] | 387 | |
---|
| 388 | self.fitter.set_data(data=metadata,Uid=self.id, |
---|
| 389 | smearer=smearer,qmin= qmin,qmax=qmax, |
---|
| 390 | ymin=ymin,ymax=ymax) |
---|
| 391 | |
---|
[948add7] | 392 | self.fitter.select_problem_for_fit(Uid=self.id,value=value.get_scheduled()) |
---|
| 393 | page_fitted=page |
---|
| 394 | self.id+=1 |
---|
| 395 | self.schedule_for_fit( 0,value) |
---|
[d89f09b] | 396 | except: |
---|
[26bf293] | 397 | raise |
---|
| 398 | #wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) |
---|
[d89f09b] | 399 | return |
---|
[948add7] | 400 | # make sure to keep an alphabetic order |
---|
| 401 | #of parameter names in the list |
---|
| 402 | try: |
---|
[e9b4cc4] | 403 | # If a thread is already started, stop it |
---|
| 404 | if self.calc_thread != None and self.calc_thread.isrunning(): |
---|
| 405 | self.calc_thread.stop() |
---|
| 406 | |
---|
| 407 | self.calc_thread =FitThread(parent =self.parent, |
---|
| 408 | fn= self.fitter, |
---|
| 409 | pars= pars, |
---|
| 410 | cpage= page_fitted, |
---|
| 411 | qmin=qmin, |
---|
| 412 | qmax=qmax, |
---|
[26bf293] | 413 | |
---|
[e9b4cc4] | 414 | completefn=self._single_fit_completed, |
---|
| 415 | updatefn=None) |
---|
| 416 | self.calc_thread.queue() |
---|
| 417 | self.calc_thread.ready(2.5) |
---|
| 418 | #while not self.done: |
---|
| 419 | #print "when here" |
---|
| 420 | # time.sleep(1) |
---|
| 421 | |
---|
| 422 | |
---|
[948add7] | 423 | except: |
---|
[26bf293] | 424 | raise |
---|
[948add7] | 425 | wx.PostEvent(self.parent, StatusEvent(status="Single Fit error: %s" % sys.exc_value)) |
---|
| 426 | return |
---|
[d89f09b] | 427 | |
---|
[9d31a8b] | 428 | def _on_simul_fit(self, id=None,qmin=None,qmax=None, ymin=None, ymax=None): |
---|
[d89f09b] | 429 | """ |
---|
| 430 | perform fit for all the pages selected on simpage and return chisqr,out and cov |
---|
| 431 | @param engineName: type of fit to be performed |
---|
| 432 | @param id: unique id corresponding to a fit problem(model, set of data) |
---|
| 433 | in park_integration |
---|
| 434 | @param model: model to fit |
---|
| 435 | |
---|
| 436 | """ |
---|
| 437 | #set an engine to perform fit |
---|
| 438 | from sans.fit.Fitting import Fit |
---|
| 439 | self.fitter= Fit(self._fit_engine) |
---|
[3b19ac9] | 440 | |
---|
[d89f09b] | 441 | #Setting an id to store model and data |
---|
| 442 | if id==None: |
---|
| 443 | id = 0 |
---|
| 444 | self.id = id |
---|
[3b19ac9] | 445 | |
---|
[d89f09b] | 446 | for page, value in self.page_finder.iteritems(): |
---|
| 447 | try: |
---|
[948add7] | 448 | if value.get_scheduled()==1: |
---|
[9d31a8b] | 449 | metadata = value.get_data() |
---|
[3b19ac9] | 450 | list = value.get_model() |
---|
| 451 | model= list[0] |
---|
[d89f09b] | 452 | #Create dictionary of parameters for fitting used |
---|
| 453 | pars = [] |
---|
| 454 | templist = [] |
---|
[3b19ac9] | 455 | templist = page.get_param_list() |
---|
[d89f09b] | 456 | for element in templist: |
---|
| 457 | try: |
---|
| 458 | name = str(element[0].GetLabelText()) |
---|
| 459 | pars.append(name) |
---|
| 460 | except: |
---|
| 461 | wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) |
---|
| 462 | return |
---|
[c80c06f] | 463 | # need to check this print "new model " |
---|
[00561739] | 464 | new_model=Model(model) |
---|
[8e81af0] | 465 | param=value.get_model_param() |
---|
| 466 | |
---|
| 467 | if len(param)>0: |
---|
| 468 | for item in param: |
---|
| 469 | param_value = item[1] |
---|
| 470 | param_name = item[0] |
---|
| 471 | #print "fitting ", param,param_name, param_value |
---|
| 472 | |
---|
| 473 | #new_model.set( model.getParam(param_name[0])= param_value) |
---|
| 474 | #new_model.set( exec"%s=%s"%(param_name[0], param_value)) |
---|
| 475 | #new_model.set( exec "%s"%(param_nam) = param_value) |
---|
| 476 | new_model.parameterset[ param_name].set( param_value ) |
---|
[c80c06f] | 477 | |
---|
[948add7] | 478 | self.fitter.set_model(new_model, self.id, pars) |
---|
[9d31a8b] | 479 | self.fitter.set_data(metadata,self.id,qmin,qmax,ymin,ymax) |
---|
[948add7] | 480 | self.fitter.select_problem_for_fit(Uid=self.id,value=value.get_scheduled()) |
---|
[3b19ac9] | 481 | self.id += 1 |
---|
[d89f09b] | 482 | except: |
---|
[89032bf] | 483 | #raise |
---|
[3b19ac9] | 484 | wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) |
---|
| 485 | return |
---|
[dabb633] | 486 | #Do the simultaneous fit |
---|
[d89f09b] | 487 | try: |
---|
[e9b4cc4] | 488 | # If a thread is already started, stop it |
---|
| 489 | if self.calc_thread != None and self.calc_thread.isrunning(): |
---|
| 490 | self.calc_thread.stop() |
---|
| 491 | |
---|
| 492 | self.calc_thread =FitThread(parent =self.parent, |
---|
| 493 | fn= self.fitter, |
---|
| 494 | qmin=qmin, |
---|
| 495 | qmax=qmax, |
---|
| 496 | ymin= ymin, |
---|
| 497 | ymax= ymax, |
---|
| 498 | completefn= self._simul_fit_completed, |
---|
| 499 | updatefn=None) |
---|
| 500 | self.calc_thread.queue() |
---|
| 501 | self.calc_thread.ready(2.5) |
---|
| 502 | |
---|
[d89f09b] | 503 | except: |
---|
[89032bf] | 504 | #raise |
---|
[d89f09b] | 505 | wx.PostEvent(self.parent, StatusEvent(status="Simultaneous Fitting error: %s" % sys.exc_value)) |
---|
| 506 | return |
---|
[3b19ac9] | 507 | |
---|
| 508 | |
---|
| 509 | def _onset_engine(self,event): |
---|
| 510 | """ set engine to scipy""" |
---|
| 511 | if self._fit_engine== 'park': |
---|
| 512 | self._on_change_engine('scipy') |
---|
| 513 | else: |
---|
| 514 | self._on_change_engine('park') |
---|
| 515 | wx.PostEvent(self.parent, StatusEvent(status="Engine set to: %s" % self._fit_engine)) |
---|
| 516 | |
---|
| 517 | |
---|
[d89f09b] | 518 | def _on_change_engine(self, engine='park'): |
---|
| 519 | """ |
---|
| 520 | Allow to select the type of engine to perform fit |
---|
| 521 | @param engine: the key work of the engine |
---|
| 522 | """ |
---|
| 523 | self._fit_engine = engine |
---|
| 524 | |
---|
| 525 | |
---|
| 526 | def _on_model_panel(self, evt): |
---|
| 527 | """ |
---|
| 528 | react to model selection on any combo box or model menu.plot the model |
---|
| 529 | """ |
---|
[e1a310f] | 530 | |
---|
[d89f09b] | 531 | model = evt.model |
---|
| 532 | name = evt.name |
---|
[32d802f] | 533 | |
---|
[94999eb] | 534 | sim_page=self.fit_panel.GetPage(1) |
---|
[d89f09b] | 535 | current_pg = self.fit_panel.get_current_page() |
---|
| 536 | if current_pg != sim_page: |
---|
| 537 | current_pg.set_panel(model) |
---|
[6bcdad1] | 538 | model.name = self.page_finder[current_pg].get_name() |
---|
[d89f09b] | 539 | try: |
---|
[bcd6d51] | 540 | metadata=self.page_finder[current_pg].get_data() |
---|
[6bcdad1] | 541 | M_name=model.name+"= "+name+"("+metadata.group_id+")" |
---|
[d89f09b] | 542 | except: |
---|
[6bcdad1] | 543 | M_name=model.name+"= "+name |
---|
| 544 | #model.name="M"+str(self.index_model) |
---|
[d89f09b] | 545 | self.index_model += 1 |
---|
[6bcdad1] | 546 | # save model name |
---|
[442895f] | 547 | |
---|
[6bcdad1] | 548 | # save the name containing the data name with the appropriate model |
---|
[1b07935d] | 549 | self.page_finder[current_pg].set_model(model,M_name) |
---|
[d89f09b] | 550 | self.plot_helper(currpage= current_pg,qmin= None,qmax= None) |
---|
| 551 | sim_page.add_model(self.page_finder) |
---|
| 552 | |
---|
[08b9c6c8] | 553 | def set_smearer(self,smearer): |
---|
| 554 | current_pg=self.fit_panel.get_current_page() |
---|
| 555 | self.page_finder[current_pg].set_smearer(smearer) |
---|
| 556 | |
---|
[d89f09b] | 557 | def redraw_model(self,qmin= None,qmax= None): |
---|
| 558 | """ |
---|
| 559 | Draw a theory according to model changes or data range. |
---|
| 560 | @param qmin: the minimum value plotted for theory |
---|
| 561 | @param qmax: the maximum value plotted for theory |
---|
| 562 | """ |
---|
| 563 | current_pg=self.fit_panel.get_current_page() |
---|
| 564 | for page, value in self.page_finder.iteritems(): |
---|
| 565 | if page ==current_pg : |
---|
| 566 | break |
---|
| 567 | self.plot_helper(currpage=page,qmin= qmin,qmax= qmax) |
---|
| 568 | |
---|
[89032bf] | 569 | def plot_helper(self,currpage, fitModel=None, qmin=None,qmax=None, |
---|
[4af20b4] | 570 | ymin=None,ymax=None, xmin=None, xmax=None,title=None ): |
---|
[d89f09b] | 571 | """ |
---|
| 572 | Plot a theory given a model and data |
---|
| 573 | @param model: the model from where the theory is derived |
---|
| 574 | @param currpage: page in a dictionary referring to some data |
---|
| 575 | """ |
---|
[26bf293] | 576 | if self.fit_panel.GetPageCount() >1: |
---|
[d89f09b] | 577 | for page in self.page_finder.iterkeys(): |
---|
| 578 | if page==currpage : |
---|
[bcd6d51] | 579 | data=self.page_finder[page].get_data() |
---|
| 580 | list=self.page_finder[page].get_model() |
---|
| 581 | model=list[0] |
---|
[d89f09b] | 582 | break |
---|
[26bf293] | 583 | print "model in fitting",model |
---|
[693ab78] | 584 | if data!=None and data.__class__.__name__ != 'Data2D': |
---|
[d89f09b] | 585 | theory = Theory1D(x=[], y=[]) |
---|
[6bcdad1] | 586 | theory.name = model.name |
---|
[d89f09b] | 587 | theory.group_id = data.group_id |
---|
[6bcdad1] | 588 | theory.id = "Model" |
---|
[d89f09b] | 589 | x_name, x_units = data.get_xaxis() |
---|
| 590 | y_name, y_units = data.get_yaxis() |
---|
| 591 | theory.xaxis(x_name, x_units) |
---|
| 592 | theory.yaxis(y_name, y_units) |
---|
| 593 | if qmin == None : |
---|
| 594 | qmin = min(data.x) |
---|
| 595 | if qmax == None : |
---|
[4af20b4] | 596 | qmax = max(data.x) |
---|
[d89f09b] | 597 | try: |
---|
| 598 | tempx = qmin |
---|
[1b07935d] | 599 | tempy = model.run(qmin) |
---|
[d89f09b] | 600 | theory.x.append(tempx) |
---|
| 601 | theory.y.append(tempy) |
---|
| 602 | except : |
---|
| 603 | wx.PostEvent(self.parent, StatusEvent(status="fitting \ |
---|
| 604 | skipping point x %g %s" %(qmin, sys.exc_value))) |
---|
| 605 | |
---|
| 606 | for i in range(len(data.x)): |
---|
| 607 | try: |
---|
| 608 | if data.x[i]> qmin and data.x[i]< qmax: |
---|
| 609 | tempx = data.x[i] |
---|
[1b07935d] | 610 | tempy = model.run(tempx) |
---|
[d89f09b] | 611 | theory.x.append(tempx) |
---|
| 612 | theory.y.append(tempy) |
---|
[04edd0d] | 613 | |
---|
[d89f09b] | 614 | except: |
---|
| 615 | wx.PostEvent(self.parent, StatusEvent(status="fitting \ |
---|
| 616 | skipping point x %g %s" %(data.x[i], sys.exc_value))) |
---|
| 617 | try: |
---|
| 618 | tempx = qmax |
---|
[1b07935d] | 619 | tempy = model.run(qmax) |
---|
[d89f09b] | 620 | theory.x.append(tempx) |
---|
| 621 | theory.y.append(tempy) |
---|
| 622 | except: |
---|
[00561739] | 623 | wx.PostEvent(self.parent, StatusEvent(status="fitting \ |
---|
[32d802f] | 624 | skipping point x %g %s" %(qmin, sys.exc_value)) ) |
---|
| 625 | wx.PostEvent(self.parent, NewPlotEvent(plot=theory, |
---|
| 626 | title=str(data.name))) |
---|
[6f73a08] | 627 | else: |
---|
[89032bf] | 628 | |
---|
[dc317d1] | 629 | theory=Data2D(data.data, data.err_data) |
---|
[6bcdad1] | 630 | theory.name= model.name |
---|
[89032bf] | 631 | if title !=None: |
---|
| 632 | self.title = title |
---|
| 633 | theory.id= self.title |
---|
| 634 | theory.group_id= self.title+data.name |
---|
| 635 | else: |
---|
| 636 | self.title= "Analytical model 2D " |
---|
| 637 | theory.id= "Model" |
---|
| 638 | theory.group_id= "Model"+data.name |
---|
[6f73a08] | 639 | theory.x_bins= data.x_bins |
---|
| 640 | theory.y_bins= data.y_bins |
---|
| 641 | tempy=[] |
---|
[4af20b4] | 642 | print "max x,y",max(data.xmax,data.xmin),max(data.ymax,data.ymin) |
---|
[17fc6f8] | 643 | if qmin==None: |
---|
[4af20b4] | 644 | qmin=0#data.xmin |
---|
[17fc6f8] | 645 | if qmax==None: |
---|
[4af20b4] | 646 | qmax=math.sqrt(math.pow(max(math.fabs(data.xmax),math.fabs(data.xmin)),2)/ |
---|
| 647 | +math.pow(max(math.fabs(data.ymax),math.fabs(data.ymin)),2)) |
---|
[17fc6f8] | 648 | if ymin==None: |
---|
| 649 | ymin=data.ymin |
---|
| 650 | if ymax==None: |
---|
| 651 | ymax=data.ymax |
---|
[4af20b4] | 652 | if xmin ==None: |
---|
| 653 | xmin=data.xmin |
---|
| 654 | if xmax==None: |
---|
| 655 | xmax=data.xmax |
---|
[888e62c] | 656 | #print " q range =", |
---|
[57668f8] | 657 | theory.data = numpy.zeros((len(data.y_bins),len(data.x_bins))) |
---|
[4af20b4] | 658 | for j in range(len(data.y_bins)): |
---|
| 659 | for i in range(len(data.x_bins)): |
---|
| 660 | tempqij=math.sqrt((math.pow(data.y_bins[j],2)+math.pow(data.x_bins[i],2))) |
---|
| 661 | if tempqij>= qmin: |
---|
| 662 | if tempqij<= qmax: |
---|
[17fc6f8] | 663 | theory.data[j][i]=model.runXY([data.y_bins[j],data.x_bins[i]]) |
---|
[4af20b4] | 664 | else: |
---|
| 665 | theory.data[j][i]=0 |
---|
[26bf293] | 666 | |
---|
[44bbf6a] | 667 | #print "fitting : plot_helper:", theory.image |
---|
[6f73a08] | 668 | #print data.image |
---|
[2dbb681] | 669 | #print "fitting : plot_helper:",theory.image |
---|
[1f62278] | 670 | theory.detector= data.detector |
---|
| 671 | theory.source= data.source |
---|
[6f73a08] | 672 | theory.zmin= data.zmin |
---|
| 673 | theory.zmax= data.zmax |
---|
[17fc6f8] | 674 | theory.xmin= xmin |
---|
| 675 | theory.xmax= xmax |
---|
[4274c0e] | 676 | theory.ymin= ymin |
---|
| 677 | theory.ymax= ymax |
---|
[04edd0d] | 678 | |
---|
[32d802f] | 679 | wx.PostEvent(self.parent, NewPlotEvent(plot=theory, |
---|
[89032bf] | 680 | title=self.title +str(data.name))) |
---|
[6f73a08] | 681 | |
---|
| 682 | |
---|
[d89f09b] | 683 | def _on_model_menu(self, evt): |
---|
| 684 | """ |
---|
| 685 | Plot a theory from a model selected from the menu |
---|
| 686 | """ |
---|
[86c1832] | 687 | name = evt.model.__name__ |
---|
| 688 | if hasattr(evt.model, "name"): |
---|
| 689 | name = evt.model.name |
---|
[32d802f] | 690 | print "on model menu", name |
---|
[b2c3225] | 691 | model=evt.model() |
---|
[2dbb681] | 692 | description=model.description |
---|
[3dc83be] | 693 | |
---|
| 694 | # Create a model page. If a new page is created, the model |
---|
| 695 | # will be plotted automatically. If a page already exists, |
---|
| 696 | # the content will be updated and the plot refreshed |
---|
| 697 | self.fit_panel.add_model_page(model,description,name,topmenu=True) |
---|
[1b07935d] | 698 | |
---|
[26bf293] | 699 | def draw_model(self,model,name ,data=None,description=None,enable1D=True, enable2D=False, |
---|
[cfc68540] | 700 | qmin=DEFAULT_QMIN, qmax=DEFAULT_QMAX, qstep=DEFAULT_NPTS): |
---|
[3b19ac9] | 701 | """ |
---|
| 702 | draw model with default data value |
---|
| 703 | """ |
---|
[26bf293] | 704 | if data !=None: |
---|
| 705 | print "qmin qmax",qmin, qmax |
---|
| 706 | self.redraw_model(qmin,qmax) |
---|
| 707 | return |
---|
[d74d751] | 708 | self._draw_model2D(model=model, |
---|
| 709 | description=model.description, |
---|
| 710 | enable2D= enable2D, |
---|
| 711 | qmin=qmin, |
---|
| 712 | qmax=qmax, |
---|
[c48a26a] | 713 | qstep=qstep) |
---|
[86c1832] | 714 | self._draw_model1D(model,name,model.description, enable1D,qmin,qmax, qstep) |
---|
[cfc68540] | 715 | |
---|
| 716 | def _draw_model1D(self,model,name,description=None, enable1D=True, |
---|
| 717 | qmin=DEFAULT_QMIN, qmax=DEFAULT_QMAX, qstep=DEFAULT_NPTS): |
---|
[e5a9e32] | 718 | |
---|
[d250f7d] | 719 | if enable1D: |
---|
[d15c0202] | 720 | x= numpy.linspace(start= qmin, |
---|
| 721 | stop= qmax, |
---|
| 722 | num= qstep, |
---|
| 723 | endpoint=True |
---|
| 724 | ) |
---|
[f39511b] | 725 | xlen= len(x) |
---|
| 726 | y = numpy.zeros(xlen) |
---|
[d250f7d] | 727 | if not enable1D: |
---|
[f39511b] | 728 | for i in range(xlen): |
---|
| 729 | y[i] = model.run(x[i]) |
---|
[d15c0202] | 730 | |
---|
[f39511b] | 731 | try: |
---|
| 732 | new_plot = Theory1D(x, y) |
---|
[32d802f] | 733 | |
---|
[86c1832] | 734 | new_plot.name = name |
---|
[f39511b] | 735 | new_plot.xaxis("\\rm{Q}", 'A^{-1}') |
---|
| 736 | new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") |
---|
[6bcdad1] | 737 | new_plot.id = "Model" |
---|
| 738 | new_plot.group_id ="Model" |
---|
[f39511b] | 739 | wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Analytical model 1D")) |
---|
| 740 | except: |
---|
[32d802f] | 741 | wx.PostEvent(self.parent, StatusEvent(status="Draw model 1D error: %s" % sys.exc_value)) |
---|
| 742 | #raise |
---|
[f39511b] | 743 | else: |
---|
| 744 | for i in range(xlen): |
---|
| 745 | y[i] = model.run(x[i]) |
---|
[d15c0202] | 746 | #print x, y |
---|
[f39511b] | 747 | try: |
---|
| 748 | new_plot = Theory1D(x, y) |
---|
[32d802f] | 749 | print "draw model 1D", name |
---|
[86c1832] | 750 | new_plot.name = name |
---|
[f39511b] | 751 | new_plot.xaxis("\\rm{Q}", 'A^{-1}') |
---|
| 752 | new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") |
---|
[6bcdad1] | 753 | new_plot.id ="Model" |
---|
| 754 | new_plot.group_id ="Model" |
---|
[3dc83be] | 755 | |
---|
| 756 | # Pass the reset flag to let the plotting event handler |
---|
| 757 | # know that we are replacing the whole plot |
---|
[6bcdad1] | 758 | wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, |
---|
[3dc83be] | 759 | title="Analytical model 1D ", reset=True )) |
---|
[f39511b] | 760 | |
---|
| 761 | except: |
---|
[32d802f] | 762 | #raise |
---|
| 763 | wx.PostEvent(self.parent, StatusEvent(status="Draw model 1D error: %s" % sys.exc_value)) |
---|
[e9b4cc4] | 764 | def update(self, output,time): |
---|
| 765 | pass |
---|
[20be946] | 766 | |
---|
[b2c6d23] | 767 | def complete(self, output, elapsed, model, qmin, qmax,qstep=DEFAULT_NPTS): |
---|
[26bf293] | 768 | |
---|
[20be946] | 769 | wx.PostEvent(self.parent, StatusEvent(status="Calc \ |
---|
| 770 | complete in %g sec" % elapsed)) |
---|
[d15c0202] | 771 | #print "complete",output, model,qmin, qmax |
---|
[20be946] | 772 | data = output |
---|
| 773 | theory= Data2D(data) |
---|
[d15c0202] | 774 | #print data.detector |
---|
| 775 | #theory.detector= data.detector |
---|
| 776 | from DataLoader.data_info import Detector, Source |
---|
| 777 | |
---|
| 778 | detector = Detector() |
---|
| 779 | theory.detector=[] |
---|
| 780 | theory.detector.append(detector) |
---|
| 781 | |
---|
[b2c6d23] | 782 | theory.detector[0].pixel_size.x= qmax/(qstep/2-1)#5.0 |
---|
| 783 | theory.detector[0].pixel_size.y= qmax/(qstep/2-1)#5.0 |
---|
| 784 | theory.detector[0].beam_center.x= qmax |
---|
| 785 | theory.detector[0].beam_center.y= qmax |
---|
| 786 | theory.detector[0].distance= 1e+12#13705.0 |
---|
[d15c0202] | 787 | theory.source= Source() |
---|
[b2c6d23] | 788 | theory.source.wavelength= 2*math.pi/1e+12#8.4 |
---|
[d15c0202] | 789 | |
---|
[20be946] | 790 | theory.name= model.name |
---|
| 791 | theory.group_id ="Model" |
---|
| 792 | theory.id ="Model" |
---|
[d15c0202] | 793 | theory.xmin= -qmax |
---|
[20be946] | 794 | theory.xmax= qmax |
---|
[d15c0202] | 795 | theory.ymin= -qmax |
---|
[20be946] | 796 | theory.ymax= qmax |
---|
[b2c6d23] | 797 | |
---|
[89032bf] | 798 | print "model draw comptele xmax",theory.xmax,model.name |
---|
[20be946] | 799 | wx.PostEvent(self.parent, NewPlotEvent(plot=theory, |
---|
[32d802f] | 800 | title="Analytical model 2D ", reset=True )) |
---|
[20be946] | 801 | |
---|
| 802 | |
---|
| 803 | |
---|
[cfc68540] | 804 | def _draw_model2D(self,model,description=None, enable2D=False, |
---|
| 805 | qmin=DEFAULT_QMIN, qmax=DEFAULT_QMAX, qstep=DEFAULT_NPTS): |
---|
[d15c0202] | 806 | |
---|
| 807 | x= numpy.linspace(start= -1*qmax, |
---|
| 808 | stop= qmax, |
---|
| 809 | num= qstep, |
---|
| 810 | endpoint=True ) |
---|
| 811 | y = numpy.linspace(start= -1*qmax, |
---|
| 812 | stop= qmax, |
---|
| 813 | num= qstep, |
---|
| 814 | endpoint=True ) |
---|
| 815 | |
---|
[dc317d1] | 816 | lx = len(x) |
---|
[1c5b068] | 817 | #print x |
---|
[dc317d1] | 818 | data=numpy.zeros([len(x),len(y)]) |
---|
[20be946] | 819 | self.model= model |
---|
[dc317d1] | 820 | if enable2D: |
---|
[20be946] | 821 | from model_thread import Calc2D |
---|
[d15c0202] | 822 | self.calc_thread = Calc2D(parent =self.parent,x=x, |
---|
| 823 | y=y,model= self.model, |
---|
| 824 | qmin=qmin, |
---|
| 825 | qmax=qmax, |
---|
[b2c6d23] | 826 | qstep=qstep, |
---|
[20be946] | 827 | completefn=self.complete, |
---|
[e9b4cc4] | 828 | updatefn=None) |
---|
[20be946] | 829 | self.calc_thread.queue() |
---|
| 830 | self.calc_thread.ready(2.5) |
---|
[89032bf] | 831 | |
---|
| 832 | def show_panel2D(self, id=None ): |
---|
[32d802f] | 833 | self.parent.show_panel(self.model2D_id) |
---|
[20be946] | 834 | |
---|
[db709e4] | 835 | |
---|
[d89f09b] | 836 | if __name__ == "__main__": |
---|
| 837 | i = Plugin() |
---|
| 838 | |
---|
| 839 | |
---|
| 840 | |
---|
| 841 | |
---|