Example #1
0
def main():
    compton.setup_plot()

    output = PdfPages('quadrupole-trajectory-diagram.pdf')
    plot_quadrupole(output)
    output.close()

    output = PdfPages('sextupole-trajectory-diagram.pdf')
    plot_sextupole(output)
    output.close()
Example #2
0
def main():
    compton.setup_plot()
    plot.rc('figure.subplot', right=0.96, top=0.97, bottom=0.15, left=0.13)

    output = PdfPages('comparison.pdf')
    for thickness in common.thickness_vals:
        for energy in common.energy_vals:
            for particle in ['e-']:
                desc = '{:.3f}mm_{:.3f}MeV'.format(round(thickness / mm, 3),
                                                   round(energy / MeV, 3))
                filename = 'out/' + desc + '.h5'
                plot_run(output, filename, thickness, energy, particle)
    output.close()
def main():
    compton.setup_plot()

    with PdfPages('collimation-output.pdf') as output:
        dump(
            output, 'results/W-5-p45-10.h5', 'results/uncollimated.h5',
            'Tungsten collimator\n' +
            r'$a = 5\,{\rm mm}, r = 0.45\,a, d = 10\,{\rm mm}$')
        dump(
            output, 'results/W-4-p43-12.h5', 'results/uncollimated.h5',
            'Tungsten collimator\n' +
            r'$a = 4\,{\rm mm}, r = 0.43\,a, d = 12\,{\rm mm}$')
        dump(
            output, 'results/W-5-p42-15.h5', 'results/uncollimated.h5',
            'Tungsten collimator\n' +
            r'$a = 5\,{\rm mm}, r = 0.42\,a, d = 15\,{\rm mm}$')
        dump(
            output, 'results/Al-5-p45-10.h5', 'results/uncollimated.h5',
            'Aluminum collimator\n' +
            r'$a = 5\,{\rm mm}, r = 0.45\,a, d = 10\,{\rm mm}$')
def plot_homing_map(filename, homing_map, hull):
    os.makedirs(os.path.dirname(filename), exist_ok=True)
    output = PdfPages(filename)
    compton.setup_plot()
    plot.rc('figure.subplot', right=0.99, top=0.99, bottom=0.09, left=0.10)

    mesh_dx = 0.5 * mm

    Y, Z = np.meshgrid(
        np.arange(hull.min_bound[0] - mesh_dx, hull.max_bound[0] + mesh_dx,
                  mesh_dx),
        np.arange(hull.min_bound[1] - mesh_dx, hull.max_bound[1] + mesh_dx,
                  mesh_dx))
    smoothed_xi = homing_map(Y, Z)[:, :, 0]
    smoothed_phi = homing_map(Y, Z)[:, :, 1]

    fig = plot.figure(figsize=(244 / 72, 100 / 72))
    ax = fig.add_subplot(1, 1, 1, aspect=1.0)
    ax.contour(Z / mm,
               Y / mm,
               smoothed_xi,
               levels=np.linspace(-1.0, 1.0, 20),
               linewidths=0.3,
               colors='#0083b8',
               linestyles='solid',
               zorder=0)
    ax.fill(hull.points[hull.vertices, 1] / mm,
            hull.points[hull.vertices, 0] / mm,
            fill=False,
            linewidth=0.5,
            edgecolor='k',
            zorder=10)
    scale_limits(ax.xaxis, 1.1)
    scale_limits(ax.yaxis, 1.1)
    plot.title(r'$\xi(z, y)$')
    plot.xlabel(r'$z_{\rm scint}$ (mm)', labelpad=0.0)
    plot.ylabel(r'$y_{\rm scint}$ (mm)', labelpad=0.0)
    ax.xaxis.set_minor_locator(matplotlib.ticker.AutoMinorLocator())
    ax.yaxis.set_minor_locator(matplotlib.ticker.AutoMinorLocator())
    output.savefig(fig, transparent=True)

    fig = plot.figure(figsize=(244 / 72, 100 / 72))
    ax = fig.add_subplot(1, 1, 1, aspect=1.0)
    ax.contour(Z / mm,
               Y / mm,
               smoothed_phi,
               levels=20,
               linewidths=0.3,
               colors='#0083b8',
               linestyles='solid',
               zorder=0)
    ax.fill(hull.points[hull.vertices, 1] / mm,
            hull.points[hull.vertices, 0] / mm,
            fill=False,
            linewidth=0.5,
            edgecolor='k',
            zorder=10)
    scale_limits(ax.xaxis, 1.1)
    scale_limits(ax.yaxis, 1.1)
    plot.title(r'$\phi(z, y)$')
    plot.xlabel(r'$z_{\rm scint}$ (mm)', labelpad=0.0)
    plot.ylabel(r'$y_{\rm scint}$ (mm)', labelpad=0.0)
    ax.xaxis.set_minor_locator(matplotlib.ticker.AutoMinorLocator())
    ax.yaxis.set_minor_locator(matplotlib.ticker.AutoMinorLocator())
    output.savefig(fig, transparent=True)
    output.close()
