Skip to content

Commit ac6b10b

Browse files
committed
Update heterodyne.py
1 parent 524eb33 commit ac6b10b

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

tests/mixed/heterodyne.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@
4242

4343
def check_phase():
4444
# TODO: use assertions to check phase
45-
...
46-
47-
48-
if __name__ == "__main__":
4945
scan = exp.run(ham, mp=False, windowed=True)
5046

5147
efields = scan.efields()
@@ -55,26 +51,37 @@ def check_phase():
5551

5652
driven_sig = 1j * efields.prod(axis=-2)
5753

58-
# plot amplitude
59-
import matplotlib.pyplot as plt
60-
plt.close('all')
61-
fig, gs = wt.artists.create_figure(width='single', nrows=2, cols=[1, 1, 1])
54+
diff = []
55+
driven_diff = []
56+
6257
for i in range(scan.npulses):
6358
lo = efields[..., i, :]
6459
if scan.pm[i] == 1:
6560
lo = lo.conjugate()
66-
diff = (lo * sig).imag.sum(axis=-1)
67-
driven_diff = (lo * driven_sig).imag.sum(axis=-1)
61+
diff.append((lo * sig).imag.sum(axis=-1))
62+
driven_diff.append((lo * driven_sig).imag.sum(axis=-1))
63+
64+
return diff, driven_diff
65+
66+
67+
if __name__ == "__main__":
68+
diff, driven_diff = check_phase()
69+
70+
# plot amplitude
71+
import matplotlib.pyplot as plt
72+
plt.close('all')
73+
fig, gs = wt.artists.create_figure(width='single', nrows=2, cols=[1, 1, 1])
74+
for i, (di, ddi) in enumerate(zip(diff, driven_diff)):
6875

6976
axi = plt.subplot(gs[i])
70-
axi.pcolormesh(exp.d2.points, exp.d1.points, -diff,
71-
vmin=-np.abs(diff).max(),
72-
vmax=np.abs(diff).max(),
77+
axi.pcolormesh(exp.d2.points, exp.d1.points, -di,
78+
vmin=-np.abs(di).max(),
79+
vmax=np.abs(di).max(),
7380
cmap='signed')
7481
axi2 = plt.subplot(gs[i+3])
75-
axi2.pcolormesh(exp.d2.points, exp.d1.points, driven_diff,
76-
vmin=-np.abs(driven_diff).max(),
77-
vmax=np.abs(driven_diff).max(),
82+
axi2.pcolormesh(exp.d2.points, exp.d1.points, ddi,
83+
vmin=-np.abs(ddi).max(),
84+
vmax=np.abs(ddi).max(),
7885
cmap='signed')
7986
[ax.grid(True) for ax in [axi, axi2]]
8087

0 commit comments

Comments
 (0)