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

cleanup/improve tests

parent 16ce5e48
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,8 @@
from pulse_lib.tests.configurations.test_configuration import context
#%%
# %%
def test1():
pulse = context.init_pulselib(n_gates=2, n_sensors=2)
......@@ -62,7 +63,7 @@ def test4():
s = pulse.mk_segment()
s.P1.add_block(0, 20, 100) #lp.linspace(-100, 100, 5, axis=0, name='amplitude', unit='mV'))
s.P1.add_block(0, 20, 100) # lp.linspace(-100, 100, 5, axis=0, name='amplitude', unit='mV'))
s.P2.add_block(0, 20, -100)
s.SD1.acquire(0, 1000, threshold=1.0, wait=True)
s.SD2.acquire(0, 1000, threshold=2.0, wait=True)
......@@ -74,13 +75,13 @@ def test4():
return context.run('m_param2', sequence, m_param)
#%%
# %%
if __name__ == '__main__':
ds1 = test1()
ds2 = test2()
ds3 = []
for iq_mode in [#'Complex',
for iq_mode in [ # 'Complex',
'I', 'Q', 'amplitude', 'phase', 'I+Q', 'amplitude+phase']:
ds3.append(test3(iq_mode))
ds4 = test4()
......@@ -10,16 +10,15 @@ from pulse_lib.qblox.pulsar_sequencers import PulsarConfig
PulsarConfig.NS_SUB_DIVISION = 10
def conveyor_cosine_modulation(
def conveyor_cosine_modulation_position(
t: np.ndarray,
duration: float,
amplitude: float,
start_pos: float,
stop_pos: float,
mod_period: float,
phase: float,
) -> np.ndarray:
"""Creates a cosine modulated sine pulse: y = sin(center - d*cos(2*pi*t/period) + phase),
"""Cosine modulated position of the charge: charge_pos = center - d*cos(2*pi*t/period) + phase),
where d = pi*(stop-start) and center = pi*(start+stop).
Args:
......@@ -37,18 +36,19 @@ def conveyor_cosine_modulation(
Note:
Max frequency (of sin) is max of -d*sin(2*pi*t/period)*2*pi/period = d*2*pi/period
"""
center = np.pi*(start_pos + stop_pos)
d = np.pi*(stop_pos - start_pos)
return amplitude * np.sin(center - d*np.cos(2*np.pi*t/mod_period) + phase)
center = (start_pos + stop_pos)/2
d = (stop_pos - start_pos)/2
return amplitude * (center - d*np.cos(2*np.pi*t/mod_period))
def conveyor_cosine_modulation_position(
def conveyor_cosine_modulation(
t: np.ndarray,
duration: float,
amplitude: float,
start_pos: float,
stop_pos: float,
mod_period: float,
phase: float,
) -> np.ndarray:
"""Creates a cosine modulated sine pulse: y = sin(center - d*cos(2*pi*t/period) + phase),
where d = pi*(stop-start) and center = pi*(start+stop).
......@@ -68,9 +68,8 @@ def conveyor_cosine_modulation_position(
Note:
Max frequency (of sin) is max of -d*sin(2*pi*t/period)*2*pi/period = d*2*pi/period
"""
center = np.pi*(start_pos + stop_pos)
d = np.pi*(stop_pos - start_pos)
return amplitude * (center - d*np.cos(2*np.pi*t/mod_period))/(2*np.pi)
charge_pos = conveyor_cosine_modulation_position(t, duration, 1.0, start_pos, stop_pos, mod_period)
return amplitude * np.sin(2*np.pi*charge_pos + phase)
def test1(hres=False):
......@@ -221,7 +220,6 @@ def test3(hres=False, t_wait=0.0):
return context.run('cos_modulation3', sequence, m_param)
# @@@ Maxim: shuttling => X90 gate.
# Qblox: break on 4 ns alignment. Z90 = ~2 ns, mZ90= ~6 ns.
# Set build specific break length.
......
......@@ -29,8 +29,8 @@ def test1(t):
s.reset_time()
s.reset_time()
s.SD1.acquire(0, 20)
s.wait(20)
s.SD1.acquire(0, 40)
s.wait(40)
sequence = pulse.mk_sequence(segments)
sequence.n_rep = 2
......@@ -70,8 +70,8 @@ def test2(t):
s.reset_time()
s.reset_time()
s.SD1.acquire(0, 20)
s.wait(20)
s.SD1.acquire(0, 40)
s.wait(40)
sequence = pulse.mk_sequence(segments)
sequence.n_rep = 2
......
......@@ -7,7 +7,6 @@ def test1():
"""Specific test for bug with ramp > 100 ns at multiple of 4 ns followed and constant voltage of 0.0V >= 4 ns.
"""
pulse = context.init_pulselib(n_gates=3)
# context.station.AWG1.set_digital_filter_mode(3)
s = pulse.mk_segment(hres=False)
......@@ -35,6 +34,40 @@ def test1():
context.plot_awgs(sequence, xlim=(0, 800), ylim=(-0.01, 0.12))
def test2():
pulse = context.init_pulselib(n_gates=2)
s = pulse.mk_segment(hres=False)
s.P1.wait(10)
s.P1.reset_time()
s.P1.add_block(10, 200, 100.0)
s.P1.add_ramp_ss(200, 340, 100.0, 0.0)
s.P1.reset_time()
s.P1.add_ramp_ss(400, 520, 0.0, 100.0)
s.P1.add_block(520, 700, 100.0)
s.P1.add_ramp_ss(700, 840, 100.0, 0.0)
s.P2.wait(20)
s.P2.reset_time()
s.P2.add_block(10, 200, 100.0)
s.P2.add_ramp_ss(200, 340, 100.0, 0.0)
s.P2.reset_time()
s.P2.add_ramp_ss(400, 520, 0.0, 100.0)
s.P2.add_block(520, 700, 100.0)
s.P2.add_ramp_ss(700, 840, 100.0, 0.0)
s.wait(200)
sequence = pulse.mk_sequence([s])
sequence.n_rep = 2
context.plot_awgs(sequence, xlim=(0, 1300), ylim=(-0.01, 0.12))
# %%
if __name__ == '__main__':
test1()
test2()
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