Skip to content

Commit

Permalink
allow user to skip pixelcal after pixelcal (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
rboston628 authored Dec 12, 2024
1 parent 998393d commit 0ad840a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/snapred/ui/view/DiffCalTweakPeakView.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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 @@ -100,7 +103,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 @@ -325,3 +329,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

0 comments on commit 0ad840a

Please sign in to comment.