- Timestamp:
- Oct 26, 2018 6:44:15 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:
- b1b71ad
- Parents:
- a3c59503 (diff), 75906a1 (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:
-
- 2 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/DataExplorer.py
ra3c59503 rd00475d 1470 1470 self.manager.update_stored_data(deleted_names) 1471 1471 1472 def closeAllPlots(self): 1473 """ 1474 Close all currently displayed plots 1475 """ 1476 1477 for plot_id in PlotHelper.currentPlots(): 1478 try: 1479 plotter = PlotHelper.plotById(plot_id) 1480 plotter.close() 1481 self.plot_widgets[plot_id].close() 1482 self.plot_widgets.pop(plot_id, None) 1483 except AttributeError as ex: 1484 logging.error("Closing of %s failed:\n %s" % (plot_id, str(ex))) 1485 1472 1486 def closePlotsForItem(self, item): 1473 1487 """ -
src/sas/qtgui/MainWindow/GuiManager.py
ra3c59503 rd00475d 24 24 from sas.qtgui.Utilities.PluginManager import PluginManager 25 25 from sas.qtgui.Utilities.GridPanel import BatchOutputPanel 26 from sas.qtgui.Utilities.ResultPanel import ResultPanel 26 27 27 28 from sas.qtgui.Utilities.ReportDialog import ReportDialog … … 147 148 self.aboutWidget = AboutBox() 148 149 self.categoryManagerWidget = CategoryManager(self._parent, manager=self) 150 149 151 self.grid_window = None 150 152 self.grid_window = BatchOutputPanel(parent=self) … … 154 156 self.grid_subwindow.setVisible(False) 155 157 self.grid_window.windowClosedSignal.connect(lambda: self.grid_subwindow.setVisible(False)) 158 159 self.results_panel = ResultPanel(parent=self._parent, manager=self) 160 self.results_frame = self._workspace.workspace.addSubWindow(self.results_panel) 161 self.results_frame.setVisible(False) 162 self.results_panel.windowClosedSignal.connect(lambda: self.results_frame.setVisible(False)) 156 163 157 164 self._workspace.toolBar.setVisible(LocalConfig.TOOLBAR_SHOW) … … 443 450 """ 444 451 # disable not yet fully implemented actions 445 #self._workspace.actionOpen_Analysis.setVisible(False)446 452 self._workspace.actionUndo.setVisible(False) 447 453 self._workspace.actionRedo.setVisible(False) … … 450 456 self._workspace.actionImage_Viewer.setVisible(False) 451 457 self._workspace.actionCombine_Batch_Fit.setVisible(False) 452 self._workspace.actionFit_Results.setVisible(False)453 458 # orientation viewer set to invisible SASVIEW-1132 454 459 self._workspace.actionOrientation_Viewer.setVisible(False) … … 510 515 self._workspace.actionNext.triggered.connect(self.actionNext) 511 516 self._workspace.actionPrevious.triggered.connect(self.actionPrevious) 517 self._workspace.actionClosePlots.triggered.connect(self.actionClosePlots) 512 518 # Analysis 513 519 self._workspace.actionFitting.triggered.connect(self.actionFitting) … … 524 530 525 531 self.communicate.sendDataToGridSignal.connect(self.showBatchOutput) 532 self.communicate.resultPlotUpdateSignal.connect(self.showFitResults) 526 533 527 534 #============ FILE ================= … … 853 860 """ 854 861 """ 855 print("actionFit_Results TRIGGERED") 856 pass 862 self.showFitResults(None) 863 864 def showFitResults(self, output_data): 865 """ 866 Show bumps convergence plots 867 """ 868 self.results_frame.setVisible(True) 869 if output_data: 870 self.results_panel.onPlotResults(output_data) 857 871 858 872 def actionAdd_Custom_Model(self): … … 945 959 """ 946 960 self._workspace.workspace.activatePreviousSubWindow() 961 962 def actionClosePlots(self): 963 """ 964 Closes all Plotters and Plotter2Ds. 965 """ 966 self.filesWidget.closeAllPlots() 967 pass 947 968 948 969 #============ HELP ================= -
src/sas/qtgui/MainWindow/MainWindow.py
rb14db78 r33812c3 6 6 from PyQt5.QtWidgets import QApplication 7 7 from PyQt5.QtGui import QPixmap 8 from PyQt5.QtCore import Qt 8 9 import os 9 10 import sys … … 58 59 splash = SplashScreen() 59 60 splash.show() 60 61 app.setAttribute(Qt.AA_EnableHighDpiScaling) 61 62 # fix for pyinstaller packages app to avoid ReactorAlreadyInstalledError 62 63 import sys -
src/sas/qtgui/MainWindow/UI/MainWindowUI.ui
refaf022 r6bc0840 25 25 <y>0</y> 26 26 <width>915</width> 27 <height>2 1</height>27 <height>26</height> 28 28 </rect> 29 29 </property> … … 128 128 <addaction name="actionPrevious"/> 129 129 <addaction name="separator"/> 130 <addaction name="actionClosePlots"/> 130 131 </widget> 131 132 <widget class="QMenu" name="menuAnalysis"> … … 571 572 </property> 572 573 </action> 574 <action name="actionClosePlots"> 575 <property name="text"> 576 <string>Close All Plots</string> 577 </property> 578 </action> 573 579 </widget> 574 580 <resources/> -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rb8dccb8 rd00475d 1573 1573 if param_dict is None: 1574 1574 return 1575 if hasattr(res, 'convergence') and len(res.convergence)>0: 1576 self.communicate.resultPlotUpdateSignal.emit(result[0]) 1575 1577 1576 1578 elapsed = result[1] … … 2333 2335 max_column = self.lstParams.itemDelegate().param_max 2334 2336 if model_column == param_column: 2335 self.kernel_module.setParam(parameter_name, value) 2337 # don't try to update multiplicity counters if they aren't there. 2338 # Note that this will fail for proper bad update where the model 2339 # doesn't contain multiplicity parameter 2340 if parameter_name != self.kernel_module.multiplicity_info.control: 2341 self.kernel_module.setParam(parameter_name, value) 2336 2342 elif model_column == min_column: 2337 2343 # min/max to be changed in self.kernel_module.details[parameter_name] = ['Ang', 0.0, inf] … … 3373 3379 else: 3374 3380 index = self.theory_item 3381 params = FittingUtilities.getStandardParam(self._model_model) 3375 3382 report_logic = ReportPageLogic(self, 3376 3383 kernel_module=self.kernel_module, 3377 3384 data=self.data, 3378 3385 index=index, 3379 model=self._model_model)3386 params=params) 3380 3387 3381 3388 return report_logic.reportList() -
src/sas/qtgui/Perspectives/Fitting/ReportPageLogic.py
r085ee014 r75906a1 13 13 14 14 import sas.qtgui.Utilities.GuiUtils as GuiUtils 15 from sas.qtgui.Perspectives.Fitting import FittingUtilities16 15 17 16 class ReportPageLogic(object): … … 19 18 Logic for the Report Page functionality. Refactored from FittingWidget. 20 19 """ 21 def __init__(self, parent=None, kernel_module=None, data=None, index=None, model=None):20 def __init__(self, parent=None, kernel_module=None, data=None, index=None, params=None): 22 21 23 22 self.parent = parent … … 25 24 self.data = data 26 25 self._index = index 27 self. model = model26 self.params = params 28 27 29 28 @staticmethod … … 119 118 Look at widget state and extract parameters 120 119 """ 121 pars = FittingUtilities.getStandardParam(self.model) 122 if pars is None: 120 if self.params is None: 123 121 return "" 124 122 125 123 report = "" 126 124 plus_minus = " ± " 127 for value in pars:125 for value in self.params: 128 126 try: 129 127 par_name = value[1] -
src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
r6ae7466 raed159f 473 473 self._calculator.set_qmax(qmax) 474 474 if np.size(self.logic.data.dy) == 0 or np.all(self.logic.data.dy) == 0: 475 self. logic.data.dy = self._calculator.add_errors(self.logic.data.y)475 self._calculator.add_errors() 476 476 self.updateDataList(data) 477 477 self.populateDataComboBox(self.logic.data.filename, data) -
src/sas/qtgui/Plotting/Binder.py
rcee5c78 r75906a1 233 233 """ 234 234 # TODO: sort by zorder of axes then by zorder within axes 235 #self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder))236 #self._artists.sort(cmp=lambda x, y: y.zorder.__gt__(x.zorder))237 235 found = Selection() 236 self._artists.sort(key=lambda x: x.zorder, reverse=True) 238 237 for artist in self._artists: 239 238 # TODO: should contains() return false if invisible? -
src/sas/qtgui/Plotting/ColorMap.py
rd6b8a1d r8fad50b 8 8 9 9 import matplotlib as mpl 10 from matplotlib import pylab11 10 import numpy 12 11 … … 32 31 self.data = data 33 32 self._cmap_orig = self._cmap = cmap if cmap is not None else DEFAULT_MAP 34 self.all_maps = [m for m in pylab.cm.datad]33 self.all_maps = [m for m in mpl.cm.datad] 35 34 self.maps = sorted(m for m in self.all_maps if not m.endswith("_r")) 36 35 self.rmaps = sorted(set(self.all_maps) - set(self.maps)) -
src/sas/qtgui/Plotting/ConvertUnits.py
rb8080e1 r75906a1 10 10 """ 11 11 if power != 0: 12 if unit.find("^") != -1: # if the unit contains a power er^13 toks = re.split( "\^", unit)12 if unit.find("^") != -1: # if the unit contains a power ^ 13 toks = re.split(r"\^", unit) 14 14 if toks[0].find("/") != -1 or \ 15 15 toks[0].find("-") != -1: -
src/sas/qtgui/Plotting/Plotter2D.py
r2f55df6 r8fad50b 1 1 import copy 2 2 import numpy 3 import pylab4 3 import functools 5 4 import logging … … 9 8 from PyQt5 import QtWidgets 10 9 11 DEFAULT_CMAP = pylab.cm.jet12 10 13 11 #import sys … … 15 13 import matplotlib as mpl 16 14 mpl.use("Qt5Agg") 15 DEFAULT_CMAP = mpl.cm.jet 17 16 18 17 from mpl_toolkits.mplot3d import Axes3D -
src/sas/qtgui/Plotting/PlotterBase.py
r34f13a83 r8fad50b 1 import pylab2 1 import numpy 3 2 … … 10 9 11 10 import matplotlib.pyplot as plt 11 import matplotlib as mpl 12 12 from matplotlib import rcParams 13 13 14 DEFAULT_CMAP = pylab.cm.jet14 DEFAULT_CMAP = mpl.cm.jet 15 15 from sas.qtgui.Plotting.Binder import BindArtist 16 16 from sas.qtgui.Plotting.PlotterData import Data1D -
src/sas/qtgui/Plotting/Slicers/AzimutSlicer.py
re20870bc r75906a1 137 137 sector = sect(self.base.data2D) 138 138 139 from sas. sasgui.guiframe.dataFittingimport Data1D139 from sas.qtgui.Plotting.PlotterData import Data1D 140 140 if hasattr(sector, "dxl"): 141 141 dxl = sector.dxl -
src/sas/qtgui/Utilities/CategoryInstaller.py
rc889a3e r75906a1 26 26 def __init__(self): 27 27 """ initialization """ 28 29 @staticmethod30 def _get_installed_model_dir():31 """32 returns the dir where installed_models.txt should be33 """34 import sas.sascalc.dataloader.readers35 return sas.sascalc.dataloader.readers.get_data_path()36 37 @staticmethod38 def _get_models_py_dir():39 """40 returns the dir where models.py should be41 """42 import sas.sasgui.perspectives.fitting.models43 return sas.sasgui.perspectives.fitting.models.get_model_python_path()44 45 @staticmethod46 def _get_default_cat_file_dir():47 """48 returns the dir where default_cat.j should be49 """50 # The default categories file is usually found with the code, except51 # when deploying using py2app (it will be in Contents/Resources), or52 # py2exe (it will be in the exec dir).53 import sas.sasview54 cat_file = "default_categories.json"55 56 possible_cat_file_paths = [57 os.path.join(os.path.split(sas.sasview.__file__)[0], cat_file), # Source58 os.path.join(os.path.dirname(sys.executable), '..', 'Resources', cat_file), # Mac59 os.path.join(os.path.dirname(sys.executable), cat_file) # Windows60 ]61 62 for path in possible_cat_file_paths:63 if os.path.isfile(path):64 return os.path.dirname(path)65 66 raise RuntimeError('CategoryInstaller: Could not find folder containing default categories')67 28 68 29 @staticmethod -
src/sas/qtgui/Utilities/GridPanel.py
ra4b9b7a r75906a1 491 491 """ 492 492 location = GuiUtils.HELP_DIRECTORY_LOCATION 493 url = "/user/ sasgui/perspectives/pr/pr_help.html#batch-pr-mode"493 url = "/user/qtgui/Perspectives/Fitting/fitting_help.html#batch-fit-mode" 494 494 try: 495 495 webbrowser.open('file://' + os.path.realpath(location + url)) -
src/sas/qtgui/Utilities/GuiUtils.py
r2eeda93 rd00475d 106 106 except ImportError: 107 107 pass 108 #logging.error("Error loading %s/%s: %s" % (path, confg_file, sys.exc_value))109 108 except ValueError: 110 109 print("Value error") … … 113 112 if fObj is not None: 114 113 fObj.close() 115 #logging.info("GuiManager loaded %s/%s" % (path, confg_file))116 114 return config_module 117 115 … … 294 292 changeDataExplorerTabSignal = QtCore.pyqtSignal(int) 295 293 296 def updateModelItemWithPlot(item, update_data, name="", checkbox_state=None): 294 # Plot fitting results (FittingWidget->GuiManager) 295 resultPlotUpdateSignal = QtCore.pyqtSignal(list) 296 297 297 """ 298 298 Adds a checkboxed row named "name" to QStandardItem -
src/sas/sascalc/pr/fit/expression.py
r1431dab raed159f 209 209 """%("\n ".join(assignments),"\n ".join(code)) 210 210 211 #print("Function: "+functiondef) 212 exec(functiondef) in globals, locals 211 exec(functiondef, globals, locals) 213 212 retfn = locals['eval_expressions'] 214 213 -
src/sas/sascalc/pr/invertor.py
reeea6a3 raed159f 227 227 return None 228 228 229 def add_errors(self, yvalues): 230 """ 231 Adds errors to data set is they are not avaialble 232 :return: 233 """ 234 stats_errors = np.zeros(len(yvalues)) 235 for i in range(len(yvalues)): 236 # Scale the error so that we can fit over several decades of Q 237 scale = 0.05 * np.sqrt(yvalues[i]) 238 min_err = 0.01 * yvalues[i] 239 stats_errors[i] = scale * np.sqrt(np.fabs(yvalues[i])) + min_err 240 logger.warning("Simulated errors have been added to the data set\n") 241 return stats_errors 229 def add_errors(self, sigma=0.05): 230 """ 231 Adds errors to data set is they are not available. 232 Uses $\Delta y = \sigma | y |$. 233 """ 234 self.dy = sigma * np.fabs(self.y) 242 235 243 236 def clone(self): … … 514 507 # We were not able to estimate the errors 515 508 # Return an empty error matrix 516 logger.error(sys.exc_ value)509 logger.error(sys.exc_info()[1]) 517 510 518 511 # Keep a copy of the last output … … 559 552 # number of terms 560 553 best_alpha, _, _ = self.estimate_alpha(self.nfunc) 561 logger.warning("Invertor.estimate_numterms: %s" % sys.exc_ value)554 logger.warning("Invertor.estimate_numterms: %s" % sys.exc_info()[1]) 562 555 return self.nfunc, best_alpha, "Could not estimate number of terms" 563 556 … … 646 639 647 640 except: 648 message = "Invertor.estimate_alpha: %s" % sys.exc_ value641 message = "Invertor.estimate_alpha: %s" % sys.exc_info()[1] 649 642 return 0, message, elapsed 650 643 … … 763 756 764 757 except: 765 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_ value758 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_info()[1] 766 759 raise RuntimeError(msg) 767 760 else: -
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/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/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
rd2007a8 r2eeda93 175 175 category_index = self.widget.cbCategory.findText("Shape Independent") 176 176 self.widget.cbCategory.setCurrentIndex(category_index) 177 model_index = self.widget.cbModel.findText("be_polyelectrolyte") 178 self.widget.cbModel.setCurrentIndex(model_index) 177 179 178 180 # test the model combo content 179 self.assertEqual(self.widget.cbModel.count(), 29)181 self.assertEqual(self.widget.cbModel.count(), 30) 180 182 181 183 # Try to change back to default … … 201 203 category_index = self.widget.cbCategory.findText("Shape Independent") 202 204 self.widget.cbCategory.setCurrentIndex(category_index) 205 model_index = self.widget.cbModel.findText("be_polyelectrolyte") 206 self.widget.cbModel.setCurrentIndex(model_index) 203 207 204 208 # check the enablement of controls … … 215 219 # 216 220 # Now change the model 217 self.widget.cbModel.setCurrentIndex( 3)221 self.widget.cbModel.setCurrentIndex(4) 218 222 self.assertEqual(self.widget.cbModel.currentText(),'dab') 219 223 … … 226 230 self.widget.data_is_loaded = True 227 231 # Reset the sasmodel index 228 self.widget.cbModel.setCurrentIndex( 1)232 self.widget.cbModel.setCurrentIndex(2) 229 233 self.assertEqual(self.widget.cbModel.currentText(),'broad_peak') 230 234 … … 377 381 category_index = self.widget.cbCategory.findText("Shape Independent") 378 382 self.widget.cbCategory.setCurrentIndex(category_index) 383 model_index = self.widget.cbModel.findText("be_polyelectrolyte") 384 self.widget.cbModel.setCurrentIndex(model_index) 385 379 386 # Check the poly model 380 387 self.assertEqual(self.widget._poly_model.rowCount(), 0) … … 383 390 # Change the category index so we have a model available 384 391 self.widget.cbCategory.setCurrentIndex(2) 392 self.widget.cbModel.setCurrentIndex(1) 385 393 386 394 # Check the poly model … … 556 564 category_index = self.widget.cbCategory.findText("Sphere") 557 565 self.widget.cbCategory.setCurrentIndex(category_index) 566 model_index = self.widget.cbModel.findText("adsorbed_layer") 567 self.widget.cbModel.setCurrentIndex(model_index) 558 568 559 569 # Check the magnetic model … … 634 644 category_index = self.widget.cbCategory.findText("Sphere") 635 645 self.widget.cbCategory.setCurrentIndex(category_index) 646 model_index = self.widget.cbModel.findText("adsorbed_layer") 647 self.widget.cbModel.setCurrentIndex(model_index) 636 648 637 649 # Check the enablement/text … … 973 985 category_index = self.widget.cbCategory.findText("Sphere") 974 986 self.widget.cbCategory.setCurrentIndex(category_index) 987 model_index = self.widget.cbModel.findText("adsorbed_layer") 988 self.widget.cbModel.setCurrentIndex(model_index) 975 989 self.widget.main_params_to_fit = ['scale'] 976 990 … … 986 1000 self.assertListEqual(fp.main_params_to_fit, ['scale']) 987 1001 988 def testPushFitPage(self):1002 def notestPushFitPage(self): 989 1003 """ 990 1004 Push current state of fitpage onto stack … … 997 1011 self.widget.data = item 998 1012 category_index = self.widget.cbCategory.findText("Sphere") 1013 model_index = self.widget.cbModel.findText("adsorbed_layer") 1014 self.widget.cbModel.setCurrentIndex(model_index) 999 1015 1000 1016 # Asses the initial state of stack
Note: See TracChangeset
for help on using the changeset viewer.