Working RX dwelltime.

This commit is contained in:
jupfi 2024-05-04 21:55:43 +02:00
parent 2c63fa4028
commit 1a6342e4cb
2 changed files with 54 additions and 9 deletions

View file

@ -4,10 +4,12 @@ import logging
import tempfile import tempfile
from pathlib import Path from pathlib import Path
import numpy as np import numpy as np
from scipy.signal import resample, decimate
from limedriver.binding import PyLimeConfig from limedriver.binding import PyLimeConfig
from limedriver.hdf_reader import HDF from limedriver.hdf_reader import HDF
from nqrduck.helpers.unitconverter import UnitConverter
from nqrduck_spectrometer.base_spectrometer_controller import BaseSpectrometerController from nqrduck_spectrometer.base_spectrometer_controller import BaseSpectrometerController
from nqrduck_spectrometer.measurement import Measurement from nqrduck_spectrometer.measurement import Measurement
from nqrduck_spectrometer.pulseparameters import TXPulse, RXReadout from nqrduck_spectrometer.pulseparameters import TXPulse, RXReadout
@ -55,6 +57,29 @@ class LimeNQRController(BaseSpectrometerController):
measurement_data = self.process_measurement_results(lime) measurement_data = self.process_measurement_results(lime)
# Resample the RX data to the dwell time settings
dwell_time = self.module.model.get_setting_by_name(
self.module.model.RX_DWELL_TIME
).value
dwell_time = UnitConverter.to_float(dwell_time) * 1e6
logger.debug("Dwell time: %s", dwell_time)
logger.debug(f"Last tdx value: {measurement_data.tdx[-1]}")
if dwell_time:
n_data_points = int(measurement_data.tdx[-1] / dwell_time)
logger.debug("Resampling to %s data points", n_data_points)
tdx = np.linspace(
0, measurement_data.tdx[-1], n_data_points, endpoint=False
)
tdy = resample(measurement_data.tdy, n_data_points)
measurement_data = Measurement(
tdx,
tdy,
self.module.model.target_frequency,
IF_frequency=self.module.model.if_frequency,
)
if measurement_data: if measurement_data:
self.emit_measurement_data(measurement_data) self.emit_measurement_data(measurement_data)
self.emit_status_message("Finished Measurement") self.emit_status_message("Finished Measurement")
@ -456,6 +481,7 @@ class LimeNQRController(BaseSpectrometerController):
parameter.get_option_by_name(TXPulse.RELATIVE_AMPLITUDE).value / 100 parameter.get_option_by_name(TXPulse.RELATIVE_AMPLITUDE).value / 100
) )
pulse_amplitude = np.clip(pulse_amplitude, -0.99, 0.99) pulse_amplitude = np.clip(pulse_amplitude, -0.99, 0.99)
return pulse_shape, pulse_amplitude return pulse_shape, pulse_amplitude
def modulate_pulse_amplitude( def modulate_pulse_amplitude(
@ -475,6 +501,11 @@ class LimeNQRController(BaseSpectrometerController):
num_samples = int(float(event.duration) * lime.srate) num_samples = int(float(event.duration) * lime.srate)
tdx = np.linspace(0, float(event.duration), num_samples, endpoint=False) tdx = np.linspace(0, float(event.duration), num_samples, endpoint=False)
shift_signal = np.exp(1j * 2 * np.pi * self.module.model.if_frequency * tdx) shift_signal = np.exp(1j * 2 * np.pi * self.module.model.if_frequency * tdx)
# The pulse amplitude needs to be resampled to the number of samples
logger.debug("Resampling pulse amplitude to %s samples", num_samples)
pulse_amplitude = resample(pulse_amplitude, num_samples)
pulse_complex = pulse_amplitude * shift_signal pulse_complex = pulse_amplitude * shift_signal
modulated_amplitude = np.abs(pulse_complex) modulated_amplitude = np.abs(pulse_complex)
modulated_phase = self.unwrap_phase(np.angle(pulse_complex)) modulated_phase = self.unwrap_phase(np.angle(pulse_complex))

View file

@ -8,6 +8,7 @@ from nqrduck_spectrometer.settings import (
IntSetting, IntSetting,
BooleanSetting, BooleanSetting,
SelectionSetting, SelectionSetting,
StringSetting,
) )
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -19,17 +20,18 @@ class LimeNQRModel(BaseSpectrometerModel):
CHANNEL = "TX/RX Channel" CHANNEL = "TX/RX Channel"
TX_MATCHING = "TX Matching" TX_MATCHING = "TX Matching"
RX_MATCHING = "RX Matching" RX_MATCHING = "RX Matching"
SAMPLING_FREQUENCY = "Sampling Frequency" SAMPLING_FREQUENCY = "Sampling Frequency (Hz)"
IF_FREQUENCY = "IF Frequency" RX_DWELL_TIME = "RX Dwell Time (s)"
ACQUISITION_TIME = "Acquisition time" IF_FREQUENCY = "IF Frequency (Hz)"
ACQUISITION_TIME = "Acquisition time (s)"
GATE_ENABLE = "Enable" GATE_ENABLE = "Enable"
GATE_PADDING_LEFT = "Gate padding left" GATE_PADDING_LEFT = "Gate padding left"
GATE_PADDING_RIGHT = "Gate padding right" GATE_PADDING_RIGHT = "Gate padding right"
GATE_SHIFT = "Gate shift" GATE_SHIFT = "Gate shift"
RX_GAIN = "RX Gain" RX_GAIN = "RX Gain"
TX_GAIN = "TX Gain" TX_GAIN = "TX Gain"
RX_LPF_BW = "RX LPF BW" RX_LPF_BW = "RX LPF BW (Hz)"
TX_LPF_BW = "TX LPF BW" TX_LPF_BW = "TX LPF BW (Hz)"
TX_I_DC_CORRECTION = "TX I DC correction" TX_I_DC_CORRECTION = "TX I DC correction"
TX_Q_DC_CORRECTION = "TX Q DC correction" TX_Q_DC_CORRECTION = "TX Q DC correction"
TX_I_GAIN_CORRECTION = "TX I Gain correction" TX_I_GAIN_CORRECTION = "TX I Gain correction"
@ -79,15 +81,27 @@ class LimeNQRModel(BaseSpectrometerModel):
) )
self.add_setting(rx_matching_setting, self.ACQUISITION) self.add_setting(rx_matching_setting, self.ACQUISITION)
sampling_frequency_setting = FloatSetting(
sampling_frequency_options = [
"30.72e6",
"15.36e6",
"7.68e6",
]
sampling_frequency_setting = SelectionSetting(
self.SAMPLING_FREQUENCY, self.SAMPLING_FREQUENCY,
30.72e6, sampling_frequency_options,
"30.72e6",
"The rate at which the spectrometer samples the input signal.", "The rate at which the spectrometer samples the input signal.",
min_value=0,
max_value=30.72e6,
) )
self.add_setting(sampling_frequency_setting, self.ACQUISITION) self.add_setting(sampling_frequency_setting, self.ACQUISITION)
rx_dwell_time_setting = StringSetting(
self.RX_DWELL_TIME,
"22n",
"The time between samples in the receive path.",
)
self.add_setting(rx_dwell_time_setting, self.ACQUISITION)
if_frequency_setting = FloatSetting( if_frequency_setting = FloatSetting(
self.IF_FREQUENCY, self.IF_FREQUENCY,
5e6, 5e6,