Changeset 9ff861b in sasview
- Timestamp:
- Aug 1, 2009 8:29:38 AM (15 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:
- e082e2c
- Parents:
- 6dc9ad8
- Location:
- prview/perspectives/pr
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
prview/perspectives/pr/explore_dialog.py
r96c430d r9ff861b 27 27 from danse.common.plottools.plottables import Graph 28 28 29 from pr_widgets import PrTextCtrl 30 29 31 # Default number of points on the output plot 30 32 DEFAULT_NPTS = 10 … … 148 150 149 151 # Control for number of points 150 self.npts_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))152 self.npts_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 151 153 # Control for the minimum value of D_max 152 self.dmin_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))154 self.dmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 153 155 # Control for the maximum value of D_max 154 self.dmax_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))156 self.dmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 155 157 156 158 # Output selection box for the y axis -
prview/perspectives/pr/inversion_panel.py
r0ccd214 r9ff861b 9 9 import sys 10 10 import logging 11 from wx.lib.scrolledpanel import ScrolledPanel 11 12 from sans.guicomm.events import StatusEvent 12 13 from inversion_state import InversionState 13 14 class InversionDlg(wx.Dialog): 15 def __init__(self, parent, id, title, plots, file=False, pars=True): 16 17 # Estimate size 18 nplots = len(plots) 19 # y size for data set only 20 ysize = 110 + nplots*20 21 # y size including parameters 22 if pars: 23 ysize += 90 24 25 wx.Dialog.__init__(self, parent, id, title, size=(250, ysize)) 26 self.SetTitle(title) 27 28 # Data set 29 self.datasets = InversionPanel(self, -1, plots) 30 vbox = wx.BoxSizer(wx.VERTICAL) 31 32 vbox.Add(self.datasets) 33 34 # Parameters 35 self.pars_flag = False 36 if pars==True: 37 self.pars_flag = True 38 self.pars = ParsDialog(self, -1, file=file) 39 vbox.Add(self.pars) 40 41 static_line = wx.StaticLine(self, -1) 42 vbox.Add(static_line, 0, wx.EXPAND, 0) 43 44 button_OK = wx.Button(self, wx.ID_OK, "OK") 45 button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 46 47 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 48 sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 49 sizer_button.Add(button_OK, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10) 50 sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 51 vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 52 53 self.SetSizer(vbox) 54 self.SetAutoLayout(True) 55 56 self.Layout() 57 self.Centre() 58 59 def get_content(self): 60 dataset = self.datasets.get_selected() 61 if self.pars_flag: 62 nfunc, alpha, dmax, file = self.pars.getContent() 63 return dataset, nfunc, alpha, dmax 64 else: 65 return dataset 66 67 def set_content(self, dataset, nfunc, alpha, dmax): 68 if not dataset==None and dataset in self.datasets.radio_buttons.keys(): 69 self.datasets.radio_buttons[dataset].SetValue(True) 70 if self.pars_flag: 71 self.pars.setContent(nfunc, alpha, dmax, None) 72 73 class InversionPanel(wx.Panel): 74 75 def __init__(self, parent, id = -1, plots = None, **kwargs): 76 wx.Panel.__init__(self, parent, id = id, **kwargs) 77 78 self.plots = plots 79 self.radio_buttons = {} 80 81 self._do_layout() 82 83 def _do_layout(self): 84 panel = wx.Panel(self, -1) 85 vbox = wx.BoxSizer(wx.VERTICAL) 86 87 ysize = 30+20*len(self.plots) 88 wx.StaticBox(panel, -1, 'Choose a data set', (5, 5), (230, ysize)) 89 ypos = 30 90 self.radio_buttons = {} 91 for item in self.plots.keys(): 92 self.radio_buttons[self.plots[item].name] = wx.RadioButton(panel, -1, self.plots[item].name, (15, ypos)) 93 ypos += 20 94 95 vbox.Add(panel) 96 97 self.SetSizer(vbox) 98 99 def get_selected(self): 100 for item in self.radio_buttons: 101 if self.radio_buttons[item].GetValue(): 102 return item 103 return None 104 105 class InversionControl(wx.Panel): 14 from pr_widgets import PrTextCtrl, DataFileTextCtrl, OutputTextCtrl 15 16 17 18 class InversionControl(ScrolledPanel): 106 19 window_name = 'pr_control' 107 20 window_caption = "P(r) control panel" … … 114 27 115 28 def __init__(self, parent, id = -1, plots = None, standalone=False, **kwargs): 116 wx.Panel.__init__(self, parent, id = id, **kwargs) 29 ScrolledPanel.__init__(self, parent, id = id, **kwargs) 30 self.SetupScrolling() 117 31 118 32 self.plots = plots … … 451 365 pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 452 366 453 self.plot_data = wx.TextCtrl(self, -1, size=(220,20))454 self.plot_data.SetEditable(False)455 pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx. ADJUST_MINSIZE, 15)367 self.plot_data = DataFileTextCtrl(self, -1, size=(260,20)) 368 369 pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 15) 456 370 457 371 self.bck_chk = wx.CheckBox(self, -1, "Estimate background level") … … 475 389 #label_sunits1 = wx.StaticText(self, -1, "[A^(-1)]") 476 390 label_sunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55,20)) 477 self.sheight_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))478 self.swidth_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))391 self.sheight_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 392 self.swidth_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 479 393 self.sheight_ctl.SetToolTipString("Enter slit height in units of Q or leave blank.") 480 394 self.swidth_ctl.SetToolTipString("Enter slit width in units of Q or leave blank.") … … 506 420 #label_qunits1 = wx.StaticText(self, -1, "[A^(-1)]") 507 421 label_qunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55,20)) 508 self.qmin_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))509 self.qmax_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))422 self.qmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 423 self.qmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 510 424 self.qmin_ctl.SetToolTipString("Select a lower bound for Q or leave blank.") 511 425 self.qmax_ctl.SetToolTipString("Select an upper bound for Q or leave blank.") … … 550 464 #self.label_sugg.Hide() 551 465 552 self.nfunc_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))466 self.nfunc_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 553 467 self.nfunc_ctl.SetToolTipString("Number of terms in the expansion.") 554 self.alpha_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))468 self.alpha_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 555 469 self.alpha_ctl.SetToolTipString("Control parameter for the size of the regularization term.") 556 self.dmax_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))470 self.dmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 557 471 self.dmax_ctl.SetToolTipString("Maximum distance between any two points in the system.") 558 472 id = wx.NewId() … … 618 532 label_bck = wx.StaticText(self, -1, "Background") 619 533 label_bck_unit = wx.StaticText(self, -1, "[A^(-1)]") 620 self.rg_ctl = wx.TextCtrl(self, -1, size=(60,20)) 621 self.rg_ctl.SetEditable(False) 534 self.rg_ctl = OutputTextCtrl(self, -1, size=(60,20)) 622 535 self.rg_ctl.SetToolTipString("Radius of gyration for the computed P(r).") 623 self.iq0_ctl = wx.TextCtrl(self, -1, size=(60,20)) 624 self.iq0_ctl.SetEditable(False) 536 self.iq0_ctl = OutputTextCtrl(self, -1, size=(60,20)) 625 537 self.iq0_ctl.SetToolTipString("Scattering intensity at Q=0 for the computed P(r).") 626 self.bck_ctl = wx.TextCtrl(self, -1, size=(60,20)) 627 self.bck_ctl.SetEditable(False) 538 self.bck_ctl = OutputTextCtrl(self, -1, size=(60,20)) 628 539 self.bck_ctl.SetToolTipString("Value of estimated constant background.") 629 540 … … 636 547 label_pos_err = wx.StaticText(self, -1, "1-sigma positive fraction") 637 548 638 self.time_ctl = wx.TextCtrl(self, -1, size=(60,20)) 639 self.time_ctl.SetEditable(False) 549 self.time_ctl = OutputTextCtrl(self, -1, size=(60,20)) 640 550 self.time_ctl.SetToolTipString("Computation time for the last inversion, in seconds.") 641 551 642 self.chi2_ctl = wx.TextCtrl(self, -1, size=(60,20)) 643 self.chi2_ctl.SetEditable(False) 552 self.chi2_ctl = OutputTextCtrl(self, -1, size=(60,20)) 644 553 self.chi2_ctl.SetToolTipString("Chi^2 over degrees of freedom.") 645 554 646 555 # Oscillation parameter 647 self.osc_ctl = wx.TextCtrl(self, -1, size=(60,20)) 648 self.osc_ctl.SetEditable(False) 556 self.osc_ctl = OutputTextCtrl(self, -1, size=(60,20)) 649 557 self.osc_ctl.SetToolTipString("Oscillation parameter. P(r) for a sphere has an oscillation parameter of 1.1.") 650 558 651 559 # Positive fraction figure of merit 652 self.pos_ctl = wx.TextCtrl(self, -1, size=(60,20)) 653 self.pos_ctl.SetEditable(False) 560 self.pos_ctl = OutputTextCtrl(self, -1, size=(60,20)) 654 561 self.pos_ctl.SetToolTipString("Fraction of P(r) that is positive. Theoretically, P(r) is defined positive.") 655 562 656 563 # 1-simga positive fraction figure of merit 657 self.pos_err_ctl = wx.TextCtrl(self, -1, size=(60,20)) 658 self.pos_err_ctl.SetEditable(False) 564 self.pos_err_ctl = OutputTextCtrl(self, -1, size=(60,20)) 659 565 message = "Fraction of P(r) that is at least 1 standard deviation greater than zero.\n" 660 566 message += "This figure of merit tells you about the size of the P(r) errors.\n" … … 1019 925 1020 926 label_npts = wx.StaticText(self, -1, "Number of points") 1021 self.npts_ctl = wx.TextCtrl(self, -1, size=(100,20))927 self.npts_ctl = PrTextCtrl(self, -1, size=(100,20)) 1022 928 1023 929 pars_sizer = wx.GridBagSizer(5,5) … … 1079 985 self.npts_ctl.SetValue("%i" % npts) 1080 986 1081 1082 class ParsDialog(wx.Panel):1083 """1084 Dialog box to let the user edit detector settings1085 """1086 1087 def __init__(self, parent, id = id, file=True, **kwargs):1088 1089 wx.Panel.__init__(self, parent, id = id, **kwargs)1090 self.file = file1091 1092 self.label_nfunc = wx.StaticText(self, -1, "Number of terms")1093 self.label_alpha = wx.StaticText(self, -1, "Regularization constant")1094 self.label_dmax = wx.StaticText(self, -1, "Max distance [A]")1095 1096 # Npts, q max1097 self.nfunc_ctl = wx.TextCtrl(self, -1, size=(60,20))1098 self.alpha_ctl = wx.TextCtrl(self, -1, size=(60,20))1099 self.dmax_ctl = wx.TextCtrl(self, -1, size=(60,20))1100 1101 self.label_file = None1102 self.file_ctl = None1103 1104 self.static_line_3 = wx.StaticLine(self, -1)1105 1106 1107 1108 self.__do_layout()1109 1110 self.Fit()1111 1112 def _load_file(self, evt):1113 import os1114 path = None1115 dlg = wx.FileDialog(self, "Choose a file", os.getcwd(), "", "*.txt", wx.OPEN)1116 if dlg.ShowModal() == wx.ID_OK:1117 path = dlg.GetPath()1118 mypath = os.path.basename(path)1119 dlg.Destroy()1120 1121 if path and os.path.isfile(path):1122 self.file_ctl.SetValue(str(path))1123 1124 1125 def checkValues(self, event):1126 flag = True1127 try:1128 float(self.alpha_ctl.GetValue())1129 self.alpha_ctl.SetBackgroundColour(wx.WHITE)1130 self.alpha_ctl.Refresh()1131 except:1132 flag = False1133 self.alpha_ctl.SetBackgroundColour("pink")1134 self.alpha_ctl.Refresh()1135 1136 try:1137 float(self.dmax_ctl.GetValue())1138 self.dmax_ctl.SetBackgroundColour(wx.WHITE)1139 self.dmax_ctl.Refresh()1140 except:1141 flag = False1142 self.dmax_ctl.SetBackgroundColour("pink")1143 self.dmax_ctl.Refresh()1144 1145 try:1146 int(self.nfunc_ctl.GetValue())1147 self.nfunc_ctl.SetBackgroundColour(wx.WHITE)1148 self.nfunc_ctl.Refresh()1149 except:1150 flag = False1151 self.nfunc_ctl.SetBackgroundColour("pink")1152 self.nfunc_ctl.Refresh()1153 1154 if flag:1155 event.Skip(True)1156 1157 def setContent(self, nfunc, alpha, dmax, file):1158 self.nfunc_ctl.SetValue(str(nfunc))1159 self.alpha_ctl.SetValue(str(alpha))1160 self.dmax_ctl.SetValue(str(dmax))1161 if self.file:1162 self.file_ctl.SetValue(str(file))1163 1164 def getContent(self):1165 nfunc = int(self.nfunc_ctl.GetValue())1166 alpha = float(self.alpha_ctl.GetValue())1167 dmax = float(self.dmax_ctl.GetValue())1168 file = None1169 if self.file:1170 file = self.file_ctl.GetValue()1171 return nfunc, alpha, dmax, file1172 1173 1174 def __do_layout(self):1175 sizer_main = wx.BoxSizer(wx.VERTICAL)1176 sizer_params = wx.GridBagSizer(5,5)1177 1178 iy = 01179 sizer_params.Add(self.label_nfunc, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1180 sizer_params.Add(self.nfunc_ctl, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)1181 iy += 11182 sizer_params.Add(self.label_alpha, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1183 sizer_params.Add(self.alpha_ctl, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)1184 iy += 11185 sizer_params.Add(self.label_dmax, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1186 sizer_params.Add(self.dmax_ctl, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)1187 iy += 11188 if self.file:1189 self.label_file = wx.StaticText(self, -1, "Input file")1190 self.file_ctl = wx.TextCtrl(self, -1, size=(120,20))1191 sizer_params.Add(self.label_file, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1192 sizer_params.Add(self.file_ctl, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)1193 1194 sizer_main.Add(sizer_params, 0, wx.EXPAND|wx.ALL, 10)1195 1196 1197 if self.file:1198 sizer_button = wx.BoxSizer(wx.HORIZONTAL)1199 self.button_load = wx.Button(self, 1, "Choose file")1200 self.Bind(wx.EVT_BUTTON, self._load_file, id = 1)1201 sizer_button.Add(self.button_load, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10)1202 1203 1204 sizer_main.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)1205 self.SetAutoLayout(True)1206 self.SetSizer(sizer_main)1207 self.Layout()1208 self.Centre()1209 # end wxGlade1210 1211 1212 # end of class DialogAbout1213 1214 987 ##### testing code ############################################################ 1215 988 class TestPlot: -
prview/perspectives/pr/pr.py
rceaf16e r9ff861b 1 """ 2 This software was developed by the University of Tennessee as part of the 3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 project funded by the US National Science Foundation. 5 6 See the license text in license.txt 7 8 copyright 2009, University of Tennessee 9 """ 10 1 11 # Make sure the option of saving each curve is available 2 12 # Use the I(q) curve as input and compare the output to P(r) … … 1162 1172 panel = event.GetEventObject() 1163 1173 1164 from inversion_panel import InversionDlg1165 1166 1174 # If we have more than one displayed plot, make the user choose 1167 1175 if len(panel.plots)>1 and panel.graph.selected_plottable in panel.plots: 1168 1176 dataset = panel.graph.selected_plottable 1169 if False:1170 dialog = InversionDlg(None, -1, "P(r) Inversion", panel.plots, pars=False)1171 dialog.set_content(self.last_data, self.nfunc, self.alpha, self.max_length)1172 if dialog.ShowModal() == wx.ID_OK:1173 dataset = dialog.get_content()1174 dialog.Destroy()1175 else:1176 dialog.Destroy()1177 return1178 1177 elif len(panel.plots)==1: 1179 1178 dataset = panel.plots.keys()[0]
Note: See TracChangeset
for help on using the changeset viewer.