Added docs + rescaled logos.

This commit is contained in:
jupfi 2023-07-22 13:48:55 +02:00
parent 9bb5696b9d
commit 7f245f4c89
10 changed files with 87 additions and 44 deletions

View file

@ -31,6 +31,16 @@ class BaseSpectrometerModel(ModuleModel):
class PulseParameter: class PulseParameter:
"""A pulse parameter is a value that can be different for each event in a pulse sequence.
E.g. the transmit pulse power or the phase of the transmit pulse.
Arguments:
name (str) -- The name of the pulse parameter
Attributes:
name (str) -- The name of the pulse parameter
options (OrderedDict) -- The options of the pulse parameter
"""
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
self.options = OrderedDict() self.options = OrderedDict()

View file

@ -17,7 +17,7 @@ class SpectrometerController(ModuleController):
super().__init__(module) super().__init__(module)
def _load_spectrometer_modules(self): def _load_spectrometer_modules(self):
"""This method loads the spectrometer modules and adds them to the spectrometer model.""" """This method loads the spectrometer (sub-)modules and adds them to the spectrometer model."""
# Get the modules with entry points in the nqrduck group # Get the modules with entry points in the nqrduck group
modules = MainController._get_modules() modules = MainController._get_modules()
logger.debug("Found modules: %s", modules) logger.debug("Found modules: %s", modules)
@ -41,10 +41,13 @@ class SpectrometerController(ModuleController):
self._module.view.create_menu_entry() self._module.view.create_menu_entry()
def process_signals(self, key: str, value: None): def process_signals(self, key: str, value: None):
# This signal starts a measurement
if key == "start_measurement": if key == "start_measurement":
self.on_measurement_start() self.on_measurement_start()
# This signal sets the frequency
elif key == "set_frequency": elif key == "set_frequency":
self.module.model.active_spectrometer.controller.set_frequency(value) self.module.model.active_spectrometer.controller.set_frequency(value)
# This signal sets the number of averages
elif key == "set_averages": elif key == "set_averages":
self.module.model.active_spectrometer.controller.set_averages(value) self.module.model.active_spectrometer.controller.set_averages(value)

View file

@ -2,16 +2,17 @@ from PyQt6.QtGui import QPixmap
from pathlib import Path from pathlib import Path
from .base_spectrometer_model import BaseSpectrometerModel from .base_spectrometer_model import BaseSpectrometerModel
class Option():
"""Defines options for the pulse parameters which can then be set accordingly. class Option:
""" """Defines options for the pulse parameters which can then be set accordingly."""
def set_value(self): def set_value(self):
raise NotImplementedError raise NotImplementedError
class BooleanOption(Option): class BooleanOption(Option):
"""Defines a boolean option for a pulse parameter option. """Defines a boolean option for a pulse parameter option."""
"""
def __init__(self, value) -> None: def __init__(self, value) -> None:
super().__init__() super().__init__()
self.value = value self.value = value
@ -19,9 +20,10 @@ class BooleanOption(Option):
def set_value(self, value): def set_value(self, value):
self.value = value self.value = value
class NumericOption(Option): class NumericOption(Option):
"""Defines a numeric option for a pulse parameter option. """Defines a numeric option for a pulse parameter option."""
"""
def __init__(self, value) -> None: def __init__(self, value) -> None:
super().__init__() super().__init__()
self.value = value self.value = value
@ -29,9 +31,10 @@ class NumericOption(Option):
def set_value(self, value): def set_value(self, value):
self.value = float(value) self.value = float(value)
class WidgetSelectionOption(Option): class WidgetSelectionOption(Option):
"""Defines a widget selection option for a pulse parameter option. """Defines a widget selection option for a pulse parameter option."""
"""
def __init__(self, widgets) -> None: def __init__(self, widgets) -> None:
super().__init__() super().__init__()
@ -45,24 +48,25 @@ class TXPulse(BaseSpectrometerModel.PulseParameter):
def get_pixmap(self): def get_pixmap(self):
self_path = Path(__file__).parent self_path = Path(__file__).parent
if self.options["TX Amplitude"].value > 0: if self.options["TX Amplitude"].value > 0:
image_path = self_path / "resources/pulseparameter/TX_Pulse.png" image_path = self_path / "resources/pulseparameter/TXOn.png"
else: else:
image_path = self_path / "resources/pulseparameter/NoPulse.png" image_path = self_path / "resources/pulseparameter/TXOff.png"
pixmap = QPixmap(str(image_path)) pixmap = QPixmap(str(image_path))
return pixmap return pixmap
class RectPulse(): class RectPulse:
def __init__(self, name) -> None: def __init__(self, name) -> None:
super().__init__(name) super().__init__(name)
class SincPulse(): class SincPulse:
def __init__(self, name) -> None: def __init__(self, name) -> None:
super().__init__(name) super().__init__(name)
class GaussianPulse(): class GaussianPulse:
def __init__(self, name) -> None: def __init__(self, name) -> None:
super().__init__(name) super().__init__(name)
class RXReadout(BaseSpectrometerModel.PulseParameter): class RXReadout(BaseSpectrometerModel.PulseParameter):
def __init__(self, name) -> None: def __init__(self, name) -> None:
super().__init__(name) super().__init__(name)
@ -80,8 +84,8 @@ class RXReadout(BaseSpectrometerModel.PulseParameter):
def set_options(self, options): def set_options(self, options):
self.state = options self.state = options
class Gate(BaseSpectrometerModel.PulseParameter):
class Gate(BaseSpectrometerModel.PulseParameter):
def __init__(self, name) -> None: def __init__(self, name) -> None:
super().__init__(name) super().__init__(name)
self.add_option("Gate State", BooleanOption(False)) self.add_option("Gate State", BooleanOption(False))
@ -97,5 +101,3 @@ class Gate(BaseSpectrometerModel.PulseParameter):
def set_options(self, options): def set_options(self, options):
self.state = options self.state = options

