mirror of
https://github.com/nqrduck/nqrduck-spectrometer.git
synced 2024-11-09 12:30:01 +00:00
Added setting of frequency and averages.
This commit is contained in:
parent
0ea47d16be
commit
4b89719f67
5 changed files with 56 additions and 19 deletions
|
@ -8,4 +8,10 @@ class BaseSpectrometerController(ModuleController):
|
||||||
def start_measurement(self):
|
def start_measurement(self):
|
||||||
"""Starts the measurement.
|
"""Starts the measurement.
|
||||||
"""
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def set_frequency(self, value):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def set_averages(self, value):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
|
@ -1,29 +1,21 @@
|
||||||
import logging
|
import logging
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from PyQt6.QtCore import pyqtSlot
|
from PyQt6.QtCore import pyqtSlot, pyqtSignal, QObject
|
||||||
from nqrduck.module.module_model import ModuleModel
|
from nqrduck.module.module_model import ModuleModel
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class BaseSpectrometerModel(ModuleModel):
|
class BaseSpectrometerModel(ModuleModel):
|
||||||
def __init__(self, module):
|
settings : OrderedDict
|
||||||
super().__init__(module)
|
pulse_parameter_options : OrderedDict
|
||||||
self.settings = OrderedDict()
|
|
||||||
self.pulse_parameter_options = OrderedDict()
|
|
||||||
|
|
||||||
def add_setting(self, name, value, description, category) -> None:
|
class Setting(QObject):
|
||||||
if category not in self.settings.keys():
|
|
||||||
self.settings[category] = []
|
|
||||||
self.settings[category].append(self.Setting(name, value, description))
|
|
||||||
|
|
||||||
def add_pulse_parameter_option(self, name, pulse_parameter_class) -> None:
|
|
||||||
self.pulse_parameter_options[name] = pulse_parameter_class
|
|
||||||
|
|
||||||
class Setting:
|
|
||||||
"""A setting for the spectrometer is a value that is the same for all events in a pulse sequence.
|
"""A setting for the spectrometer is a value that is the same for all events in a pulse sequence.
|
||||||
E.g. the number of averages or the number of points in a spectrum."""
|
E.g. the number of averages or the number of points in a spectrum."""
|
||||||
|
settings_changed = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, name, default, description) -> None:
|
def __init__(self, name, default, description) -> None:
|
||||||
|
super().__init__()
|
||||||
self.name = name
|
self.name = name
|
||||||
self.value = default
|
self.value = default
|
||||||
self.description = description
|
self.description = description
|
||||||
|
@ -32,6 +24,7 @@ class BaseSpectrometerModel(ModuleModel):
|
||||||
def on_value_changed(self, value):
|
def on_value_changed(self, value):
|
||||||
logger.debug("Setting %s changed to %s", self.name, value)
|
logger.debug("Setting %s changed to %s", self.name, value)
|
||||||
self.value = value
|
self.value = value
|
||||||
|
self.settings_changed.emit()
|
||||||
|
|
||||||
def get_setting(self):
|
def get_setting(self):
|
||||||
return float(self.value)
|
return float(self.value)
|
||||||
|
@ -50,6 +43,39 @@ class BaseSpectrometerModel(ModuleModel):
|
||||||
|
|
||||||
def get_options(self):
|
def get_options(self):
|
||||||
return self.options
|
return self.options
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, module):
|
||||||
|
super().__init__(module)
|
||||||
|
self.settings = OrderedDict()
|
||||||
|
self.pulse_parameter_options = OrderedDict()
|
||||||
|
|
||||||
|
def add_setting(self, name, value, description, category) -> None:
|
||||||
|
if category not in self.settings.keys():
|
||||||
|
self.settings[category] = []
|
||||||
|
self.settings[category].append(self.Setting(name, value, description))
|
||||||
|
|
||||||
|
def get_setting_by_name(self, name : str) -> Setting:
|
||||||
|
for category in self.settings.keys():
|
||||||
|
for setting in self.settings[category]:
|
||||||
|
if setting.name == name:
|
||||||
|
return setting
|
||||||
|
raise ValueError("Setting with name %s not found" % name)
|
||||||
|
|
||||||
|
def add_pulse_parameter_option(self, name, pulse_parameter_class) -> None:
|
||||||
|
self.pulse_parameter_options[name] = pulse_parameter_class
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_frequency(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@target_frequency.setter
|
||||||
|
def target_frequency(self, value):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@property
|
||||||
|
def averages(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@averages.setter
|
||||||
|
def averages(self, value):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from PyQt6.QtWidgets import QWidget, QLabel, QLineEdit, QHBoxLayout, QSizePolicy, QSpacerItem, QVBoxLayout
|
from PyQt6.QtWidgets import QWidget, QLabel, QLineEdit, QHBoxLayout, QSizePolicy, QSpacerItem, QVBoxLayout
|
||||||
from PyQt6.QtCore import Qt
|
from PyQt6.QtCore import Qt, pyqtSlot
|
||||||
from nqrduck.module.module_view import ModuleView
|
from nqrduck.module.module_view import ModuleView
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -12,7 +12,7 @@ class BaseSpectrometerView(ModuleView):
|
||||||
super().__init__(module)
|
super().__init__(module)
|
||||||
|
|
||||||
def load_settings_ui(self):
|
def load_settings_ui(self):
|
||||||
"""This method automaticall generates a view for the settings of the module.
|
"""This method automatically generates a view for the settings of the module.
|
||||||
If there is a widget file that has been generated by Qt Designer, it will be used. Otherwise, a default view will be generated."""
|
If there is a widget file that has been generated by Qt Designer, it will be used. Otherwise, a default view will be generated."""
|
||||||
|
|
||||||
from .base_spectrometer_widget import Ui_Form
|
from .base_spectrometer_widget import Ui_Form
|
||||||
|
|
|
@ -43,6 +43,10 @@ class SpectrometerController(ModuleController):
|
||||||
def process_signals(self, key: str, value: None):
|
def process_signals(self, key: str, value: None):
|
||||||
if key == "start_measurement":
|
if key == "start_measurement":
|
||||||
self.on_measurement_start()
|
self.on_measurement_start()
|
||||||
|
elif key == "set_frequency":
|
||||||
|
self.module.model.active_spectrometer.controller.set_frequency(value)
|
||||||
|
elif key == "set_averages":
|
||||||
|
self.module.model.active_spectrometer.controller.set_averages(value)
|
||||||
|
|
||||||
def on_loading(self):
|
def on_loading(self):
|
||||||
"""This method is called when the module is loaded.
|
"""This method is called when the module is loaded.
|
||||||
|
|
|
@ -9,15 +9,16 @@ class Measurement():
|
||||||
tdx (np.array): Time axis for the x axis of the measurement data.
|
tdx (np.array): Time axis for the x axis of the measurement data.
|
||||||
tdy (np.array): Time axis for the y axis of the measurement data.
|
tdy (np.array): Time axis for the y axis of the measurement data.
|
||||||
target_frequency (float): Target frequency of the measurement.
|
target_frequency (float): Target frequency of the measurement.
|
||||||
|
frequency_shift (float): Frequency shift of the measurement.
|
||||||
xf (np.array): Frequency axis for the x axis of the measurement data.
|
xf (np.array): Frequency axis for the x axis of the measurement data.
|
||||||
yf (np.array): Frequency axis for the y axis of the measurement data.
|
yf (np.array): Frequency axis for the y axis of the measurement data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, tdx, tdy, target_frequency) -> None:
|
def __init__(self, tdx, tdy, target_frequency, frequency_shift : float = 0) -> None:
|
||||||
self.tdx = tdx
|
self.tdx = tdx
|
||||||
self.tdy = tdy
|
self.tdy = tdy
|
||||||
self.target_frequency = target_frequency
|
self.target_frequency = target_frequency
|
||||||
self.fdx, self.fdy = sp.fft(tdx, tdy)
|
self.fdx, self.fdy = sp.fft(tdx, tdy, frequency_shift)
|
||||||
|
|
||||||
# Measurement data
|
# Measurement data
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in a new issue