Changeset 8045572 in sasview for src/sas/qtgui/Perspectives/PrInversion
- Timestamp:
- Oct 26, 2017 10:37:23 AM (7 years ago)
- Branches:
- 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
- Children:
- 406f420
- Parents:
- e32b120
- Location:
- src/sas/qtgui/Perspectives/PrInversion
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/PrInversion/PrInversionPerspective.py
re32b120 r8045572 1 1 import logging 2 import numpy as np 2 3 3 4 from PyQt4 import QtGui, QtCore, QtWebKit … … 31 32 32 33 # Set initial values 33 self._path = "" 34 self._background = 0.0 35 self._qmin = 0.0 36 self._qmax = 1.0 37 self._slit_height = 0.0 38 self._slit_width = 0.0 39 self._terms = 10 40 self._regularization = 0.0001 41 self._max_distance = 140 42 self._bgd_input = False 43 self._terms_button = False 44 self._reg_button = False 34 self._data_index = 0 35 self._path = [""] 36 self._background = [0.0] 37 self._qmin = [0.0] 38 self._qmax = [1.0] 39 self._slit_height = [0.0] 40 self._slit_width = [0.0] 41 self._terms = [10] 42 self._regularization = [0.0001] 43 self._max_distance = [140] 44 self._bgd_input = [False] 45 self._terms_button = [False] 46 self._reg_button = [False] 47 self._terms_label = [""] 48 self._reg_label = [""] 45 49 # Set results 46 self._rg = 0.047 self._i_0 = 0.048 self._comp_time = 0.049 self._chi_dof = 0.050 self._oscillations = 0.051 self._pos_fraction = 0.052 self._sigma_pos_fraction = 0.050 self._rg = [0.0] 51 self._i_0 = [0.0] 52 self._comp_time = [0.0] 53 self._chi_dof = [0.0] 54 self._oscillations = [0.0] 55 self._pos_fraction = [0.0] 56 self._sigma_pos_fraction = [0.0] 53 57 54 58 # Let's choose the Standard Item Model. … … 64 68 logging.debug("P(r) Inversion Perspective loaded") 65 69 70 ###################################################################### 71 # Base Perspective Class Definitions 72 66 73 def allowBatch(self): 67 return False74 return True 68 75 69 76 def setClosable(self, value=True): … … 87 94 self.setWindowState(QtCore.Qt.WindowMinimized) 88 95 96 ###################################################################### 97 # Initialization routines 98 89 99 def setupLinks(self): 100 self.dataList.currentIndexChanged.connect(self.displayChange) 90 101 self.calculateButton.clicked.connect(self.calculatePrInversion) 91 102 self.statusButton.clicked.connect(self.status) … … 103 114 104 115 # Filename 105 self.mapper.addMapping(self.data FileName, WIDGETS.W_FILENAME)116 self.mapper.addMapping(self.dataList, WIDGETS.W_FILENAME) 106 117 # Background 107 118 self.mapper.addMapping(self.backgroundInput, WIDGETS.W_BACKGROUND) … … 118 129 119 130 # Parameter Items 120 self.mapper.addMapping(self.regularizationConstantInput, WIDGETS.W_REGULARIZATION) 121 self.mapper.addMapping(self.regConstantSuggestionButton, WIDGETS.W_REGULARIZATION_SUGGEST) 131 self.mapper.addMapping(self.regularizationConstantInput, 132 WIDGETS.W_REGULARIZATION) 133 self.mapper.addMapping(self.regConstantSuggestionButton, 134 WIDGETS.W_REGULARIZATION_SUGGEST) 122 135 self.mapper.addMapping(self.explorerButton, WIDGETS.W_EXPLORE) 123 136 self.mapper.addMapping(self.maxDistanceInput, WIDGETS.W_MAX_DIST) 124 137 self.mapper.addMapping(self.noOfTermsInput, WIDGETS.W_NO_TERMS) 125 self.mapper.addMapping(self.noOfTermsSuggestionButton, WIDGETS.W_NO_TERMS_SUGGEST) 138 self.mapper.addMapping(self.noOfTermsSuggestionButton, 139 WIDGETS.W_NO_TERMS_SUGGEST) 126 140 127 141 # Output … … 133 147 self.mapper.addMapping(self.oscillationValue, WIDGETS.W_OSCILLATION) 134 148 self.mapper.addMapping(self.posFractionValue, WIDGETS.W_POS_FRACTION) 135 self.mapper.addMapping(self.sigmaPosFractionValue, WIDGETS.W_SIGMA_POS_FRACTION) 149 self.mapper.addMapping(self.sigmaPosFractionValue, 150 WIDGETS.W_SIGMA_POS_FRACTION) 136 151 137 152 # Main Buttons … … 142 157 self.mapper.toFirst() 143 158 159 ###################################################################### 160 # Methods for updating GUI 161 144 162 def setupModel(self): 145 163 """ 146 164 Update boxes with latest values 147 165 """ 148 item = QtGui.QStandardItem(self._path )166 item = QtGui.QStandardItem(self._path[self._data_index]) 149 167 self.model.setItem(WIDGETS.W_FILENAME, item) 150 item = QtGui.QStandardItem(self._background )168 item = QtGui.QStandardItem(self._background[self._data_index]) 151 169 self.model.setItem(WIDGETS.W_BACKGROUND, item) 152 self.estimateBgd.click() 153 self.backgroundInput.setEnabled(self._bgd_input) 154 item = QtGui.QStandardItem(self._qmin) 170 self.checkBgdClicked(self._bgd_input[self._data_index]) 171 item = QtGui.QStandardItem(self._qmin[self._data_index]) 155 172 self.model.setItem(WIDGETS.W_QMIN, item) 156 item = QtGui.QStandardItem(self._qmax )173 item = QtGui.QStandardItem(self._qmax[self._data_index]) 157 174 self.model.setItem(WIDGETS.W_QMAX, item) 158 item = QtGui.QStandardItem(self._slit_width )175 item = QtGui.QStandardItem(self._slit_width[self._data_index]) 159 176 self.model.setItem(WIDGETS.W_SLIT_WIDTH, item) 160 item = QtGui.QStandardItem(self._slit_height )177 item = QtGui.QStandardItem(self._slit_height[self._data_index]) 161 178 self.model.setItem(WIDGETS.W_SLIT_HEIGHT, item) 162 item = QtGui.QStandardItem(self._terms )179 item = QtGui.QStandardItem(self._terms[self._data_index]) 163 180 self.model.setItem(WIDGETS.W_NO_TERMS, item) 164 item = QtGui.QStandardItem(self._regularization )181 item = QtGui.QStandardItem(self._regularization[self._data_index]) 165 182 self.model.setItem(WIDGETS.W_REGULARIZATION, item) 166 item = QtGui.QStandardItem(self._max_distance )183 item = QtGui.QStandardItem(self._max_distance[self._data_index]) 167 184 self.model.setItem(WIDGETS.W_MAX_DIST, item) 168 item = QtGui.QStandardItem(self._rg )185 item = QtGui.QStandardItem(self._rg[self._data_index]) 169 186 self.model.setItem(WIDGETS.W_RG, item) 170 item = QtGui.QStandardItem(self._i_0 )187 item = QtGui.QStandardItem(self._i_0[self._data_index]) 171 188 self.model.setItem(WIDGETS.W_I_ZERO, item) 172 item = QtGui.QStandardItem(self._background )189 item = QtGui.QStandardItem(self._background[self._data_index]) 173 190 self.model.setItem(WIDGETS.W_BACKGROUND, item) 174 item = QtGui.QStandardItem(self._comp_time )191 item = QtGui.QStandardItem(self._comp_time[self._data_index]) 175 192 self.model.setItem(WIDGETS.W_COMP_TIME, item) 176 item = QtGui.QStandardItem(self._chi_dof )193 item = QtGui.QStandardItem(self._chi_dof[self._data_index]) 177 194 self.model.setItem(WIDGETS.W_CHI_SQUARED, item) 178 item = QtGui.QStandardItem(self._oscillations )195 item = QtGui.QStandardItem(self._oscillations[self._data_index]) 179 196 self.model.setItem(WIDGETS.W_OSCILLATION, item) 180 item = QtGui.QStandardItem(self._pos_fraction )197 item = QtGui.QStandardItem(self._pos_fraction[self._data_index]) 181 198 self.model.setItem(WIDGETS.W_POS_FRACTION, item) 182 item = QtGui.QStandardItem(self._sigma_pos_fraction )199 item = QtGui.QStandardItem(self._sigma_pos_fraction[self._data_index]) 183 200 self.model.setItem(WIDGETS.W_SIGMA_POS_FRACTION, item) 184 201 self.enableButtons() 202 203 def enableButtons(self): 204 """ 205 Disable buttons when no data present, else enable them 206 """ 207 if self._path[self._data_index] == "" and len(self._path) == 1: 208 self.calculateButton.setEnabled(False) 209 self.explorerButton.setEnabled(False) 210 self.statusButton.setEnabled(False) 211 else: 212 self.statusButton.setEnabled(True) 213 self.explorerButton.setEnabled(True) 214 self.calculateButton.setEnabled(True) 215 216 def reDraw(self): 217 """ 218 Redraws the window with any and all necessary updates. 219 """ 220 self.populateDataComboBox() 221 self.dataList.setCurrentIndex(self._data_index) 222 self.setupModel() 223 224 def populateDataComboBox(self): 225 string_list = QtCore.QStringList() 226 for item in self._data: 227 qt_item = QtCore.QString.fromUtf8(item) 228 string_list.append(qt_item) 229 self.dataList.addItems(string_list) 230 231 def _addPr(self, data_list): 232 """ 233 Add a new data set to the P(r) window and updates as needed. 234 :param data_list: List of data sent from the data manager 235 """ 236 assert data_list is not None 237 238 for data in data_list: 239 # TODO: populate class variable lists with data from data_list 240 pass 241 self.reDraw() 242 243 244 ###################################################################### 185 245 # GUI Actions 246 186 247 def calculatePrInversion(self): 248 """ 249 Calculate the P(r) for every data set in the data list 250 """ 187 251 pass 188 252 189 253 def status(self): 254 """ 255 Show the status of the calculations 256 """ 190 257 pass 191 258 192 259 def help(self): 193 pass 194 195 def toggleBgd(self, item): 196 pass 260 """ 261 Open the P(r) Inversion help browser 262 """ 263 tree_location = (GuiUtils.HELP_DIRECTORY_LOCATION + 264 "user/sasgui/perspectives/pr/pr_help.html") 265 266 # Actual file anchor will depend on the combo box index 267 # Note that we can be clusmy here, since bad current_fitter_id 268 # will just make the page displayed from the top 269 self._helpView.load(QtCore.QUrl(tree_location)) 270 self._helpView.show() 271 272 def checkBgdClicked(self, boolean=None): 273 if boolean or self.manualBgd.isChecked(): 274 self.manualBgd.setChecked(True) 275 self.toggleBgd(self.manualBgd) 276 self._bgd_input[self._data_index] = True 277 else: 278 self.estimateBgd.setChecked(True) 279 self.toggleBgd(self.estimateBgd) 280 self._bgd_input[self._data_index] = False 281 282 def toggleBgd(self, item=None): 283 """ 284 Toggle the background between manual and estimated 285 :param item: gui item that was triggered 286 """ 287 if not item: 288 self.checkBgdClicked() 289 elif isinstance(item, QtGui.QRadioButton): 290 if item is self.estimateBgd: 291 self.backgroundInput.setEnabled(False) 292 else: 293 self.backgroundInput.setEnabled(True) 197 294 198 295 def openExplorerWindow(self): 296 """ 297 Open the Explorer window to see correlations between params and results 298 """ 199 299 # TODO: This depends on SVCC-45 200 300 pass 301 302 def displayChange(self): 303 """ 304 Display the values of the data set selected from the data combo box 305 """ 306 self._data_index = self.dataList.currentIndex() 307 self.setupModel() 308 309 ###################################################################### 310 # Response Actions 311 312 def setData(self, data_item=None, is_batch=False): 313 """ 314 Assign new data set or sets to the P(r) perspective 315 Obtain a QStandardItem object and dissect it to get Data1D/2D 316 Pass it over to the calculator 317 """ 318 assert data_item is not None 319 320 if not isinstance(data_item, list): 321 msg = "Incorrect type passed to the P(r) Perspective" 322 raise AttributeError, msg 323 324 if not isinstance(data_item[0], QtGui.QStandardItem): 325 msg = "Incorrect type passed to the P(r) Perspective" 326 raise AttributeError, msg 327 328 self._addPr(data_item) -
src/sas/qtgui/Perspectives/PrInversion/UI/TabbedPrInversionUI.ui
re32b120 r8045572 180 180 </item> 181 181 <item row="0" column="0"> 182 <layout class="QHBoxLayout" name="horizontalLayout_2" >182 <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,3"> 183 183 <item> 184 184 <widget class="QLabel" name="label"> … … 189 189 </item> 190 190 <item> 191 <widget class="QLineEdit" name="dataFileName"> 192 <property name="enabled"> 193 <bool>true</bool> 194 </property> 195 <property name="frame"> 196 <bool>false</bool> 197 </property> 198 <property name="readOnly"> 199 <bool>false</bool> 200 </property> 201 </widget> 191 <widget class="QComboBox" name="dataList"/> 202 192 </item> 203 193 </layout>
Note: See TracChangeset
for help on using the changeset viewer.