mirror of
https://github.com/nqrduck/quackseq-simulator.git
synced 2025-01-02 18:08:07 +00:00
Moved general methods to base class.
This commit is contained in:
parent
014bf53efd
commit
36df848983
1 changed files with 1 additions and 51 deletions
|
@ -226,54 +226,4 @@ class SimulatorController(SpectrometerController):
|
|||
)
|
||||
simulation_length = self.calculate_simulation_length(sequence)
|
||||
dwell_time = simulation_length / n_points
|
||||
return dwell_time
|
||||
|
||||
def calculate_simulation_length(self, sequence: QuackSequence) -> float:
|
||||
"""This method calculates the simulation length based on the settings and the pulse sequence.
|
||||
|
||||
Returns:
|
||||
float: The simulation length in seconds.
|
||||
"""
|
||||
events = sequence.events
|
||||
simulation_length = 0
|
||||
for event in events:
|
||||
simulation_length += event.duration
|
||||
return simulation_length
|
||||
|
||||
def translate_rx_event(self, sequence: QuackSequence) -> tuple:
|
||||
"""This method translates the RX event of the pulse sequence to the limr object.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the start and stop time of the RX event in µs
|
||||
"""
|
||||
# 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
|
||||
|
||||
previous_events_duration = 0
|
||||
# offset = 0
|
||||
rx_duration = 0
|
||||
for event in events:
|
||||
logger.debug("Event %s has parameters: %s", event.name, event.parameters)
|
||||
for parameter in event.parameters.values():
|
||||
logger.debug(
|
||||
"Parameter %s has options: %s", parameter.name, parameter.options
|
||||
)
|
||||
|
||||
if (
|
||||
parameter.name == sequence.RX_READOUT
|
||||
and parameter.get_option_by_name(RXReadout.RX).value
|
||||
):
|
||||
# Get the length of all previous events
|
||||
previous_events = events[: events.index(event)]
|
||||
previous_events_duration = sum(
|
||||
[event.duration for event in previous_events]
|
||||
)
|
||||
rx_duration = event.duration
|
||||
|
||||
rx_begin = float(previous_events_duration)
|
||||
if rx_duration:
|
||||
rx_stop = rx_begin + float(rx_duration)
|
||||
return rx_begin * 1e6, rx_stop * 1e6
|
||||
|
||||
else:
|
||||
return None, None
|
||||
return dwell_time
|
Loading…
Reference in a new issue