mirror of
https://github.com/nqrduck/nqrduck-measurement.git
synced 2024-12-22 07:40:29 +00:00
Added fitting of frequency domain data.
This commit is contained in:
parent
df9461019c
commit
dca1c6816f
3 changed files with 10 additions and 19 deletions
|
@ -45,7 +45,7 @@ class MeasurementModel(ModuleModel):
|
||||||
|
|
||||||
FILE_EXTENSION = "meas"
|
FILE_EXTENSION = "meas"
|
||||||
# This constants are used to determine which view is currently displayed.
|
# This constants are used to determine which view is currently displayed.
|
||||||
FFT_VIEW = "fft"
|
FFT_VIEW = "frequency"
|
||||||
TIME_VIEW = "time"
|
TIME_VIEW = "time"
|
||||||
|
|
||||||
displayed_measurement_changed = pyqtSignal(Measurement)
|
displayed_measurement_changed = pyqtSignal(Measurement)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import sympy
|
import sympy
|
||||||
from nqrduck_spectrometer.measurement import Measurement, Fit, T2StarFit
|
from nqrduck_spectrometer.measurement import Measurement, Fit, T2StarFit, LorentzianFit
|
||||||
from nqrduck.helpers.functions import Function, GaussianFunction, CustomFunction
|
from nqrduck.helpers.functions import Function, GaussianFunction, CustomFunction
|
||||||
from nqrduck.helpers.formbuilder import (
|
from nqrduck.helpers.formbuilder import (
|
||||||
DuckFormBuilder,
|
DuckFormBuilder,
|
||||||
|
@ -27,22 +27,6 @@ class FIDFunction(Function):
|
||||||
|
|
||||||
self.add_parameter(Function.Parameter("T2star (microseconds)", "T2star", 10))
|
self.add_parameter(Function.Parameter("T2star (microseconds)", "T2star", 10))
|
||||||
|
|
||||||
|
|
||||||
class LorentzianFunction(Function):
|
|
||||||
"""The Lorentzian function."""
|
|
||||||
|
|
||||||
name = "Lorentzian"
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
|
||||||
"""Lorentzian function."""
|
|
||||||
expr = sympy.sympify("1 / (1 + (x / T2star)^2)")
|
|
||||||
super().__init__(expr)
|
|
||||||
self.start_x = 0
|
|
||||||
self.end_x = 30
|
|
||||||
|
|
||||||
self.add_parameter(Function.Parameter("T2star (microseconds)", "T2star", 10))
|
|
||||||
|
|
||||||
|
|
||||||
class Apodization(DuckFormBuilder):
|
class Apodization(DuckFormBuilder):
|
||||||
"""Apodization parameter.
|
"""Apodization parameter.
|
||||||
|
|
||||||
|
@ -100,6 +84,7 @@ class Fitting(DuckFormBuilder):
|
||||||
|
|
||||||
fits = {}
|
fits = {}
|
||||||
fits["T2*"] = T2StarFit(self.measurement)
|
fits["T2*"] = T2StarFit(self.measurement)
|
||||||
|
fits["Lorentzian"] = LorentzianFit(self.measurement)
|
||||||
|
|
||||||
selection_field = DuckFormDropdownField(
|
selection_field = DuckFormDropdownField(
|
||||||
text=None,
|
text=None,
|
||||||
|
|
|
@ -251,10 +251,16 @@ class MeasurementView(ModuleView):
|
||||||
return
|
return
|
||||||
|
|
||||||
for fit in measurement.fits:
|
for fit in measurement.fits:
|
||||||
logger.debug(f"Plotting fit {fit.name}.")
|
|
||||||
if fit.domain == self.module.model.view_mode:
|
if fit.domain == self.module.model.view_mode:
|
||||||
|
logger.debug(f"Plotting {fit.name} fit in domain {fit.domain}.")
|
||||||
x = fit.x
|
x = fit.x
|
||||||
y = fit.y
|
y = fit.y
|
||||||
|
# Shift the x values if the view mode is FFT
|
||||||
|
if fit.domain == self.module.model.FFT_VIEW:
|
||||||
|
x = x + float(
|
||||||
|
measurement.target_frequency - measurement.IF_frequency
|
||||||
|
) * 1e-6
|
||||||
|
|
||||||
self._ui_form.plotter.canvas.ax.plot(
|
self._ui_form.plotter.canvas.ax.plot(
|
||||||
x, y, label=f"{fit.name} Fit", linestyle="--"
|
x, y, label=f"{fit.name} Fit", linestyle="--"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue