Index: src/sas/qtgui/MainWindow/DataExplorer.py
===================================================================
--- src/sas/qtgui/MainWindow/DataExplorer.py (revision d4881f6af1db66e68fbbc5d7b5c67fc1f7bc1ea7)
+++ src/sas/qtgui/MainWindow/DataExplorer.py (revision 6a3e1fed96400e06c3fff6a0cf0316fe8169b0d5)
@@ -1034,5 +1034,5 @@
# Top-level item: checkbox with label
- checkbox_item = QtGui.QStandardItem(True)
+ checkbox_item = GuiUtils.HashableStandardItem()
checkbox_item.setCheckable(True)
checkbox_item.setCheckState(QtCore.Qt.Checked)
@@ -1040,5 +1040,5 @@
# Add the actual Data1D/Data2D object
- object_item = QtGui.QStandardItem()
+ object_item = GuiUtils.HashableStandardItem()
object_item.setData(data)
Index: src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py
===================================================================
--- src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py (revision d4881f6af1db66e68fbbc5d7b5c67fc1f7bc1ea7)
+++ src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py (revision 6a3e1fed96400e06c3fff6a0cf0316fe8169b0d5)
@@ -24,7 +24,5 @@
# local
-from .UI.dmax import Ui_DmaxExplorer
-# from InvariantDetails import DetailsDialog
-# from InvariantUtils import WIDGETS
+from .UI.DMaxExplorer import Ui_DmaxExplorer
logger = logging.getLogger(__name__)
@@ -78,12 +76,7 @@
def setupModel(self):
self.model.setItem(W.NPTS, QtGui.QStandardItem(str(self.nfunc)))
- self.model.setItem(W.DMIN,
- QtGui.QStandardItem(
- str(0.9*self.pr_state.d_max)))
- self.model.setItem(W.DMAX,
- QtGui.QStandardItem(
- str(1.1*self.pr_state.d_max)))
- self.model.setItem(W.VARIABLE,
- QtGui.QStandardItem( "ϲ/dof"))
+ self.model.setItem(W.DMIN, QtGui.QStandardItem(str(0.9*self.pr_state.d_max)))
+ self.model.setItem(W.DMAX, QtGui.QStandardItem(str(1.1*self.pr_state.d_max)))
+ self.model.setItem(W.VARIABLE, QtGui.QStandardItem( "ϲ/dof"))
def setupMapper(self):
@@ -133,9 +126,15 @@
msg += "for D_max=%s\n%s" % (str(x), sys.exc_info()[1])
print(msg)
- # logger.error(msg)
+ logger.error(msg)
#Return the invertor to its original state
self.pr_state.d_max = original
- self.pr_state.invert(self.nfunc)
+ try:
+ self.pr_state.invert(self.nfunc)
+ except RuntimeError as ex:
+ msg = "ExploreDialog: inversion failed "
+ msg += "for D_max=%s\n%s" % (str(x), sys.exc_info()[1])
+ print(msg)
+ logger.error(msg)
plotter = str(self.model.item(W.VARIABLE).text())
Index: src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py
===================================================================
--- src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py (revision d4881f6af1db66e68fbbc5d7b5c67fc1f7bc1ea7)
+++ src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py (revision 6a3e1fed96400e06c3fff6a0cf0316fe8169b0d5)
@@ -132,6 +132,6 @@
"""Connect the use controls to their appropriate methods"""
self.dataList.currentIndexChanged.connect(self.displayChange)
- self.calculateAllButton.clicked.connect(self.startThreadAll)
- self.calculateThisButton.clicked.connect(self.startThread)
+ #self.calculateAllButton.clicked.connect(self.startThreadAll)
+ #self.calculateThisButton.clicked.connect(self.startThread)
self.removeButton.clicked.connect(self.removeData)
self.helpButton.clicked.connect(self.help)
@@ -208,7 +208,7 @@
# Main Buttons
self.mapper.addMapping(self.removeButton, WIDGETS.W_REMOVE)
- self.mapper.addMapping(self.calculateAllButton, WIDGETS.W_CALCULATE_ALL)
- self.mapper.addMapping(self.calculateThisButton,
- WIDGETS.W_CALCULATE_VISIBLE)
+ #self.mapper.addMapping(self.calculateAllButton, WIDGETS.W_CALCULATE_ALL)
+ #self.mapper.addMapping(self.calculateThisButton,
+ # WIDGETS.W_CALCULATE_VISIBLE)
self.mapper.addMapping(self.helpButton, WIDGETS.W_HELP)
@@ -269,6 +269,6 @@
self.removeButton.setEnabled(self.logic.data_is_loaded)
self.explorerButton.setEnabled(self.logic.data_is_loaded)
- self.calculateAllButton.setEnabled(self.logic.data_is_loaded)
- self.calculateThisButton.setEnabled(self.logic.data_is_loaded)
+ #self.calculateAllButton.setEnabled(self.logic.data_is_loaded)
+ #self.calculateThisButton.setEnabled(self.logic.data_is_loaded)
def populateDataComboBox(self, filename, data_ref):
@@ -278,7 +278,5 @@
:param data_ref: QStandardItem reference for data set to be added
"""
- qt_item = QtCore.QString.fromUtf8(filename)
- ref = QtCore.QVariant(data_ref)
- self.dataList.addItem(qt_item, ref)
+ self.dataList.addItem(filename, data_ref)
def acceptNoTerms(self):
@@ -294,5 +292,5 @@
def displayChange(self):
variant_ref = self.dataList.itemData(self.dataList.currentIndex())
- self.setCurrentData(variant_ref.toPyObject())
+ self.setCurrentData(variant_ref)
def removeData(self):
@@ -326,10 +324,8 @@
if self.pr_plot is not None:
title = self.pr_plot.name
- GuiUtils.updateModelItemWithPlot(
- self._data, QtCore.QVariant(self.pr_plot), title)
+ GuiUtils.updateModelItemWithPlot(self._data, self.pr_plot, title)
if self.data_plot is not None:
title = self.data_plot.name
- GuiUtils.updateModelItemWithPlot(
- self._data, QtCore.QVariant(self.data_plot), title)
+ GuiUtils.updateModelItemWithPlot(self._data, self.data_plot, title)
self.mapper.toFirst()
@@ -383,13 +379,9 @@
for data in data_item:
# Create initial internal mappings
- # TODO: in PyQt5 QStandardItem no longer can be used as dict key
- # Possibly the easiest solution is to subclass QStandardItem
- # and reimplement __hash__() method so it can be hashed.
- self._data_list[data] = self._calculator.clone() #<- this crashes
+ self._data_list[data] = self._calculator.clone()
self._data_set = GuiUtils.dataFromItem(data)
self.data_plot_list[data] = self.data_plot
self.pr_plot_list[data] = self.pr_plot
- ref_var = QtCore.QVariant(data)
- self.populateDataComboBox(self._data_set.filename, ref_var)
+ self.populateDataComboBox(self._data_set.filename, data)
self.setCurrentData(data)
@@ -400,8 +392,6 @@
# Estimate q range
qmin, qmax = self.logic.computeDataRange()
- self.model.setItem(WIDGETS.W_QMIN, QtGui.QStandardItem(
- "{:.4g}".format(qmin)))
- self.model.setItem(WIDGETS.W_QMAX, QtGui.QStandardItem(
- "{:.4g}".format(qmax)))
+ self.model.setItem(WIDGETS.W_QMIN, QtGui.QStandardItem("{:.4g}".format(qmin)))
+ self.model.setItem(WIDGETS.W_QMAX, QtGui.QStandardItem("{:.4g}".format(qmax)))
self.enableButtons()
@@ -409,8 +399,11 @@
def getNFunc(self):
"""Get the n_func value from the GUI object"""
- return int(UI.TabbedInversionUI._fromUtf8(self.noOfTermsInput.text()))
+ return int(self.noOfTermsInput.text())
def setCurrentData(self, data_ref):
"""Get the current data and display as necessary"""
+
+ if data_ref is None:
+ return
if not isinstance(data_ref, QtGui.QStandardItem):
@@ -424,4 +417,7 @@
self.pr_plot = self.pr_plot_list[data_ref]
self.data_plot = self.data_plot_list[data_ref]
+ # Rerun the calculations for the current set
+ self.startThread()
+ self.model_changed()
######################################################################
@@ -512,7 +508,6 @@
"""
# Save useful info
- self.model.setItem(WIDGETS.W_COMP_TIME,
- QtGui.QStandardItem(str(elapsed)))
- self.regConstantSuggestionButton.setText(QtCore.QString(str(alpha)))
+ self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem(str(elapsed)))
+ self.regConstantSuggestionButton.setText("{:-3.2g}".format(alpha))
self.regConstantSuggestionButton.setEnabled(True)
if message:
@@ -531,13 +526,10 @@
"""
# Save useful info
- self.noOfTermsSuggestionButton.setText(QtCore.QString(
- "{:n}".format(nterms)))
+ self.noOfTermsSuggestionButton.setText("{:n}".format(nterms))
self.noOfTermsSuggestionButton.setEnabled(True)
- self.regConstantSuggestionButton.setText(QtCore.QString(
- "{:.3g}".format(alpha)))
+ self.regConstantSuggestionButton.setText("{:.3g}".format(alpha))
self.regConstantSuggestionButton.setEnabled(True)
- self.model.setItem(WIDGETS.W_COMP_TIME,
- QtGui.QStandardItem(str(elapsed)))
- self.PrTabWidget.setCurrentIndex(0)
+ self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem(str(elapsed)))
+ #self.PrTabWidget.setCurrentIndex(0)
if message:
logging.info(message)
@@ -563,23 +555,17 @@
# TODO: Connect self._calculator to GUI - two-to-one connection possible?
self.model.setItem(WIDGETS.W_RG, QtGui.QStandardItem(str(pr.rg(out))))
- self.model.setItem(WIDGETS.W_I_ZERO,
- QtGui.QStandardItem(str(pr.iq0(out))))
+ self.model.setItem(WIDGETS.W_I_ZERO, QtGui.QStandardItem(str(pr.iq0(out))))
self.model.setItem(WIDGETS.W_BACKGROUND_INPUT,
QtGui.QStandardItem("{:.3f}".format(pr.est_bck)))
- self.model.setItem(WIDGETS.W_BACKGROUND_OUTPUT,
- QtGui.QStandardItem(str(pr.background)))
- self.model.setItem(WIDGETS.W_CHI_SQUARED,
- QtGui.QStandardItem(str(pr.chi2[0])))
- self.model.setItem(WIDGETS.W_COMP_TIME,
- QtGui.QStandardItem(str(elapsed)))
- self.model.setItem(WIDGETS.W_OSCILLATION,
- QtGui.QStandardItem(str(pr.oscillations(out))))
- self.model.setItem(WIDGETS.W_POS_FRACTION,
- QtGui.QStandardItem(str(pr.get_positive(out))))
+ self.model.setItem(WIDGETS.W_BACKGROUND_OUTPUT, QtGui.QStandardItem(str(pr.background)))
+ self.model.setItem(WIDGETS.W_CHI_SQUARED, QtGui.QStandardItem(str(pr.chi2[0])))
+ self.model.setItem(WIDGETS.W_COMP_TIME, QtGui.QStandardItem(str(elapsed)))
+ self.model.setItem(WIDGETS.W_OSCILLATION, QtGui.QStandardItem(str(pr.oscillations(out))))
+ self.model.setItem(WIDGETS.W_POS_FRACTION, QtGui.QStandardItem(str(pr.get_positive(out))))
self.model.setItem(WIDGETS.W_SIGMA_POS_FRACTION,
QtGui.QStandardItem(str(pr.get_pos_err(out, cov))))
# Display results tab
- self.PrTabWidget.setCurrentIndex(1)
+ #self.PrTabWidget.setCurrentIndex(1)
# Save Pr invertor
self._calculator = pr
Index: src/sas/qtgui/Perspectives/Inversion/UI/TabbedInversionUI.ui
===================================================================
--- src/sas/qtgui/Perspectives/Inversion/UI/TabbedInversionUI.ui (revision fa81e94af983227efded2314c2c544f98e2c56ba)
+++ src/sas/qtgui/Perspectives/Inversion/UI/TabbedInversionUI.ui (revision 6a3e1fed96400e06c3fff6a0cf0316fe8169b0d5)
@@ -32,37 +32,541 @@
P(r) Inversion
-
- -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ 0
+
+
+
+ P(r) Parameters
+
+
+
-
+
+
+ I(q) data source
+
+
+
-
+
+
-
+
+
+ Data File Name:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Remove
+
+
+
+
+
+ -
+
+
-
+
+
+ Background Level:
+
+
+
+ -
+
+
+ false
+
+
+ 0.0
+
+
+
+ -
+
+
+ <html><head/><body><p>Ã
+<span style=" vertical-align:super;">-1</span></p></body></html>
+
+
+
+ -
+
+
+ Estimate
+
+
+
+ -
+
+
+ Manual Input
+
+
+
+
+
+
+
+
+ -
+
+
+ Total Q range
+
+
+
-
+
+
-
+
+
+ Min:
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p>Ã
+<span style=" vertical-align:super;">-1</span></p></body></html>
+
+
+
+ -
+
+
+ Max:
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p>Ã
+<span style=" vertical-align:super;">-1</span></p></body></html>
+
+
+
+
+
+
+
+
+ -
+
+
+ Slit Parameters
+
+
+
-
+
+
-
+
+
+ Height
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p>Ã
+<span style=" vertical-align:super;">-1</span></p></body></html>
+
+
+
+ -
+
+
+ Width
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p>Ã
+<span style=" vertical-align:super;">-1</span></p></body></html>
+
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;">
+<pre style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;><span style=" font-family:'Courier New'; font-size:9pt; color:#000000;">P(r) is found by fitting a set of base functions to I(Q). The minimization involves a regularization term to ensure a smooth P(r). The regularization constant gives the size of that term. The suggested value is the value above which the output P(r) will have only one peak.</span></pre></body></html>
+
+
+ Parameters
+
+
+
-
+
+
+ Regularization constant
+
+
+
+ -
+
+
+ false
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ <html><head/><body><p>Open the D<span style=" vertical-align:sub;">max</span> explorer window.</p></body></html>
+
+
+ Qt::LeftToRight
+
+
+ Explore
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ Number of Terms
+
+
+
+ -
+
+
+ false
+
+
+
+
+
+
+ -
+
+
+ Max distance [Ã
+]
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+ Outputs
+
+
+
-
+
+
+ Calculated Value
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Units
+
+
+
+ -
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ Background
+
+
+
+ -
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ Ã
+-1
+
+
+
+ -
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ Rg
+
+
+
+ -
+
+
+ Ã
+
+
+
+
+ -
+
+
+ Oscillations
+
+
+
+ -
+
+
+ Computation Time
+
+
+
+ -
+
+
+ secs
+
+
+
+ -
+
+
+ I(Q=0)
+
+
+
+ -
+
+
+ Ã
+-1
+
+
+
+ -
+
+
+ Parameter
+
+
+
+ -
+
+
+ 1-sigma positive fraction
+
+
+
+ -
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ Chi^2/dof
+
+
+
+ -
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ Positive Fraction
+
+
+
+ -
+
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 2
+
+
+
+
+ -
QLayout::SetDefaultConstraint
-
-
-
-
- Remove
-
-
-
- -
-
-
- Calculate
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Calculate All
-
-
-
-
@@ -96,491 +600,4 @@
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 2
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
- 0
-
-
-
- P(r) Parameters
-
-
-
-
-
-
- I(q) data source
-
-
-
-
-
-
-
-
-
- Background Level:
-
-
-
- -
-
-
- false
-
-
- 0.0
-
-
-
- -
-
-
- <html><head/><body><p>Ã
-<span style=" vertical-align:super;">-1</span></p></body></html>
-
-
-
- -
-
-
- Estimate
-
-
-
- -
-
-
- Manual Input
-
-
-
-
-
- -
-
-
-
-
-
- Data File Name:
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
- Total Q range
-
-
-
-
-
-
-
-
-
- Min:
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- <html><head/><body><p>Ã
-<span style=" vertical-align:super;">-1</span></p></body></html>
-
-
-
- -
-
-
- Max:
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- <html><head/><body><p>Ã
-<span style=" vertical-align:super;">-1</span></p></body></html>
-
-
-
-
-
-
-
-
- -
-
-
- Slit Parameters
-
-
-
-
-
-
-
-
-
- Height
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- <html><head/><body><p>Ã
-<span style=" vertical-align:super;">-1</span></p></body></html>
-
-
-
- -
-
-
- Width
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- <html><head/><body><p>Ã
-<span style=" vertical-align:super;">-1</span></p></body></html>
-
-
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" /><style type="text/css">
-p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;">
-<pre style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;><span style=" font-family:'Courier New'; font-size:9pt; color:#000000;">P(r) is found by fitting a set of base functions to I(Q). The minimization involves a regularization term to ensure a smooth P(r). The regularization constant gives the size of that term. The suggested value is the value above which the output P(r) will have only one peak.</span></pre></body></html>
-
-
- Parameters
-
-
-
-
-
-
- Regularization constant
-
-
-
- -
-
-
- false
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- <html><head/><body><p>Open the D<span style=" vertical-align:sub;">max</span> explorer window.</p></body></html>
-
-
- Qt::LeftToRight
-
-
- Explore
-
-
-
- -
-
-
- -
-
-
- -
-
-
- Number of Terms
-
-
-
- -
-
-
- false
-
-
-
-
-
-
- -
-
-
- Max distance [Ã
-]
-
-
-
- -
-
-
-
-
-
- -
-
-
- Outputs
-
-
-
-
-
-
- Calculated Value
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- Units
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- Background
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- Ã
--1
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- Rg
-
-
-
- -
-
-
- Ã
-
-
-
-
- -
-
-
- Oscillations
-
-
-
- -
-
-
- Computation Time
-
-
-
- -
-
-
- secs
-
-
-
- -
-
-
- I(Q=0)
-
-
-
- -
-
-
- Ã
--1
-
-
-
- -
-
-
- Parameter
-
-
-
- -
-
-
- 1-sigma positive fraction
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- Chi^2/dof
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- Positive Fraction
-
-
-
- -
-
-
- false
-
-
-
-
-
-
-
-
-
-
Index: src/sas/qtgui/Utilities/GuiUtils.py
===================================================================
--- src/sas/qtgui/Utilities/GuiUtils.py (revision d4881f6af1db66e68fbbc5d7b5c67fc1f7bc1ea7)
+++ src/sas/qtgui/Utilities/GuiUtils.py (revision 6a3e1fed96400e06c3fff6a0cf0316fe8169b0d5)
@@ -265,4 +265,18 @@
item.appendRow(checkbox_item)
+class HashableStandardItem(QtGui.QStandardItem):
+ """
+ Subclassed standard item with reimplemented __hash__
+ to allow for use as an index.
+ """
+ def __init__(self, parent=None):
+ super(QtGui.QStandardItem, self).__init__()
+
+ def __hash__(self):
+ ''' just a random hash value '''
+ #return hash(self.__init__)
+ return 0
+
+
def createModelItemWithPlot(update_data, name=""):
"""
@@ -272,5 +286,5 @@
py_update_data = update_data
- checkbox_item = QtGui.QStandardItem()
+ checkbox_item = HashableStandardItem()
checkbox_item.setCheckable(True)
checkbox_item.setCheckState(QtCore.Qt.Checked)
Index: src/sas/sascalc/pr/invertor.py
===================================================================
--- src/sas/sascalc/pr/invertor.py (revision d04ac056c476a91de374975fdb618e1cf1d27ca1)
+++ src/sas/sascalc/pr/invertor.py (revision 6a3e1fed96400e06c3fff6a0cf0316fe8169b0d5)
@@ -540,5 +540,5 @@
"""
- from num_term import NTermEstimator
+ from sas.sascalc.pr.num_term import NTermEstimator
estimator = NTermEstimator(self.clone())
try: