Changeset b415abc in sasview


Ignore:
Timestamp:
Mar 20, 2019 7:04:10 AM (6 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl
Children:
a5f7bf4, 8051faa
Parents:
b2572f4
Message:

Cherry picked fixes from PR#206 - fixed problems in smearing sizer.
Additionally, allow for presenting dQ data smearing option even if no
model is defined.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py

    rb2572f4 rb415abc  
    115115        if data is None: 
    116116            self.setElementsVisibility(False) 
    117         if self.kernel_model is not None: 
    118             # model already present - recalculate 
    119             model = self.kernel_model 
    120             self.updateKernelModel(model) 
     117        model = self.kernel_model 
     118        self.updateKernelModel(model) 
    121119 
    122120    def updateKernelModel(self, kernel_model=None): 
     
    131129            self.setElementsVisibility(False) 
    132130            return 
    133         if self.kernel_model is None: 
    134             return 
    135131        # Find out if data has dQ 
    136132        (self.smear_type, self.dq_l, self.dq_r) = self.getSmearInfo() 
     
    139135            self.cbSmearing.addItem(SMEARING_QD) 
    140136            index_to_show = 1 
     137 
     138        if self.kernel_model is None: 
     139            # No model definend yet - just use data file smearing, if any 
     140            self.cbSmearing.blockSignals(False) 
     141            self.cbSmearing.setCurrentIndex(index_to_show) 
     142            return 
     143 
    141144        if isinstance(self.data, Data1D): 
    142145            self.cbSmearing.addItems(SMEARING_1D) 
     
    216219            self.lblSmearUp.setText('<html><head/><body><p>&lt;dQ<span style=" vertical-align:sub;">low</span>&gt;</p></body></html>') 
    217220        else: 
    218             self.lblSmearUp.setText('<html><head/><body><p>dQ<span style=" vertical-align:sub;">%</span></p></body></html>') 
     221            self.lblSmearUp.setText('<html><head/><body><p>dQ/Q</p></body></html>') 
    219222            self.lblUnitUp.setText('%') 
    220223        self.txtSmearDown.setEnabled(True) 
    221224        self.txtSmearUp.setEnabled(True) 
    222         #self.txtSmearDown.setText(str(0.0)) 
    223         #self.txtSmearUp.setText(str(0.0)) 
    224225 
    225226    def setSlitLabels(self): 
     
    235236        self.txtSmearDown.setEnabled(True) 
    236237        self.txtSmearUp.setEnabled(True) 
    237         #self.txtSmearDown.setText(str(0.0)) 
    238         #self.txtSmearUp.setText(str(0.0)) 
    239238 
    240239    def setDQLabels(self): 
    241240        """ 
    242         Use pinhole labels 
     241        Use appropriate labels 
    243242        """ 
    244243        if self.smear_type == "Pinhole": 
    245             self.lblSmearDown.setText('<html><head/><body><p>dQ<span style=" vertical-align:sub;">high</span></p></body></html>') 
    246             self.lblSmearUp.setText('<html><head/><body><p>dQ<span style=" vertical-align:sub;">low</span></p></body></html>') 
    247         else: 
    248             self.lblSmearUp.setText('<dQp>') 
    249             self.lblSmearDown.setText('<dQs>') 
    250         self.lblUnitUp.setText('<html><head/><body><p>à
    251 <span style=" vertical-align:super;">-1</span></p></body></html>') 
    252         self.lblUnitDown.setText('<html><head/><body><p>à
    253 <span style=" vertical-align:super;">-1</span></p></body></html>') 
     244            text_down = '<html><head/><body><p>[dQ/Q]<span style=" vertical-align:sub;">max</span></p></body></html>' 
     245            text_up = '<html><head/><body><p>[dQ/Q]<span style=" vertical-align:sub;">min</span></p></body></html>' 
     246            text_unit = '%' 
     247        elif self.smear_type == "Slit": 
     248            text_down = '<html><head/><body><p>Slit width</p></body></html>' 
     249            text_up = '<html><head/><body><p>Slit height</p></body></html>' 
     250            text_unit = '<html><head/><body><p>à
     251<span style=" vertical-align:super;">-1</span></p></body></html>' 
     252        else: 
     253            text_unit = '%' 
     254            text_up = '<html><head/><body><p>&lsaquo;dQ/Q&rsaquo;<span style=" vertical-align:sub;">r</span></p></body></html>' 
     255            text_down = '<html><head/><body><p>&lsaquo;dQ/Q&rsaquo;<span style=" vertical-align:sub;">&phi;</span></p></body></html>' 
     256 
     257        self.lblSmearDown.setText(text_down) 
     258        self.lblSmearUp.setText(text_up) 
     259 
     260        self.lblUnitUp.setText(text_unit) 
     261        self.lblUnitDown.setText(text_unit) 
     262 
    254263        self.txtSmearDown.setText(str(self.dq_r)) 
    255264        self.txtSmearUp.setText(str(self.dq_l)) 
     
    369378 
    370379        :return: self.smear_type, self.dq_l and self.dq_r, 
    371             respectively the type of the smear, dq_min and 
    372             dq_max for pinhole smear data 
    373             while dxl and dxw for slit smear 
     380            respectively the type of the smear, the average <dq/q> radial(p) 
     381            and <dq/q> theta (s)s for 2D pinhole resolution in % (slit is not 
     382            currently supported in 2D), (dq/q)_min and (dq/q)_max for 1D pinhole 
     383            smeared data, again in %, and dxl and/or dxw for slit smeared data 
     384            given in 1/A and assumed constant. 
    374385        """ 
    375386        # default 
     
    380391        if self.data is None: 
    381392            return smear_type, dq_l, dq_r 
     393        # First check if data is 2D 
     394        # If so check that data set has smearing info and that none are zero. 
     395        # Otherwise no smearing can be applied using smear from data (a Gaussian 
     396        # width of zero will cause a divide by zero error) 
    382397        elif isinstance(data, Data2D): 
    383398            if data.dqx_data is None or data.dqy_data is None: 
    384399                return smear_type, dq_l, dq_r 
    385             elif data.dqx_data.any() != 0 and data.dqx_data.any() != 0: 
     400            elif data.dqx_data.any() != 0 and data.dqy_data.any() != 0: 
    386401                smear_type = "Pinhole2d" 
    387                 dq_l = GuiUtils.formatNumber(np.average(data.dqx_data)) 
    388                 dq_r = GuiUtils.formatNumber(np.average(data.dqy_data)) 
     402                dq_l = GuiUtils.formatNumber(np.average(data.dqx_data)/abs(data.qx_data)*100., high=True) 
     403                dq_r = GuiUtils.formatNumber(np.average(data.dqy_data)/abd(data.qy_data)*100., high=True) 
    389404                return smear_type, dq_l, dq_r 
    390405            else: 
    391406                return smear_type, dq_l, dq_r 
    392407        # check if it is pinhole smear and get min max if it is. 
    393         if data.dx is not None and np.any(data.dx): 
     408        if data.dx is not None and np.all(data.dx): 
    394409            smear_type = "Pinhole" 
    395             dq_l = data.dx[0] 
    396             dq_r = data.dx[-1] 
     410            dq_l = GuiUtils.formatNumber(data.dx[0]/data.x[0] *100., high=True) 
     411            dq_r = GuiUtils.formatNumber(data.dx[-1]/data.x[-1] *100., high=True) 
    397412 
    398413        # check if it is slit smear and get min max if it is. 
     
    400415            smear_type = "Slit" 
    401416            if data.dxl is not None and np.all(data.dxl, 0): 
    402                 dq_l = data.dxl[0] 
     417                dq_l = GuiUtils.formatNumber(data.dxl[0]) 
    403418            if data.dxw is not None and np.all(data.dxw, 0): 
    404                 dq_r = data.dxw[0] 
     419                dq_r = GuiUtils.formatNumber(data.dxw[0]) 
    405420 
    406421        return smear_type, dq_l, dq_r 
Note: See TracChangeset for help on using the changeset viewer.