Ejemplo n.º 1
0
def plot_flux_absorption_ratio(plot_title, plot_filename):
    fig, ax = plib.set_plot_style((4.5, 3.5))

    icol = 3
    
    E, flux_HI = read_flux_from_file('spectrum-PionDecayAbsorption-HI-1TeV-1PeV-16.txt', icol)
    E, flux_H2 = read_flux_from_file('spectrum-PionDecayAbsorption-H2-1TeV-1PeV-16.txt', icol)
    y_w = flux_HI + flux_H2
    
    E, flux_HI = read_flux_from_file('spectrum-PionDecay-HI-1TeV-1PeV-16.txt', icol)
    E, flux_H2 = read_flux_from_file('spectrum-PionDecay-H2-1TeV-1PeV-16.txt', icol)
    y_no = flux_HI + flux_H2
    
    r = (y_w - y_no) / y_no
    ax.plot(E, r - max(r))
    
    ax.set_xscale('log')
    ax.set_xlabel(r'E [GeV]', fontsize=12)
    ax.set_xlim([1e3, 1e6])

#    ax.set_yscale('log')
    ax.set_ylabel(r'Flux relative ratio', fontsize=12)
    ax.set_ylim([-1, 0])

    ax.set_title(plot_title, fontsize=11)

    ax.legend(fontsize=7)
    plib.savefig(plt, plot_filename)
Ejemplo n.º 2
0
def plot_map(fits_map_filename, imap, output_filename, title):
    fig, ax = plib.set_plot_style((4.5, 4))
    h = get_header(fits_map_filename)
    img = get_img(fits_map_filename, imap)

    n_lon = h["NAXIS1"]
    n_lat = h["NAXIS2"]
    b = np.linspace(-90., +90., n_lat)
    l = np.linspace(-180., +190., n_lon)
    
    logImg = np.log10(img + 1e-20)

    print (np.max(logImg), np.max(logImg) - 2.5)

    image = ax.pcolor(l, b, logImg,
                      cmap='Blues',
                      vmax=np.max(logImg),
                      vmin=np.max(logImg) - 2.5,
                      shading='auto',
                      edgecolors='face')

    make_cbar(fig, image)

    #ax.invert_xaxis()

    ax.set_title(title, pad=5, fontsize=11)
    #ax.grid(True)
    ax.set_xlabel(r'l [deg]')
    ax.set_ylabel(r'b [deg]')
    plt.savefig(output_filename + ".png")
Ejemplo n.º 3
0
def plot_map(fits_map_filename, output_filename, title, min_map, max_map):
    fig, ax = plib.set_plot_style((4.5, 4))
    nside, E_gamma = get_header_info(fits_map_filename)
    map = get_map(fits_map_filename)

    b = np.linspace(-80., +80., 160 * 2)
    l = np.linspace(-150., +150., 300 * 2)

    map_2d = convert_map_2D(map, nside, E_gamma, b, l)

    image = ax.pcolor(l,
                      b,
                      map_2d,
                      cmap='jet',
                      vmin=min_map,
                      vmax=max_map,
                      shading='auto',
                      edgecolors='face')

    make_cbar(fig, image)

    ax.invert_xaxis()

    ax.set_title(title, pad=5, fontsize=11)
    #ax.grid(True)
    ax.set_xlabel(r'l [deg]')
    ax.set_ylabel(r'b [deg]')
    plib.savefig(plt, output_filename)
