Changeset 033c14c in sasview for src/sas/sasgui/perspectives


Ignore:
Timestamp:
Jul 11, 2016 4:36:55 AM (8 years ago)
Author:
lewis
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)
Message:

Implement extract parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/corfunc/corfunc_panel.py

    r5a54aa4 r033c14c  
    1414from sas.sascalc.corfunc.corfunc_calculator import CorfuncCalculator 
    1515 
     16OUTPUT_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 
    1625if sys.platform.count("win32") > 0: 
    1726    _STATICBOX_WIDTH = 350 
     
    4150        self._data = data # The data to be analysed (corrected fr background) 
    4251        self._extrapolated_data = None # The extrapolated data set 
     52        self._transformed_data = None # Fourier trans. of the extrapolated data 
    4353        self._calculator = CorfuncCalculator() 
    4454        self._data_name_box = None # Text box to show name of file 
     
    4858        self._qmax2_input = None 
    4959        self._transform_btn = None 
    50         self._compute_btn = None 
     60        self._extract_btn = None 
    5161        self.qmin = 0 
    5262        self.qmax = (0, 0) 
    5363        self.background = 0 
    54         # Dictionary for saving IDs of text boxes used to display output data 
    55         self._output_ids = None 
     64        # Dictionary for saving refs to text boxes used to display output data 
     65        self._output_boxes = None 
    5666        self.state = None 
    5767        self._do_layout() 
     
    119129        self._enable_inputs() 
    120130        self._transform_btn.Disable() 
     131        self._extract_btn.Disable() 
    121132        self._data_name_box.SetValue(str(data.title)) 
    122133        self._data = data 
     
    174185        transformed_data = self._calculator.compute_transform( 
    175186            self._extrapolated_data, self.background) 
     187        self._transformed_data = transformed_data 
    176188        from sas.sasgui.perspectives.corfunc.corfunc import TRANSFORM_LABEL 
    177189        import numpy as np 
     
    179191        plot_y = transformed_data.y[np.where(transformed_data.x <= 200)] 
    180192        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 
    181210 
    182211 
     
    284313                msg = "qmin must be less than qmax" 
    285314                qmin_valid = False 
    286             elif background < 0 or background > self._data.y.max(): 
    287                 msg = "background must be positive and less than highest I" 
     315            elif background > self._data.y.max(): 
     316                msg = "background must be less than highest I" 
    288317                background_valid = False 
    289318        if not qmin_valid: 
     
    420449        output_sizer = wx.GridBagSizer(5, 5) 
    421450 
    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(): 
    432454            # 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(), 
    435457                value="-", style=wx.ALIGN_CENTER_HORIZONTAL) 
    436458            # Save the ID of each of the text boxes for accessing after the 
    437459            # output data has been calculated 
    438             self._output_ids[label_strings[i]] = output_box.GetId() 
     460            self._output_boxes[key] = output_box 
    439461            output_sizer.Add(label, (i, 0), (1, 1), wx.LEFT | wx.EXPAND, 15) 
    440462            output_sizer.Add(output_box, (i, 2), (1, 1), 
    441463                wx.RIGHT | wx.EXPAND, 15) 
     464            i += 1 
    442465 
    443466        outputbox_sizer.Add(output_sizer, wx.TOP, 0) 
     
    454477        extrapolate_btn = wx.Button(self, wx.NewId(), "Extrapolate") 
    455478        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") 
    457480 
    458481        self._transform_btn.Disable() 
    459         self._compute_btn.Disable() 
     482        self._extract_btn.Disable() 
    460483 
    461484        extrapolate_btn.Bind(wx.EVT_BUTTON, self.compute_extrapolation) 
    462485        self._transform_btn.Bind(wx.EVT_BUTTON, self.compute_transform) 
     486        self._extract_btn.Bind(wx.EVT_BUTTON, self.extract_parameters) 
    463487 
    464488        controls_sizer.Add(extrapolate_btn, wx.CENTER | wx.EXPAND) 
    465489        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) 
    467491 
    468492        controlbox_sizer.Add(controls_sizer, wx.TOP | wx.EXPAND, 0) 
Note: See TracChangeset for help on using the changeset viewer.