Skip to content

Commit 6b2c428

Browse files
authored
Workflows (#51)
* first attempt * Update setup.py * typo * some tests * ignore failing test for now just to make PR less confusing to review * Update default.py * codeql * move some scripts to tests some tests still need to be written * Update heterodyne.py
1 parent 65dc884 commit 6b2c428

File tree

3 files changed

+90
-88
lines changed

3 files changed

+90
-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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
scan = exp.run(ham, mp=False, windowed=True)
46+
47+
efields = scan.efields()
48+
zi0=scan.sig.channels[0][:]
49+
zi1=scan.sig.channels[1][:]
50+
sig=zi0+zi1
51+
52+
driven_sig = 1j * efields.prod(axis=-2)
53+
54+
diff = []
55+
driven_diff = []
56+
57+
for i in range(scan.npulses):
58+
lo = efields[..., i, :]
59+
if scan.pm[i] == 1:
60+
lo = lo.conjugate()
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)):
75+
76+
axi = plt.subplot(gs[i])
77+
axi.pcolormesh(exp.d2.points, exp.d1.points, -di,
78+
vmin=-np.abs(di).max(),
79+
vmax=np.abs(di).max(),
80+
cmap='signed')
81+
axi2 = plt.subplot(gs[i+3])
82+
axi2.pcolormesh(exp.d2.points, exp.d1.points, ddi,
83+
vmin=-np.abs(ddi).max(),
84+
vmax=np.abs(ddi).max(),
85+
cmap='signed')
86+
[ax.grid(True) for ax in [axi, axi2]]
87+
88+
plt.show()

0 commit comments

Comments
 (0)