mirror of
https://github.com/nqrduck/quackseq.git
synced 2024-11-09 13:10:00 +00:00
Readout scheme as sequence wide property.
This commit is contained in:
parent
9057b7245f
commit
40a2ecc029
4 changed files with 56 additions and 23 deletions
|
@ -16,7 +16,7 @@ class PhaseTable:
|
||||||
"""Initializes the phase table."""
|
"""Initializes the phase table."""
|
||||||
self.quackseq = quackseq
|
self.quackseq = quackseq
|
||||||
self.readout_scheme = ReadoutScheme(self)
|
self.readout_scheme = ReadoutScheme(self)
|
||||||
self.phase_array = self.generate_phase_array()
|
self.generate_phase_array()
|
||||||
|
|
||||||
def generate_phase_array(self):
|
def generate_phase_array(self):
|
||||||
"""Generate a list of phases for each phasecycle in the sequence.
|
"""Generate a list of phases for each phasecycle in the sequence.
|
||||||
|
@ -183,14 +183,12 @@ class PhaseTable:
|
||||||
|
|
||||||
logger.info(phase_array)
|
logger.info(phase_array)
|
||||||
|
|
||||||
|
# First set the phase array
|
||||||
|
self.phase_array = phase_array
|
||||||
|
|
||||||
|
# Then update the readout scheme (always reset it)
|
||||||
self.readout_scheme.update_readout_scheme()
|
self.readout_scheme.update_readout_scheme()
|
||||||
|
|
||||||
return phase_array
|
|
||||||
|
|
||||||
def update_phase_array(self):
|
|
||||||
"""Update the phase array of the sequence."""
|
|
||||||
self.phase_array = self.generate_phase_array()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def phase_array(self) -> np.array:
|
def phase_array(self) -> np.array:
|
||||||
"""The phase array of the sequence."""
|
"""The phase array of the sequence."""
|
||||||
|
@ -210,7 +208,8 @@ class PhaseTable:
|
||||||
"""The number of TX pulse parameters in the sequence."""
|
"""The number of TX pulse parameters in the sequence."""
|
||||||
return self.phase_array.shape[1]
|
return self.phase_array.shape[1]
|
||||||
|
|
||||||
class ReadoutScheme():
|
|
||||||
|
class ReadoutScheme:
|
||||||
"""Readout Scheme for the phase table.
|
"""Readout Scheme for the phase table.
|
||||||
|
|
||||||
The rows are the phase cycles of the sequence.
|
The rows are the phase cycles of the sequence.
|
||||||
|
@ -221,11 +220,45 @@ class ReadoutScheme():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, phase_table : PhaseTable) -> None:
|
def __init__(self, phase_table: PhaseTable) -> None:
|
||||||
"""Initializes the ReadoutOption."""
|
"""Initializes the ReadoutOption."""
|
||||||
self.phase_table = phase_table
|
self.phase_table = phase_table
|
||||||
|
|
||||||
|
|
||||||
def update_readout_scheme(self):
|
def update_readout_scheme(self):
|
||||||
"""Update the readout scheme of the sequence."""
|
"""Update the readout scheme of the sequence. Whenever the phase array is updated it will be reset."""
|
||||||
|
|
||||||
|
self.readout_scheme = np.zeros(
|
||||||
|
(self.phase_table.n_phase_cycles, self.phase_table.n_parameters)
|
||||||
|
)
|
||||||
|
|
||||||
|
def set_phase_cycle(
|
||||||
|
self, phase_cycle: int, phase_shift: float, function: str
|
||||||
|
) -> None:
|
||||||
|
"""Sets the phase shift and function of a phase cycle.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
phase_cycle (int): The phase cycle.
|
||||||
|
phase_shift (float): The phase shift.
|
||||||
|
function (str): The function.
|
||||||
|
"""
|
||||||
|
self.readout_scheme[phase_cycle] = [phase_shift, function]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def readout_scheme(self) -> np.array:
|
||||||
|
"""The readout scheme of the sequence."""
|
||||||
|
return self._readout_scheme
|
||||||
|
|
||||||
|
@readout_scheme.setter
|
||||||
|
def readout_scheme(self, readout_scheme: list) -> None:
|
||||||
|
"""Sets the readout scheme of the sequence.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
readout_scheme (list): The readout scheme.
|
||||||
|
"""
|
||||||
|
# Sanity check
|
||||||
|
if len(readout_scheme) != self.phase_table.n_phase_cycles:
|
||||||
|
raise ValueError(
|
||||||
|
f"Length of readout scheme ({len(readout_scheme)}) does not match the number of phase cycles ({self.phase_table.n_phase_cycles})"
|
||||||
|
)
|
||||||
|
|
||||||
|
self._readout_scheme = readout_scheme
|
||||||
|
|
|
@ -15,7 +15,6 @@ from quackseq.options import (
|
||||||
FunctionOption,
|
FunctionOption,
|
||||||
NumericOption,
|
NumericOption,
|
||||||
Option,
|
Option,
|
||||||
ReadoutOption,
|
|
||||||
)
|
)
|
||||||
from quackseq.functions import (
|
from quackseq.functions import (
|
||||||
RectFunction,
|
RectFunction,
|
||||||
|
@ -169,7 +168,6 @@ class RXReadout(PulseParameter):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RX = "Enable RX Readout"
|
RX = "Enable RX Readout"
|
||||||
READOUT_SCHEME = "Readout Scheme"
|
|
||||||
|
|
||||||
def __init__(self, name) -> None:
|
def __init__(self, name) -> None:
|
||||||
"""Initializes the RX Readout PulseParameter.
|
"""Initializes the RX Readout PulseParameter.
|
||||||
|
@ -179,8 +177,6 @@ class RXReadout(PulseParameter):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
self.add_option(BooleanOption(self.RX, False))
|
self.add_option(BooleanOption(self.RX, False))
|
||||||
|
|
||||||
self.add_option(ReadoutOption(self.READOUT_SCHEME))
|
|
||||||
|
|
||||||
|
|
||||||
class Gate(PulseParameter):
|
class Gate(PulseParameter):
|
||||||
"""Basic PulseParameter for the Gate. It includes an option for the Gate state.
|
"""Basic PulseParameter for the Gate. It includes an option for the Gate state.
|
||||||
|
|
|
@ -401,7 +401,7 @@ class QuackSequence(PulseSequence):
|
||||||
event = self.get_event_by_name(event)
|
event = self.get_event_by_name(event)
|
||||||
|
|
||||||
# Check that the readout scheme is valid
|
# Check that the readout scheme is valid
|
||||||
self.phase_table.update_phase_array()
|
self.phase_table.generate_phase_array()
|
||||||
n_cycles = self.phase_table.n_phase_cycles
|
n_cycles = self.phase_table.n_phase_cycles
|
||||||
|
|
||||||
rows = len(readout_scheme)
|
rows = len(readout_scheme)
|
||||||
|
@ -411,6 +411,9 @@ class QuackSequence(PulseSequence):
|
||||||
f"Readout scheme needs to have {n_cycles} cycles, but has {rows}"
|
f"Readout scheme needs to have {n_cycles} cycles, but has {rows}"
|
||||||
)
|
)
|
||||||
|
|
||||||
event.parameters[self.RX_READOUT].get_option_by_name(
|
# Old way - implement the sequence wide readout scheme here
|
||||||
RXReadout.READOUT_SCHEME
|
#event.parameters[self.RX_READOUT].get_option_by_name(
|
||||||
).value = readout_scheme
|
# RXReadout.READOUT_SCHEME
|
||||||
|
#).value = readout_scheme
|
||||||
|
|
||||||
|
self.phase_table.readout_scheme.readout_scheme = readout_scheme
|
|
@ -55,7 +55,8 @@ class SpectrometerController:
|
||||||
[event.duration for event in previous_events]
|
[event.duration for event in previous_events]
|
||||||
)
|
)
|
||||||
rx_duration = event.duration
|
rx_duration = event.duration
|
||||||
readout_scheme = parameter.get_option_by_name(RXReadout.READOUT_SCHEME).value
|
# This is fugly
|
||||||
|
readout_scheme = sequence.phase_table.readout_scheme.readout_scheme
|
||||||
|
|
||||||
rx_begin = float(previous_events_duration)
|
rx_begin = float(previous_events_duration)
|
||||||
if rx_duration:
|
if rx_duration:
|
||||||
|
|
Loading…
Reference in a new issue