コード例 #1
0
def plot_spectra_artist(background, Na, Cs, Epc):
    background = background[:948]
    Na = Na[:948]
    Cs = Cs[:948]

    data = lambda y: (range(len(y)), y)

    plot = artist.MultiPlot(1, 3, width=r".3\linewidth")
    subplot = plot.get_subplot_at(0, 0)
    subplot.plot(*data(background), mark=None)
    subplot.set_label("achtergrond")
    subplot = plot.get_subplot_at(0, 1)
    subplot.plot(*data(Na), mark=None)
    subplot.set_label("$^{22}$Na")
    subplot = plot.get_subplot_at(0, 2)
    subplot.plot(*data(Cs), mark=None)
    subplot.set_label("$^{137}$Cs")

    plot.show_xticklabels_for_all()
    plot.set_xticklabels_position(0, 1, 'top')
    plot.set_ylimits_for_all(min=0)
    plot.set_yticks_for_all()
    plot.set_xlabel("ADC kanaal")
    plot.set_ylabel("Signaalsterkte")
    plot.save_as_pdf("Na_Cs_background")

    E = arange(len(Na)) * Epc
    plot = artist.MultiPlot(1, 2, width=r".3\linewidth")
    subplot = plot.get_subplot_at(0, 0)
    subplot.plot(E, Na - background, mark=None)
    subplot.set_label("$^{22}$Na")
    subplot.add_pin(r"\SI{.511}{\mega\electronvolt}", 'above', .511, use_arrow=True)
    subplot.add_pin(r"\SI{1.2745}{\mega\electronvolt}", 'above', 1.2745, use_arrow=True, style="pin distance=20pt")
    subplot = plot.get_subplot_at(0, 1)
    subplot.plot(E, Cs - background, mark=None)
    subplot.set_label("$^{137}$Cs")

    plot.show_xticklabels_for_all()
    plot.set_xticklabels_position(0, 1, 'top')
    plot.set_ylimits_for_all(min=0)
    plot.set_yticks_for_all()
    plot.set_xlabel(r"Energie [\si{\mega\electronvolt}]")
    plot.set_ylabel("Signaalsterkte")
    plot.save_as_document("preview")
    plot.save_as_pdf("Na_Cs")
コード例 #2
0
def hist_fav_single_stations(data):
    reconstructions = data.root.reconstructions.reconstructions

    width = r'.35\linewidth'
    graph1 = artist.MultiPlot(1, 3, width=width, height=width)
    graph2 = artist.MultiPlot(1, 3, width=width, height=width)

    figure()
    for n, station in enumerate([501, 503, 506], 1):
        query = '(N == 1) & s%d' % station
        phi = reconstructions.readWhere(query, field='reconstructed_phi')
        theta = reconstructions.readWhere(query, field='reconstructed_theta')

        subplot(2, 3, n)
        N, bins, patches = hist(rad2deg(phi),
                                bins=linspace(-180, 180, 21),
                                histtype='step')
        x = (bins[:-1] + bins[1:]) / 2
        f = lambda x, a: a
        popt, pcov = curve_fit(f, x, N, sigma=sqrt(N))
        chi2 = chisquare(N, popt[0], ddof=0)
        print station, popt, pcov, chi2

        axhline(popt[0])
        xlabel(r"$\phi$")
        legend([station], loc='lower right')
        locator_params(tight=True, nbins=4)
        axis('auto')

        graph1.histogram(0, n - 1, N, bins)
        graph1.set_label(0, n - 1, station)

        subplot(2, 3, n + 3)
        N, bins, patches = hist(rad2deg(theta),
                                bins=linspace(0, 45, 21),
                                histtype='step')
        xlabel(r"$\theta$")
        legend([station], loc='lower right')
        locator_params(tight=True, nbins=4)
        axis('auto')

        graph2.histogram(0, n - 1, N, bins)
        graph2.set_label(0, n - 1, station)

    subplots_adjust(wspace=.4)
    utils.saveplot()

    graph1.set_ylimits_for_all(None, 0, 1500)
    graph1.set_xlimits_for_all(None, -180, 180)
    graph1.show_yticklabels(0, 0)
    graph1.show_xticklabels_for_all()
    graph1.set_xticklabels_position(0, 1, 'right')
    graph1.set_xticks_for_all(None, range(-180, 181, 90))
    graph1.set_xlabel(r'Shower azimuthal angle [\si{\degree}]')
    graph1.set_ylabel('Count')
    artist.utils.save_graph(graph1, suffix='phi', dirname='plots')

    graph2.set_ylimits_for_all(None, 0, 2000)
    graph2.set_xlimits_for_all(None, 0, 45)
    graph2.show_yticklabels(0, 0)
    graph2.show_xticklabels_for_all()
    graph2.set_xticklabels_position(0, 1, 'right')
    graph2.set_xlabel(r'Shower zenith angle [\si{\degree}]')
    graph2.set_ylabel('Count')
    artist.utils.save_graph(graph2, suffix='theta', dirname='plots')
