Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to skip pixelcal after pixelcal #517

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/snapred/ui/view/DiffCalTweakPeakView.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def __init__(self, samples=[], groups=[], parent=None):
self.signalRunNumberUpdate.connect(self._updateRunNumber)
self.signalMaxChiSqUpdate.connect(self._updateMaxChiSq)

# skip pixel calibration toggle
self.skipPixelCalToggle = self._labeledToggle("Skip Pixel Calibration", False)

self.continueAnyway = False
self.signalContinueAnyway.connect(self._updateContinueAnyway)

Expand Down Expand Up @@ -99,7 +102,8 @@ def __init__(self, samples=[], groups=[], parent=None):

# add all elements to the grid layout
self.layout.addWidget(self.runNumberField, 0, 0)
self.layout.addWidget(self.litemodeToggle, 0, 1)
self.layout.addWidget(self.litemodeToggle, 0, 1, 1, 2)
self.layout.addWidget(self.skipPixelCalToggle, 0, 2)
self.layout.addWidget(self.navigationBar, 1, 0)
self.layout.addWidget(self.canvas, 2, 0, 1, -1)
self.layout.addLayout(peakControlLayout, 3, 0, 1, 2)
Expand Down Expand Up @@ -318,3 +322,6 @@ def verify(self):
self._testContinueAnywayStates()

return True

def getSkipPixelCalibration(self):
return self.skipPixelCalToggle.field.getState()
35 changes: 27 additions & 8 deletions src/snapred/ui/workflow/DiffCalWorkflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def __init__(self, parent=None):
self._requestView.litemodeToggle.stateChanged.connect(self._tweakPeakView.litemodeToggle.setState)
self._tweakPeakView.litemodeToggle.stateChanged.connect(self._requestView.litemodeToggle.setState)

# connect the skip pixelcal toggles across the views
self._requestView.skipPixelCalToggle.stateChanged.connect(self._tweakPeakView.skipPixelCalToggle.setState)
self._tweakPeakView.skipPixelCalToggle.stateChanged.connect(self._requestView.skipPixelCalToggle.setState)

self.prevFWHM = DiffCalTweakPeakView.FWHM
self.prevXtalDMin = DiffCalTweakPeakView.XTAL_DMIN
self.prevXtalDMax = DiffCalTweakPeakView.XTAL_DMAX
Expand Down Expand Up @@ -257,6 +261,10 @@ def _specifyRun(self, workflowPresenter):
self._renewFitPeaks(self.peakFunction)
response = self._calculateResidual()

# freeze these toggles, as they can no longer function
self._requestView.litemodeToggle.setEnabled(False)
self._requestView.skipPixelCalToggle.setEnabled(False)

self._tweakPeakView.updateGraphs(
self.focusedWorkspace,
self.ingredients.groupedPeakLists,
Expand All @@ -280,8 +288,26 @@ def renewWhenRecalculate(self, groupingIndex, xtalDMin, xtalDMax, peakFunction,

self.focusGroupPath = list(self.focusGroups.items())[groupingIndex][0]

newSkipPixelSelection = self._tweakPeakView.skipPixelCalToggle.getState()

# if the user made a change in skip pixelcal election, redo everything
if self.skipPixelCal != newSkipPixelSelection:
self.skipPixelCal = newSkipPixelSelection
self._renewIngredients(xtalDMin, xtalDMax, peakFunction, fwhm, maxChiSq)
self._renewPixelCal()
self._renewFocus(groupingIndex)
self._renewFitPeaks(peakFunction)
self._calculateResidual()

# if the grouping file changes, load new grouping and refocus
elif groupingIndex != self.prevGroupingIndex:
self._renewIngredients(xtalDMin, xtalDMax, peakFunction, fwhm, maxChiSq)
self._renewFocus(groupingIndex)
self._renewFitPeaks(peakFunction)
self._calculateResidual()

# if peaks will change, redo only the smoothing
if (
elif (
xtalDMin != self.prevXtalDMin
or xtalDMax != self.prevXtalDMax
or peakFunction != self.peakFunction
Expand All @@ -293,13 +319,6 @@ def renewWhenRecalculate(self, groupingIndex, xtalDMin, xtalDMax, peakFunction,
self._renewFitPeaks(peakFunction)
self._calculateResidual()

# if the grouping file changes, load new grouping and refocus
if groupingIndex != self.prevGroupingIndex:
self._renewIngredients(xtalDMin, xtalDMax, peakFunction, fwhm, maxChiSq)
self._renewFocus(groupingIndex)
self._renewFitPeaks(peakFunction)
self._calculateResidual()

self.peaksWerePurged = False

# NOTE it was determined pixel calibration NOT need to be re-calculated when peak params change.
Expand Down
Loading