Ejemplo n.º 4
0
def plot_longbetadecays():
    fig, ax = plib.set_plot_style()

    R = np.logspace(-1, 3, 1000)
    
    plot_decay(ax, 4, 10, R, 1.51 * Myr, r'$\beta^-$(1.51 Myr) : $^{10}$Be $\rightarrow$ $^{10}$B', 'tab:blue')
    plot_decay(ax, 6, 14, R, 5.7 * kyr, r'$\beta^-$(5.7 kyr) : $^{14}$C $\rightarrow$ $^{14}$N', 'tab:orange')
    plot_decay(ax, 11, 22, R, 4.8 * Myr, r'$\beta^+$(4.8 Myr) : $^{22}$Na $\rightarrow$ $^{22}$Ne', 'tab:pink')
    plot_decay(ax, 13, 26, R, 0.91 * Myr, r'$\beta^+$(0.91 Myr) : $^{26}$Al $\rightarrow$ $^{26}$Mg', 'tab:green')
    plot_decay(ax, 17, 36, R, 0.307 * Myr, r'$\beta^-$(0.307 Myr) : $^{36}$Cl $\rightarrow$ $^{36}$Ar', 'tab:red')
    plot_decay(ax, 25, 54, R, 0.63 * Myr, r'$\beta^+$(0.63 Myr) : $^{54}$Mn $\rightarrow$ $^{54}$Fe', 'tab:brown')
    plot_decay(ax, 28, 56, R, 0.051 * Myr, r'$\beta^+$(51 kyr) : $^{56}$Ni $\rightarrow$ $^{56}$Fe', 'tab:olive')
    plot_decay(ax, 26, 60, R, 2.6 * Myr, r'$\beta^-$(2.6 Myr) : $^{60}$Fe $\rightarrow$ $^{60}$Co $\rightarrow$ $^{60}$Ni', 'tab:cyan')

    ax.legend(fontsize=14)

    tdiff = 5. / (1e-5 + 1e-5 * np.power(R, 0.54)) # [kyr]
    ax.plot(R, tdiff, color='k')
    ax.fill_between(R, 2. / 5.  * tdiff, 10. / 5.  * tdiff, facecolor='k', alpha=0.3, zorder=1)

    ax.set_yscale('log')
    ax.set_xscale('log')

    ax.set_xlabel(r'R [GV]')
    ax.set_ylabel('t [kyr]')
    
    #ax.plot([1, 1e3], [1, 1], ':', color='k')

    ax.set_xlim([1e0, 1e3])
    ax.set_ylim([1e-1, 1e8])
    
    plt.savefig('longbetadecays.pdf')
Ejemplo n.º 5
0
def plot_flux_absorption(plot_title, plot_filename):
    fig, ax = plib.set_plot_style((4.5, 3.5))

    icol = 3
    
    E, flux_HI = read_flux_from_file('spectrum-PionDecayAbsorption-HI-1TeV-1PeV-16.txt', icol)
    E, flux_H2 = read_flux_from_file('spectrum-PionDecayAbsorption-H2-1TeV-1PeV-16.txt', icol)
    ax.plot(E, E * E * (flux_HI + flux_H2), color='tab:blue', linestyle='-', label=r'Pion Decay')

    E, flux_HI = read_flux_from_file('spectrum-PionDecay-HI-1TeV-1PeV-16.txt', icol)
    E, flux_H2 = read_flux_from_file('spectrum-PionDecay-H2-1TeV-1PeV-16.txt', icol)
    ax.plot(E, E * E * (flux_HI + flux_H2), color='tab:blue', linestyle='--', label=r'Pion Decay (no absorption)')

    ax.set_xscale('log')
    ax.set_xlabel(r'E [GeV]', fontsize=12)
    ax.set_xlim([1e3, 1e6])

    ax.set_yscale('log')
    ax.set_ylabel(r'E$^2$ Flux [GeV m$^{-2}$ s$^{-1}$ sr$^{-1}$]', fontsize=12)
    ax.set_ylim([1e-7, 1e-2])

    ax.set_title(plot_title, fontsize=11)

    ax.legend(fontsize=7)
    plib.savefig(plt, plot_filename)
Ejemplo n.º 6
0
def plot_flux_HE(icol, plot_title, plot_filename):
    fig, ax = plib.set_plot_style((4.5, 3.5))

    E, flux_HI = read_flux_from_file('spectrum-PionDecay-HI-1TeV-1PeV-64.txt', icol)
    E, flux_H2 = read_flux_from_file('spectrum-PionDecay-H2-1TeV-1PeV-64.txt', icol)
    ax.plot(E, E * E * (flux_HI + flux_H2), color='tab:green', linestyle='-', label=r'Pion Decay ($\gamma$)')

    E, flux_HI = read_flux_from_file('spectrum-PionDecayNu-HI-1TeV-1PeV-64.txt', icol)
    E, flux_H2 = read_flux_from_file('spectrum-PionDecayNu-H2-1TeV-1PeV-64.txt', icol)
    ax.plot(E, E * E * (flux_HI + flux_H2), color='tab:orange', linestyle='--', label=r'Pion Decay ($\nu$ all-flavours)')

    E, flux_DM = read_flux_from_file('spectrum-DarkMatter-1TeV-30TeV-256.txt', icol)
    ax.plot(E, E * E * 10. * flux_DM, color='tab:red', linestyle='-', label='Dark Matter (prompt)')

    E, flux_DM = read_flux_from_file('spectrum-DarkMatterSecondary-1TeV-30TeV-64.txt', icol)
    ax.plot(E, E * E * 10. * flux_DM, color='tab:red', linestyle='--', label='Dark Matter (secondary)')

    ax.set_xscale('log')
    ax.set_xlabel(r'E [GeV]', fontsize=12)
    ax.set_xlim([1e3, 1e6])

    ax.set_yscale('log')
    ax.set_ylabel(r'E$^2$ Flux [GeV m$^{-2}$ s$^{-1}$ sr$^{-1}$]', fontsize=12)
    ax.set_ylim([1e-8, 1e-2])

    ax.set_title(plot_title, fontsize=11)

    ax.legend(fontsize=7)
    plib.savefig(plt, plot_filename)
