Added averages and target frequency to properties

This commit is contained in:
jupfi 2023-07-19 08:34:11 +02:00
parent 1cc1cd8eac
commit f4499fc774
2 changed files with 58 additions and 33 deletions

View file

@ -39,6 +39,7 @@ class LimeNQRController(BaseSpectrometerController):
lime = self.update_settings(lime)
lime = self.translate_pulse_sequence(lime)
lime.nav = self.module.model.averages
for key in sorted(lime.parsinp):
val = getattr(lime, key)
@ -99,11 +100,7 @@ class LimeNQRController(BaseSpectrometerController):
for setting in self.module.model.settings[category]:
logger.debug("Setting %s has value %s", setting.name, setting.value)
# Acquisiton settings
if setting.name == self.module.model.FREQUENCY:
self.module.model.target_frequency = setting.get_setting()
elif setting.name == self.module.model.AVERAGES:
lime.nav = setting.get_setting()
elif setting.name == self.module.model.SAMPLING_FREQUENCY:
if setting.name == self.module.model.SAMPLING_FREQUENCY:
lime.sra = setting.get_setting()
# Careful this doesn't only set the IF frequency but the local oscillator frequency
elif setting.name == self.module.model.IF_FREQUENCY:
@ -277,3 +274,23 @@ class LimeNQRController(BaseSpectrometerController):
return rx_begin * 1e6, rx_stop * 1e6
else: return None, None
def set_frequency(self, value):
logger.debug("Setting frequency to: %s", value)
try:
self.module.model.target_frequency = float(value)
logger.debug("Successfully set frequency to: %s", value)
except ValueError:
logger.warning("Could not set frequency to: %s", value)
self.module.nqrduck_signal.emit("notification", ["Error", "Could not set frequency to: " + value])
self.module.nqrduck_signal.emit("failure", ["set_frequency", value])
def set_averages(self, value):
logger.debug("Setting averages to: %s", value)
try:
self.module.model.averages = int(value)
logger.debug("Successfully set averages to: %s", value)
except ValueError:
logger.warning("Could not set averages to: %s", value)
self.module.nqrduck_signal.emit("notification", ["Error", "Could not set averages to: " + value])
self.module.nqrduck_signal.emit("failure", ["set_averages", value])

View file