Example #5
0
def main():
    fin = h5py.File('d2W.h5', 'r')
    compton.setup_plot()
    os.makedirs('figs', exist_ok=True)

    # PWFA
    if True:
        pwfa_drive_datasets = [
            'E300 PWFA/Unmatched Trailing (s=0.17)/drive',
            'E300 PWFA/Unmatched Trailing (s=0.14)/drive',
            'E300 PWFA/Matched Trailing (s=0.06)/drive',
            'E300 PWFA/Unmatched Trailing (s=0.01)/drive']
        pwfa_trailing_datasets = [
            'E300 PWFA/Unmatched Trailing (s=0.17)/trailing',
            'E300 PWFA/Unmatched Trailing (s=0.14)/trailing',
            'E300 PWFA/Matched Trailing (s=0.06)/trailing',
            'E300 PWFA/Unmatched Trailing (s=0.01)/trailing']
        output = PdfPages('figs/pwfa.pdf')
        plot_spectral_energy_density(
            output, fin, pwfa_drive_datasets,
            (MeV, 'MeV'),
            (mJ/MeV, 'mJ/MeV'),
            (-0.1, 2.0), (-0.05, 2.6))
        plot_spectral_energy_density(
            output, fin, pwfa_trailing_datasets,
            (MeV, 'MeV'),
            (mJ/MeV, 'mJ/MeV'),
            (-0.1, 2.0), (-0.05, 2.6))
        plot_spectral_photon_density(
            output, fin, pwfa_drive_datasets,
            (MeV, 'MeV'),
            (1/MeV, '1/MeV'),
            (-0.1, 2.0), (1e7, 1e13))
        plot_spectral_photon_density(
            output, fin, pwfa_trailing_datasets,
            (MeV, 'MeV'),
            (1/MeV, '1/MeV'),
            (-0.1, 2.0), (1e7, 1e13))
        for x in pwfa_drive_datasets:
            plot_spot(
                output, fin, x, 6,
                (mJ/mrad**2, r'mJ/mrad$^2$'),
                (-2.0, 2.0), (-1.5, 1.5))
        for x in pwfa_trailing_datasets:
            plot_spot(
                output, fin, x, 6,
                (mJ/mrad**2, r'mJ/mrad$^2$'),
                (-2.0, 2.0), (-1.5, 1.5))
        for x in pwfa_drive_datasets:
            plot_double_differential(
                output, fin, x, 8,
                (MeV, 'MeV'), (mrad, 'mrad'),
                (uJ/(mrad*MeV), r'uJ/(mrad$^\cdot$MeV)'),
                (0.01, 1.0), (-2.0, 2.0))
        for x in pwfa_trailing_datasets:
            plot_double_differential(
                output, fin, x, 8,
                (MeV, 'MeV'), (mrad, 'mrad'),
                (uJ/(mrad*MeV), r'uJ/(mrad$^\cdot$MeV)'),
                (0.01, 1.0), (-2.0, 2.0))
        output.close()

    # Filamentation
    if True:
        output = PdfPages('figs/filamentation.pdf')
        plot_spectral_energy_density(
            output, fin,
            ['Filamentation/solid'],
            (MeV, 'MeV'), (uJ/MeV, 'uJ/MeV'),
            (-4, 60.0), (-5, 100), display_legend=False)
        plot_spectral_photon_density(
            output, fin,
            ['Filamentation/solid'],
            (MeV, 'MeV'),
            (1/MeV, '1/MeV'),
            (-2, 60.0), (1e6, 1e10), display_legend=False)
        plot_spot(
            output, fin, 'Filamentation/solid', 5,
            (mJ/mrad**2, r'mJ/mrad$^2$'),
            (-0.2, 0.2), (-0.2, 0.2), '')
        plot_double_differential(
            output, fin, 'Filamentation/solid', 8,
            (MeV, 'MeV'), (mrad, 'mrad'),
            (uJ/(mrad*MeV), r'uJ/(mrad$\cdot$MeV)'),
            (1, 30), (-0.2, 0.2), '')
        output.close()

    # SFQED
    if True:
        output = PdfPages('figs/sfqed.pdf')
        sfqed_datasets = [
            'SFQED/MPIK/LCFA_w3.0_xi5.7',
            'SFQED/MPIK/LCFA_w2.4_xi7.2',
            'SFQED/MPIK/LCS+LCFA_w3.0_xi5.7',
            'SFQED/MPIK/LCS+LCFA_w2.4_xi7.2']
        sfqed_labels = [
            r'LCFA ($a_0=5.7, w_0=3.0\;\mu{\rm m}$)',
            r'LCFA ($a_0=7.2, w_0=2.4\;\mu{\rm m}$)',
            r'QED ($a_0=5.7, w_0=3.0\;\mu{\rm m}$)',
            r'QED ($a_0=7.2, w_0=2.4\;\mu{\rm m}$)']
        plot_spectral_energy_density(
            output, fin, sfqed_datasets,
            (GeV, 'GeV'), (mJ/GeV, 'mJ/GeV'),
            (-0.1, 10.0), (-0.1, 4),
            labels=sfqed_labels)
        plot_spectral_energy_density(
            output, fin, sfqed_datasets,
            (MeV, 'MeV'), (uJ/MeV, 'uJ/MeV'),
            (-1, 60.0), (-0.1, 3),
            labels=sfqed_labels)
        plot_spectral_photon_density(
            output, fin, sfqed_datasets,
            (GeV, 'GeV'), (1/GeV, '1/GeV'),
            (-0.1, 10.0), (1e1, 1e9),
            labels=sfqed_labels)
        plot_spectral_photon_density(
            output, fin, sfqed_datasets,
            (MeV, 'MeV'), (1/MeV, '1/MeV'),
            (-1, 60.0), (2e4, 4e7),
            labels=sfqed_labels)
        for x, y in zip(sfqed_datasets, sfqed_labels):
            plot_double_differential(
                output, fin, x, 8,
                (MeV, 'MeV'), (mrad, 'mrad'),
                (uJ/(mrad*MeV), r'uJ/(mrad$\cdot$MeV)'),
                (1, 30), (-0.5, 0.5),
                label=y)
        for x, y in zip(sfqed_datasets, sfqed_labels):
            plot_spot(
                output, fin, x, 6,
                (mJ/mrad**2, r'mJ/mrad$^2$'),
                (-0.3, 0.3), (-0.1, 0.1), label=y)
        output.close()