コード例 #3
0
def plot_fav_uncertainty_single_vs_single(data):
    cluster = [501, 503, 506]
    cluster_str = [str(u) for u in cluster]

    width = r'.35\linewidth'
    graph = artist.MultiPlot(3, 3, width=width, height=width)

    figure()
    for i in range(len(cluster)):
        for j in range(len(cluster)):
            station1 = cluster[i]
            station2 = cluster[j]

            theta_station1, phi_station1, theta_station2, phi_station2 = \
                calc_direction_single_vs_single(data, station1, station2)

            bins = linspace(0, deg2rad(45), 11)
            x, y, y2 = [], [], []
            for low, high in zip(bins[:-1], bins[1:]):
                sel_phi_c = phi_station2.compress((low <= theta_station1)
                                                  & (theta_station1 < high))
                sel_phi_s = phi_station1.compress((low <= theta_station1)
                                                  & (theta_station1 < high))
                sel_theta_c = theta_station2.compress((low <= theta_station1) &
                                                      (theta_station1 < high))
                sel_theta_s = theta_station1.compress((low <= theta_station1) &
                                                      (theta_station1 < high))
                dphi = sel_phi_s - sel_phi_c
                dtheta = sel_theta_s - sel_theta_c
                # make sure phi, theta are between -pi and pi
                dphi = (dphi + pi) % (2 * pi) - pi
                dtheta = (dtheta + pi) % (2 * pi) - pi
                print rad2deg((low + high) / 2), len(dphi), len(dtheta)
                x.append((low + high) / 2)
                #y.append(std(dphi))
                #y2.append(std(dtheta))
                y.append(
                    (scoreatpercentile(dphi, 83) - scoreatpercentile(dphi, 17))
                    / 2)
                y2.append((scoreatpercentile(dtheta, 83) -
                           scoreatpercentile(dtheta, 17)) / 2)

            ex = linspace(0, deg2rad(45), 50)
            ephi, etheta = [], []
            for theta in ex:
                ephi.append(calc_phi_error_for_station_station(theta, i, j))
                etheta.append(calc_theta_error_for_station_station(
                    theta, i, j))

            subplot(3, 3, j * 3 + i + 1)
            if i > j:
                plot(rad2deg(x), rad2deg(y), 'o')
                plot(rad2deg(ex), rad2deg(ephi))
                ylim(0, 100)

                graph.plot(j, i, rad2deg(x), rad2deg(y), linestyle=None)
                graph.plot(j, i, rad2deg(ex), rad2deg(ephi), mark=None)
            elif i < j:
                plot(rad2deg(x), rad2deg(y2), 'o')
                plot(rad2deg(ex), rad2deg(etheta))
                ylim(0, 15)
                graph.plot(j, i, rad2deg(x), rad2deg(y2), linestyle=None)
                graph.plot(j, i, rad2deg(ex), rad2deg(etheta), mark=None)

            xlim(0, 45)

            if j == 2:
                xlabel(station1)
            if i == 0:
                ylabel(station2)
            locator_params(tight=True, nbins=4)

    utils.saveplot()

    graph.set_empty_for_all([(0, 0), (1, 1), (2, 2)])
    graph.set_ylimits_for_all([(0, 1), (0, 2), (1, 2)], 0, 100)
    graph.set_ylimits_for_all([(1, 0), (2, 0), (2, 1)], 0, 15)
    graph.set_xlimits_for_all(None, 0, 45)

    graph.show_xticklabels_for_all([(2, 0), (2, 1), (0, 2)])
    graph.show_yticklabels_for_all([(0, 2), (1, 2), (1, 0), (2, 0)])

    graph.set_yticks(1, 0, [5, 10, 15])
    graph.set_yticks(0, 2, range(20, 101, 20))

    for i, station in enumerate(cluster):
        graph.set_label(i, i, station, 'center')

    graph.set_xlabel(r'Shower zenith angle [\si{\degree}]')
    graph.set_ylabel(r'Angle reconstruction uncertainty [\si{\degree}]')

    graph.set_label(0, 1, r'$\phi$')
    graph.set_label(0, 2, r'$\phi$')
    graph.set_label(1, 2, r'$\phi$')
    graph.set_label(1, 0, r'$\theta$', 'upper left')
    graph.set_label(2, 0, r'$\theta$', 'upper left')
    graph.set_label(2, 1, r'$\theta$', 'upper left')

    artist.utils.save_graph(graph, dirname='plots')
コード例 #4
0
def plot_fav_uncertainty_single_vs_cluster(data):
    cluster = [501, 503, 506]
    cluster_str = [str(u) for u in cluster]
    cluster_ids = [0, 2, 5]

    width = r'.35\linewidth'
    graph = artist.MultiPlot(2, 3, width=width, height=width)

    figure()
    for n, station in enumerate(cluster, 1):
        theta_station, phi_station, theta_cluster, phi_cluster = \
            calc_direction_single_vs_cluster(data, station, cluster)

        bins = linspace(0, deg2rad(45), 11)
        x, y, y2 = [], [], []
        for low, high in zip(bins[:-1], bins[1:]):
            sel_phi_c = phi_cluster.compress((low <= theta_station)
                                             & (theta_station < high))
            sel_phi_s = phi_station.compress((low <= theta_station)
                                             & (theta_station < high))
            sel_theta_c = theta_cluster.compress((low <= theta_station)
                                                 & (theta_station < high))
            sel_theta_s = theta_station.compress((low <= theta_station)
                                                 & (theta_station < high))
            dphi = sel_phi_s - sel_phi_c
            dtheta = sel_theta_s - sel_theta_c
            # make sure phi, theta are between -pi and pi
            dphi = (dphi + pi) % (2 * pi) - pi
            dtheta = (dtheta + pi) % (2 * pi) - pi
            print rad2deg((low + high) / 2), len(dphi), len(dtheta)
            x.append((low + high) / 2)
            #y.append(std(dphi))
            #y2.append(std(dtheta))
            y.append(
                (scoreatpercentile(dphi, 83) - scoreatpercentile(dphi, 17)) /
                2)
            y2.append(
                (scoreatpercentile(dtheta, 83) - scoreatpercentile(dtheta, 17))
                / 2)

        ex = linspace(0, deg2rad(45), 50)
        ephi, etheta = [], []
        for theta in ex:
            ephi.append(
                calc_phi_error_for_station_cluster(theta, n, cluster_ids))
            etheta.append(
                calc_theta_error_for_station_cluster(theta, n, cluster_ids))

        subplot(2, 3, n)
        plot(rad2deg(x), rad2deg(y), 'o')
        plot(rad2deg(ex), rad2deg(ephi))
        xlabel(r"$\theta_{%d}$ [deg]" % station)
        if n == 1:
            ylabel(r"$\phi$ uncertainty [deg]")
        ylim(0, 100)
        locator_params(tight=True, nbins=4)

        graph.plot(0, n - 1, rad2deg(x), rad2deg(y), linestyle=None)
        graph.plot(0, n - 1, rad2deg(ex), rad2deg(ephi), mark=None)
        graph.set_label(0, n - 1, r'$\phi$, %d' % station)

        subplot(2, 3, n + 3)
        plot(rad2deg(x), rad2deg(y2), 'o')
        plot(rad2deg(ex), rad2deg(etheta))
        xlabel(r"$\theta_{%d}$ [deg]" % station)
        if n == 1:
            ylabel(r"$\theta$ uncertainty [deg]")
        #ylabel(r"$\theta_{\{%s\}}$" % ','.join(cluster_str))
        ylim(0, 15)
        locator_params(tight=True, nbins=4)

        graph.plot(1, n - 1, rad2deg(x), rad2deg(y2), linestyle=None)
        graph.plot(1, n - 1, rad2deg(ex), rad2deg(etheta), mark=None)
        graph.set_label(1, n - 1, r'$\theta$, %d' % station)

    subplots_adjust(wspace=.3, hspace=.3)
    utils.saveplot()

    graph.set_xlimits_for_all(None, 0, 45)
    graph.set_ylimits_for_all([(0, 0), (0, 1), (0, 2)], 0, 100)
    graph.set_ylimits_for_all([(1, 0), (1, 1), (1, 2)], 0, 15)
    graph.show_xticklabels_for_all([(1, 0), (0, 1), (1, 2)])
    graph.show_yticklabels_for_all([(0, 2), (1, 0)])

    graph.set_xlabel(r"Shower zenith angle [\si{\degree}]")
    graph.set_ylabel(r"Angle reconstruction uncertainty [\si{\degree}]")

    artist.utils.save_graph(graph, dirname='plots')
コード例 #5
0
def plot_fav_single_vs_single(data):
    cluster = [501, 503, 506]
    cluster_str = [str(u) for u in cluster]

    width = r'.35\linewidth'
    graph = artist.MultiPlot(3, 3, width=width, height=width)

    figure()
    for i in range(len(cluster)):
        for j in range(len(cluster)):
            station1 = cluster[i]
            station2 = cluster[j]

            theta_station1, phi_station1, theta_station2, phi_station2 = \
                calc_direction_single_vs_single(data, station1, station2)

            subplot(3, 3, j * 3 + i + 1)
            if i > j:
                plot(rad2deg(phi_station1), rad2deg(phi_station2), ',')
                xlim(-180, 180)
                ylim(-180, 180)

                bins = linspace(-180, 180, 37)
                H, x_edges, y_edges = histogram2d(rad2deg(phi_station1),
                                                  rad2deg(phi_station2),
                                                  bins=bins)
                graph.histogram2d(j, i, H, x_edges, y_edges, 'reverse_bw')
                graph.set_label(j,
                                i,
                                r'$\phi$',
                                'upper left',
                                style='fill=white')
            elif i < j:
                plot(rad2deg(theta_station1), rad2deg(theta_station2), ',')
                xlim(0, 45)
                ylim(0, 45)

                bins = linspace(0, 45, 46)
                H, x_edges, y_edges = histogram2d(rad2deg(theta_station1),
                                                  rad2deg(theta_station2),
                                                  bins=bins)
                graph.histogram2d(j, i, H, x_edges, y_edges, 'reverse_bw')
                graph.set_label(j,
                                i,
                                r'$\theta$',
                                'upper left',
                                style='fill=white')

            if j == 2:
                xlabel(station1)
            if i == 0:
                ylabel(station2)
            locator_params(tight=True, nbins=4)

            #subplot(3, 3, n + 3)
            #plot(rad2deg(theta_station1), rad2deg(theta_station2), ',')
            #xlabel(r"$\theta_{%d}$" % station1)
            #ylabel(r"$\theta_{\{%s\}}$" % ','.join(station2_str))
            #xlim(0, 45)
            #ylim(0, 45)
            #locator_params(tight=True, nbins=4)

    utils.saveplot()

    graph.set_empty_for_all([(0, 0), (1, 1), (2, 2)])

    graph.show_xticklabels_for_all([(0, 1), (0, 2), (2, 0), (2, 1)])
    graph.set_xticks(0, 1, range(-180, 181, 90))
    graph.set_xticks(0, 2, range(-90, 181, 90))
    graph.show_yticklabels_for_all([(0, 2), (1, 2), (1, 0), (2, 0)])
    graph.set_yticks(1, 2, range(-180, 181, 90))
    graph.set_yticks(0, 2, range(-90, 181, 90))

    graph.set_xlabel(r"Shower angle [\si{\degree}]")
    graph.set_ylabel(r"Shower angle [\si{\degree}]")

    for i, station in enumerate(cluster):
        graph.set_label(i, i, cluster[i], 'center')

    artist.utils.save_graph(graph, dirname='plots')
