- Timestamp:
- Mar 20, 2019 7:04:10 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl
- Children:
- a5f7bf4, 8051faa
- Parents:
- b2572f4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py
rb2572f4 rb415abc 115 115 if data is None: 116 116 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) 121 119 122 120 def updateKernelModel(self, kernel_model=None): … … 131 129 self.setElementsVisibility(False) 132 130 return 133 if self.kernel_model is None:134 return135 131 # Find out if data has dQ 136 132 (self.smear_type, self.dq_l, self.dq_r) = self.getSmearInfo() … … 139 135 self.cbSmearing.addItem(SMEARING_QD) 140 136 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 141 144 if isinstance(self.data, Data1D): 142 145 self.cbSmearing.addItems(SMEARING_1D) … … 216 219 self.lblSmearUp.setText('<html><head/><body><p><dQ<span style=" vertical-align:sub;">low</span>></p></body></html>') 217 220 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>') 219 222 self.lblUnitUp.setText('%') 220 223 self.txtSmearDown.setEnabled(True) 221 224 self.txtSmearUp.setEnabled(True) 222 #self.txtSmearDown.setText(str(0.0))223 #self.txtSmearUp.setText(str(0.0))224 225 225 226 def setSlitLabels(self): … … 235 236 self.txtSmearDown.setEnabled(True) 236 237 self.txtSmearUp.setEnabled(True) 237 #self.txtSmearDown.setText(str(0.0))238 #self.txtSmearUp.setText(str(0.0))239 238 240 239 def setDQLabels(self): 241 240 """ 242 Use pinhole labels241 Use appropriate labels 243 242 """ 244 243 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>‹dQ/Q›<span style=" vertical-align:sub;">r</span></p></body></html>' 255 text_down = '<html><head/><body><p>‹dQ/Q›<span style=" vertical-align:sub;">φ</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 254 263 self.txtSmearDown.setText(str(self.dq_r)) 255 264 self.txtSmearUp.setText(str(self.dq_l)) … … 369 378 370 379 :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. 374 385 """ 375 386 # default … … 380 391 if self.data is None: 381 392 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) 382 397 elif isinstance(data, Data2D): 383 398 if data.dqx_data is None or data.dqy_data is None: 384 399 return smear_type, dq_l, dq_r 385 elif data.dqx_data.any() != 0 and data.dq x_data.any() != 0:400 elif data.dqx_data.any() != 0 and data.dqy_data.any() != 0: 386 401 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) 389 404 return smear_type, dq_l, dq_r 390 405 else: 391 406 return smear_type, dq_l, dq_r 392 407 # check if it is pinhole smear and get min max if it is. 393 if data.dx is not None and np.a ny(data.dx):408 if data.dx is not None and np.all(data.dx): 394 409 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) 397 412 398 413 # check if it is slit smear and get min max if it is. … … 400 415 smear_type = "Slit" 401 416 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]) 403 418 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]) 405 420 406 421 return smear_type, dq_l, dq_r
Note: See TracChangeset
for help on using the changeset viewer.