def plot_detection_efficiency_vs_R_for_angles(N):
    figure()
    graph = GraphArtist()
    locations = iter(['right', 'left', 'below left'])
    positions = iter([.18, .14, .15])

    bin_edges = linspace(0, 100, 20)
    x = (bin_edges[:-1] + bin_edges[1:]) / 2.

    for angle in [0, 22.5, 35]:
        angle_str = str(angle).replace('.', '_')
        shower_group = '/simulations/E_1PeV/zenith_%s' % angle_str

        efficiencies = []
        for low, high in zip(bin_edges[:-1], bin_edges[1:]):
            shower_results = []
            for shower in data.listNodes(shower_group):
                sel_query = '(low <= r) & (r < high)'
                coinc_sel = shower.coincidences.readWhere(sel_query)
                ids = coinc_sel['id']
                obs_sel = shower.observables.readCoordinates(ids)
                assert (obs_sel['id'] == ids).all()

                o = obs_sel
                sel = obs_sel.compress((o['n1'] >= N) & (o['n3'] >= N)
                                       & (o['n4'] >= N))
                shower_results.append(len(sel) / len(obs_sel))
            efficiencies.append(mean(shower_results))

        plot(x, efficiencies, label=r'$\theta = %s^\circ$' % angle)
        graph.plot(x, efficiencies, mark=None)
        graph.add_pin(r'\SI{%s}{\degree}' % angle,
                      location=locations.next(),
                      use_arrow=True,
                      relative_position=positions.next())

    xlabel("Core distance [m]")
    graph.set_xlabel(r"Core distance [\si{\meter}]")
    ylabel("Detection efficiency")
    graph.set_ylabel("Detection efficiency")
    #title(r"$N_{MIP} \geq %d$" % N)
    legend()
    graph.set_xlimits(0, 100)
    graph.set_ylimits(0, 1)

    utils.saveplot(N)
    artist.utils.save_graph(graph, suffix=N, dirname='plots')
def plot_detection_efficiency_vs_R_for_angles(N):
    figure()
    graph = GraphArtist()
    locations = iter(['right', 'left', 'below left'])
    positions = iter([.18, .14, .15])

    bin_edges = linspace(0, 100, 20)
    x = (bin_edges[:-1] + bin_edges[1:]) / 2.

    for angle in [0, 22.5, 35]:
        angle_str = str(angle).replace('.', '_')
        shower_group = '/simulations/E_1PeV/zenith_%s' % angle_str

        efficiencies = []
        for low, high in zip(bin_edges[:-1], bin_edges[1:]):
            shower_results = []
            for shower in data.list_nodes(shower_group):
                sel_query = '(low <= r) & (r < high)'
                coinc_sel = shower.coincidences.read_where(sel_query)
                ids = coinc_sel['id']
                obs_sel = shower.observables.read_coordinates(ids)
                assert (obs_sel['id'] == ids).all()

                o = obs_sel
                sel = obs_sel.compress((o['n1'] >= N) & (o['n3'] >= N) &
                                       (o['n4'] >= N))
                shower_results.append(len(sel) / len(obs_sel))
            efficiencies.append(mean(shower_results))

        plot(x, efficiencies, label=r'$\theta = %s^\circ$' % angle)
        graph.plot(x, efficiencies, mark=None)
        graph.add_pin(r'\SI{%s}{\degree}' % angle,
                      location=locations.next(), use_arrow=True,
                      relative_position=positions.next())

    xlabel("Core distance [m]")
    graph.set_xlabel(r"Core distance [\si{\meter}]")
    ylabel("Detection efficiency")
    graph.set_ylabel("Detection efficiency")
    #title(r"$N_{MIP} \geq %d$" % N)
    legend()
    graph.set_xlimits(0, 100)
    graph.set_ylimits(0, 1)

    utils.saveplot(N)
    artist.utils.save_graph(graph, suffix=N, dirname='plots')
def artistplot_reconstruction_efficiency_vs_R_for_angles(N):
    filename = 'DIR-plot_reconstruction_efficiency_vs_R_for_angles-%d.txt' % N
    all_data = loadtxt(os.path.join('plots/', filename))

    graph = GraphArtist()
    locations = iter(['above right', 'below left', 'below left'])
    positions = iter([.9, .2, .2])

    x = all_data[:, 0]

    for angle, efficiencies in zip([0, 22.5, 35], all_data[:, 1:].T):
        graph.plot(x, efficiencies, mark=None)
        graph.add_pin(r'\SI{%s}{\degree}' % angle, use_arrow=True,
                      location=locations.next(),
                      relative_position=positions.next())

    graph.set_xlabel("Core distance [\si{\meter}]")
    graph.set_ylabel("Reconstruction efficiency")
    graph.set_xlimits(0, 100)
    graph.set_ylimits(max=1)
    artist.utils.save_graph(graph, suffix=N, dirname='plots')
