Skip to content
Snippets Groups Projects
Commit 81db1b25 authored by Sander Snoo's avatar Sander Snoo
Browse files

Added add_long_block and add_long_wait with lower sample rate

parent 162a8c5f
No related branches found
No related tags found
No related merge requests found
......@@ -109,7 +109,7 @@ class sequence_builder:
template.build(segment, reset=False, **kwargs)
self._segments.append(cond_seg)
def wait(self, channels, t, amplitudes, reset_time=True):
def add_block(self, channels, t, amplitudes, reset_time=True):
'''
Adds a block to each of the specified channels.
Args:
......@@ -125,39 +125,58 @@ class sequence_builder:
if reset_time == True:
self.reset_time()
def add_block(self, channels, t, amplitudes, reset_time=True):
def add_ramp(self, channels, t, start_amplitudes, stop_amplitudes,
reset_time=True):
'''
Adds a block to each of the specified channels.
Adds a ramp to each of the specified channels.
Args:
t (float, loop_obj): duration of the block
channels (List[str]): channels to apply the block to
amplitudes (List[float, loop_obj]): amplitude per channel
start_amplitudes (List[float, loop_obj]): start amplitude per channel
stop_amplitudes (List[float, loop_obj]): stop amplitude per channel
reset_time (bool): if True resets segment time after block
'''
segment = self._get_segment()
for channel, amplitude in zip(channels, amplitudes):
segment[channel].add_block(0, t, amplitude)
for channel, start_amp, stop_amp in zip(channels, start_amplitudes, stop_amplitudes):
segment[channel].add_ramp_ss(0, t, start_amp, stop_amp)
if reset_time == True:
self.reset_time()
def add_ramp(self, channels, t, start_amplitudes, stop_amplitudes,
reset_time=True):
def add_long_block(self, channels, t, amplitudes, sample_rate=1e9, reset_time=True):
'''
Adds a ramp to each of the specified channels.
Adds a long block to each of the specified channels.
Sample rate can be lowered to reduce the wavelength.
Number of samples must be > 2000.
Args:
t (float, loop_obj): duration of the block
channels (List[str]): channels to apply the block to
start_amplitudes (List[float, loop_obj]): start amplitude per channel
stop_amplitudes (List[float, loop_obj]): stop amplitude per channel
amplitudes (List[float, loop_obj]): amplitude per channel
reset_time (bool): if True resets segment time after block
'''
self.reset_time()
self._segment = None
segment = self._get_segment()
for channel, start_amp, stop_amp in zip(channels, start_amplitudes, stop_amplitudes):
segment.add_ramp_ss(0, t, start_amp, stop_amp)
segment.sample_rate = sample_rate
for channel, amplitude in zip(channels, amplitudes):
segment[channel].add_block(0, t, amplitude)
if reset_time == True:
self.reset_time()
self.reset_time()
self._segment = None
def add_long_wait(self, t_wait, sample_rate=1e9):
'''
Inserts a long wait using a new segment with a specified sample rate.
Number of samples must be > 2000.
'''
self.reset_time()
self._segment = None
segment = self._get_segment()
segment.sample_rate = sample_rate
# just pick first channel to set wait time
segment[segment.channels[0]].wait(t_wait)
self.reset_time()
self._segment = None
def append(self, other):
# close active segments in both sequences
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment