Changeset 3b8efec in sasview for src/sas/sasgui
- Timestamp:
- Jul 11, 2016 2: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:
- 77e9ac6
- Parents:
- b564ea2
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/07/16 05:29:10)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/11/16 02:36:55)
- Location:
- src/sas/sasgui/perspectives/corfunc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/corfunc/corfunc.py
r9c90cf3 r3b8efec 5 5 import sys 6 6 import logging 7 import copy 7 8 from sas.sasgui.guiframe.plugin_base import PluginBase 8 9 from sas.sasgui.guiframe.gui_manager import MDIFrame … … 18 19 19 20 20 GROUP_ID_IQ_DATA = r"$I _{obs}(q)$"21 GROUP_ID_IQ_DATA = r"$I(q)$" 21 22 IQ_DATA_LABEL = r"$I_{obs}(q)$" 23 IQ_EXTRAPOLATED_DATA_LABEL = r"$I_{extrap}(q)$" 22 24 23 25 … … 117 119 info='error')) 118 120 119 def show_data(self, path=None, data=None, reset=False):121 def show_data(self, data, label, path=None, reset=False): 120 122 """ 121 123 Show data read from a file … … 125 127 :param reset: If True, all other plottables will be cleared 126 128 """ 127 if data.dy is not None: 128 new_plot = Data1D(data.x, data.y, dy=data.dy) 129 else: 130 new_plot = Data1D(data.x, data.y) 129 new_plot = Data1D(data.x, data.y, dy=data.dy) 130 131 if label == IQ_DATA_LABEL or label == IQ_EXTRAPOLATED_DATA_LABEL: 132 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 133 new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}") 134 131 135 new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 132 new_plot.name = IQ_DATA_LABEL 133 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 134 new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}") 136 new_plot.id = label 137 new_plot.name = label 135 138 new_plot.interactive = True 136 139 new_plot.group_id = GROUP_ID_IQ_DATA 137 new_plot.id = self.data_id138 140 new_plot.title = "I(q)" 139 141 # Show data on a linear scale -
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
rb564ea2 r3b8efec 6 6 from sas.sasgui.guiframe.panel_base import PanelBase 7 7 from sas.sasgui.guiframe.utils import check_float 8 from sas.sasgui.guiframe.dataFitting import Data1D 8 9 from sas.sasgui.perspectives.invariant.invariant_widgets import OutputTextCtrl 9 10 from sas.sasgui.perspectives.invariant.invariant_widgets import InvTextCtrl 10 11 from sas.sasgui.perspectives.fitting.basepage import ModelTextCtrl 11 12 from sas.sasgui.perspectives.corfunc.corfunc_state import CorfuncState 13 import sas.sasgui.perspectives.corfunc.corfunc 14 from sas.sascalc.corfunc.corfunc_calculator import CorfuncCalculator 12 15 13 16 if sys.platform.count("win32") > 0: … … 36 39 self._manager = manager 37 40 self._data = data # The data to be analysed 41 self._extrapolated_data = None # The extrapolated data set 38 42 self._data_name_box = None # Text box to show name of file 39 43 self._background_input = None … … 52 56 self._qmax1_input.Bind(wx.EVT_TEXT, self._on_enter_input) 53 57 self._qmax2_input.Bind(wx.EVT_TEXT, self._on_enter_input) 58 self._background_input.Bind(wx.EVT_TEXT, self._on_enter_input) 54 59 55 60 def set_state(self, state=None, data=None): … … 67 72 if data is not None: 68 73 self.state.data = data 69 self.set_data( self.state.data, set_qrange=False)74 self.set_data(data, set_qrange=False) 70 75 if self.state.qmin is not None: 71 76 self.set_qmin(self.state.qmin) … … 107 112 self._data = data 108 113 if self._manager is not None: 109 self._manager.show_data(data=data, reset=True) 114 from sas.sasgui.perspectives.corfunc.corfunc import IQ_DATA_LABEL 115 self._manager.show_data(data, IQ_DATA_LABEL, reset=True) 110 116 if set_qrange: 111 117 lower = data.x[-1]*0.05 … … 118 124 def get_data(self): 119 125 return self._data 126 127 def compute_extrapolation(self, event=None): 128 if self._data is None: 129 msg = "Data must be loaded in order to perform an extrapolation." 130 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 131 return 132 if not self._validate_inputs: 133 msg = "Invalid Q range entered." 134 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 135 return 136 calculator = CorfuncCalculator(self._data, self.qmin, self.qmax, 137 background=self.background) 138 self._extrapolated_data = calculator.compute_extrapolation() 139 # TODO: Find way to set xlim and ylim so full range of data can be 140 # plotted 141 maxq = self._data.x.max() 142 mask = self._extrapolated_data.x <= maxq 143 numpts = len(self._extrapolated_data.x[mask]) + 250 144 plot_x = self._extrapolated_data.x[0:numpts] 145 plot_y = self._extrapolated_data.y[0:numpts] 146 to_plot = Data1D(plot_x, plot_y) 147 from sas.sasgui.perspectives.corfunc.corfunc import\ 148 IQ_EXTRAPOLATED_DATA_LABEL 149 self._manager.show_data(to_plot, IQ_EXTRAPOLATED_DATA_LABEL) 150 120 151 121 152 def save_project(self, doc=None): … … 165 196 self.qmax = (new_qmax1, new_qmax2) 166 197 self.background = float(self._background_input.GetValue()) 167 data_id = self._manager.data_id168 from sas.sasgui.perspectives.corfunc.corfunc import GROUP_ID_IQ_DATA198 from sas.sasgui.perspectives.corfunc.corfunc import GROUP_ID_IQ_DATA,\ 199 IQ_DATA_LABEL 169 200 group_id = GROUP_ID_IQ_DATA 170 201 if event is not None: 171 202 wx.PostEvent(self._manager.parent, PlotQrangeEvent( 172 203 ctrl=[self._qmin_input, self._qmax1_input, self._qmax2_input], 173 active=event.GetEventObject(), id= data_id, group_id=group_id,204 active=event.GetEventObject(), id=IQ_DATA_LABEL, group_id=group_id, 174 205 leftdown=False)) 175 206 … … 201 232 qmin_valid = False 202 233 elif background < 0 or background > self._data.y.max(): 203 msg = "background must be positive and less than highest I value"234 msg = "background must be positive and less than highest I" 204 235 background_valid = False 205 236 if not qmin_valid: … … 365 396 compute_btn = wx.Button(self, wx.NewId(), "Compute Measuments") 366 397 398 extrapolate_btn.Bind(wx.EVT_BUTTON, self.compute_extrapolation) 399 367 400 controls_sizer.Add(extrapolate_btn, wx.CENTER | wx.EXPAND) 368 401 controls_sizer.Add(transform_btn, wx.CENTER | wx.EXPAND)
Note: See TracChangeset
for help on using the changeset viewer.