Commit 69015137 authored by Thomas Vincent's avatar Thomas Vincent

Fix computation of Intensity preview in ShiftWidget

parent f49d3238
......@@ -329,6 +329,13 @@ class ShiftSubject(Qt.QObject):
"""Return all shifts as a list."""
return list(self.__shiftValues.values())
def getShiftEntries(self):
"""Returns the names of all entries.
:rtype: List[str]
"""
return tuple(self.__shiftValues.keys())
def getIntersectionIndices(self, grid=True, progressCb=None):
"""Returns the intersection of all entries.
......
......@@ -610,6 +610,8 @@ class ShiftPreviewPanel(Qt.QWidget):
Notifies the user that a refresh is needed.
"""
self.__plot.clear()
self.__plot.setGraphTitle('')
self.__progBar.setValue(0)
self.__refreshBn.setEnabled(True)
def __slotRefreshClicked(self):
......@@ -620,24 +622,31 @@ class ShiftPreviewPanel(Qt.QWidget):
self.__refreshBn.setEnabled(False)
self.__plot.clear()
self.__plot.setGraphTitle('')
if intersectionPoints is None or intersectionPoints.size == 0:
return
iGroup = self.__subject.getIntensityGroup()
total = iGroup.getIntensityItem('Total')
intensity, scan_positions = total.getScatterData()
# data = np.zeros(scan_positions.pos_0.size)
data = np.full(scan_positions.pos_0.size, np.nan)
data[intersectionPoints] = intensity[intersectionPoints]
# Get positions
scanPositions = iGroup.getIntensityItem('Total').getScatterData()[1]
self.__plot.setPlotData(scan_positions.pos_0,
scan_positions.pos_1,
values=data)
# Compute intensity with current shift
scanShift = self.__subject.scanShift()
intensity = np.zeros(intersectionPoints.shape, dtype=np.float64)
for entry in self.__subject.getShiftEntries():
item = iGroup.getIntensityItem(entry)
entryIntensity = item.getScatterData()[0]
indices = scanShift.get_entry_intersection_indices(entry)
intensity += entryIntensity[indices]
self.__plot.setPlotData(scanPositions.pos_0[intersectionPoints],
scanPositions.pos_1[intersectionPoints],
values=intensity)
title = 'Intensity (Points: {0}/{1})'.format(
intersectionPoints.size, scan_positions.pos_0.size)
intersectionPoints.size, scanPositions.pos_0.size)
self.__plot.setGraphTitle(title)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment