1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
### import ####################################################################
import os
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['font.size'] = 14
import WrightTools as wt
import WrightData as wd
### define ####################################################################
cmap = wt.artists.colormaps['default']
directory = os.path.dirname(__file__)
### scatter interference in TrEE ###########################################################
if True:
import NISE
import NISE.lib.measure as m
import NISE.experiments.trive as trive
H0 = NISE.hamiltonians.H0
reload(trive)
reload(m)
delay_points = np.linspace(-400, 400, 201)
if False:
# simulate
for delay_state in [False, True]:
trive.exp.set_coord(trive.ss, 100.)
if delay_state:
print 'DELAY STATE'
trive.d2 = trive.S.Axis(1, 'd', name=r'$\mathsf{\tau_{old}}$',
units = 'fs',
pulse_class_name='Gauss_rwa')
d2 = trive.d2
d1 = trive.d1
d2.points = delay_points
d1.points = delay_points
H = H0.Omega()
H.TOs = [1, 2, 3, 4, 5, 6]
NISE.lib.scan.default_path = directory
#trive.exp.timestep = 80.
trive.exp.early_buffer = 1000.
trive.exp.late_buffer = 1000.
scan = trive.exp.scan(d1, d2, H=H)
print scan.timestep
scan.run(autosave=True, mp=False)
simulation_ps = {'old': os.path.join(directory, '2016.05.02 17-48-41 old delay space'),
'new': os.path.join(directory, '2016.05.02 16-33-15 current delay space')}
def measure_and_plot(ax0, ax1, key, scatter):
# get simulation path
simulation_path = simulation_ps[key]
# measure
scan = trive.S.Scan._import(simulation_path)
sig1 = m.Measure(scan, m.Scatter, m.Mono, m.SLD)
m.Mono.slitwidth = 120.
m.Scatter.pulse = scatter # pulse contributions are SCALED by this list: [1, -2, 2']
m.Scatter.chop = False
m.Scatter.ratio = 0.05
sig1.run(save=False)
m.Scatter.chop = True
sig2 = m.Measure(scan, m.Scatter, m.Mono, m.SLD)
sig2.run(save=False)
sig1.pol -= sig2.pol
data = wt.data.from_NISE(sig1, flip_delays=False)
if key == 'old':
data.transpose()
if key == 'new':
data.transpose()
data.axes[0].points *= -1
# plot
xi = data.axes[1].points
yi = data.axes[0].points
zi = data.channels[0].values
zi /= zi.max()
levels = np.linspace(0, 1, 200)
X, Y, Z = wt.artists.pcolor_helper(xi, yi, zi)
ax0.pcolor(X, Y, Z, vmin=0, vmax=1, cmap=cmap)
ax0.set_xlim(xi.min(), xi.max())
ax0.set_ylim(yi.min(), yi.max())
ax0.grid()
wt.artists.diagonal_line(xi, yi, ax=ax0, ls='-')
ax0.axhline(0, c='k')
ax0.axvline(0, c='k')
plt.setp(ax0.get_xticklabels(), visible=False)
plt.setp(ax0.get_yticklabels(), visible=False)
if key == 'old':
ax0.set_xlabel(r'$\mathsf{\tau_{2^\prime1}}$', fontsize=18)
if key == 'new':
ax0.set_xlabel(r'$\mathsf{\tau_{22^\prime}}$', fontsize=18)
# fft
zi = data.channels[0].values
fzi = np.fft.fft2(zi)
fzi = np.fft.fftshift(fzi)
step = data.axes[0].min_max_step()[2]
freqs = np.fft.fftfreq(data.axes[0].points.size, step)
freqs = np.fft.fftshift(freqs)
# plot fft
fzi /= fzi.max()
fzi = np.abs(fzi)
X, Y, Z = wt.artists.pcolor_helper(freqs, freqs, fzi)
ax1.pcolor(X, Y, Z, vmin=0, vmax=0.1, cmap=cmap)
ax1.set_xlim(freqs.min(), freqs.max())
ax1.set_ylim(freqs.min(), freqs.max())
ax1.grid()
plt.setp(ax1.get_xticklabels(), visible=False)
plt.setp(ax1.get_yticklabels(), visible=False)
if key == 'old':
ax1.set_xlabel(r'$\mathsf{f_{2^\prime1}}$', fontsize=18)
if key == 'new':
ax1.set_xlabel(r'$\mathsf{f_{22^\prime}}$', fontsize=18)
if True:
# measure, make figures
# OLD -----------------------------------------------------------------
fig, gs = wt.artists.create_figure(width='double', nrows=2,
cols=[1, 1, 1, 'cbar'], hspace=0.5)
# old w1
ax0 = plt.subplot(gs[0, 0])
ax0.set_ylabel(r'$\mathsf{\tau_{21}}$', fontsize=18)
ax1 = plt.subplot(gs[1, 0])
ax1.set_ylabel(r'$\mathsf{f_{21}}$', fontsize=18)
measure_and_plot(ax0, ax1, 'old', [1, 0, 0])
ax0.set_title(r'$\mathsf{1}$', fontsize=20, y=1.04)
# old w-2
ax0 = plt.subplot(gs[0, 1])
ax1 = plt.subplot(gs[1, 1])
measure_and_plot(ax0, ax1, 'old', [0, 1, 0])
ax0.set_title(r'$\mathsf{-2}$', fontsize=20, y=1.04)
# old w2'
ax0 = plt.subplot(gs[0, 2])
ax1 = plt.subplot(gs[1, 2])
measure_and_plot(ax0, ax1, 'old', [0, 0, 1])
ax0.set_title(r'$\mathsf{2^\prime}$', fontsize=20, y=1.04)
# colorbar
cax = plt.subplot(gs[:, -1])
ticks = np.linspace(0, 1, 11)
matplotlib.colorbar.ColorbarBase(cax, cmap=cmap, ticks=ticks)
cax.set_ylabel('intensity', fontsize=18)
# finish
plt.savefig('scatter interference in TrEE old.png', dpi=300, transparent=True, pad_inches=1)
plt.close(fig)
# NEW -----------------------------------------------------------------
fig, gs = wt.artists.create_figure(width='double', nrows=2,
cols=[1, 1, 1, 'cbar'], hspace=0.5)
# new w1
ax0 = plt.subplot(gs[0, 0])
ax0.set_ylabel(r'$\mathsf{\tau_{21}}$', fontsize=18)
ax1 = plt.subplot(gs[1, 0])
ax1.set_ylabel(r'$\mathsf{f_{21}}$', fontsize=18)
measure_and_plot(ax0, ax1, 'new', [1, 0, 0])
ax0.set_title(r'$\mathsf{1}$', fontsize=20, y=1.04)
# new w-2
ax0 = plt.subplot(gs[0, 1])
ax1 = plt.subplot(gs[1, 1])
measure_and_plot(ax0, ax1, 'new', [0, 1, 0])
ax0.set_title(r'$\mathsf{-2}$', fontsize=20, y=1.04)
# new w2'
ax0 = plt.subplot(gs[0, 2])
ax1 = plt.subplot(gs[1, 2])
measure_and_plot(ax0, ax1, 'new', [0, 0, 1])
ax0.set_title(r'$\mathsf{2^\prime}$', fontsize=20, y=1.04)
# colorbar
cax = plt.subplot(gs[:, -1])
ticks = np.linspace(0, 1, 11)
matplotlib.colorbar.ColorbarBase(cax, cmap=cmap, ticks=ticks)
cax.set_ylabel('intensity', fontsize=18)
# finish
plt.savefig('scatter interference in TrEE current.png', dpi=300, transparent=True, pad_inches=1)
plt.close(fig)
|