Improved pulse sequence structure.

This commit is contained in:
jupfi 2023-07-11 13:58:07 +02:00
parent 17cc3837eb
commit a671c339de
2 changed files with 35 additions and 5 deletions

View file

@ -1,6 +1,8 @@
from collections import OrderedDict
class PulseSequence:
def __init__(self) -> None:
self.events = list()
def __init__(self, name) -> None:
self.name = name
self.events = OrderedDict()
def get_event_names(self) -> list:
return [event.name for event in self.events]
@ -8,11 +10,30 @@ class PulseSequence:
class Event:
"""An event is a part of a pulse sequence. It has a name and a duration and different parameters that have to be set."""
parameters = list()
def __init__(self, name: str, duration: float) -> None:
self.parameters = OrderedDict()
self.name = name
self.duration = duration
def add_parameter(self, parameter) -> None:
self.parameters.append(parameter)
def dump_sequence_data(self):
"""Returns a dict with all the data in the pulse sequence"""
data = {
"name": self.name,
"events": []
}
for event in self.events.keys():
event_data = {
"name": self.events[event].name,
"duration": self.events[event].duration,
"parameters": []
}
for parameter in self.events[event].parameters.keys():
event_data["parameters"].append({
"name": parameter,
"value": self.events[event].parameters[parameter].state
})
data["events"].append(event_data)
return data

View file

@ -36,6 +36,15 @@ class TXPulse(BaseSpectrometerModel.PulseParameter):
self.rx_freq = 0
self.rx_phase = 0
class TXPhase(BaseSpectrometerModel.PulseParameter):
def __init__(self, name) -> None:
super().__init__(name)
self.phase = 0
class RXPhase(BaseSpectrometerModel.PulseParameter):
def __init__(self, name) -> None:
super().__init__(name)
self.phase = 0
class Gate(BaseSpectrometerModel.PulseParameter):
def __init__(self, name) -> None: