- Timestamp:
- Apr 6, 2017 11:04:29 AM (8 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 2df1bd1
- Parents:
- 3444492
- git-author:
- Jeff Krzywon <krzywon@…> (04/06/17 11:04:29)
- git-committer:
- krzywon <krzywon@…> (04/06/17 11:04:29)
- Location:
- src/sas
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/manipulations.py
rdd11014 r54557b5 430 430 z_max = max(data2D.q_data) 431 431 z_min = min(data2D.q_data) 432 x_max = data2D.dqx_data[ data2D.q_data[z_max]]433 x_min = data2D.dqx_data[ data2D.q_data[z_min]]434 y_max = data2D.dqy_data[ data2D.q_data[z_max]]435 y_min = data2D.dqy_data[ data2D.q_data[z_min]]432 x_max = data2D.dqx_data[numpy.where(data2D.q_data == z_max)] 433 x_min = data2D.dqx_data[numpy.where(data2D.q_data == z_min)] 434 y_max = data2D.dqy_data[numpy.where(data2D.q_data == z_max)] 435 y_min = data2D.dqy_data[numpy.where(data2D.q_data == z_min)] 436 436 # Find qdx at q = 0 437 437 dq_overlap_x = (x_min * z_max - x_max * z_min) / (z_max - z_min) … … 785 785 z_max = max(data2D.q_data) 786 786 z_min = min(data2D.q_data) 787 x_max = data2D.dqx_data[ data2D.q_data[z_max]]788 x_min = data2D.dqx_data[ data2D.q_data[z_min]]789 y_max = data2D.dqy_data[ data2D.q_data[z_max]]790 y_min = data2D.dqy_data[ data2D.q_data[z_min]]787 x_max = data2D.dqx_data[numpy.where(data2D.q_data == z_max)] 788 x_min = data2D.dqx_data[numpy.where(data2D.q_data == z_min)] 789 y_max = data2D.dqy_data[numpy.where(data2D.q_data == z_max)] 790 y_min = data2D.dqy_data[numpy.where(data2D.q_data == z_min)] 791 791 # Find qdx at q = 0 792 792 dq_overlap_x = (x_min * z_max - x_max * z_min) / (z_max - z_min) -
src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py
rb697396b r54557b5 4 4 import wx.lib.newevent 5 5 import time 6 from sas.sascalc.dataloader.readers.cansas_reader import Reader 6 7 from sas.sasgui.guiframe.events import EVT_SLICER_PARS 7 8 from sas.sasgui.guiframe.utils import format_number 8 9 from sas.sasgui.guiframe.events import EVT_SLICER 9 10 from sas.sasgui.guiframe.events import SlicerParameterEvent, SlicerEvent 11 from Plotter1D import ModelPanel1D 10 12 from Plotter2D import ModelPanel2D 11 13 from sas.sascalc.dataloader.data_info import Data1D, Data2D 12 ApplyParams, EVT_APPLY_PARAMS = wx.lib.newevent.NewEvent() 14 apply_params, EVT_APPLY_PARAMS = wx.lib.newevent.NewEvent() 15 auto_save, EVT_AUTO_SAVE = wx.lib.newevent.NewEvent() 16 auto_close, EVT_ON_CLOSE = wx.lib.newevent.NewEvent() 13 17 14 18 … … 33 37 self.bck = wx.GridBagSizer(5, 5) 34 38 self.SetSizer(self.bck) 39 self.auto_save = None 40 self.path = None 41 self.type_list = ["SectorInteractor", "AnnulusInteractor", 42 "BoxInteractorX", "BoxInteractorY"] 43 self.type_select = wx.ComboBox(parent=self, choices=self.type_list) 44 self.append_name = wx.TextCtrl(parent=self, id=wx.NewId(), 45 name="Append to file name:") 46 self.data_list = None 35 47 label = "Right-click on 2D plot for slicer options" 36 48 title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) … … 40 52 self.parent.Bind(EVT_SLICER, self.onEVT_SLICER) 41 53 self.parent.Bind(EVT_SLICER_PARS, self.onParamChange) 42 self.Bind(EVT_APPLY_PARAMS, self.apply_params_list) 54 self.Bind(EVT_APPLY_PARAMS, self.apply_params_list_and_process) 55 self.Bind(EVT_AUTO_SAVE, self.save_files) 56 self.Bind(EVT_ON_CLOSE, self.on_close) 43 57 44 58 def onEVT_SLICER(self, event): … … 109 123 self.bck.Add(ctl, (iy, ix), (1, 1), 110 124 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 125 126 # Change slicer within the window 111 127 ix = 0 112 128 iy += 1 113 114 # Change slicer within the window 115 txt = "Slicer" 129 txt = "Slicer type:" 116 130 text = wx.StaticText(self, -1, txt, style=wx.ALIGN_LEFT) 117 131 self.bck.Add(text, (iy, ix), (1, 1), 118 132 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 119 type_list = ["SectorInteractor", "AnnulusInteractor",120 "BoxInteractorX", "BoxInteractorY"]121 self.type_select = wx.ComboBox(parent=self, choices=type_list)122 133 self.Bind(wx.EVT_COMBOBOX, self.onChangeSlicer) 123 index = self.type_select.FindString( self.type)134 index = self.type_select.FindString(type) 124 135 self.type_select.SetSelection(index) 125 136 self.bck.Add(self.type_select, (iy, 1), (1, 1), … … 130 141 title = wx.StaticText(self, -1, title_text, style=wx.ALIGN_LEFT) 131 142 iy += 1 132 l n= wx.StaticLine(self, -1, style=wx.LI_VERTICAL)133 l n.SetSize((60,60))134 self.bck.Add(l n, (iy, ix), (1, 2),143 line = wx.StaticLine(self, -1, style=wx.LI_VERTICAL) 144 line.SetSize((60, 60)) 145 self.bck.Add(line, (iy, ix), (1, 2), 135 146 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 136 147 iy += 1 137 148 self.bck.Add(title, (iy, ix), (1, 1), 138 149 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 139 iy += 1 150 140 151 # Create a list box with all of the 2D plots 152 iy += 1 141 153 self.process_list() 142 154 self.bck.Add(self.data_list, (iy, ix), (1, 1), 143 155 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 144 iy += 1 156 157 # Checkbox for autosaving data 158 iy += 1 159 160 self.auto_save = wx.CheckBox(parent=self, id=wx.NewId(), 161 label="Auto save generated 1D:") 162 self.Bind(wx.EVT_CHECKBOX, self.on_auto_save_checked) 163 self.bck.Add(self.auto_save, (iy, ix), (1, 1), 164 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 165 iy += 1 166 # File browser 167 save_to = "Save files to:" 168 save = wx.StaticText(self, -1, save_to, style=wx.ALIGN_LEFT) 169 self.path = wx.DirPickerCtrl(self, id=wx.NewId(), path="", 170 message=save_to) 171 self.path.Enable(False) 172 self.bck.Add(save, (iy, ix), (1, 1), 173 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 174 self.bck.Add(self.path, (iy, 1), (1, 1), 175 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 176 # Append to file 177 iy += 1 178 default_value = "_{0}".format(self.type) 179 for key in params: 180 default_value += "_%d.2" % params[key] 181 append_text = "Append to file name:" 182 append = wx.StaticText(self, -1, append_text, style=wx.ALIGN_LEFT) 183 self.append_name.SetValue(default_value) 184 self.append_name.Enable(False) 185 self.bck.Add(append, (iy, ix), (1, 1), 186 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 187 self.bck.Add(self.append_name, (iy, 1), (1, 1), 188 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 189 190 # TODO: Fix fitting options combobox/radiobox 191 # Combobox for selecting fitting options 192 # iy += 1 193 # self.fitting_radio = wx.RadioBox(parent=self, id=wx.NewId(), 194 # size=(4,1)) 195 # self.fitting_radio.SetString(0, "No fitting") 196 # self.fitting_radio.SetString(1, "Batch Fitting") 197 # self.fitting_radio.SetString(2, "Fitting") 198 # self.fitting_radio.SetString(3, "Simultaneous and Constrained Fit") 199 # self.fitting_radio.SetValue(0) 200 # self.bck.Add(self.fitting_radio, (iy, ix), (1, 1), 201 # wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 202 145 203 # Button to start batch slicing 204 iy += 1 146 205 button_label = "Apply Slicer to Selected Plots" 147 206 self.batch_slicer_button = wx.Button(parent=self, 148 207 label=button_label) 149 self.Bind(wx.EVT_BUTTON, self.on BatchSlice)208 self.Bind(wx.EVT_BUTTON, self.on_batch_slicer) 150 209 self.bck.Add(self.batch_slicer_button, (iy, ix), (1, 1), 151 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 152 # TODO: Check box for saving file 153 # TODO: append to file information and file type 154 # TODO: Send to fitting options 155 210 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 156 211 iy += 1 157 212 self.bck.Add((5, 5), (iy, ix), (1, 1), … … 196 251 wx.PostEvent(self.parent, event) 197 252 198 def on BatchSlice(self, evt=None):253 def on_batch_slicer(self, evt=None): 199 254 """ 200 255 Method invoked with batch slicing button is pressed … … 205 260 params = self.parent.slicer.get_params() 206 261 type = self.type_select.GetStringSelection() 262 save = self.auto_save.IsChecked() 263 append = self.append_name.GetValue() 264 path = self.path.GetPath() 207 265 208 266 # Find desired 2D data panels … … 217 275 # Post an event to apply appropriate slicer params to each slicer 218 276 # Event needed due to how apply_slicer_to_plot works 219 event = ApplyParams(params=params, plot_list=apply_to_list) 277 event = apply_params(params=params, plot_list=apply_to_list, 278 auto_save=save, append=append, 279 path=path) 220 280 wx.PostEvent(self, event) 221 # TODO: save file (if desired)222 # TODO: send to fitting (if desired)281 event = auto_close() 282 wx.PostEvent(self, event) 223 283 224 284 def onChangeSlicer(self, evt): … … 264 324 choices=self.loaded_data, 265 325 name="Apply Slicer to 2D Plots:") 266 # Check all items b ty default326 # Check all items by default 267 327 for item in range(len(self.data_list.Items)): 268 328 self.data_list.Check(item) 269 self.data_list.Bind(wx.EVT_CHECKLISTBOX, self.on CheckBoxList)270 271 def on CheckBoxList(self,e):329 self.data_list.Bind(wx.EVT_CHECKLISTBOX, self.on_check_box_list) 330 331 def on_check_box_list(self, evt=None): 272 332 """ 273 333 Prevent a checkbox item from being unchecked 274 334 :param e: Event triggered when a checkbox list item is checked 275 335 """ 276 index = e.GetSelection() 336 if evt is None: 337 return 338 index = evt.GetSelection() 277 339 if index == self.checkme: 278 340 self.data_list.Check(index) 279 341 280 def apply_params_list (self, evt=None):342 def apply_params_list_and_process(self, evt=None): 281 343 """ 282 344 Event based parameter setting. … … 288 350 item.slicer.set_params(evt.params) 289 351 item.slicer.base.update() 290 # Close the slicer window 352 # Post an event to save each data set to file 353 if evt.auto_save: 354 event = auto_save(append_to_name=evt.append, 355 file_list=evt.plot_list, 356 path=evt.path) 357 wx.PostEvent(self, event) 358 359 def save_files(self, evt=None): 360 """ 361 Automatically save the sliced data to file. 362 :param evt: Event that triggered the call to the method 363 """ 364 if evt is None: 365 return 366 writer = Reader() 367 main_window = self.parent.parent 368 data_list = [] 369 append = evt.append_to_name 370 for key, plot in main_window.plot_panels.iteritems(): 371 if not hasattr(plot, "data2D"): 372 for item in plot.plots: 373 data_list.append(item) 374 for item in data_list: 375 data1d = item.plots 376 base = item.name.split(".")[0] 377 save_to = evt.path + base + ".xml" 378 writer.write(path, data1d) 379 380 # TODO: determine data sets 381 # TODO: generate file names 382 # TODO: link one to the other 383 # TODO: save all files 384 385 def on_auto_save_checked(self, evt=None): 386 """ 387 Enable/Disable auto append when checkbox is checked 388 :param evt: Event 389 """ 390 self.append_name.Enable(self.auto_save.IsChecked()) 391 self.path.Enable(self.auto_save.IsChecked()) 392 393 def on_close(self, evt=None): 394 """ 395 Auto close the panel 396 """ 291 397 self.Destroy()
Note: See TracChangeset
for help on using the changeset viewer.