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

Updated tests

parent 8cbbe29f
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ class IQDemodulator:
self.frequency = frequency
def demodulate(self, t_start, ch_data):
# sample_rate = self.digitizer.sample_rate.cache()
# sample_rate = self.digitizer.sample_rate.cache()
n = ch_data.shape[-1]
t = np.arange(0, n) * (1/self.sample_rate)
demod_vector = np.exp(-2j*np.pi*self.frequency*t)
......@@ -34,8 +34,8 @@ def test_iqdemod_func():
def test1():
pulse = context.init_pulselib(n_gates=2, n_sensors=2, rf_sources=True)
pulse.digitizer_channels['SD1'].iq_out=True
pulse.digitizer_channels['SD2'].iq_out=True
pulse.digitizer_channels['SD1'].iq_out = True
pulse.digitizer_channels['SD2'].iq_out = True
backend = context.pulse._backend
if backend == 'Tektronix_5014':
......@@ -72,8 +72,8 @@ def test1():
m_param = sequence.get_measurement_param(iq_mode='amplitude+phase')
context.add_hw_schedule(sequence)
t = np.arange(0, t_measure, 1e9/sample_rate) # [ns]
t *= 1e-9 # [s]
t = np.arange(0, t_measure, 1e9/sample_rate) # [ns]
t *= 1e-9 # [s]
context.set_mock_data({
'SD1': [np.cos(2*np.pi*f*t+np.pi/10)]*trigger_factor,
......@@ -90,7 +90,7 @@ def demodulate(t_start, data):
n = data.shape[-1]
v = np.full(n, -1.0)
v = v.cumprod()
if n%2 == 1:
if n % 2 == 1:
print('Warning: odd number of points')
# set last to 0, because average of vector must be 0.
v[-1] = 0
......
......@@ -46,8 +46,8 @@ def test1():
m_param = sequence.get_measurement_param(iq_mode='amplitude+phase')
context.add_hw_schedule(sequence)
t = np.arange(0, t_measure, 1e9/sample_rate) # [ns]
t *= 1e-9 # [s]
t = np.arange(0, t_measure, 1e9/sample_rate) # [ns]
t *= 1e-9 # [s]
context.set_mock_data({
'SD1': [np.cos(2*np.pi*f1*t+np.pi/10)]*trigger_factor,
......
......@@ -18,12 +18,12 @@ def test1():
2000,
iq_mode='Complex')
data1 = m_param1D()
# data1 = m_param1D()
print(m_param1D.names)
print(data1)
data2 = m_param2D()
# print(data1)
# data2 = m_param2D()
print(m_param2D.names)
print(data2)
# print(data2)
print(flush=True)
return context.run('fast_scan', m_param1D, m_param2D)
......@@ -43,12 +43,12 @@ def test2():
2000,
iq_mode='I')
data1 = m_param1D()
# data1 = m_param1D()
print(m_param1D.names)
print(data1)
data2 = m_param2D()
# print(data1)
# data2 = m_param2D()
print(m_param2D.names)
print(data2)
# print(data2)
print(flush=True)
return context.run('fast_scan_IQ', m_param1D, m_param2D)
......@@ -66,19 +66,33 @@ def test3():
'P1', 100, 51,
'P2', 20, 21,
2000,
iq_mode='abs+angle')
iq_mode='I+Q')
data1 = m_param1D()
# data1 = m_param1D()
print(m_param1D.names)
print(data1)
data2 = m_param2D()
# print(data1)
# data2 = m_param2D()
print(m_param2D.names)
print(data2)
# print(data2)
print(flush=True)
return context.run('fast_scan_IQ', m_param1D, m_param2D)
def test4():
pulse = context.init_pulselib(n_gates=2, n_sensors=2, rf_sources=True)
m_param2D = fast_scan2D_param(
pulse,
'P1', 100, 51,
'P2', 20, 21,
2000,
iq_mode='amplitude+phase')
return context.run('fast_scan_IQ', m_param2D)
if __name__ == '__main__':
ds1 = test1()
ds2 = test2()
ds3 = test3()
ds4 = test4()
......@@ -2,7 +2,7 @@
from pulse_lib.tests.configurations.test_configuration import context
#%%
# %%
def test1():
pulse = context.init_pulselib(n_gates=2, n_sensors=2)
......@@ -10,19 +10,22 @@ def test1():
s.P1.add_block(0, 20, 100)
s.P2.add_block(0, 20, -100)
s.SD1.acquire(0, 1000, wait=True)
s.SD1.acquire(0, 1000, 'm1', wait=True)
s.SD2.acquire(0, 1000, wait=True, threshold=3000, accept_if=1)
sequence = pulse.mk_sequence([s])
sequence.n_rep = 10
m_param = sequence.get_measurement_param(selectors=False, total_selected=False)
m_param = sequence.get_measurement_param(accept_mask=True)
m_param.add_measurement_histogram('m1', 20, (0.0, 20_000.0)) # (m_name, bins, (min,nax))
m_param.add_sensor_histogram('SD1', 20, (0.0, 20_000.0))
m_param.add_sensor_histogram('SD2', 20, (0.0, 20_000.0), accepted_only=True)
context.add_hw_schedule(sequence)
return context.run('histogram', sequence, m_param)
#%%
# %%
if __name__ == '__main__':
ds1 = test1()
......@@ -136,10 +136,9 @@ def test3():
# sequence.dt(0.2)
# context.plot_awgs(sequence, ylim=(-0.100,0.100), xlim=(0, 26))
for _ in range(20):
for t in sequence.dt.values:
sequence.dt(t)
context.plot_awgs(sequence, ylim=(-0.100,0.100))
for t in sequence.dt.values:
sequence.dt(t)
context.plot_awgs(sequence, ylim=(-0.100,0.100), xlim=(0, 40))
# return context.run('hres2', sequence)
......
......@@ -9,7 +9,28 @@ def test1(filter_mode):
s = pulse.mk_segment()
s.wait(100)
s.P1.add_block(20, 40, 100.0)
s.P1.add_block(20, 220, 100.0)
sequence = pulse.mk_sequence([s])
sequence.n_rep = 1
context.add_hw_schedule(sequence)
context.plot_awgs(sequence, analogue_out=True)
# return context.run('hres1', sequence)
def test2(filter_mode, t_ramp):
pulse = context.init_pulselib(n_gates=1)
context.station.AWG1.set_digital_filter_mode(filter_mode)
s = pulse.mk_segment()
p1 = s.P1
p1.wait(20)
p1.reset_time()
p1.add_ramp_ss(0, t_ramp, 0, 100.0)
p1.add_block(t_ramp, 200, 100.0)
p1.reset_time()
p1.add_ramp_ss(0, t_ramp, 100.0, 0.0)
sequence = pulse.mk_sequence([s])
sequence.n_rep = 1
......@@ -24,3 +45,7 @@ if __name__ == '__main__':
test1(0)
test1(1)
test1(3)
test2(0, 4)
test2(1, 4)
test2(3, 4)
from pulse_lib.tests.configurations.test_configuration import context
#%%
import pulse_lib.segments.utility.looping as lp
def test():
......@@ -24,6 +26,7 @@ def test():
context.plot_segments([s], index=[i])
sequence = pulse.mk_sequence([s])
sequence.n_rep = 10
context.add_hw_schedule(sequence)
for n in sequence.n_pulses.values:
sequence.n_pulses(n)
......
......@@ -39,7 +39,7 @@ class PhaseParameter(Parameter):
def __init__(self, pulselib, digitizer_channel_name):
super().__init__(
name=f'{digitizer_channel_name} phase',
label=f'{digitizer_channel_name} phasey',
label=f'{digitizer_channel_name} phase',
unit='degrees')
self.channel = pulselib.digitizer_channels[digitizer_channel_name]
......
......@@ -66,9 +66,9 @@ def test2():
s.P1.add_block(10, 20, -10)
s.wait(30, reset_time=True)
s.SD1.acquire(0, t_measure, 'm0', threshold=0.0024, zero_on_high=True, wait=True)
s.SD1.acquire(0, t_measure, 'm0', threshold=0.0024, zero_on_high=False, wait=True)
s.wait(200, reset_time=True)
s.SD1.acquire(0, t_measure, 'm1', threshold=0.0024, zero_on_high=True, wait=True)
s.SD1.acquire(0, t_measure, 'm1', threshold=0.0024, zero_on_high=False, wait=True)
s.wait(feedback_latency, reset_time=True)
s_true = pulse.mk_segment()
......@@ -77,7 +77,7 @@ def test2():
s_false.q1.add_MW_pulse(10, 20, 80.0, 2.450e9)
s_false.wait(10, reset_time=True)
cond_seg1 = conditional_segment(MeasurementRef('m1'), [s_false, s_true], name='cond')
cond_seg1 = conditional_segment(MeasurementRef('m0'), [s_false, s_true], name='cond')
sequence = pulse.mk_sequence([s1, cond_seg1])
sequence.n_rep = 3
......@@ -92,6 +92,6 @@ def test2():
#%%
if __name__ == '__main__':
context.init_coretools()
# ds1 = test1()
ds1 = test1()
ds2 = test2()
ds2.m1_1(), ds2.m1_2(), ds2.m1_3(), ds2.m1_4()
print(ds2.m1_1(), ds2.m1_2(), ds2.m1_3(), ds2.m1_4())
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