Skip to content

Commit 524eb33

Browse files
committed
move some scripts to tests
some tests still need to be written
1 parent 693d798 commit 524eb33

File tree

3 files changed

+83
-88
lines changed

3 files changed

+83
-88
lines changed

WrightSim/experiment/_scan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def efields(self, windowed=None):
259259
efields_shape = list(efp.shape)
260260
if windowed == self.windowed:
261261
efields_shape[-1] = self.iprime
262-
efields = np.zeros((efields_shape), dtype=np.complex)
262+
efields = np.zeros((efields_shape), dtype=np.complex128)
263263
with wt.kit.Timer():
264264
for ind in np.ndindex(tuple(efields_shape[:-2])):
265265
efi = self.pulse_class.pulse(efp[ind], self.t_args, pm=self.pm)
@@ -272,7 +272,7 @@ def efields(self, windowed=None):
272272
else:
273273
efields_shape[-1] = self.t.size
274274

275-
efields = np.zeros((efields_shape), dtype=np.complex)
275+
efields = np.zeros((efields_shape), dtype=np.complex128)
276276
with wt.kit.Timer():
277277
for ind in np.ndindex(tuple(efields_shape[:-2])):
278278
efi = self.pulse_class.pulse(efp[ind], self.t_args, pm=self.pm)

scripts/test_default_phase_delay_dependence.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

tests/mixed/heterodyne.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""
2+
look at the phase fringes ddue to interference with each pulse
3+
4+
E1 interference (first column) should modulate along y-axis
5+
E2 interference (second column) should modulate along diagonal
6+
E2p interference (third column) should modulate along x-axis
7+
8+
simulated and driven experiments (top and bottom rows, resp.)
9+
should have the same phase of fringes
10+
"""
11+
12+
13+
import WrightSim as ws
14+
import WrightTools as wt
15+
import numpy as np
16+
17+
dt = 50
18+
nt = 21
19+
wn_to_omega = 2 * np.pi * 3e-5 # cm / s
20+
w_central = 3000
21+
coupling = 0
22+
23+
ham = ws.hamiltonian.Hamiltonian(
24+
w_central=w_central * wn_to_omega,
25+
coupling=coupling * wn_to_omega,
26+
)
27+
ham.recorded_elements = [7, 8]
28+
29+
exp = ws.experiment.builtin('trive')
30+
exp.w1.points = w_central # wn
31+
exp.w2.points = w_central # wn
32+
exp.d2.points = np.linspace(-10, 10, nt) # fs
33+
exp.d1.points = np.linspace(-10, 10, nt)
34+
exp.s1.points = exp.s2.points = dt # fs
35+
36+
exp.d1.active = exp.d2.active = True
37+
38+
exp.timestep = 1
39+
exp.early_buffer = 100.
40+
exp.late_buffer = 300.
41+
42+
43+
def check_phase():
44+
# TODO: use assertions to check phase
45+
...
46+
47+
48+
if __name__ == "__main__":
49+
scan = exp.run(ham, mp=False, windowed=True)
50+
51+
efields = scan.efields()
52+
zi0=scan.sig.channels[0][:]
53+
zi1=scan.sig.channels[1][:]
54+
sig=zi0+zi1
55+
56+
driven_sig = 1j * efields.prod(axis=-2)
57+
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])
62+
for i in range(scan.npulses):
63+
lo = efields[..., i, :]
64+
if scan.pm[i] == 1:
65+
lo = lo.conjugate()
66+
diff = (lo * sig).imag.sum(axis=-1)
67+
driven_diff = (lo * driven_sig).imag.sum(axis=-1)
68+
69+
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(),
73+
cmap='signed')
74+
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(),
78+
cmap='signed')
79+
[ax.grid(True) for ax in [axi, axi2]]
80+
81+
plt.show()

0 commit comments

Comments
 (0)