Changeset c1e380e in sasview for src/sas/qtgui/Perspectives/Fitting
- Timestamp:
- May 30, 2017 4:14:29 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:
- 358b39d
- Parents:
- c416a17
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r6964d44 rc1e380e 40 40 CATEGORY_STRUCTURE = "Structure Factor" 41 41 STRUCTURE_DEFAULT = "None" 42 43 # Mapping between column index and relevant parameter name extension 44 POLY_COLUMN_DICT = { 45 1: 'width', 46 2: 'min', 47 3: 'max', 48 4: 'npts', 49 5: 'nsigmas'} 42 50 43 51 class FittingWidget(QtGui.QWidget, Ui_FittingWidgetUI): … … 239 247 self.setTableProperties(self.lstPoly) 240 248 # Delegates for custom editing and display 241 self.lstPoly.setItemDelegate(PolyViewDelegate(self))249 # self.lstPoly.setItemDelegate(PolyViewDelegate(self)) 242 250 243 251 # Magnetism model displayed in magnetism list … … 469 477 model_row = item.row() 470 478 name_index = self._poly_model.index(model_row, 0) 479 parameter_name = str(name_index.data().toString()).lower() # "distribution of sld" etc. 480 if "distribution of" in parameter_name: 481 parameter_name = parameter_name[16:] 482 471 483 # Extract changed value. Assumes proper validation by QValidator/Delegate 472 484 # TODO: abstract away hardcoded column numbers … … 475 487 value = item.checkState() 476 488 # TODO: add the param to self.params_for_fitting 489 parameter_name = parameter_name+'.width' 490 if value == QtCore.Qt.Checked: 491 self.parameters_to_fit.append(parameter_name) 492 else: 493 if parameter_name in self.parameters_to_fit: 494 self.parameters_to_fit.remove(parameter_name) 495 return 477 496 elif model_column == 6: 478 497 value = item.text() … … 485 504 return 486 505 487 parameter_name = str(self._poly_model.data(name_index).toPyObject()) # "distribution of sld" etc. 488 if "Distribution of" in parameter_name: 489 parameter_name = parameter_name[16:] 490 property_name = str(self._poly_model.headerData(model_column, 1).toPyObject()) # Value, min, max, etc. 506 property_name = str(self._poly_model.headerData(model_column, 1).toPyObject()).lower() # Value, min, max, etc. 491 507 # print "%s(%s) => %d" % (parameter_name, property_name, value) 492 508 493 509 # Update the sasmodel 494 #self.kernel_module.params[parameter_name] = value 510 # PD[ratio] -> width, npts -> npts, nsigs -> nsigmas 511 self.kernel_module.setParam(parameter_name + '.' + POLY_COLUMN_DICT[model_column], value) 495 512 496 513 # Reload the main model - may not be required if no variable is shown in main view … … 521 538 qmax = self.q_range_max 522 539 params_to_fit = self.parameters_to_fit 540 541 print "OPTIMIZING: ", params_to_fit 523 542 524 543 # Potential weights added directly to data … … 963 982 status = item.checkState() 964 983 965 def isChecked(row):966 return self._model_model.item(row, 0).checkState() == QtCore.Qt.Checked967 968 984 def isCheckable(row): 969 985 return self._model_model.item(row, 0).isCheckable() … … 979 995 980 996 # update the list of parameters to fit 981 self.parameters_to_fit = [str(self._model_model.item(row_index, 0).text()) 982 for row_index in xrange(self._model_model.rowCount()) 983 if isChecked(row_index)] 997 main_params = self.checkedListFromModel(self._model_model) 998 poly_params = self.checkedListFromModel(self._poly_model) 999 # Retrieve poly params names 1000 poly_params = [param[16:]+'.width' for param in poly_params] 1001 # TODO : add magnetic params 1002 1003 self.parameters_to_fit = main_params + poly_params 1004 1005 def checkedListFromModel(self, model): 1006 """ 1007 Returns list of checked parameters for given model 1008 """ 1009 def isChecked(row): 1010 return model.item(row, 0).checkState() == QtCore.Qt.Checked 1011 1012 return [str(model.item(row_index, 0).text()) 1013 for row_index in xrange(model.rowCount()) 1014 if isChecked(row_index)] 984 1015 985 1016 def nameForFittedData(self, name): … … 1077 1108 calc_thread = threads.deferToThread(method.compute) 1078 1109 calc_thread.addCallback(self.methodCompleteForData()) 1079 calc_thread.addErrback(self.calculateDataFailed ())1110 calc_thread.addErrback(self.calculateDataFailed) 1080 1111 1081 1112 def calculateDataFailed(self): 1082 1113 """ 1114 Thread returned error 1083 1115 """ 1084 1116 print "Calculate Data failed." … … 1128 1160 def calcException(self, etype, value, tb): 1129 1161 """ 1130 Something horrible happened in the deferred. 1131 """ 1162 Thread threw an exception. 1163 """ 1164 # TODO: remimplement thread cancellation 1132 1165 logging.error("".join(traceback.format_exception(etype, value, tb))) 1133 1166 … … 1164 1197 continue 1165 1198 1199 # Values from the sasmodel 1200 width = self.kernel_module.getParam(param.name+'.width') 1201 npts = self.kernel_module.getParam(param.name+'.npts') 1202 nsigs = self.kernel_module.getParam(param.name+'.nsigmas') 1166 1203 # Potential multishell params 1167 checked_list = ["Distribution of "+param.name, str( param.default),1204 checked_list = ["Distribution of "+param.name, str(width), 1168 1205 str(param.limits[0]), str(param.limits[1]), 1169 "35", "3", "gaussian"]1206 str(npts), str(nsigs), ""] 1170 1207 FittingUtilities.addCheckedListToModel(self._poly_model, checked_list) 1171 1208 1172 1209 #TODO: Need to find cleaner way to input functions 1173 #func = QtGui.QComboBox()1174 #func.addItems(['rectangle', 'array', 'lognormal', 'gaussian', 'schulz',])1175 #func_index = self.lstPoly.model().index(row, 6)1176 #self.lstPoly.setIndexWidget(func_index, func)1210 func = QtGui.QComboBox() 1211 func.addItems(['rectangle', 'array', 'lognormal', 'gaussian', 'schulz',]) 1212 func_index = self.lstPoly.model().index(row, 6) 1213 self.lstPoly.setIndexWidget(func_index, func) 1177 1214 1178 1215 FittingUtilities.addPolyHeadersToModel(self._poly_model) -
src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py
rdc5ef15 rc1e380e 84 84 self.txtMinRange.setText(str(QMIN_DEFAULT)) 85 85 self.txtNpts.setText(str(NPTS_DEFAULT)) 86 self.txtNptsFit.setText(str(NPTS_DEFAULT)) 86 87 self.model.blockSignals(False) 87 88 … … 125 126 Callback for resetting qmin/qmax 126 127 """ 127 pass128 self.updateQRange(QMIN_DEFAULT, QMAX_DEFAULT, NPTS_DEFAULT) 128 129 129 130 def onWeightingChoice(self, button): -
src/sas/qtgui/Perspectives/Fitting/UI/OptionsWidgetUI.ui
r180bd54 rc1e380e 31 31 </item> 32 32 <item row="0" column="1"> 33 <widget class="QLineEdit" name="txtMinRange"/> 33 <widget class="QLineEdit" name="txtMinRange"> 34 <property name="toolTip"> 35 <string><html><head/><body><p>Minimum value of Q.</p></body></html></string> 36 </property> 37 </widget> 34 38 </item> 35 39 <item row="0" column="2"> … … 49 53 </item> 50 54 <item row="1" column="1"> 51 <widget class="QLineEdit" name="txtMaxRange"/> 55 <widget class="QLineEdit" name="txtMaxRange"> 56 <property name="toolTip"> 57 <string><html><head/><body><p>Maximum value of Q.</p></body></html></string> 58 </property> 59 </widget> 52 60 </item> 53 61 <item row="1" column="2"> … … 76 84 <item row="0" column="2"> 77 85 <widget class="QPushButton" name="cmdReset"> 86 <property name="toolTip"> 87 <string><html><head/><body><p>Reset the Q range to the default.</p></body></html></string> 88 </property> 78 89 <property name="text"> 79 90 <string>Reset</string> … … 107 118 </item> 108 119 <item row="0" column="1"> 109 <widget class="QLineEdit" name="txtNpts"/> 120 <widget class="QLineEdit" name="txtNpts"> 121 <property name="toolTip"> 122 <string><html><head/><body><p>Total number of data points.</p></body></html></string> 123 </property> 124 </widget> 110 125 </item> 111 126 <item row="0" column="2"> 112 127 <widget class="QCheckBox" name="chkLogData"> 128 <property name="toolTip"> 129 <string><html><head/><body><p>Check to use log spaced points.</p></body></html></string> 130 </property> 113 131 <property name="text"> 114 132 <string>Log spaced points</string> … … 125 143 <item row="1" column="1"> 126 144 <widget class="QLineEdit" name="txtNptsFit"> 145 <property name="toolTip"> 146 <string><html><head/><body><p>Number of points selected for fitting.</p></body></html></string> 147 </property> 127 148 <property name="readOnly"> 128 149 <bool>true</bool>
Note: See TracChangeset
for help on using the changeset viewer.