Skip to content

Commit

Permalink
verify of qmin values added and warning added
Browse files Browse the repository at this point in the history
  • Loading branch information
smalex-z committed Jun 29, 2023
1 parent c326cc8 commit 8668cbe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
26 changes: 23 additions & 3 deletions src/sas/qtgui/Calculators/GenericScatteringCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self, parent=None):
# code to highlight incompleted values in the GUI and prevent calculation
# list of lineEdits to be checked
self.lineEdits = [self.txtUpFracIn, self.txtUpFracOut, self.txtUpTheta, self.txtUpPhi, self.txtBackground,
self.txtScale, self.txtSolventSLD, self.txtTotalVolume, self.txtNoQBins, self.txtQxMax,
self.txtScale, self.txtSolventSLD, self.txtTotalVolume, self.txtNoQBins, self.txtQxMax, self.txtQxMin,
self.txtMx, self.txtMy, self.txtMz, self.txtNucl, self.txtXnodes, self.txtYnodes,
self.txtZnodes, self.txtXstepsize, self.txtYstepsize, self.txtZstepsize, self.txtEnvYaw,
self.txtEnvPitch, self.txtEnvRoll, self.txtSampleYaw, self.txtSamplePitch, self.txtSampleRoll]
Expand Down Expand Up @@ -216,6 +216,11 @@ def __init__(self, parent=None):
validat_regex_q = QtCore.QRegularExpression(r'^1000$|^[+]?(\d{1,3}([.]\d+)?)$')
self.txtQxMax.setValidator(QtGui.QRegularExpressionValidator(validat_regex_q,
self.txtQxMax))

# 0 < Qmin <= 1000
validat_regex_q = QtCore.QRegularExpression(r'^1000$|^[+]?(\d{1,3}([.]\d+)?)$')
self.txtQxMin.setValidator(QtGui.QRegularExpressionValidator(validat_regex_q,
self.txtQxMin))

# 2 <= Qbin and nodes integers < 1000
validat_regex_int = QtCore.QRegularExpression(r'^[2-9]|[1-9]\d{1,2}$')
Expand Down Expand Up @@ -444,10 +449,21 @@ def gui_text_changed(self, sender):
zstepsize = float(self.txtZstepsize.text())
value = float(str(self.txtQxMax.text()))
max_q = numpy.pi / (max(xstepsize, ystepsize, zstepsize))
if value <= 0 or value > max_q:
if value <= 0 or value > max_q or value < float(self.txtQxMin.text()):
self.txtQxMax.setStyleSheet(self.TEXTBOX_WARNING_STYLESTRING)
else:
self.txtQxMax.setStyleSheet(self.TEXTBOX_DEFAULT_STYLESTRING)
elif sender == self.txtQxMin:
xstepsize = float(self.txtXstepsize.text())
ystepsize = float(self.txtYstepsize.text())
zstepsize = float(self.txtZstepsize.text())
value = float(str(self.txtQxMin.text()))
min_q = numpy.pi / (min(xstepsize, ystepsize, zstepsize))
if value <= 0 or value > min_q or value > float(self.txtQxMax.text()):
self.txtQxMin.setStyleSheet(self.TEXTBOX_WARNING_STYLESTRING)
else:
self.txtQxMin.setStyleSheet(self.TEXTBOX_DEFAULT_STYLESTRING)




Expand Down Expand Up @@ -860,6 +876,7 @@ def update_gui(self):
# If nodes or stepsize changed then this may effect what values are allowed
self.gui_text_changed(sender=self.txtNoQBins)
self.gui_text_changed(sender=self.txtQxMax)
self.gui_text_changed(sender=self.txtQxMin)

def update_geometry_effects(self):
"""This function updates the number of pixels and total volume when the number of nodes/stepsize is changed
Expand Down Expand Up @@ -888,6 +905,7 @@ def update_geometry_effects(self):
# If nodes or stepsize changed then this may effect what values are allowed
self.gui_text_changed(sender=self.txtNoQBins)
self.gui_text_changed(sender=self.txtQxMax)
self.gui_text_changed(sender=self.txtQxMin)

def write_new_values_from_gui(self):
"""Update parameters in model using modified inputs from GUI
Expand Down Expand Up @@ -953,6 +971,7 @@ def onReset(self):
self.txtTotalVolume.setText("216000.0")
self.txtNoQBins.setText("30")
self.txtQxMax.setText("0.3")
self.txtQxMin.setText("0.0003")
self.txtNoPixels.setText("1000")
self.txtMx.setText("0.0")
self.txtMy.setText("0.0")
Expand Down Expand Up @@ -1097,10 +1116,11 @@ def _create_default_1d_data(self):
residuals.dxw = None
"""
self.qmax_x = float(self.txtQxMax.text())
self.qmin_x = float(self.txtQxMin.text())
self.npts_x = int(self.txtNoQBins.text())
# Default values
xmax = self.qmax_x
xmin = self.qmax_x * _Q1D_MIN
xmin = self.qmin_x
qstep = self.npts_x
x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)
# store x and y bin centers in q space
Expand Down
5 changes: 4 additions & 1 deletion src/sas/qtgui/Calculators/UI/GenericScatteringCalculator.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1093,13 +1093,16 @@ Number of Qbins &amp;isin; [2, 1000].</string>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit">
<widget class="QLineEdit" name="txtQxMin">
<property name="minimumSize">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
<property name="text">
<string>0.0003</string>
</property>
</widget>
</item>
<item row="2" column="2">
Expand Down

0 comments on commit 8668cbe

Please sign in to comment.