View file

@ -3,8 +3,10 @@ from collections import OrderedDict
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class PulseSequence: class PulseSequence:
"""A pulse sequence is a collection of events that are executed in a certain order.""" """A pulse sequence is a collection of events that are executed in a certain order."""
def __init__(self, name) -> None: def __init__(self, name) -> None:
self.name = name self.name = name
self.events = list() self.events = list()
@ -29,50 +31,76 @@ class PulseSequence:
@classmethod @classmethod
def load_event(cls, event, pulse_parameter_options): def load_event(cls, event, pulse_parameter_options):
"""Loads an event from a dict. The pulse paramter options are needed to load the parameters """
and determine if the correct spectrometer is active.""" Loads an event from a dict. The pulse paramter options are needed to load the parameters
and determine if the correct spectrometer is active.
Args:
event (dict): The dict with the event data
pulse_parameter_options (dict): The dict with the pulse parameter options
Returns:
Event: The loaded event
"""
obj = cls(event["name"], event["duration"]) obj = cls(event["name"], event["duration"])
for parameter in event["parameters"]: for parameter in event["parameters"]:
for pulse_parameter_option in pulse_parameter_options.keys(): for pulse_parameter_option in pulse_parameter_options.keys():
# This checks if the pulse paramter options are the same as the ones in the pulse sequence # This checks if the pulse paramter options are the same as the ones in the pulse sequence
if pulse_parameter_option == parameter["name"]: if pulse_parameter_option == parameter["name"]:
pulse_paramter_class = pulse_parameter_options[pulse_parameter_option] pulse_paramter_class = pulse_parameter_options[
obj.parameters[pulse_parameter_option] = pulse_paramter_class(parameter["name"]) pulse_parameter_option
]
obj.parameters[pulse_parameter_option] = pulse_paramter_class(
parameter["name"]
)
for option in parameter["value"]: for option in parameter["value"]:
obj.parameters[pulse_parameter_option].options[option["name"]].value = option["value"] obj.parameters[pulse_parameter_option].options[
option["name"]
].value = option["value"]
return obj return obj
def dump_sequence_data(self): def dump_sequence_data(self):
"""Returns a dict with all the data in the pulse sequence""" """Returns a dict with all the data in the pulse sequence
data = {
"name": self.name, Returns:
"events": [] dict: The dict with the sequence data"""
} data = {"name": self.name, "events": []}
for event in self.events: for event in self.events:
event_data = { event_data = {
"name": event.name, "name": event.name,
"duration": event.duration, "duration": event.duration,
"parameters": [] "parameters": [],
} }
for parameter in event.parameters.keys(): for parameter in event.parameters.keys():
event_data["parameters"].append({ event_data["parameters"].append({"name": parameter, "value": []})
"name": parameter,
"value": []
})
for option in event.parameters[parameter].options.keys(): for option in event.parameters[parameter].options.keys():
event_data["parameters"][-1]["value"].append({ event_data["parameters"][-1]["value"].append(
{
"name": option, "name": option,
"value": event.parameters[parameter].options[option].value "value": event.parameters[parameter].options[option].value,
}) }
)
data["events"].append(event_data) data["events"].append(event_data)
return data return data
@classmethod @classmethod
def load_sequence(cls, sequence, pulse_parameter_options): def load_sequence(cls, sequence, pulse_parameter_options):
"""Loads a pulse sequence from a dict. The pulse paramter options are needed to load the parameters
and make sure the correct spectrometer is active.
Args:
sequence (dict): The dict with the sequence data
pulse_parameter_options (dict): The dict with the pulse parameter options
Returns:
PulseSequence: The loaded pulse sequence
Raises:
KeyError: If the pulse parameter options are not the same as the ones in the pulse sequence
"""
obj = cls(sequence["name"]) obj = cls(sequence["name"])
for event_data in sequence["events"]: for event_data in sequence["events"]:
obj.events.append(cls.Event.load_event(event_data, pulse_parameter_options)) obj.events.append(cls.Event.load_event(event_data, pulse_parameter_options))
return obj return obj

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 B

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 B