Changeset fb59ed9 in sasview for theoryview/perspectives
- Timestamp:
- Oct 20, 2010 6:08:34 PM (14 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d2539aa
- Parents:
- f118fe2f
- Location:
- theoryview/perspectives/theory
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
theoryview/perspectives/theory/basepage.py
ra1b2471 rfb59ed9 80 80 ##[cb state, name, value, "+/-", error of fit, min, max , units] 81 81 self.parameters=[] 82 # non-fittable parameter whose value is astring 83 self.str_parameters = [] 82 84 ## list of parameters to fit , must be like self.parameters 83 85 self.param_toFit=[] … … 721 723 self._reset_parameters_state(self.orientation_params, 722 724 state.orientation_params) 725 self._reset_parameters_state(self.str_parameters, 726 state.str_parameters) 723 727 self._reset_parameters_state(self.parameters,state.parameters) 724 728 ## display dispersion info layer … … 1059 1063 elif k == "Structure Factors": 1060 1064 self.struct_rbutton.SetValue(True) 1065 elif k == "Multi-Functions": 1066 continue 1061 1067 else: 1062 1068 self.plugin_rbutton.SetValue(True) … … 1109 1115 elif k == "Structure Factors": 1110 1116 self.struct_rbutton.SetValue(True) 1117 elif k == "Multi-Functions": 1118 continue 1111 1119 else: 1112 1120 self.plugin_rbutton.SetValue(True) … … 1195 1203 self.text2 = wx.StaticText( self,-1,"P(Q)*S(Q)" ) 1196 1204 self.mutifactor_text = wx.StaticText( self,-1,"No. of Shells: " ) 1205 self.mutifactor_text1 = wx.StaticText( self,-1,"" ) 1197 1206 self.show_sld_button = wx.Button( self,-1,"Show SLD Profile" ) 1198 1207 self.show_sld_button.Bind(wx.EVT_BUTTON,self._on_show_sld) … … 1244 1253 mutifactor_selection.Add(self.multifactorbox) 1245 1254 mutifactor_selection.Add((5,5)) 1255 mutifactor_selection.Add(self.mutifactor_text1) 1256 mutifactor_selection.Add((10,5)) 1246 1257 mutifactor_selection.Add(self.show_sld_button) 1247 1258 … … 1253 1264 1254 1265 self._set_multfactor_combobox() 1266 self.multifactorbox.SetSelection(1) 1255 1267 self.show_sld_button.Hide() 1256 1268 … … 1271 1283 sld_data = Data1D(x,y) 1272 1284 sld_data.name = 'SLD' 1273 1274 self.panel = SLDPanel(self, data=sld_data, id =-1 )1285 sld_data.axes = self.sld_axes 1286 self.panel = SLDPanel(self, data=sld_data,axes =self.sld_axes,id =-1 ) 1275 1287 self.panel.ShowModal() 1276 1288 1277 def _set_multfactor_combobox(self ):1289 def _set_multfactor_combobox(self, multiplicity=10): 1278 1290 """ 1279 1291 Set comboBox for muitfactor of CoreMultiShellModel 1280 """ 1281 for idx in range(0,5): 1292 :param multiplicit: no. of multi-functionality 1293 """ 1294 # build content of the combobox 1295 for idx in range(0,multiplicity): 1282 1296 self.multifactorbox.Append(str(idx),int(idx)) 1283 self.multifactorbox.SetSelection(1)1297 #self.multifactorbox.SetSelection(1) 1284 1298 self._hide_multfactor_combobox() 1285 1299 … … 1290 1304 if not self.mutifactor_text.IsShown(): 1291 1305 self.mutifactor_text.Show(True) 1306 self.mutifactor_text1.Show(True) 1292 1307 if not self.multifactorbox.IsShown(): 1293 1308 self.multifactorbox.Show(True) … … 1299 1314 if self.mutifactor_text.IsShown(): 1300 1315 self.mutifactor_text.Hide() 1316 self.mutifactor_text1.Hide() 1301 1317 if self.multifactorbox.IsShown(): 1302 1318 self.multifactorbox.Hide() … … 1487 1503 # set multifactor for Mutifunctional models 1488 1504 if form_factor().__class__ in self.model_list_box["Multi-Functions"]: 1505 m_id = self.multifactorbox.GetCurrentSelection() 1506 multiplicity = form_factor().multiplicity_info[0] 1507 self.multifactorbox.Clear() 1508 #self.mutifactor_text.SetLabel(form_factor().details[]) 1509 self._set_multfactor_combobox(multiplicity) 1489 1510 self._show_multfactor_combobox() 1490 self.show_sld_button.Show(True) 1491 m_id = self.multifactorbox.GetCurrentSelection() 1511 text = form_factor().multiplicity_info[1]#'No. of Shells: ' 1512 1513 #self.mutifactor_text.Clear() 1514 self.mutifactor_text.SetLabel(text) 1515 1516 # Check max value 1517 if m_id > multiplicity -1: 1518 # default value 1519 m_id = 1 1492 1520 self.multi_factor = self.multifactorbox.GetClientData(m_id) 1493 1521 if self.multi_factor == None: self.multi_factor =1 1494 1522 form_factor = form_factor(int(self.multi_factor)) 1523 self.multifactorbox.SetSelection(m_id) 1524 # Check len of the text1 and max_multiplicity 1525 text = '' 1526 if form_factor.multiplicity_info[0] == len(form_factor.multiplicity_info[2]): 1527 text = form_factor.multiplicity_info[2][self.multi_factor] 1528 self.mutifactor_text1.SetLabel(text) 1529 # Check if model has get sld profile. 1530 if len(form_factor.multiplicity_info[3]) > 0: 1531 self.sld_axes = form_factor.multiplicity_info[3] 1532 self.show_sld_button.Show(True) 1533 else: 1534 self.sld_axes = "" 1495 1535 else: 1496 1536 self._hide_multfactor_combobox() -
theoryview/perspectives/theory/model_panel.py
r20905a0 rfb59ed9 362 362 event = PageInfoEvent(page = self) 363 363 wx.PostEvent(self.parent, event) 364 365 def _set_fun_box_list(self,fun_box): 366 """ 367 Set the list of func for multifunctional models 368 369 :param fun_box: function combo box 370 """ 371 # Check if it is multi_functional model 372 if self.model.__class__ not in self.model_list_box["Multi-Functions"]: 373 return None 374 # Get the func name list 375 list = self.model.fun_list 376 377 if len(list) == 0: 378 return None 379 380 # build function (combo)box 381 ind = 0 382 while(ind < len(list)): 383 for key, val in list.iteritems(): 384 if (val == ind): 385 fun_box.Append(key,val) 386 break 387 ind += 1 388 389 def _on_fun_box(self,event): 390 """ 391 Select an func: Erf,Rparabola,LParabola... 392 """ 393 fun_val = None 394 fun_box = event.GetEventObject() 395 name = fun_box.Name 396 value = fun_box.GetValue() 397 if self.model.fun_list.has_key(value): 398 fun_val = self.model.fun_list[value] 399 400 self.model.setParam(name,fun_val) 401 # save state 402 self._copy_parameters_state(self.str_parameters, self.state.str_parameters) 403 # update params 404 #self._update_paramv_on_fit() 405 406 # draw 407 self._draw_model() 408 self.Refresh() 409 # get ready for new event 410 event.Skip() 364 411 365 412 def set_data(self, list=[], state=None): … … 507 554 self.sizer3.Clear(True) 508 555 self.parameters = [] 556 self.str_parameters = [] 509 557 self.param_toFit=[] 510 558 self.fixed_param=[] … … 532 580 Custom compare to order, first by alphabets then second by number. 533 581 """ 582 # number at the last digit 534 583 a_last = a[len(a)-1] 535 584 b_last = b[len(b)-1] 536 585 # default 537 586 num_a = None 538 587 num_b = None 588 # split the names 589 a2 = a.lower().split('_') 590 b2 = b.lower().split('_') 591 # check length of a2, b2 592 len_a2 = len(a2) 593 len_b2 = len(b2) 539 594 # check if it contains a int number(<10) 540 595 try: … … 544 599 num_b = int(b_last) 545 600 except: pass 601 # Put 'scale' near the top; happens 602 # when numbered param name exists 603 if a == 'scale': 604 return -1 546 605 # both have a number 547 606 if num_a != None and num_b != None: 548 if num_a > num_b: return 1 607 if num_a > num_b: return -1 608 # same number 549 609 elif num_a == num_b: 550 return cmp(a.lower(), b.lower()) 551 else: return -1 610 # different last names 611 if a2[len_a2-1] != b2[len_b2-1] and num_a != 0: 612 return -cmp(a2[len_a2-1], b2[len_b2-1]) 613 else: 614 return cmp(a, b) 615 else: return 1 552 616 # one of them has a number 553 617 elif num_a != None: return 1 554 618 elif num_b != None: return -1 555 # no nu umbers619 # no numbers 556 620 else: return cmp(a.lower(), b.lower()) 557 621 558 622 keys.sort(custom_compare) 559 623 … … 578 642 iy += 1 579 643 ix = 0 580 name = wx.StaticText(self, -1,item) 581 sizer.Add( name,( iy, ix),(1,1), 582 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 583 584 ix += 1 585 value= self.model.getParam(item) 586 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 587 style=wx.TE_PROCESS_ENTER) 588 589 ctl1.SetValue(str (format_number(value))) 590 591 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 592 ix +=1 593 # Units 594 if self.model.details.has_key(item): 595 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 644 if self.model.__class__ in self.model_list_box["Multi-Functions"]\ 645 and item in self.model.non_fittable: 646 non_fittable_name = wx.StaticText(self, -1, item ) 647 sizer.Add(non_fittable_name,(iy, ix),(1,1),\ 648 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 649 ## add parameter value 650 ix += 1 651 value= self.model.getParam(item) 652 if len(self.model.fun_list) > 0: 653 num = item.split('_')[1][5:7] 654 fun_box = wx.ComboBox(self, -1,size=(100,-1),style=wx.CB_READONLY, name = '%s'% item) 655 self._set_fun_box_list(fun_box) 656 fun_box.SetSelection(0) 657 #self.fun_box.SetToolTipString("A function describing the interface") 658 wx.EVT_COMBOBOX(fun_box,-1, self._on_fun_box) 659 else: 660 fun_box = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 661 style=wx.TE_PROCESS_ENTER, name ='%s'% item) 662 fun_box.SetToolTipString("Hit 'Enter' after typing.") 663 fun_box.SetValue(format_number(value)) 664 sizer.Add(fun_box, (iy,ix),(1,1), wx.EXPAND) 665 ##[cb state, name, value, "+/-", error of fit, min, max , units] 666 self.str_parameters.append([None,item, fun_box, \ 667 None,None,None,None,None]) 596 668 else: 597 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 598 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 599 ##[cb state, name, value, "+/-", error of fit, min, max , units] 600 self.parameters.append([None,item, ctl1, 601 None,None, None, None,None]) 669 name = wx.StaticText(self, -1,item) 670 sizer.Add( name,( iy, ix),(1,1), 671 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 672 673 ix += 1 674 value= self.model.getParam(item) 675 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 676 style=wx.TE_PROCESS_ENTER) 677 678 ctl1.SetValue(str (format_number(value))) 679 680 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 681 ix +=1 682 # Units 683 if self.model.details.has_key(item): 684 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 685 else: 686 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 687 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 688 ##[cb state, name, value, "+/-", error of fit, min, max , units] 689 self.parameters.append([None,item, ctl1, 690 None,None, None, None,None]) 602 691 iy+=1 603 692 sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) -
theoryview/perspectives/theory/models.py
re87f9fc rfb59ed9 240 240 self.multiplication_factor.append(ParallelepipedModel) 241 241 242 from sans.models.CSParallelepipedModel import CSParallelepipedModel 243 self.shape_list.append(CSParallelepipedModel) 244 self.multiplication_factor.append(CSParallelepipedModel) 245 242 246 from sans.models.EllipticalCylinderModel import EllipticalCylinderModel 243 247 self.shape_list.append(EllipticalCylinderModel) 244 248 self.multiplication_factor.append(EllipticalCylinderModel) 245 249 250 from sans.models.BarBellModel import BarBellModel 251 self.shape_list.append(BarBellModel) 252 # not implemeted yet! 253 #self.multiplication_factor.append(BarBellModel) 254 255 from sans.models.CappedCylinderModel import CappedCylinderModel 256 self.shape_list.append(CappedCylinderModel) 257 # not implemeted yet! 258 #self.multiplication_factor.append(CappedCylinderModel) 259 246 260 from sans.models.EllipsoidModel import EllipsoidModel 247 261 self.shape_list.append(EllipsoidModel) … … 267 281 from sans.models.LamellarPSHGModel import LamellarPSHGModel 268 282 self.shape_list.append(LamellarPSHGModel) 283 284 from sans.models.LamellarPCrystalModel import LamellarPCrystalModel 285 self.shape_list.append(LamellarPCrystalModel) 286 287 from sans.models.SCCrystalModel import SCCrystalModel 288 self.shape_list.append(SCCrystalModel) 289 290 from sans.models.FCCrystalModel import FCCrystalModel 291 self.shape_list.append(FCCrystalModel) 292 293 from sans.models.BCCrystalModel import BCCrystalModel 294 self.shape_list.append(BCCrystalModel) 269 295 270 296 ## Structure factor … … 290 316 self.shape_indep_list.append(BEPolyelectrolyte ) 291 317 self.form_factor_dict[str(wx.NewId())] = [SphereModel] 292 318 319 from sans.models.BroadPeakModel import BroadPeakModel 320 self.shape_indep_list.append(BroadPeakModel) 321 322 from sans.models.CorrLengthModel import CorrLengthModel 323 self.shape_indep_list.append(CorrLengthModel) 324 293 325 from sans.models.DABModel import DABModel 294 326 self.shape_indep_list.append(DABModel ) … … 297 329 self.shape_indep_list.append(DebyeModel ) 298 330 331 #FractalModel (a c-model)is now being used instead of FractalAbsModel. 332 from sans.models.FractalModel import FractalModel 333 self.shape_indep_list.append(FractalModel ) 334 335 from sans.models.FractalCoreShellModel import FractalCoreShellModel 336 self.shape_indep_list.append(FractalCoreShellModel ) 337 338 from sans.models.GaussLorentzGelModel import GaussLorentzGelModel 339 self.shape_indep_list.append(GaussLorentzGelModel) 340 299 341 from sans.models.GuinierModel import GuinierModel 300 342 self.shape_indep_list.append(GuinierModel ) 301 343 302 from sans.models. FractalModel import FractalModel303 self.shape_indep_list.append( FractalModel )304 344 from sans.models.GuinierPorodModel import GuinierPorodModel 345 self.shape_indep_list.append(GuinierPorodModel ) 346 305 347 from sans.models.LorentzModel import LorentzModel 306 348 self.shape_indep_list.append( LorentzModel) … … 314 356 from sans.models.Poly_GaussCoil import Poly_GaussCoil 315 357 self.shape_indep_list.append(Poly_GaussCoil) 316 358 359 from sans.models.PolymerExclVolume import PolymerExclVolume 360 self.shape_indep_list.append(PolymerExclVolume) 361 317 362 from sans.models.PorodModel import PorodModel 318 self.shape_indep_list.append(PorodModel ) 319 320 #FractalModel (a c-model)will be used.321 #from sans.models.FractalAbsModel import FractalAbsModel322 #self.shape_indep_list.append(FractalAbsModel)363 self.shape_indep_list.append(PorodModel ) 364 365 from sans.models.RPA10Model import RPA10Model 366 self.shape_indep_list.append(RPA10Model) 367 self.multi_func_list.append(RPA10Model) 323 368 324 369 from sans.models.TeubnerStreyModel import TeubnerStreyModel 325 370 self.shape_indep_list.append(TeubnerStreyModel ) 326 371 372 from sans.models.TwoLorentzianModel import TwoLorentzianModel 373 self.shape_indep_list.append(TwoLorentzianModel ) 374 375 from sans.models.TwoPowerLawModel import TwoPowerLawModel 376 self.shape_indep_list.append(TwoPowerLawModel ) 377 378 from sans.models.UnifiedPowerRgModel import UnifiedPowerRgModel 379 self.shape_indep_list.append(UnifiedPowerRgModel ) 380 self.multi_func_list.append(UnifiedPowerRgModel) 381 327 382 from sans.models.LineModel import LineModel 328 383 self.shape_indep_list.append(LineModel) 384 385 from sans.models.ReflectivityModel import ReflectivityModel 386 self.multi_func_list.append(ReflectivityModel) 329 387 330 388 #Looking for plugins 331 389 self.plugins = findModels() 332 390 self._get_multifunc_models() 391 self.plugins.append(ReflectivityModel) 333 392 return 0 334 393 … … 347 406 self.model_combobox.set_list("Multi-Functions", self.multi_func_list) 348 407 return self.model_combobox 349 408 409 def _get_multifunc_models(self): 410 """ 411 Get the multifunctional models 412 """ 413 for item in self.plugins: 414 try: 415 # check the multiplicity if any 416 if item.multiplicity_info[0] > 1: 417 self.multi_func_list.append(item) 418 except: 419 # pass to other items 420 pass -
theoryview/perspectives/theory/pagestate.py
r4523b68 rfb59ed9 41 41 # Contains link between model ,all its parameters, and panel organization 42 42 self.parameters =[] 43 # String parameter list that can not be fitted 44 self.str_parameters = [] 43 45 # Contains list of parameters that cannot be fitted and reference to 44 46 #panel objects … … 124 126 obj.enable2D = copy.deepcopy(self.enable2D) 125 127 obj.parameters = copy.deepcopy(self.parameters) 128 obj.str_parameters = copy.deepcopy(self.str_parameters) 126 129 obj.fixed_param = copy.deepcopy(self.fixed_param) 127 130 obj.fittable_param = copy.deepcopy(self.fittable_param) … … 181 184 rep += "maximum value : %s \n"%str(item[6][1]) 182 185 rep += "parameter unit: %s\n\n"%str(item[7]) 186 rep += "number str_parameters(self.str_parameters): %s\n"%len(self.str_parameters) 183 187 rep +="number orientation parameters" 184 188 rep +="(self.orientation_params): %s\n"%len(self.orientation_params) -
theoryview/perspectives/theory/profile_dialog.py
ra1b2471 rfb59ed9 2 2 import sys 3 3 4 import copy,numpy4 from copy import deepcopy 5 5 from danse.common.plottools.PlotPanel import PlotPanel 6 6 from danse.common.plottools.plottables import Graph … … 17 17 if sys.platform.count("win32")>0: 18 18 _STATICBOX_WIDTH = 380 19 PANEL_SIZE = 4 2019 PANEL_SIZE = 475 20 20 FONT_VARIANT = 0 21 21 else: 22 22 _STATICBOX_WIDTH = 410 23 PANEL_SIZE = 45023 PANEL_SIZE = 505 24 24 FONT_VARIANT = 1 25 25 … … 36 36 ## Flag to tell the AUI manager to put this panel in the center pane 37 37 CENTER_PANE = True 38 def __init__(self, parent=None,base=None,data =None, id = -1, *args, **kwds):38 def __init__(self, parent=None,base=None,data =None,axes =['Radius'], id = -1, *args, **kwds): 39 39 kwds["style"] = wx.DEFAULT_DIALOG_STYLE 40 kwds["size"] = wx.Size(_STATICBOX_WIDTH* 2,PANEL_SIZE)40 kwds["size"] = wx.Size(_STATICBOX_WIDTH*1.5,PANEL_SIZE) 41 41 wx.Dialog.__init__(self, parent, id = id, *args, **kwds) 42 42 if data != None: … … 54 54 self.name = self.data.name 55 55 56 # Panel for 2Dplot57 self.plotpanel = SLDplotpanel(self, -1, style=wx.TRANSPARENT_WINDOW)56 # Panel for plot 57 self.plotpanel = SLDplotpanel(self, axes, -1, style=wx.TRANSPARENT_WINDOW) 58 58 self.cmap = DEFAULT_CMAP 59 59 ## Create Artist and bind it … … 61 61 62 62 self._setup_layout() 63 self.newplot=Theory1D(self.data.x,self.data.y) 63 data_plot = deepcopy(self.data) 64 self.newplot=Theory1D(data_plot.x,data_plot.y) 64 65 self.newplot.name = 'SLD' 65 66 self.plotpanel.add_image(self.newplot) … … 76 77 sizer = wx.GridBagSizer(14,14) 77 78 78 sizer.Add(self.plotpanel,(0, 0), (13, 13), wx.EXPAND | wx.LEFT| wx.RIGHT, 1 5)79 sizer.Add(self.plotpanel,(0, 0), (13, 13), wx.EXPAND | wx.LEFT| wx.RIGHT, 1) 79 80 80 81 #-----Button------------1 … … 110 111 Panel 111 112 """ 112 def __init__(self, parent, id = -1, color = None, dpi = None, **kwargs):113 def __init__(self, parent,axes=[], id = -1, color = None, dpi = None, **kwargs): 113 114 """ 114 115 """ … … 120 121 self.plots = {} 121 122 self.graph = Graph() 122 123 123 self.axes_label = [] 124 for idx in range(0,len(axes)): 125 self.axes_label.append(axes[idx]) 124 126 125 127 def add_image(self, plot): … … 133 135 self.graph.add(plot) 134 136 #add axes 135 self.graph.xaxis('\\rm{Radius} ', '\\AA') 137 x1_label = self.axes_label[0] 138 self.graph.xaxis('\\rm{%s} '% x1_label, '\\AA') 136 139 self.graph.yaxis('\\rm{SLD} ', '\\AA^{-2}') 137 140
Note: See TracChangeset
for help on using the changeset viewer.