Changeset 186d678 in sasview
- Timestamp:
- Oct 31, 2018 4:08:16 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 48df831
- Parents:
- b1b71ad (diff), 04e1c80 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/DataExplorer.py
rb1b71ad r186d678 545 545 pass 546 546 547 def sendData(self, event ):547 def sendData(self, event=None): 548 548 """ 549 549 Send selected item data to the current perspective and set the relevant notifiers … … 1371 1371 Mask Editor for 2D plots 1372 1372 """ 1373 msg = QtWidgets.QMessageBox() 1374 msg.setIcon(QtWidgets.QMessageBox.Information) 1375 msg.setText("Error: cannot apply mask.\n"+ 1376 "Please select a 2D dataset.") 1377 msg.setStandardButtons(QtWidgets.QMessageBox.Ok) 1378 1373 1379 try: 1374 1380 if data is None or not isinstance(data, Data2D): 1381 # if data wasn't passed - try to get it from 1382 # the currently selected item 1375 1383 index = self.current_view.selectedIndexes()[0] 1376 1384 proxy = self.current_view.model() … … 1381 1389 1382 1390 if data is None or not isinstance(data, Data2D): 1383 msg = QtWidgets.QMessageBox() 1384 msg.setIcon(QtWidgets.QMessageBox.Information) 1385 msg.setText("Error: cannot apply mask. \ 1386 Please select a 2D dataset.") 1387 msg.setStandardButtons(QtWidgets.QMessageBox.Cancel) 1391 # If data is still not right, complain 1388 1392 msg.exec_() 1389 1393 return 1390 1394 except: 1391 msg = QtWidgets.QMessageBox()1392 msg.setIcon(QtWidgets.QMessageBox.Information)1393 msg.setText("Error: No dataset selected. \1394 Please select a 2D dataset.")1395 msg.setStandardButtons(QtWidgets.QMessageBox.Cancel)1396 1395 msg.exec_() 1397 1396 return -
src/sas/qtgui/MainWindow/GuiManager.py
rb1b71ad r186d678 10 10 from PyQt5.QtGui import * 11 11 from PyQt5.QtCore import Qt, QLocale, QUrl 12 13 import matplotlib as mpl 14 mpl.use("Qt5Agg") 12 15 13 16 from twisted.internet import reactor … … 868 871 self.results_frame.setVisible(True) 869 872 if output_data: 870 self.results_panel.onPlotResults(output_data )873 self.results_panel.onPlotResults(output_data, optimizer=self.perspective().optimizer) 871 874 872 875 def actionAdd_Custom_Model(self): -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rd00475d r186d678 294 294 self.has_magnet_error_column = False 295 295 296 # Enablement of comboboxes 297 self.enabled_cbmodel = False 298 self.enabled_sfmodel = False 299 296 300 # If the widget generated theory item, save it 297 301 self.theory_item = None … … 460 464 self.cbModel.setEnabled(False) 461 465 self.lblModel.setEnabled(False) 466 self.enabled_cbmodel = False 462 467 463 468 def enableModelCombo(self): … … 465 470 self.cbModel.setEnabled(True) 466 471 self.lblModel.setEnabled(True) 472 self.enabled_cbmodel = True 467 473 468 474 def disableStructureCombo(self): … … 470 476 self.cbStructureFactor.setEnabled(False) 471 477 self.lblStructure.setEnabled(False) 478 self.enabled_sfmodel = False 472 479 473 480 def enableStructureCombo(self): … … 475 482 self.cbStructureFactor.setEnabled(True) 476 483 self.lblStructure.setEnabled(True) 484 self.enabled_sfmodel = True 477 485 478 486 def togglePoly(self, isChecked): … … 1009 1017 Checks if the current model has magnetic scattering implemented 1010 1018 """ 1011 current_model = self.cbModel.currentText() 1012 return self.is2D and current_model in self.MAGNETIC_MODELS 1019 has_params = False 1020 if self.kernel_module: 1021 has_mag_params = len(self.kernel_module.magnetic_params) > 0 1022 return self.is2D and has_mag_params 1013 1023 1014 1024 def onSelectModel(self): … … 1034 1044 if not model: 1035 1045 return 1046 1036 1047 self.chkMagnetism.setEnabled(self.canHaveMagnetism()) 1037 1048 self.chkMagnetism.setEnabled(self.canHaveMagnetism()) … … 1175 1186 self.SASModelToQModel(model, structure_factor) 1176 1187 1188 # Enable magnetism checkbox for selected models 1189 self.chkMagnetism.setEnabled(self.canHaveMagnetism()) 1190 self.tabFitting.setTabEnabled(TAB_MAGNETISM, self.chkMagnetism.isChecked() and self.canHaveMagnetism()) 1191 1192 # Update column widths 1177 1193 for column, width in self.lstParamHeaderSizes.items(): 1178 1194 self.lstParams.setColumnWidth(column, width) … … 1573 1589 if param_dict is None: 1574 1590 return 1575 if hasattr(res, 'convergence') and len(res.convergence)>0: 1576 self.communicate.resultPlotUpdateSignal.emit(result[0]) 1591 self.communicate.resultPlotUpdateSignal.emit(result[0]) 1577 1592 1578 1593 elapsed = result[1] … … 3110 3125 shell_par = None 3111 3126 for par in kernel_pars: 3112 if par.name == param_name: 3127 parname = par.name 3128 if '[' in parname: 3129 parname = parname[:parname.index('[')] 3130 if parname == param_name: 3113 3131 shell_par = par 3114 3132 break 3115 if not shell_par:3133 if shell_par is None: 3116 3134 logger.error("Could not find %s in kernel parameters.", param_name) 3135 return 3117 3136 default_shell_count = shell_par.default 3118 3137 shell_min = 0 … … 3124 3143 # no info about limits 3125 3144 pass 3145 except Exception as ex: 3146 logging.error("Badly defined multiplicity: "+ str(ex)) 3147 return 3126 3148 # don't update the kernel here - this data is display only 3127 3149 self._model_model.blockSignals(True) … … 3130 3152 self._model_model.blockSignals(False) 3131 3153 3154 ## Respond to index change 3155 #func.currentTextChanged.connect(self.modifyShellsInList) 3156 3157 # Respond to button press 3158 button.clicked.connect(self.onShowSLDProfile) 3159 3160 # Available range of shells displayed in the combobox 3161 func.addItems([str(i) for i in range(shell_min, shell_max+1)]) 3162 3132 3163 # Respond to index change 3133 3164 func.currentTextChanged.connect(self.modifyShellsInList) 3134 3165 3135 # Respond to button press3136 button.clicked.connect(self.onShowSLDProfile)3137 3138 # Available range of shells displayed in the combobox3139 func.addItems([str(i) for i in range(shell_min, shell_max+1)])3140 3141 3166 # Add default number of shells to the model 3142 3167 func.setCurrentText(str(default_shell_count)) 3168 self.modifyShellsInList(str(default_shell_count)) 3143 3169 3144 3170 def modifyShellsInList(self, text): … … 3188 3214 """ 3189 3215 # get profile data 3190 x, y = self.kernel_module.getProfile() 3216 try: 3217 x, y = self.kernel_module.getProfile() 3218 except TypeError: 3219 msg = "SLD profile calculation failed." 3220 logging.error(msg) 3221 return 3222 3191 3223 y *= 1.0e6 3192 3224 profile_data = Data1D(x=x, y=y) … … 3221 3253 3222 3254 self.cbCategory.setEnabled(enabled) 3223 self.cbModel.setEnabled(enabled) 3255 3256 if enabled: 3257 # worry about original enablement of model and SF 3258 self.cbModel.setEnabled(self.enabled_cbmodel) 3259 self.cbStructureFactor.setEnabled(self.enabled_sfmodel) 3260 else: 3261 self.cbModel.setEnabled(enabled) 3262 self.cbStructureFactor.setEnabled(enabled) 3263 3224 3264 self.cmdPlot.setEnabled(enabled) 3225 3265 -
src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py
rf20ea3f r04e1c80 220 220 self.txtSmearDown.setEnabled(True) 221 221 self.txtSmearUp.setEnabled(True) 222 self.txtSmearDown.setText(str(0.0))223 self.txtSmearUp.setText(str(0.0))222 #self.txtSmearDown.setText(str(0.0)) 223 #self.txtSmearUp.setText(str(0.0)) 224 224 225 225 def setSlitLabels(self): … … 235 235 self.txtSmearDown.setEnabled(True) 236 236 self.txtSmearUp.setEnabled(True) 237 self.txtSmearDown.setText(str(0.0))238 self.txtSmearUp.setText(str(0.0))237 #self.txtSmearDown.setText(str(0.0)) 238 #self.txtSmearUp.setText(str(0.0)) 239 239 240 240 def setDQLabels(self): … … 330 330 """ 331 331 _, accuracy, d_height, d_width = self.state() 332 332 333 # Check changes in slit width 333 334 if d_width is None: … … 337 338 338 339 if isinstance(self.data, Data2D): 340 self.current_smearer = smear_selection(self.data, self.kernel_model) 339 341 return 340 342 # make sure once more if it is smearer -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r2eeda93 r186d678 185 185 186 186 # Observe no such luck 187 self.assertEqual(self.widget.cbCategory.currentIndex(), 7)187 self.assertEqual(self.widget.cbCategory.currentIndex(), 6) 188 188 self.assertEqual(self.widget.cbModel.count(), 29) 189 189 … … 219 219 # 220 220 # Now change the model 221 <<<<<<< HEAD 221 222 self.widget.cbModel.setCurrentIndex(4) 223 ======= 224 self.widget.cbModel.setCurrentIndex(2) 225 >>>>>>> ESS_GUI 222 226 self.assertEqual(self.widget.cbModel.currentText(),'dab') 223 227 -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r906e0c7 r722b7d6 13 13 Overwrite generic constructor to allow for some globals 14 14 """ 15 super( QtWidgets.QStyledItemDelegate, self).__init__()15 super(ModelViewDelegate, self).__init__() 16 16 17 17 # Main parameter table view columns … … 125 125 Overwrite generic constructor to allow for some globals 126 126 """ 127 super( QtWidgets.QStyledItemDelegate, self).__init__()127 super(PolyViewDelegate, self).__init__() 128 128 129 129 self.poly_parameter = 0 … … 226 226 Overwrite generic constructor to allow for some globals 227 227 """ 228 super( QtWidgets.QStyledItemDelegate, self).__init__()228 super(MagnetismViewDelegate, self).__init__() 229 229 230 230 self.mag_parameter = 0 -
src/sas/qtgui/Plotting/Plotter2D.py
r8fad50b rf5cec7c 9 9 10 10 11 #import sys12 #print("SYS.PATH = ", sys.path)13 11 import matplotlib as mpl 14 mpl.use("Qt5Agg")15 12 DEFAULT_CMAP = mpl.cm.jet 16 13 … … 116 113 """ 117 114 # Toggle the scale 118 zmin_temp = self.zmin if self.zmin else MIN_Z115 zmin_temp = self.zmin 119 116 zmax_temp = self.zmax 120 117 # self.scale predefined in the baseclass … … 425 422 if self.scale == 'log_{10}': 426 423 try: 427 if self.zmin <= 0and len(output[output > 0]) > 0:424 if self.zmin is None and len(output[output > 0]) > 0: 428 425 zmin_temp = self.zmin 429 426 output[output > 0] = numpy.log10(output[output > 0]) … … 437 434 except: 438 435 #Too many problems in 2D plot with scale 439 output[output > 0] = numpy.log10(output[output > 0])440 436 pass 441 437 … … 453 449 else: 454 450 self.im = self.ax.imshow(output, interpolation='nearest', 451 origin='lower', 455 452 vmin=zmin_temp, vmax=zmax_temp, 456 453 cmap=self.cmap, -
src/sas/qtgui/Utilities/ResultPanel.py
r8748751 r0c83303 55 55 sys.modules['bumps.gui.plot_view'] = PlotView 56 56 57 def onPlotResults(self, results ):57 def onPlotResults(self, results, optimizer="Unknown"): 58 58 # Clear up previous results 59 59 for view in (self.convergenceView, self.correlationView, 60 60 self.uncertaintyView, self.traceView): 61 61 view.close() 62 # close all tabs. REMEMBER TO USE REVERSED RANGE!!! 63 for index in reversed(range(self.count())): 64 self.removeTab(index) 62 65 63 66 result = results[0][0] 64 67 filename = result.data.sas_data.filename 65 current_ time = datetime.datetime.now().strftime("%I:%M%p, %B %d, %Y")66 self.setWindowTitle(self.window_name + " - " + filename + " - " + current_ time)67 if hasattr(result, 'convergence') :68 current_optimizer = optimizer 69 self.setWindowTitle(self.window_name + " - " + filename + " - " + current_optimizer) 70 if hasattr(result, 'convergence') and len(result.convergence) > 0: 68 71 best, pop = result.convergence[:, 0], result.convergence[:, 1:] 69 72 self.convergenceView.update(best, pop) … … 89 92 for view in (self.correlationView, self.uncertaintyView, self.traceView): 90 93 view.close() 94 # no tabs in the widget - possibly LM optimizer. Mark "closed" 95 if self.count()==0: 96 self.close() 91 97 92 98 def closeEvent(self, event): -
src/sas/qtgui/MainWindow/DataManager.py
re2e5f3d r345b3b3 29 29 from sas.qtgui.Plotting.PlotterData import Data1D 30 30 from sas.qtgui.Plotting.PlotterData import Data2D 31 from sas.qtgui.Plotting.Plottables import Plottable32 31 from sas.qtgui.Plotting.Plottables import PlottableTheory1D 33 32 from sas.qtgui.Plotting.Plottables import PlottableFit1D -
src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py
ra24eacf rb1b71ad 854 854 855 855 # Attempt at deleting 856 self.form.delete Item()856 self.form.deleteSelectedItem() 857 857 858 858 # Test the warning dialog called once … … 868 868 self.form.current_view.selectionModel().select(select_index, QtCore.QItemSelectionModel.Rows) 869 869 # delete it. now for good 870 self.form.delete Item()870 self.form.deleteSelectedItem() 871 871 872 872 # Test the warning dialog called once -
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
rd2007a8 ra3c59503 112 112 def onLatexCopy(self): 113 113 self.currentTab.onCopyToClipboard("Latex") 114 115 def serializeAllFitpage(self): 116 # serialize all active fitpages and return 117 # a dictionary: {data_id: fitpage_state} 118 params = {} 119 for i, tab in enumerate(self.tabs): 120 tab_data = self.getSerializedFitpage(tab) 121 if tab.tab_id is None: continue 122 id = tab_data['data_id'][0] 123 params[id] = tab_data 124 return params 125 126 def serializeCurrentFitpage(self): 127 # serialize current(active) fitpage 128 return self.getSerializedFitpage(self.currentTab) 129 130 def getSerializedFitpage(self, tab): 131 """ 132 get serialize requested fit tab 133 """ 134 fitpage_state = tab.getFitPage() 135 fitpage_state += tab.getFitModel() 136 # put the text into dictionary 137 line_dict = {} 138 for line in fitpage_state: 139 #content = line.split(',') 140 if len(line) > 1: 141 line_dict[line[0]] = line[1:] 142 return line_dict 143 144 def currentTabDataId(self): 145 """ 146 Returns the data ID of the current tab 147 """ 148 tab_id = None 149 if self.currentTab.data: 150 tab_id = self.currentTab.data.id 151 return tab_id 152 153 def updateFromParameters(self, parameters): 154 """ 155 Pass the update parameters to the current fit page 156 """ 157 self.currentTab.createPageForParameters(parameters) 114 158 115 159 def closeEvent(self, event): … … 258 302 return True 259 303 304 def isSerializable(self): 305 """ 306 Tell the caller that this perspective writes its state 307 """ 308 return True 309 260 310 def setData(self, data_item=None, is_batch=False): 261 311 """ … … 337 387 pass 338 388 389 def getCurrentStateAsXml(self): 390 """ 391 Returns an XML version of the current state 392 """ 393 state = {} 394 for tab in self.tabs: 395 pass 396 return state 397 339 398 @property 340 399 def currentTab(self): -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/ComplexConstraintTest.py
r725d9c06 r2eeda93 34 34 category_index = self.tab1.cbCategory.findText("Shape Independent") 35 35 self.tab1.cbCategory.setCurrentIndex(category_index) 36 model_index = self.tab1.cbModel.findText("be_polyelectrolyte") 37 self.tab1.cbModel.setCurrentIndex(model_index) 38 36 39 category_index = self.tab2.cbCategory.findText("Cylinder") 37 40 self.tab2.cbCategory.setCurrentIndex(category_index) 41 model_index = self.tab2.cbModel.findText("barbell") 42 self.tab2.cbModel.setCurrentIndex(model_index) 38 43 39 44 tabs = [self.tab1, self.tab2] -
src/sas/qtgui/Utilities/GuiUtils.py
raed159f rb1b71ad 11 11 import webbrowser 12 12 import urllib.parse 13 import json 14 from io import BytesIO 13 15 14 16 import numpy as np … … 26 28 from sas.qtgui.Plotting.PlotterData import Data1D 27 29 from sas.qtgui.Plotting.PlotterData import Data2D 30 from sas.qtgui.Plotting.Plottables import Plottable 31 from sas.sascalc.dataloader.data_info import Sample, Source, Vector 32 from sas.qtgui.Plotting.Plottables import View 33 from sas.qtgui.Plotting.Plottables import PlottableTheory1D 34 from sas.qtgui.Plotting.Plottables import PlottableFit1D 35 from sas.qtgui.Plotting.Plottables import Text 36 from sas.qtgui.Plotting.Plottables import Chisq 37 from sas.qtgui.MainWindow.DataState import DataState 38 28 39 from sas.sascalc.dataloader.loader import Loader 29 40 from sas.qtgui.Utilities import CustomDir … … 257 268 sendDataToGridSignal = QtCore.pyqtSignal(list) 258 269 259 # Action Save Analysis triggered260 saveAnalysisSignal = QtCore.pyqtSignal()261 262 270 # Mask Editor requested 263 271 maskEditorSignal = QtCore.pyqtSignal(Data2D) … … 287 295 resultPlotUpdateSignal = QtCore.pyqtSignal(list) 288 296 289 def updateModelItemWithPlot(item, update_data, name="" ):297 def updateModelItemWithPlot(item, update_data, name="", checkbox_state=None): 290 298 """ 291 299 Adds a checkboxed row named "name" to QStandardItem … … 312 320 # Force redisplay 313 321 return 314 315 322 # Create the new item 316 323 checkbox_item = createModelItemWithPlot(update_data, name) 317 324 325 if checkbox_state is not None: 326 checkbox_item.setCheckState(checkbox_state) 318 327 # Append the new row to the main item 319 328 item.appendRow(checkbox_item) … … 566 575 if isinstance(data.process, list) and data.process: 567 576 for process in data.process: 577 if process is None: 578 continue 568 579 process_date = process.date 569 580 process_date_item = QtGui.QStandardItem("Date: " + process_date) … … 1140 1151 return result 1141 1152 1153 def saveData(fp, data): 1154 """ 1155 save content of data to fp (a .write()-supporting file-like object) 1156 """ 1157 1158 def add_type(dict, type): 1159 dict['__type__'] = type.__name__ 1160 return dict 1161 1162 def jdefault(o): 1163 """ 1164 objects that can't otherwise be serialized need to be converted 1165 """ 1166 # tuples and sets (TODO: default JSONEncoder converts tuples to lists, create custom Encoder that preserves tuples) 1167 if isinstance(o, (tuple, set)): 1168 content = { 'data': list(o) } 1169 return add_type(content, type(o)) 1170 1171 # "simple" types 1172 if isinstance(o, (Sample, Source, Vector)): 1173 return add_type(o.__dict__, type(o)) 1174 if isinstance(o, (Plottable, View)): 1175 return add_type(o.__dict__, type(o)) 1176 1177 # DataState 1178 if isinstance(o, (Data1D, Data2D)): 1179 # don't store parent 1180 content = o.__dict__.copy() 1181 #content.pop('parent') 1182 return add_type(content, type(o)) 1183 1184 # ndarray 1185 if isinstance(o, np.ndarray): 1186 buffer = BytesIO() 1187 np.save(buffer, o) 1188 buffer.seek(0) 1189 content = { 'data': buffer.read().decode('latin-1') } 1190 return add_type(content, type(o)) 1191 1192 # not supported 1193 logging.info("data cannot be serialized to json: %s" % type(o)) 1194 return None 1195 1196 json.dump(data, fp, indent=2, sort_keys=True, default=jdefault) 1197 1198 def readDataFromFile(fp): 1199 ''' 1200 ''' 1201 supported = [ 1202 tuple, set, 1203 Sample, Source, Vector, 1204 Plottable, Data1D, Data2D, PlottableTheory1D, PlottableFit1D, Text, Chisq, View, 1205 DataState, np.ndarray] 1206 1207 lookup = dict((cls.__name__, cls) for cls in supported) 1208 1209 class TooComplexException(Exception): 1210 pass 1211 1212 def simple_type(cls, data, level): 1213 class Empty(object): 1214 def __init__(self): 1215 for key, value in data.items(): 1216 setattr(self, key, generate(value, level)) 1217 1218 # create target object 1219 o = Empty() 1220 o.__class__ = cls 1221 1222 return o 1223 1224 def construct(type, data, level): 1225 try: 1226 cls = lookup[type] 1227 except KeyError: 1228 logging.info('unknown type: %s' % type) 1229 return None 1230 1231 # tuples and sets 1232 if cls in (tuple, set): 1233 # convert list to tuple/set 1234 return cls(generate(data['data'], level)) 1235 1236 # "simple" types 1237 if cls in (Sample, Source, Vector): 1238 return simple_type(cls, data, level) 1239 if issubclass(cls, Plottable) or (cls == View): 1240 return simple_type(cls, data, level) 1241 1242 # DataState 1243 if cls == DataState: 1244 o = simple_type(cls, data, level) 1245 o.parent = None # TODO: set to ??? 1246 return o 1247 1248 # ndarray 1249 if cls == np.ndarray: 1250 buffer = BytesIO() 1251 buffer.write(data['data'].encode('latin-1')) 1252 buffer.seek(0) 1253 return np.load(buffer) 1254 1255 logging.info('not implemented: %s, %s' % (type, cls)) 1256 return None 1257 1258 def generate(data, level): 1259 if level > 16: # recursion limit (arbitrary number) 1260 raise TooComplexException() 1261 else: 1262 level += 1 1263 1264 if isinstance(data, dict): 1265 try: 1266 type = data['__type__'] 1267 except KeyError: 1268 # if dictionary doesn't have __type__ then it is assumed to be just an ordinary dictionary 1269 o = {} 1270 for key, value in data.items(): 1271 o[key] = generate(value, level) 1272 return o 1273 1274 return construct(type, data, level) 1275 1276 if isinstance(data, list): 1277 return [generate(item, level) for item in data] 1278 1279 return data 1280 1281 new_stored_data = {} 1282 for id, data in json.load(fp).items(): 1283 try: 1284 new_stored_data[id] = generate(data, 0) 1285 except TooComplexException: 1286 logging.info('unable to load %s' % id) 1287 1288 return new_stored_data 1289 1290 def readProjectFromSVS(filepath): 1291 """ 1292 Read old SVS file and convert to the project dictionary 1293 """ 1294 from sas.sascalc.dataloader.readers.cansas_reader import Reader as CansasReader 1295 from sas.sascalc.fit.pagestate import Reader 1296 1297 loader = Loader() 1298 loader.associate_file_reader('.svs', Reader) 1299 temp = loader.load(filepath) 1300 state_reader = Reader() 1301 data_svs, state_svs = state_reader.read(filepath) 1302 1303 output = [] 1304 if isinstance(temp, list) and isinstance(state_svs, list): 1305 for item, state in zip(temp, state_svs): 1306 output.append([item, state]) 1307 else: 1308 output[temp, state_svs] 1309 return output 1310 1311 def convertFromSVS(datasets): 1312 """ 1313 Read in properties from SVS and convert into a simple dict 1314 """ 1315 content = {} 1316 for dataset in datasets: 1317 # we already have data - interested only in properties 1318 #[[item_1, state_1], [item_2, state_2],...] 1319 data = dataset[0] 1320 params = dataset[1] 1321 content[params.data_id] = {} 1322 content[params.data_id]['fit_data'] = [data, {'checked': 2}, []] 1323 param_dict = {} 1324 param_dict['fitpage_category'] = [params.categorycombobox] 1325 param_dict['fitpage_model'] = [params.formfactorcombobox] 1326 param_dict['fitpage_structure'] = [params.structurecombobox] 1327 param_dict['2D_params'] = [str(params.is_2D)] 1328 param_dict['chainfit_params'] = ["False"] 1329 param_dict['data_id'] = [params.data_id] 1330 param_dict['data_name'] = [params.data_name] 1331 param_dict['is_data'] = [str(params.is_data)] 1332 param_dict['magnetic_params'] = [str(params.magnetic_on)] 1333 param_dict['model_name'] = [params.formfactorcombobox] 1334 param_dict['polydisperse_params'] = [str(params.enable_disp)] 1335 param_dict['q_range_max'] = [str(params.qmax)] 1336 param_dict['q_range_min'] = [str(params.qmin)] 1337 # Smearing is a bit trickier. 4.x has multiple keywords, 1338 # one for each combobox option 1339 if params.enable_smearer: 1340 if params.slit_smearer: 1341 w = 1 1342 elif params.pinhole_smearer: 1343 w = 2 1344 else: 1345 w = 0 1346 param_dict['smearing'] = [str(w)] 1347 # weighting is a bit trickier. 4.x has multiple keywords, 1348 # one for each radio box. 1349 if params.dI_noweight: 1350 w = 2 1351 elif params.dI_didata: 1352 w = 3 1353 elif params.dI_sqrdata: 1354 w = 4 1355 elif params.dI_idata: 1356 w = 5 1357 else: 1358 w = 2 1359 param_dict['weighting'] = [str(w)] 1360 1361 # 4.x multi_factor is really the multiplicity 1362 if params.multi_factor is not None: 1363 param_dict['multiplicity'] = [str(int(params.multi_factor))] 1364 1365 # playing with titles 1366 data.filename = params.file 1367 data.title = params.data_name 1368 data.name = params.data_name 1369 1370 # main parameters 1371 for p in params.parameters: 1372 p_name = p[1] 1373 param_dict[p_name] = [str(p[0]), str(p[2]), None, str(p[5][1]), str(p[6][1])] 1374 # orientation parameters 1375 if params.is_2D: 1376 for p in params.orientation_params: 1377 p_name = p[1] 1378 param_dict[p_name] = [str(p[0]), str(p[2]), None, str(p[5][1]), str(p[6][1])] 1379 1380 # disperse parameters 1381 if params.enable_disp: 1382 for p in params.fittable_param: 1383 p_name = p[1] 1384 param_dict[p_name] = [str(p[0]), str(p[2]), None, str(35), str(3)] 1385 1386 # magnetic parameters 1387 1388 content[params.data_id]['fit_params'] = param_dict 1389 return content 1142 1390 1143 1391 def enum(*sequential, **named): -
src/sas/sascalc/dataloader/readers/cansas_reader.py
rb8080e1 rb1b71ad 184 184 if CANSAS_NS.get(self.cansas_version).get("ns") == value.rsplit(" ")[0]: 185 185 return True 186 if ext == " svs":186 if ext == ".svs": 187 187 return True # Why is this required? 188 188 # If we get to this point then file isn't valid CanSAS -
src/sas/sascalc/fit/pagestate.py
rb8080e1 rb1b71ad 1249 1249 1250 1250 else: 1251 self.call_back(format=ext)1251 #self.call_back(format=ext) 1252 1252 raise RuntimeError("%s is not a file" % path) 1253 1253 1254 1254 # Return output consistent with the loader's api 1255 1255 if len(output) == 0: 1256 self.call_back(state=None, datainfo=None, format=ext)1256 #self.call_back(state=None, datainfo=None, format=ext) 1257 1257 return None 1258 1258 else: 1259 states=[] 1259 1260 for data in output: 1260 1261 # Call back to post the new state … … 1281 1282 if isinstance(data.run_name, dict): 1282 1283 # Note: key order in dict is not guaranteed, so sort 1283 name = data.run_name.keys()[0]1284 name = list(data.run_name.keys())[0] 1284 1285 else: 1285 1286 name = data.run_name … … 1289 1290 state.version = fitstate.version 1290 1291 # store state in fitting 1291 self.call_back(state=state, datainfo=data, format=ext)1292 #self.call_back(state=state, datainfo=data, format=ext) 1292 1293 self.state = state 1294 states.append(state) 1293 1295 simfitstate = self._parse_simfit_state(entry) 1294 1296 if simfitstate is not None: 1295 self.call_back(state=simfitstate)1296 1297 return output1297 #self.call_back(state=simfitstate) 1298 states.append(simfitstate) 1299 return (output, states) 1298 1300 except: 1299 self.call_back(format=ext)1301 #self.call_back(format=ext) 1300 1302 raise 1301 1303
Note: See TracChangeset
for help on using the changeset viewer.