Changeset 033c14c 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:
- cdd1c3b
- Parents:
- 5a54aa4
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/08/16 09:08:15)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/11/16 04:36:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
r5a54aa4 r033c14c 14 14 from sas.sascalc.corfunc.corfunc_calculator import CorfuncCalculator 15 15 16 OUTPUT_STRINGS = { 17 'max': "Long Period (A): ", 18 'Lc': "Average Hard Block Thickness (A): ", 19 'dtr': "Average Interface Thickness (A): ", 20 'd0': "Average Core Thickness: ", 21 'A': "PolyDispersity: ", 22 'Lc/max': "Filling Fraction: " 23 } 24 16 25 if sys.platform.count("win32") > 0: 17 26 _STATICBOX_WIDTH = 350 … … 41 50 self._data = data # The data to be analysed (corrected fr background) 42 51 self._extrapolated_data = None # The extrapolated data set 52 self._transformed_data = None # Fourier trans. of the extrapolated data 43 53 self._calculator = CorfuncCalculator() 44 54 self._data_name_box = None # Text box to show name of file … … 48 58 self._qmax2_input = None 49 59 self._transform_btn = None 50 self._ compute_btn = None60 self._extract_btn = None 51 61 self.qmin = 0 52 62 self.qmax = (0, 0) 53 63 self.background = 0 54 # Dictionary for saving IDs oftext boxes used to display output data55 self._output_ ids = None64 # Dictionary for saving refs to text boxes used to display output data 65 self._output_boxes = None 56 66 self.state = None 57 67 self._do_layout() … … 119 129 self._enable_inputs() 120 130 self._transform_btn.Disable() 131 self._extract_btn.Disable() 121 132 self._data_name_box.SetValue(str(data.title)) 122 133 self._data = data … … 174 185 transformed_data = self._calculator.compute_transform( 175 186 self._extrapolated_data, self.background) 187 self._transformed_data = transformed_data 176 188 from sas.sasgui.perspectives.corfunc.corfunc import TRANSFORM_LABEL 177 189 import numpy as np … … 179 191 plot_y = transformed_data.y[np.where(transformed_data.x <= 200)] 180 192 self._manager.show_data(Data1D(plot_x, plot_y), TRANSFORM_LABEL) 193 self._extract_btn.Enable() 194 195 def extract_parameters(self, event=None): 196 params = None 197 try: 198 params = self._calculator.extract_parameters(self._transformed_data) 199 except: 200 params = None 201 if params is None: 202 msg = "Error extracting parameters." 203 wx.PostEvent(self._manager.parent, 204 StatusEvent(status=msg, info="error")) 205 return 206 for key in OUTPUT_STRINGS.keys(): 207 value = params[key] 208 self._output_boxes[key].SetValue(value) 209 181 210 182 211 … … 284 313 msg = "qmin must be less than qmax" 285 314 qmin_valid = False 286 elif background < 0 or background> self._data.y.max():287 msg = "background must be positive andless than highest I"315 elif background > self._data.y.max(): 316 msg = "background must be less than highest I" 288 317 background_valid = False 289 318 if not qmin_valid: … … 420 449 output_sizer = wx.GridBagSizer(5, 5) 421 450 422 label_strings = [ 423 "Long Period (A): ", 424 "Average Hard Block Thickness (A): ", 425 "Average Interface Thickness (A): ", 426 "Average Core Thickness: ", 427 "PolyDispersity: ", 428 "Filling Fraction: " 429 ] 430 self._output_ids = dict() 431 for i in range(len(label_strings)): 451 self._output_boxes = dict() 452 i = 0 453 for key, value in OUTPUT_STRINGS.iteritems(): 432 454 # Create a label and a text box for each poperty 433 label = wx.StaticText(self, -1, label_strings[i])434 output_box = OutputTextCtrl(self, wx.NewId(), size=(50, 20),455 label = wx.StaticText(self, -1, value) 456 output_box = OutputTextCtrl(self, wx.NewId(), 435 457 value="-", style=wx.ALIGN_CENTER_HORIZONTAL) 436 458 # Save the ID of each of the text boxes for accessing after the 437 459 # output data has been calculated 438 self._output_ ids[label_strings[i]] = output_box.GetId()460 self._output_boxes[key] = output_box 439 461 output_sizer.Add(label, (i, 0), (1, 1), wx.LEFT | wx.EXPAND, 15) 440 462 output_sizer.Add(output_box, (i, 2), (1, 1), 441 463 wx.RIGHT | wx.EXPAND, 15) 464 i += 1 442 465 443 466 outputbox_sizer.Add(output_sizer, wx.TOP, 0) … … 454 477 extrapolate_btn = wx.Button(self, wx.NewId(), "Extrapolate") 455 478 self._transform_btn = wx.Button(self, wx.NewId(), "Transform") 456 self._ compute_btn = wx.Button(self, wx.NewId(), "Compute Measuments")479 self._extract_btn = wx.Button(self, wx.NewId(), "Compute Measuments") 457 480 458 481 self._transform_btn.Disable() 459 self._ compute_btn.Disable()482 self._extract_btn.Disable() 460 483 461 484 extrapolate_btn.Bind(wx.EVT_BUTTON, self.compute_extrapolation) 462 485 self._transform_btn.Bind(wx.EVT_BUTTON, self.compute_transform) 486 self._extract_btn.Bind(wx.EVT_BUTTON, self.extract_parameters) 463 487 464 488 controls_sizer.Add(extrapolate_btn, wx.CENTER | wx.EXPAND) 465 489 controls_sizer.Add(self._transform_btn, wx.CENTER | wx.EXPAND) 466 controls_sizer.Add(self._ compute_btn, wx.CENTER | wx.EXPAND)490 controls_sizer.Add(self._extract_btn, wx.CENTER | wx.EXPAND) 467 491 468 492 controlbox_sizer.Add(controls_sizer, wx.TOP | wx.EXPAND, 0)
Note: See TracChangeset
for help on using the changeset viewer.