Added some information for views.

This commit is contained in:
jupfi 2024-05-29 16:04:40 +02:00
parent 36df848983
commit 964e98f8d8
3 changed files with 17 additions and 9 deletions

View file

@ -7,7 +7,7 @@ from .simulator_controller import SimulatorController
class Simulator(Spectrometer): class Simulator(Spectrometer):
def __init__(self): def __init__(self):
self.model = SimulatorModel() self.model = SimulatorModel()
self.controller = SimulatorController(self.model) self.controller = SimulatorController(self)
def run_sequence(self, sequence): def run_sequence(self, sequence):
result = self.controller.run_sequence(sequence) result = self.controller.run_sequence(sequence)

View file

@ -19,10 +19,10 @@ logger = logging.getLogger(__name__)
class SimulatorController(SpectrometerController): class SimulatorController(SpectrometerController):
"""The controller class for the nqrduck simulator module.""" """The controller class for the nqrduck simulator module."""
def __init__(self, model): def __init__(self, simulator):
"""Initializes the SimulatorController.""" """Initializes the SimulatorController."""
super().__init__() super().__init__()
self.model = model self.simulator = simulator
def run_sequence(self, sequence: QuackSequence) -> None: def run_sequence(self, sequence: QuackSequence) -> None:
"""This method is called when the start_measurement signal is received from the core. """This method is called when the start_measurement signal is received from the core.
@ -62,7 +62,7 @@ class SimulatorController(SpectrometerController):
result = result[evidx] result = result[evidx]
# Measurement name date + module + target frequency + averages + sequence name # Measurement name date + module + target frequency + averages + sequence name
name = f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Simulator - {self.model.target_frequency / 1e6} MHz - {self.model.averages} averages - {sequence.name}" name = f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Simulator - {self.simulator.model.target_frequency / 1e6} MHz - {self.simulator.model.averages} averages - {sequence.name}"
logger.debug(f"Measurement name: {name}") logger.debug(f"Measurement name: {name}")
measurement_data = Measurement( measurement_data = Measurement(
@ -81,7 +81,7 @@ class SimulatorController(SpectrometerController):
Returns: Returns:
Sample: The sample object created from the settings. Sample: The sample object created from the settings.
""" """
model = self.model model = self.simulator.model
atom_density = None atom_density = None
sample_volume = None sample_volume = None
sample_length = None sample_length = None
@ -190,7 +190,7 @@ class SimulatorController(SpectrometerController):
Returns: Returns:
Simulation: The simulation object created from the settings and the pulse sequence. Simulation: The simulation object created from the settings and the pulse sequence.
""" """
model = self.model model = self.simulator.model
# noise = float(model.get_setting_by_name(model.NOISE).value) # noise = float(model.get_setting_by_name(model.NOISE).value)
simulation = Simulation( simulation = Simulation(
@ -222,7 +222,9 @@ class SimulatorController(SpectrometerController):
float: The dwell time in seconds. float: The dwell time in seconds.
""" """
n_points = int( n_points = int(
self.model.get_setting_by_display_name(self.model.NUMBER_POINTS).value self.simulator.model.get_setting_by_display_name(
self.simulator.model.NUMBER_POINTS
).value
) )
simulation_length = self.calculate_simulation_length(sequence) simulation_length = self.calculate_simulation_length(sequence)
dwell_time = simulation_length / n_points dwell_time = simulation_length / n_points

View file

@ -111,6 +111,7 @@ class SimulatorModel(SpectrometerModel):
"Adds a specified level of random noise to the simulation to mimic real-world signal variations.", "Adds a specified level of random noise to the simulation to mimic real-world signal variations.",
min_value=0, min_value=0,
max_value=100, max_value=100,
slider=True,
) )
self.add_setting("noise", noise_setting) self.add_setting("noise", noise_setting)
@ -185,6 +186,7 @@ class SimulatorModel(SpectrometerModel):
"The absolute temperature during the experiment. This influences the SNR of the measurement.", "The absolute temperature during the experiment. This influences the SNR of the measurement.",
min_value=0.1, min_value=0.1,
max_value=400, max_value=400,
slider=True,
) )
self.add_setting("temperature", temperature_setting) self.add_setting("temperature", temperature_setting)
@ -195,6 +197,7 @@ class SimulatorModel(SpectrometerModel):
"The signal loss occurring in the transmission path, affecting the effective RF pulse power.", "The signal loss occurring in the transmission path, affecting the effective RF pulse power.",
min_value=0.1, min_value=0.1,
max_value=60, max_value=60,
slider=True,
) )
self.add_setting("loss_tx", loss_tx_setting) self.add_setting("loss_tx", loss_tx_setting)
@ -205,6 +208,7 @@ class SimulatorModel(SpectrometerModel):
"The signal loss in the reception path, which can reduce the signal that is ultimately detected.", "The signal loss in the reception path, which can reduce the signal that is ultimately detected.",
min_value=0.1, min_value=0.1,
max_value=60, max_value=60,
slider=True,
) )
self.add_setting("loss_rx", loss_rx_setting) self.add_setting("loss_rx", loss_rx_setting)
@ -214,7 +218,9 @@ class SimulatorModel(SpectrometerModel):
2884, 2884,
"Conversion factor (spectrometer units / V)", "Conversion factor (spectrometer units / V)",
) )
self.add_setting("conversion_factor", conversion_factor_setting) # Conversion factor for the LimeSDR based spectrometer self.add_setting(
"conversion_factor", conversion_factor_setting
) # Conversion factor for the LimeSDR based spectrometer
# Sample settings # Sample settings
sample_name_setting = StringSetting( sample_name_setting = StringSetting(