Ejemplo n.º 7
0
def plot_flux(icol, plot_title, plot_filename):
    fig, ax = plib.set_plot_style((4.5, 3.5))

    E, flux_HI = read_flux_from_file('spectrum-PionDecay-HI-100MeV-1TeV-64.txt', icol)
    ax.plot(E, E * E * flux_HI, color='tab:green', linestyle='--', label='Pion Decay (HI)')

    E, flux_H2 = read_flux_from_file('spectrum-PionDecay-H2-100MeV-1TeV-64.txt', icol)
    ax.plot(E, E * E * flux_H2, color='tab:green', linestyle=':', label='Pion Decay (H2)')

    ax.plot(E, E * E * (flux_HI + flux_H2), color='tab:green', linestyle='-', label='Pion Decay (total)')
    
    E, flux_IC = read_flux_from_file('spectrum-InverseCompton-100MeV-1TeV-64.txt', icol)
    ax.plot(E, E * E * flux_IC, color='tab:red', linestyle='-', label='Inverse Compton')

    E, flux_Bremss_HI = read_flux_from_file('spectrum-Bremsstrahlung-HI-100MeV-1TeV-64.txt', icol)
    E, flux_Bremss_H2 = read_flux_from_file('spectrum-Bremsstrahlung-HI-100MeV-1TeV-64.txt', icol)
    ax.plot(E, E * E * (flux_Bremss_HI + flux_Bremss_H2), color='tab:orange', linestyle='-', label='Bremsstrahlung')

    flux = flux_Bremss_HI + flux_Bremss_H2 + flux_HI + flux_H2 + flux_IC
    ax.plot(E, E * E * flux, color='tab:blue', linestyle='-', label='Total')

    ax.set_xscale('log')
    ax.set_xlabel(r'E [GeV]', fontsize=12)
    ax.set_xlim([0.1, 1e3])

    ax.set_yscale('log')
    ax.set_ylabel(r'E$^2$ Flux [GeV m$^{-2}$ s$^{-1}$ sr$^{-1}$]', fontsize=12)
    ax.set_ylim([1e-5, 1])

    ax.set_title(plot_title, fontsize=11)

    ax.legend(fontsize=7)
    plib.savefig(plt, plot_filename)
Ejemplo n.º 8
0
def plot_ghostdecays():
    fig, ax = plib.set_plot_style()
    
    filename = '../data/ghost_list.txt'
    f = open(filename, "r")
    lines = f.readlines()
    for line in lines[1:]:
        line = line.split()
        Zp = plib.str_to_Z(line[0])
        Ap = int(line[1])
        Zd = plib.str_to_Z(line[2])
        Ad = int(line[3])
        #ax.plot([Zp, Zd], [Ap, Ad])

        rect = patches.Rectangle((Zp,Ap),1,1,linewidth=0,edgecolor='tab:gray',facecolor='tab:gray',alpha=0.3)
        ax.add_patch(rect)
        
        if (Zd - Zp) > 0:
            ax.arrow(Zp + 0.5, Ap + 0.5, (Zd - Zp) * 0.8, (Ad - Ap) * 0.8, length_includes_head=True,
                     head_width=0.3, head_length=0.2, fc='tab:orange', ec='tab:orange')
        else:
            ax.arrow(Zp + 0.5, Ap + 0.5, (Zd - Zp) * 0.8, (Ad - Ap) * 0.8, length_includes_head=True,
                    head_width=0.3, head_length=0.2, fc='tab:green', ec='tab:green')

    filename = '../data/crchart_Z28_2020.txt'
    f = open(filename, "r")
    lines = f.readlines()
    for line in lines[1:]:
        line = line.split()
        Z = int(line[0])
        A = int(line[1])
        mode = line[3]
        if (mode == 'BETA+'):
            rect = patches.Rectangle((Z,A),1,1,linewidth=0,edgecolor='tab:purple',facecolor='tab:purple',alpha=0.7)
            ax.add_patch(rect)
        elif (mode == 'BETA-'):
            rect = patches.Rectangle((Z,A),1,1,linewidth=0,edgecolor='tab:red',facecolor='tab:red',alpha=0.7)
            ax.add_patch(rect)
        else:
            rect = patches.Rectangle((Z,A),1,1,linewidth=0,edgecolor='tab:blue',facecolor='tab:blue',alpha=0.7)
            ax.add_patch(rect)
            
    ax.text(12, 12, r'409 ghost nuclei', fontsize=20)
    ax.text(12,  7, r'with msec $< \tau_{1/2} <$ kyr', fontsize=20)

    ax.text(4, 70, r'$\beta+$ ghost', color='tab:green', fontsize=18)
    ax.text(4, 65, r'$\beta-$ ghost', color='tab:orange', fontsize=18)
    ax.text(4, 60, r'$\beta+$ long-lived', color='tab:purple', fontsize=18)
    ax.text(4, 55, r'$\beta-$ long-lived', color='tab:red', fontsize=18)
    ax.text(4, 50, r'Stable', color='tab:blue', fontsize=18)

    ax.set_xlim([0, 32])
    ax.set_ylim([0, 80])
    ax.set_xlabel('Z')
    ax.set_ylabel('A')
    plt.savefig('ghostdecays.pdf')
