Commit 0d0cee58 authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

Merge branch 'add_point_rocking' into 'master'

Add frame number at rocking curves plot

See merge request julia.garriga/darfix!119
parents b9b5b8d5 b5495414
Pipeline #46655 passed with stage
in 4 minutes and 39 seconds
......@@ -26,7 +26,7 @@
__authors__ = ["J. Garriga"]
__license__ = "MIT"
__date__ = "23/12/2020"
__date__ = "11/05/2021"
import numpy
import logging
......@@ -124,6 +124,7 @@ class RockingCurvesWidget(qt.QMainWindow):
self._thread = OperationThread(self, self.dataset.apply_fit)
self.setStack()
self._sv.getPlotWidget().sigPlotSignal.connect(self._mouseSignal)
self._sv.sigFrameChanged.connect(self._addPoint)
if len(self.dataset.data.shape) > 3:
self._chooseDimensionDock.show()
self._chooseDimensionDock.widget.setDimensions(self.dataset.dims)
......@@ -177,6 +178,19 @@ class RockingCurvesWidget(qt.QMainWindow):
self._sv.getPlotWidget().addCurve((0, data.shape[2]), (py, py), legend='y', color='r')
self.plotRockingCurves(data, px, py)
def _addPoint(self, i):
"""
Slot to add curve for frame number in rocking curves plot.
:param int i: frame number
"""
try:
self._plot.addCurve([self.x[i]], [self.y[i]], symbol='o', legend='dot_o', color='b')
i_gauss = i * int((len(self.y_gauss) - 1) / (len(self.x) - 1))
self._plot.addCurve([self.x_gauss[i_gauss]], [self.y_gauss[i_gauss]], symbol='o', legend='dot_fit', color='r')
except ValueError:
pass
def plotRockingCurves(self, data, px, py):
"""
Plot rocking curves of data and fitted data at pixel (px, py).
......@@ -209,12 +223,20 @@ class RockingCurvesWidget(qt.QMainWindow):
# Show rocking curves and fitted curve into plot
self._plot.clear()
self._plot.addCurve(x, y, legend="data", color='b')
i = self._sv.getFrameNumber()
try:
y_gauss = fit_rocking_curve(item, values=x, num_points=1000)
except TypeError:
y_gauss = y
_logger.warning("Cannot fit")
self._plot.addCurve(numpy.linspace(x[0], x[-1], len(y_gauss)), y_gauss, legend="fit", color='r')
# Add curves (points) for stackview frame number
self.x_gauss = numpy.linspace(x[0], x[-1], len(y_gauss))
self._plot.addCurve(self.x_gauss, y_gauss, legend="fit", color='r')
self._plot.addCurve([x[i]], [y[i]], symbol='o', legend='dot_o', color='b')
i_gauss = i * int((len(y_gauss) - 1) / (len(x) - 1))
self._plot.addCurve([self.x_gauss[i_gauss]], [y_gauss[i_gauss]], symbol='o', legend='dot_fit', color='r')
self.x, self.y, self.y_gauss = x, y, y_gauss
def _grainPlot(self):
"""
......
Supports Markdown
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