mirror of
https://github.com/nqrduck/quackseq.git
synced 2024-11-09 21:10:01 +00:00
RX Phase implementation.
This commit is contained in:
parent
cf3109f2f0
commit
34ae866092
3 changed files with 26 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
||||||
import logging
|
import logging
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy.optimize import curve_fit
|
from scipy.optimize import curve_fit
|
||||||
|
from numpy.fft import ifft, fft
|
||||||
|
|
||||||
from quackseq.functions import Function
|
from quackseq.functions import Function
|
||||||
from quackseq.signalprocessing import SignalProcessing as sp
|
from quackseq.signalprocessing import SignalProcessing as sp
|
||||||
|
@ -18,8 +19,8 @@ class Measurement:
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name (str): Name of the measurement.
|
name (str): Name of the 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. This can be multi-dimensional.
|
||||||
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. This can be multi-dimensional.
|
||||||
target_frequency (float): Target frequency of the measurement.
|
target_frequency (float): Target frequency of the measurement.
|
||||||
frequency_shift (float, optional): Frequency shift of the measurement. Defaults to 0.
|
frequency_shift (float, optional): Frequency shift of the measurement. Defaults to 0.
|
||||||
IF_frequency (float, optional): Intermediate frequency of the measurement. Defaults to 0.
|
IF_frequency (float, optional): Intermediate frequency of the measurement. Defaults to 0.
|
||||||
|
@ -78,6 +79,18 @@ class Measurement:
|
||||||
)
|
)
|
||||||
return apodized_measurement
|
return apodized_measurement
|
||||||
|
|
||||||
|
def phase_shift(self, phase: float, axis = 0) -> np.array:
|
||||||
|
"""Applies a phase shift to the measurement data.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
phase (float): Phase shift in degrees.
|
||||||
|
axis (int): Axis to apply the phase shift to. Defaults to 0.
|
||||||
|
"""
|
||||||
|
spec = fft(self.tdy)
|
||||||
|
shifted_signal = np.exp(1j * np.deg2rad(phase)) * spec
|
||||||
|
|
||||||
|
self.tdy = ifft(shifted_signal, n=len(self.tdy))
|
||||||
|
|
||||||
def add_fit(self, fit: "Fit") -> None:
|
def add_fit(self, fit: "Fit") -> None:
|
||||||
"""Adds a fit to the measurement.
|
"""Adds a fit to the measurement.
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,8 @@ class RXReadout(PulseParameter):
|
||||||
RX (str): The RX Readout state.
|
RX (str): The RX Readout state.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RX = "RX"
|
RX = "Enable RX Readout"
|
||||||
|
PHASE = "RX Phase (°)"
|
||||||
|
|
||||||
def __init__(self, name) -> None:
|
def __init__(self, name) -> None:
|
||||||
"""Initializes the RX Readout PulseParameter.
|
"""Initializes the RX Readout PulseParameter.
|
||||||
|
@ -159,6 +160,11 @@ class RXReadout(PulseParameter):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
self.add_option(BooleanOption(self.RX, False))
|
self.add_option(BooleanOption(self.RX, False))
|
||||||
|
|
||||||
|
# Receiver Phase
|
||||||
|
self.add_option(
|
||||||
|
NumericOption(self.PHASE, 0, min_value=0, max_value=360, is_float=True)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
|
@ -30,7 +30,7 @@ class SpectrometerController:
|
||||||
"""This method translates the RX event of the pulse sequence to the limr object.
|
"""This method translates the RX event of the pulse sequence to the limr object.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
tuple: A tuple containing the start and stop time of the RX event in µs
|
tuple: A tuple containing the start and stop time of the RX event in µs and the phase of the RX event.
|
||||||
"""
|
"""
|
||||||
# This is a correction factor for the RX event. The offset of the first pulse is 2.2µs longer than from the specified samples.
|
# This is a correction factor for the RX event. The offset of the first pulse is 2.2µs longer than from the specified samples.
|
||||||
events = sequence.events
|
events = sequence.events
|
||||||
|
@ -55,14 +55,15 @@ class SpectrometerController:
|
||||||
[event.duration for event in previous_events]
|
[event.duration for event in previous_events]
|
||||||
)
|
)
|
||||||
rx_duration = event.duration
|
rx_duration = event.duration
|
||||||
|
phase = parameter.get_option_by_name(RXReadout.PHASE).value
|
||||||
|
|
||||||
rx_begin = float(previous_events_duration)
|
rx_begin = float(previous_events_duration)
|
||||||
if rx_duration:
|
if rx_duration:
|
||||||
rx_stop = rx_begin + float(rx_duration)
|
rx_stop = rx_begin + float(rx_duration)
|
||||||
return rx_begin * 1e6, rx_stop * 1e6
|
return rx_begin * 1e6, rx_stop * 1e6, phase
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return None, None
|
return None, None, None
|
||||||
|
|
||||||
def calculate_simulation_length(self, sequence: QuackSequence) -> float:
|
def calculate_simulation_length(self, sequence: QuackSequence) -> float:
|
||||||
"""This method calculates the simulation length based on the settings and the pulse sequence.
|
"""This method calculates the simulation length based on the settings and the pulse sequence.
|
||||||
|
|
Loading…
Reference in a new issue