コード例 #6
0
def plot_fav_single_vs_cluster(data):
    cluster = [501, 503, 506]
    cluster_str = [str(u) for u in cluster]

    width = r'.35\linewidth'
    graph1 = artist.MultiPlot(1, 3, width=width, height=width)
    graph2 = artist.MultiPlot(1, 3, width=width, height=width)

    figure()
    for n, station in enumerate(cluster, 1):
        theta_station, phi_station, theta_cluster, phi_cluster = \
            calc_direction_single_vs_cluster(data, station, cluster, 2000)

        subplot(2, 3, n)
        plot(rad2deg(phi_station), rad2deg(phi_cluster), ',')
        xlabel(r"$\phi_{%d}$" % station)
        xlim(-180, 180)
        ylim(-180, 180)
        locator_params(tight=True, nbins=4)
        if n == 1:
            ylabel(r"$\phi_{\{%s\}}$" % ','.join(cluster_str))

        bins = linspace(-180, 180, 37)
        H, x_edges, y_edges = histogram2d(rad2deg(phi_station),
                                          rad2deg(phi_cluster),
                                          bins=bins)
        graph1.histogram2d(0, n - 1, H, x_edges, y_edges, 'reverse_bw')
        graph1.set_label(0, n - 1, station, 'upper left', style='fill=white')

        subplot(2, 3, n + 3)
        plot(rad2deg(theta_station), rad2deg(theta_cluster), ',')
        xlabel(r"$\theta_{%d}$" % station)
        xlim(0, 45)
        ylim(0, 45)
        locator_params(tight=True, nbins=4)
        if n == 1:
            ylabel(r"$\theta_{\{%s\}}$" % ','.join(cluster_str))

        bins = linspace(0, 45, 46)
        H, x_edges, y_edges = histogram2d(rad2deg(theta_station),
                                          rad2deg(theta_cluster),
                                          bins=bins)
        graph2.histogram2d(0, n - 1, H, x_edges, y_edges, 'reverse_bw')
        graph2.set_label(0, n - 1, station, 'upper left', style='fill=white')

    subplots_adjust(wspace=.4, hspace=.4)
    utils.saveplot()

    graph1.set_xticks_for_all(None, range(-180, 181, 90))
    graph1.set_yticks_for_all(None, range(-180, 181, 90))
    graph1.show_xticklabels_for_all(None)
    graph1.show_yticklabels(0, 0)
    graph1.set_xticklabels_position(0, 1, 'right')
    graph1.set_xlabel(r"Azimuthal angle (station) [\si{\degree}]")
    graph1.set_ylabel(r"Azimuthal angle (cluster) [\si{\degree}]")

    graph2.show_xticklabels_for_all(None)
    graph2.show_yticklabels(0, 0)
    graph2.set_xticklabels_position(0, 1, 'right')
    graph2.set_xlabel(r"Zenith angle (station) [\si{\degree}]")
    graph2.set_ylabel(r"Zenith angle (cluster) [\si{\degree}]")

    artist.utils.save_graph(graph1, suffix='phi', dirname='plots')
    artist.utils.save_graph(graph2, suffix='theta', dirname='plots')