From 9d89c09dfe49aba4c68b6911600715add419babd Mon Sep 17 00:00:00 2001 From: Blaise Thompson Date: Tue, 27 Feb 2018 23:58:32 -0600 Subject: 2018-02-27 23:58 --- active_correction/scatter/figures 2.py | 184 +++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 active_correction/scatter/figures 2.py (limited to 'active_correction/scatter/figures 2.py') diff --git a/active_correction/scatter/figures 2.py b/active_correction/scatter/figures 2.py new file mode 100644 index 0000000..6764400 --- /dev/null +++ b/active_correction/scatter/figures 2.py @@ -0,0 +1,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) + + -- cgit v1.2.3