Пример #1
0
def plot_interaction_height(cq):
    plot = Plot()

    p = 'proton'
    for e in sorted(cq.available_parameters('energy', particle=p)):
        median_altitude = []
        min_altitude = []
        max_altitude = []
        zeniths = []
        for z in sorted(cq.available_parameters('zenith', particle=p,
                                                energy=e)):
            selection = cq.simulations(particle=p, energy=e, zenith=z)
            if len(selection) > 50:
                interaction_altitudes = selection[
                    'first_interaction_altitude'] / 1e3
                median_altitude.append(median(interaction_altitudes))
                min_altitude.append(percentile(interaction_altitudes, 2))
                max_altitude.append(percentile(interaction_altitudes, 98))
                zeniths.append(z)
        if len(zeniths):
            plot.plot(zeniths + (e - 12) / 3., median_altitude)
            # plot.shade_region(zeniths, min_altitude, max_altitude,
            #                   color='lightgray,semitransparent')
            plot.add_pin('%.1f' % e, relative_position=0)
    plot.set_ylabel(r'First interaction altitude [\si{\kilo\meter}]')
    plot.set_xlabel(r'Zenith [\si{\radian}]')
    plot.save_as_pdf('plots/interaction_altitude')
Пример #2
0
def plot_shower_size(leptons=['electron', 'muon']):
    plot = Plot(axis='semilogy')
    cq = CorsikaQuery(OVERVIEW)
    p = 'proton'
    for e in sorted(cq.available_parameters('energy', particle=p)):
        median_size = []
        min_size = []
        max_size = []
        zeniths = sorted(cq.available_parameters('zenith', energy=e, particle=p))
        for z in zeniths:
            selection = cq.simulations(zenith=z, energy=e, particle=p)
            n_leptons = selection['n_%s' % leptons[0]]
            for lepton in leptons[1:]:
                n_leptons += selection['n_%s' % lepton]
            sizes = percentile(n_leptons, [16, 50, 84])
            min_size.append(sizes[0] if sizes[0] else 0.1)
            median_size.append(sizes[1] if sizes[1] else 0.1)
            max_size.append(sizes[2] if sizes[2] else 0.1)
        if len(zeniths):
            plot.plot(zeniths, median_size, linestyle='very thin')
            plot.shade_region(zeniths, min_size, max_size,
                              color='lightgray, semitransparent')
            plot.add_pin('%.1f' % e, relative_position=0)

    plot.set_xticks([t for t in arange(0, 60.1, 7.5)])
    plot.set_ylimits(1, 1e9)
    plot.set_ylabel(r'Shower size (leptons)')
    plot.set_xlabel(r'Zenith [\si{\degree}]')
    plot.save_as_pdf('shower_sizes_%s' % '_'.join(leptons))
    cq.finish()
Пример #3
0
def plot_shower_size_distributions():
    plot = Plot(axis='semilogx')
    cq = CorsikaQuery(OVERVIEW)
    p = 'proton'
    z = 0
    for e in sorted(cq.available_parameters('energy', particle=p, zenith=z)):
        selection = cq.simulations(zenith=z, energy=e, particle=p)
        n_leptons = selection['n_muon'] + selection['n_electron']
        plot.histogram(*histogram(n_leptons, bins=logspace(0, 9, 200)))
        plot.add_pin('%.1f' % e, x=mean(n_leptons), location='above')
    plot.set_ylimits(min=0)
    plot.set_xlimits(1, 1e9)
    plot.set_ylabel(r'pdf')
    plot.set_xlabel(r'Shower size (leptons)')
    plot.save_as_pdf('shower_size_distribution')
    cq.finish()
Пример #4
0
 def plot_slice(self, n):
     densities = [1, 3, 8, 15, 30]
     bins = linspace(0, 15, 150)
     plot = Plot()
     for density in densities:
         padding = round(sqrt(density) / 2.)
         counts, bins = histogram(
             n.compress(abs(self.src_k - density) < padding),
             bins=bins,
             density=True)
         plot.histogram(counts, bins)
         plot.add_pin(
             r'\SI[multi-part-units=single, separate-uncertainty]{%d\pm%d}{\per\meter\squared}'
             % (density, padding), 'above', bins[counts.argmax()])
     plot.set_ylimits(min=0)
     plot.set_xlimits(min=bins[0], max=bins[-1])
     plot.set_xlabel(r'HiSPARC detected density [\si{\per\meter\squared}]')
     plot.set_ylabel(r'Counts')
     return plot
Пример #5
0
def plot_effiencies():
    efficiencies, errors = collect_efficiencies()

    for energy in efficiencies.keys():
        plot = Plot('semilogx')
        for i, zenith in enumerate(sorted(efficiencies[energy].keys())):
            if any(abs(zenith - z) < 0.1 for z in [0, 22.5, 37.5]):
                plot.plot(CORE_DISTANCES, efficiencies[energy][zenith],
                          # yerr=errors[energy][zenith],
                          markstyle='mark size=1pt', linestyle='blue')
                plot.add_pin(str(zenith), x=15, use_arrow=True)
            else:
                plot.plot(CORE_DISTANCES, efficiencies[energy][zenith], mark=None)
        plot_david_data(plot)
        plot.set_ylabel('Efficiency')
        plot.set_ylimits(min=0, max=1.02)
        plot.set_xlimits(min=2, max=500)
        plot.set_xlabel('Core distance')
        plot.save_as_pdf('efficiency_%s_%.1f.pdf' % (STATION_TYPE[STATION_NUMBER], energy))