Ejemplo n.º 9
0
def plot_radiospectra(icol, plot_title, plot_filename):
    fig, ax = plib.set_plot_style((4.5, 3.5))

    freq, flux = read_spectrum_from_file('spectrum-Synchro-64.txt', icol)
    ax.plot(freq,
            freq * freq * flux,
            label='Synchrotron (B regular + B turbulent)',
            color='tab:blue')

    freq, flux = read_spectrum_from_file('spectrum-Synchro-noturb-64.txt',
                                         icol)
    ax.plot(freq,
            freq * freq * flux,
            linestyle=':',
            label='Synchrotron (B regular only)',
            color='tab:blue')

    freq, flux = read_spectrum_from_file('spectrum-Synchro-absorption-64.txt',
                                         icol)
    ax.plot(freq,
            freq * freq * flux,
            linestyle='--',
            label='Synchrotron (including absorption)',
            color='tab:orange')

    freq, flux = read_spectrum_from_file('spectrum-FreeFree-64.txt', icol)
    ax.plot(freq, freq * freq * flux, color='tab:red', label='Free-free')

    ax.set_xscale('log')
    ax.set_xlabel(r'$\nu$ [MHz]', fontsize=12)
    ax.set_xlim([1, 1e5])

    ax.set_yscale('log')
    ax.set_ylabel(r'$\nu^2$ T$_{\rm b}$ [MHz$^2$ K]', fontsize=12)
    ax.set_ylim([1e2, 1e8])

    ax.set_title(plot_title, fontsize=11)

    ax.legend(fontsize=9, loc='lower left')
    plib.savefig(plt, plot_filename)
Ejemplo n.º 10
0
    plt.ylabel(r'n$_e$ [cm$^{-3}$]')
    plt.title(title, fontsize=25)

    plt.legend(['YMW'])

    return 'ne_los.pdf'


def plot_B(filename, title):
    d, B_perp, B_tot = np.loadtxt(filename, skiprows=1, usecols=(0, 1, 2), unpack=True)

    plt.plot(d, B_perp, 'r')
    plt.plot(d, B_tot, 'r:')

    plt.xlabel(r'd [pc]')
    plt.ylabel(r'B [$\mu$G]')
    plt.title(title, fontsize=25)

    return 'B_los.pdf'


pl.set_plot_style()

filename = 'output/HESSJ1640-465.los'

# plotname = plot_ne(filename, 'HESSJ1640-465')
plotname = plot_B(filename, 'HESSJ1640-465')

# plt.show()
plt.savefig(plotname)
Ejemplo n.º 11
0
                      pad=4,
                      bottom=True,
                      top=True,
                      left=True,
                      right=True)
    cb.outline.set_linewidth(0.8)


# MAIN

output_filename = 'SynchrotronSlope-408MHz-cartesian-128'
title = r'Synchrotron Slope'
units = r'$\beta$'
min_map, max_map = -3.1, -2.9

fig, ax = plib.set_plot_style((4.5, 4))

nside = get_header_info('fits/map-Synchro-408MHz-128.fits.gz')

map_nu1 = get_map('fits/map-Synchro-noturb-408MHz-128.fits.gz')
map_nu2 = get_map('fits/map-Synchro-noturb-412MHz-128.fits.gz')
nu1, nu2 = 408., 412.

b = np.linspace(-80., +80., 160 * 2)
l = np.linspace(-150., +150., 300 * 2)

map_2d = compute_map_slope(map_nu1, map_nu2, nu1, nu2, b, l)

image = ax.pcolor(l,
                  b,
                  map_2d,