@ -6,11 +6,8 @@ from nqrduck_spectrometer.pulseparameters import Gate, TXPulse, RXReadout
logger = logging.getLogger(__name__)
class LimeNQRModel(BaseSpectrometerModel):
class LimeNQRModel(BaseSpectrometerModel):
# Setting constants for the names of the spectrometer settings
FREQUENCY = "Frequency"
AVERAGES = "Averages"
SAMPLING_FREQUENCY = "Sampling Frequency"
IF_FREQUENCY = "IF Frequency"
ACQUISITION_TIME = "Acquisition time"
@ -33,6 +30,12 @@ class LimeNQRModel(BaseSpectrometerModel):
RX_Q_GAIN_CORRECTION = "RX Q Gain correction"
RX_PHASE_ADJUSTMENT = "RX phase adjustment"
# Constants for the Categories of the settings
ACQUISITION = "Acquisition"
GATE_SETTINGS = "Gate Settings"
RX_TX_SETTINGS = "RX/TX Settings"
CALIBRATION = "Calibration"
# Pulse parameter constants
TX = "TX"
RX = "RX"
@ -44,34 +47,31 @@ class LimeNQRModel(BaseSpectrometerModel):
def __init__(self, module) -> None:
super().__init__(module)
# Acquisition settings
self.add_setting(self.FREQUENCY, 100e6, "Experiment frequency", "Acquisition")
self.target_frequency = 100e6
self.add_setting(self.AVERAGES, 100, "Number of averages", "Acquisition")
self.add_setting(self.SAMPLING_FREQUENCY, 30.72e6 , "Sampling frequency", "Acquisition")
self.add_setting(self.IF_FREQUENCY, 1.2e6, "IF Frequency", "Acquisition")
self.add_setting(self.SAMPLING_FREQUENCY, 30.72e6 , "Sampling frequency", self.ACQUISITION)
self.add_setting(self.IF_FREQUENCY, 1.2e6, "IF Frequency", self.ACQUISITION)
self.if_frequency = 1.2e6
self.add_setting(self.ACQUISITION_TIME, 82e-6, "Acquisition time - this is from the beginning of the pulse sequence", "Acquisition")
self.add_setting(self.ACQUISITION_TIME, 82e-6, "Acquisition time - this is from the beginning of the pulse sequence", self.ACQUISITION)
# Gate Settings
self.add_setting(self.GATE_ENABLE, True, "Enable", "Gate Settings")
self.add_setting(self.GATE_PADDING_LEFT, 10, "Gate padding left", "Gate Settings")
self.add_setting(self.GATE_PADDING_RIGHT, 10, "Gate padding right", "Gate Settings")
self.add_setting(self.GATE_SHIFT, 53, "Gate shift", "Gate Settings")
self.add_setting(self.GATE_ENABLE, True, "Enable", self.GATE_SETTINGS)
self.add_setting(self.GATE_PADDING_LEFT, 10, "Gate padding left", self.GATE_SETTINGS)
self.add_setting(self.GATE_PADDING_RIGHT, 10, "Gate padding right", self.GATE_SETTINGS)
self.add_setting(self.GATE_SHIFT, 53, "Gate shift", self.GATE_SETTINGS)
# RX/TX settings
self.add_setting(self.RX_GAIN, 55, "RX Gain", "RX/TX Settings")
self.add_setting(self.TX_GAIN, 40, "TX Gain", "RX/TX Settings")
self.add_setting(self.RX_LPF_BW, 30.72e6/2, "RX LPF BW", "RX/TX Settings")
self.add_setting(self.TX_LPF_BW, 130.0e6, "TX LPF BW", "RX/TX Settings")
self.add_setting(self.RX_GAIN, 55, "RX Gain", self.RX_TX_SETTINGS)
self.add_setting(self.TX_GAIN, 40, "TX Gain", self.RX_TX_SETTINGS)
self.add_setting(self.RX_LPF_BW, 30.72e6/2, "RX LPF BW", self.RX_TX_SETTINGS)
self.add_setting(self.TX_LPF_BW, 130.0e6, "TX LPF BW", self.RX_TX_SETTINGS)
# Calibration settings
self.add_setting(self.TX_I_DC_CORRECTION, -45, "TX I DC correction", "Calibration")
self.add_setting(self.TX_Q_DC_CORRECTION, 0, "TX Q DC correction", "Calibration")
self.add_setting(self.TX_I_GAIN_CORRECTION, 2047, "TX I Gain correction", "Calibration")
self.add_setting(self.TX_Q_GAIN_CORRECTION, 2039, "TX Q Gain correction", "Calibration")
self.add_setting(self.TX_PHASE_ADJUSTMENT, 3, "TX phase adjustment", "Calibration")
self.add_setting(self.RX_I_DC_CORRECTION, 0, "RX I DC correction", "Calibration")
self.add_setting(self.RX_Q_DC_CORRECTION, 0, "RX Q DC correction", "Calibration")
self.add_setting(self.RX_I_GAIN_CORRECTION, 2047, "RX I Gain correction", "Calibration")
self.add_setting(self.RX_Q_DC_CORRECTION, 2047, "TX Q Gain correction", "Calibration")
self.add_setting(self.RX_PHASE_ADJUSTMENT, 0, "TX phase adjustment", "Calibration")
self.add_setting(self.TX_I_DC_CORRECTION, -45, "TX I DC correction", self.CALIBRATION)
self.add_setting(self.TX_Q_DC_CORRECTION, 0, "TX Q DC correction", self.CALIBRATION)
self.add_setting(self.TX_I_GAIN_CORRECTION, 2047, "TX I Gain correction", self.CALIBRATION)
self.add_setting(self.TX_Q_GAIN_CORRECTION, 2039, "TX Q Gain correction", self.CALIBRATION)
self.add_setting(self.TX_PHASE_ADJUSTMENT, 3, "TX phase adjustment", self.CALIBRATION)
self.add_setting(self.RX_I_DC_CORRECTION, 0, "RX I DC correction", self.CALIBRATION)
self.add_setting(self.RX_Q_DC_CORRECTION, 0, "RX Q DC correction", self.CALIBRATION)
self.add_setting(self.RX_I_GAIN_CORRECTION, 2047, "RX I Gain correction", self.CALIBRATION)
self.add_setting(self.RX_Q_DC_CORRECTION, 2047, "TX Q Gain correction", self.CALIBRATION)
self.add_setting(self.RX_PHASE_ADJUSTMENT, 0, "TX phase adjustment", self.CALIBRATION)
# Pulse parameter options
self.add_pulse_parameter_option(self.TX, TXPulse)
@ -95,6 +95,14 @@ class LimeNQRModel(BaseSpectrometerModel):
def target_frequency(self, value):
self._target_frequency = value
@property
def averages(self):
return self._averages
@averages.setter
def averages(self, value):
self._averages = value
@property
def if_frequency(self):
return self._if_frequency