Пример #6
0
def main():
    gamma = np.genfromtxt('data/showere15-proton.t2001', usecols=(1, 2))
    e = np.genfromtxt('data/showere15-proton.t2205', usecols=(1, 2))
    mu = np.genfromtxt('data/showere15-proton.t2207', usecols=(1, 2))

    graph = Plot(axis='loglog')

    graph.plot(gamma[:, 0], gamma[:, 1], mark=None)
    graph.add_pin(r'$\gamma$')

    graph.plot(e[:, 0], e[:, 1], mark=None)
    graph.add_pin('e')

    graph.plot(mu[:, 0], mu[:, 1], mark=None)
    graph.add_pin(r'$\mu$')

    graph.set_xlabel(r"Core distance [\si{\meter}]")
    graph.set_ylabel(r"Particle density [\si{\per\square\meter}]")
    graph.set_logyticks(range(-6, 3, 2))
    graph.save('eas-lateral')
Пример #7
0
def main():
    plot = Plot(width=r'.5\linewidth', height=r'.5\linewidth')
    r = linspace(1, 5, 100)
    phi = linspace(0, 4.5 * pi, 100)
    x = r * cos(phi)
    y = r * sin(phi)
    plot.plot(x, y, mark=None)
    plot.add_pin('start', relative_position=0, use_arrow=True)
    plot.add_pin('half', relative_position=.5, use_arrow=True)
    plot.add_pin('46\%', relative_position=.46, use_arrow=True,
                 location='above')
    plot.add_pin('end', relative_position=1, use_arrow=True, location='below')

    phi = linspace(0, 2 * pi, 10)
    x = 6 * cos(phi)
    y = 6 * sin(phi)
    plot.plot(x, y, mark=None, linestyle='thick, gray')
    plot.add_pin('start', relative_position=0, use_arrow=True,
                 location='above right')
    plot.add_pin('half', relative_position=.5, use_arrow=True,
                 location='above left')
    plot.add_pin('70\%', relative_position=.7, use_arrow=True,
                 location='below')
    plot.add_pin('end', relative_position=1, use_arrow=True,
                 location='below right')

    plot.plot([-5, 2, 5], [-7.5, -7.5, -7.5], linestyle='lightgray')
    plot.add_pin('50\%', relative_position=.5, use_arrow=True,
                 location='above right')

    plot.set_xlimits(-8, 8)
    plot.set_ylimits(-8, 8)
    plot.save('relative_pin')

    # With one logarithmic axis
    plot = Plot(axis='semilogy')

    x = [2, 2, 2]
    y = [1, 10, 100]
    plot.plot(x, y)
    for xi, yi in zip(x, y):
        plot.add_pin_at_xy(xi, yi, '(%d,%d)' % (xi, yi),
                           location='below right')
    plot.add_pin('half', relative_position=.5, use_arrow=True,
                 location='right')

    x = [4, 5, 6]
    y = [3, 3, 3]
    plot.plot(x, y)
    for xi, yi in zip(x, y):
        plot.add_pin_at_xy(xi, yi, '(%d,%d)' % (xi, yi), location='below')
    plot.add_pin('half', relative_position=.5, use_arrow=True,
                 location='above')

    x = [3, 4, 5]
    y = [1, 10, 100]
    plot.plot(x, y)
    for xi, yi in zip(x, y):
        plot.add_pin_at_xy(xi, yi, '(%d,%d)' % (xi, yi), location='above left')
    plot.add_pin('half', relative_position=.5, use_arrow=True,
                 location='right')

    plot.save('relative_pin_log')
Пример #8
0
def main():
    leap = np.genfromtxt('data/leap-prot.dat', delimiter=',',
                         usecols=(0, 1), names=['E', 'F'])
    leap['E'] *= 1e6
    leap['F'] *= 1e3 * 2

    proton = read_data('data/proton', 1, 0)
    akeno_new_lo = read_data('data/akeno-new-lo', 0, 1)
    flys_eye = read_data('data/fe-new', 0, 1)
    yakutsk = read_data('data/yakustk', 1, 0)
    haverah = read_data('data/haverah', 1, 0)

    graph = Plot(axis='loglog', width=r'.5\linewidth', height=r'.65\linewidth')

    graph.plot(leap['E'], leap['F'], mark=None)
    graph.add_pin('LEAP', 'above right', use_arrow=True,
                  relative_position=.5)
    graph.plot(proton['E'], proton['F'], mark=None)
    graph.add_pin('PROTON', 'above right', use_arrow=True,
                  relative_position=.5)
    graph.plot(akeno_new_lo['E'], akeno_new_lo['F'], mark=None)
    graph.add_pin('AGASA', 'above right', use_arrow=True,
                  relative_position=.5)

    graph.plot(yakutsk['E'], yakutsk['F'], mark=None)
    graph.add_pin('Yakutsk', 'below left', use_arrow=True,
                  relative_position=.55)
    graph.plot(haverah['E'], haverah['F'], mark=None)
    graph.add_pin('Haverah Park', 'below left', use_arrow=True,
                  relative_position=.85)
    graph.plot(flys_eye['E'], flys_eye['F'], mark=None)
    graph.add_pin("Fly's Eye", 'below left', use_arrow=True,
                  relative_position=1.0)

    graph.set_xlabel(r"Energy [\si{\electronvolt}]")
    graph.set_ylabel(r"Flux [\si{\per\square\meter\per\steradian"
                     "\per\second\per\giga\electronvolt}]")

    x = np.logspace(11, 17)
    graph.plot(x, 1.5e29 * x ** -2.75, mark=None, linestyle='dashed')

    graph.set_logxticks(range(6, 22, 3))
    graph.save('spectrum')