Changeset 911dbe4 in sasview for src/sas/sasgui/perspectives/corfunc
- Timestamp:
- Jul 11, 2016 4:36:55 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.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 7a219e3e
- Parents:
- f2bbabf
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/07/16 11:30:07)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/11/16 04:36:55)
- Location:
- src/sas/sasgui/perspectives/corfunc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/corfunc/corfunc.py
r3b8efec r911dbe4 22 22 IQ_DATA_LABEL = r"$I_{obs}(q)$" 23 23 IQ_EXTRAPOLATED_DATA_LABEL = r"$I_{extrap}(q)$" 24 25 GROUP_ID_TRANSFORM = r"$\Gamma(x)$" 26 TRANSFORM_LABEL = r"$\Gamma(x)$" 24 27 25 28 … … 129 132 new_plot = Data1D(data.x, data.y, dy=data.dy) 130 133 134 group_id = "" 131 135 if label == IQ_DATA_LABEL or label == IQ_EXTRAPOLATED_DATA_LABEL: 132 136 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 133 137 new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}") 134 138 group_id = GROUP_ID_IQ_DATA 139 elif label == TRANSFORM_LABEL: 140 new_plot.xaxis("{x}", 'A') 141 new_plot.yaxis("{\\Gamma}", '') 142 group_id = GROUP_ID_TRANSFORM 135 143 new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 136 144 new_plot.id = label 137 145 new_plot.name = label 146 new_plot.group_id = group_id 138 147 new_plot.interactive = True 139 new_plot.group_id = GROUP_ID_IQ_DATA 140 new_plot.title = "I(q)" 148 new_plot.title = group_id.replace('$', '').replace('\\', '') 141 149 # Show data on a linear scale 142 150 new_plot.xtransform = 'x' 143 151 new_plot.ytransform = 'y' 144 152 wx.PostEvent(self.parent, 145 NewPlotEvent(plot=new_plot, title="I(q)", reset=reset)) 153 NewPlotEvent(plot=new_plot, title=new_plot.title, 154 reset=reset)) -
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
rf2bbabf r911dbe4 38 38 self.SetWindowVariant(variant=FONT_VARIANT) 39 39 self._manager = manager 40 self._data = data # The data to be analysed 40 # The data with no correction for background values 41 self._data = data # The data to be analysed (corrected fr background) 41 42 self._extrapolated_data = None # The extrapolated data set 43 self._calculator = CorfuncCalculator() 42 44 self._data_name_box = None # Text box to show name of file 43 45 self._background_input = None … … 45 47 self._qmax1_input = None 46 48 self._qmax2_input = None 49 self._transform_btn = None 50 self._compute_btn = None 47 51 self.qmin = 0 48 52 self.qmax = (0, 0) … … 107 111 :param data: The data that has been loaded 108 112 """ 113 self._transform_btn.Disable() 109 114 if data is None: 110 115 return 111 116 self._data_name_box.SetValue(str(data.title)) 112 117 self._data = data 118 self._calculator.set_data(data) 113 119 if self._manager is not None: 114 120 from sas.sasgui.perspectives.corfunc.corfunc import IQ_DATA_LABEL 115 self._manager.show_data( data, IQ_DATA_LABEL, reset=True)121 self._manager.show_data(self._data, IQ_DATA_LABEL, reset=True) 116 122 if set_qrange: 117 123 lower = data.x[-1]*0.05 … … 120 126 self.set_qmin(lower) 121 127 self.set_qmax((upper1, upper2)) 122 self.set_background( 0.0)128 self.set_background(self._calculator.compute_background(self.qmax)) 123 129 124 130 def get_data(self): … … 134 140 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 135 141 return 136 calculator = CorfuncCalculator(self._data, self.qmin, self.qmax, 137 background=self.background) 138 self._extrapolated_data = calculator.compute_extrapolation() 142 self._calculator.set_data(self._data) 143 self._calculator.lowerq = self.qmin 144 self._calculator.upperq = self.qmax 145 self._extrapolated_data = self._calculator.compute_extrapolation() 139 146 # TODO: Find way to set xlim and ylim so full range of data can be 140 147 # plotted … … 148 155 IQ_EXTRAPOLATED_DATA_LABEL 149 156 self._manager.show_data(to_plot, IQ_EXTRAPOLATED_DATA_LABEL) 157 self._transform_btn.Enable() 158 159 def compute_transform(self, event=None): 160 transformed_data = self._calculator.compute_transform( 161 self._extrapolated_data, self.background) 162 from sas.sasgui.perspectives.corfunc.corfunc import TRANSFORM_LABEL 163 import numpy as np 164 plot_x = transformed_data.x[np.where(transformed_data.x <= 200)] 165 plot_y = transformed_data.y[np.where(transformed_data.x <= 200)] 166 self._manager.show_data(Data1D(plot_x, plot_y), TRANSFORM_LABEL) 150 167 151 168 … … 183 200 self._background_input.SetValue(str(bg)) 184 201 202 def _compute_background(self, event=None): 203 self.set_background(self._calculator.compute_background(self.qmax)) 185 204 186 205 def _on_enter_input(self, event=None): … … 200 219 group_id = GROUP_ID_IQ_DATA 201 220 if event is not None: 221 if self._manager is not None and\ 222 event.GetEventObject() == self._background_input: 223 from sas.sasgui.perspectives.corfunc.corfunc\ 224 import IQ_DATA_LABEL 225 self._manager.show_data(self._data, IQ_DATA_LABEL, reset=True) 202 226 wx.PostEvent(self._manager.parent, PlotQrangeEvent( 203 227 ctrl=[self._qmin_input, self._qmax1_input, self._qmax2_input], … … 309 333 wx.RIGHT | wx.EXPAND, 5) 310 334 335 background_button = wx.Button(self, wx.NewId(), "Calculate", 336 size=(75, 25)) 337 background_button.Bind(wx.EVT_BUTTON, self._compute_background) 338 q_sizer.Add(background_button, (1, 2), (1, 1), wx.RIGHT | wx.EXPAND, 5) 339 311 340 qrange_label = wx.StaticText(self, -1, "Q Range:", size=(50,20)) 312 341 q_sizer.Add(qrange_label, (2,0), (1,1), wx.LEFT | wx.EXPAND, 5) … … 395 424 396 425 extrapolate_btn = wx.Button(self, wx.NewId(), "Extrapolate") 397 transform_btn = wx.Button(self, wx.NewId(), "Transform") 398 compute_btn = wx.Button(self, wx.NewId(), "Compute Measuments") 426 self._transform_btn = wx.Button(self, wx.NewId(), "Transform") 427 self._compute_btn = wx.Button(self, wx.NewId(), "Compute Measuments") 428 429 self._transform_btn.Disable() 430 self._compute_btn.Disable() 399 431 400 432 extrapolate_btn.Bind(wx.EVT_BUTTON, self.compute_extrapolation) 433 self._transform_btn.Bind(wx.EVT_BUTTON, self.compute_transform) 401 434 402 435 controls_sizer.Add(extrapolate_btn, wx.CENTER | wx.EXPAND) 403 controls_sizer.Add( transform_btn, wx.CENTER | wx.EXPAND)404 controls_sizer.Add( compute_btn, wx.CENTER | wx.EXPAND)436 controls_sizer.Add(self._transform_btn, wx.CENTER | wx.EXPAND) 437 controls_sizer.Add(self._compute_btn, wx.CENTER | wx.EXPAND) 405 438 406 439 controlbox_sizer.Add(controls_sizer, wx.TOP | wx.EXPAND, 0)
Note: See TracChangeset
for help on using the changeset viewer.