Esempio n. 4
0
def plot_pulseheight_histogram(data):
    events = data.root.hisparc.cluster_kascade.station_601.events
    ph = events.col('pulseheights')

    s = landau.Scintillator()
    mev_scale = 3.38 / 340
    count_scale = 6e3 / .32

    clf()
    n, bins, patches = hist(ph[:, 0],
                            bins=arange(0, 1501, 10),
                            histtype='step')
    x = linspace(0, 1500, 1500)
    plot(x, s.conv_landau_for_x(x,
                                mev_scale=mev_scale,
                                count_scale=count_scale))
    plot(x, count_scale * s.landau_pdf(x * mev_scale))
    ylim(ymax=25000)
    xlim(xmax=1500)

    # Remove one statistical fluctuation from data.  It is not important
    # for the graph, but it detracts from the main message
    index = bins.searchsorted(370)
    n[index] = mean([n[index - 1], n[index + 1]])

    graph = GraphArtist()
    n_trunc = where(n <= 100000, n, 100000)
    graph.histogram(n_trunc, bins, linestyle='gray')
    graph.add_pin('data', x=800, location='above right', use_arrow=True)
    graph.add_pin('$\gamma$', x=90, location='above right', use_arrow=True)
    graph.plot(x,
               s.conv_landau_for_x(x,
                                   mev_scale=mev_scale,
                                   count_scale=count_scale),
               mark=None)
    graph.add_pin('convolved Landau',
                  x=450,
                  location='above right',
                  use_arrow=True)
    graph.plot(x,
               count_scale * s.landau_pdf(x * mev_scale),
               mark=None,
               linestyle='black')
    graph.add_pin('Landau', x=380, location='above right', use_arrow=True)

    graph.set_xlabel(r"Pulseheight [\adc{}]")
    graph.set_ylabel(r"Number of events")
    graph.set_xlimits(0, 1400)
    graph.set_ylimits(0, 21000)
    graph.save("plots/plot_pulseheight_histogram")
def artistplot_reconstruction_efficiency_vs_R_for_angles(N):
    filename = 'DIR-plot_reconstruction_efficiency_vs_R_for_angles-%d.txt' % N
    all_data = loadtxt(os.path.join('plots/', filename))

    graph = GraphArtist()
    locations = iter(['above right', 'below left', 'below left'])
    positions = iter([.9, .2, .2])

    x = all_data[:, 0]

    for angle, efficiencies in zip([0, 22.5, 35], all_data[:, 1:].T):
        graph.plot(x, efficiencies, mark=None)
        graph.add_pin(r'\SI{%s}{\degree}' % angle,
                      use_arrow=True,
                      location=locations.next(),
                      relative_position=positions.next())

    graph.set_xlabel("Core distance [\si{\meter}]")
    graph.set_ylabel("Reconstruction efficiency")
    graph.set_xlimits(0, 100)
    graph.set_ylimits(max=1)
    artist.utils.save_graph(graph, suffix=N, dirname='plots')
def plot_pulseheight_histogram(data):
    events = data.root.hisparc.cluster_kascade.station_601.events
    ph = events.col("pulseheights")

    s = landau.Scintillator()
    mev_scale = 3.38 / 340
    count_scale = 6e3 / 0.32

    clf()
    n, bins, patches = hist(ph[:, 0], bins=arange(0, 1501, 10), histtype="step")
    x = linspace(0, 1500, 1500)
    plot(x, s.conv_landau_for_x(x, mev_scale=mev_scale, count_scale=count_scale))
    plot(x, count_scale * s.landau_pdf(x * mev_scale))
    ylim(ymax=25000)
    xlim(xmax=1500)

    # Remove one statistical fluctuation from data.  It is not important
    # for the graph, but it detracts from the main message
    index = bins.searchsorted(370)
    n[index] = mean([n[index - 1], n[index + 1]])

    graph = GraphArtist()
    n_trunc = where(n <= 100000, n, 100000)
    graph.histogram(n_trunc, bins, linestyle="gray")
    graph.add_pin("data", x=800, location="above right", use_arrow=True)
    graph.add_pin("$\gamma$", x=90, location="above right", use_arrow=True)
    graph.plot(x, s.conv_landau_for_x(x, mev_scale=mev_scale, count_scale=count_scale), mark=None)
    graph.add_pin("convolved Landau", x=450, location="above right", use_arrow=True)
    graph.plot(x, count_scale * s.landau_pdf(x * mev_scale), mark=None, linestyle="black")
    graph.add_pin("Landau", x=380, location="above right", use_arrow=True)

    graph.set_xlabel(r"Pulseheight [\adc{}]")
    graph.set_ylabel(r"Number of events")
    graph.set_xlimits(0, 1400)
    graph.set_ylimits(0, 21000)
    graph.save("plots/plot_pulseheight_histogram")