コード例 #1
0
def plot_densities(data):
    """Make particle count plots for each detector to compare densities/responses"""

    e501 = data.get_node('/hisparc/cluster_amsterdam/station_501', 'events')
    e510 = data.get_node('/hisparc/cluster_amsterdam/station_510', 'events')

    sn501 = (e501.col('n1') + e501.col('n2') + e501.col('n3') +
             e501.col('n4')) / 2
    sn510 = (e510.col('n1') + e510.col('n2') + e510.col('n3') +
             e510.col('n4')) / 2
    n501 = [e501.col('n1'), e501.col('n2'), e501.col('n3'), e501.col('n4')]
    n510 = [e510.col('n1'), e510.col('n2'), e510.col('n3'), e510.col('n4')]

    n_min = 0.5  # remove peak at 0
    n_max = 200
    bins = np.logspace(np.log10(n_min), np.log10(n_max), 50)

    for minn in [0, 1, 2, 4, 8, 16]:
        # poisson_errors = np.sqrt(bins)
        # filter = sn501 > minn
        filter = (sn501 > minn) & (sn510 > minn)
        plot = MultiPlot(4,
                         4,
                         'loglog',
                         width=r'.22\linewidth',
                         height=r'.22\linewidth')
        for i in range(4):
            for j in range(4):
                ncounts, x, y = np.histogram2d(n501[i].compress(filter),
                                               n510[j].compress(filter),
                                               bins=bins)
                subplot = plot.get_subplot_at(i, j)
                subplot.histogram2d(ncounts,
                                    x,
                                    y,
                                    type='reverse_bw',
                                    bitmap=True)
                # subplot.plot(bins - poisson_errors, bins + poisson_errors,
                #              mark=None, linestyle='red')
                # subplot.plot(bins + poisson_errors, bins - poisson_errors,
                #              mark=None, linestyle='red')

        plot.show_xticklabels_for_all([(3, 0), (3, 1), (3, 2), (3, 3)])
        plot.show_yticklabels_for_all([(0, 3), (1, 3), (2, 3), (3, 3)])
        # plot.set_title(0, 1, 'Particle counts for station 501 and 510')
        for i in range(4):
            plot.set_subplot_xlabel(0, i, 'detector %d' % (i + 1))
            plot.set_subplot_ylabel(i, 0, 'detector %d' % (i + 1))
        plot.set_xlabel('Number of particles 501')
        plot.set_ylabel('Number of particles 510')
        plot.save_as_pdf('n_minn%d_501_510_bins_log' % minn)

    ncounts, x, y = np.histogram2d(sn501, sn510, bins=bins)
    plot = Plot('loglog')
    plot.set_axis_equal()
    plot.histogram2d(ncounts, x, y, type='reverse_bw', bitmap=True)
    # plot.set_title('Particle counts for station 501 and 510')
    plot.set_xlabel('Particle density in 501')
    plot.set_ylabel('Particle density in 510')
    plot.save_as_pdf('n_501_510_sum_log')
コード例 #2
0
ファイル: densities.py プロジェクト: 153957/topaz
def plot_densities(data):
    """Make particle count plots for each detector to compare densities/responses"""

    n_min = 0.5  # remove gamma peak
    n_max = 50
    bins = np.linspace(np.log10(n_min), np.log10(n_max), 60)

    for station_number in [501, 510]:
        events = data.get_node('/s%d' % station_number, 'events')
        average_n = (events.col('n1') + events.col('n2') + events.col('n3') + events.col('n4')) / 4.
        n = [events.col('n1'), events.col('n2'), events.col('n3'), events.col('n4')]

        for minn in [0, 1, 2, 4, 8, 16]:
            filter = (average_n > minn) & (n[0] > 0) & (n[1] > 0) & (n[2] > 0) & (n[3] > 0)
            plot = MultiPlot(4, 4, width=r'.25\linewidth',
                             height=r'.25\linewidth')
            for i in range(4):
                for j in range(4):
                    if i < j:
                        continue
                    elif i == j:
                        ncounts, x, y = np.histogram2d(np.log10(average_n.compress(filter)),
                                                       np.log10(n[i].compress(filter)),
                                                       bins=bins)
                    else:
                        ncounts, x, y = np.histogram2d(np.log10(n[i].compress(filter)),
                                                       np.log10(n[j].compress(filter)),
                                                       bins=bins)
                    subplot = plot.get_subplot_at(i, j)
                    subplot.histogram2d(ncounts, x, y, type='reverse_bw',
                                        bitmap=True)
            plot.set_xlimits_for_all(min=0, max=np.log10(n_max))
            plot.set_ylimits_for_all(min=0, max=np.log10(n_max))
            plot.show_xticklabels_for_all([(3, 0), (3, 1), (3, 2), (3, 3)])
            plot.show_yticklabels_for_all([(0, 3), (1, 3), (2, 3), (3, 3)])
        #     plot.set_title(0, 1, 'Particle counts for station 501 and 510')
            for i in range(4):
                plot.set_subplot_xlabel(0, i, 'detector %d' % (i + 1))
                plot.set_subplot_ylabel(i, 0, 'detector %d' % (i + 1))
            plot.set_xlabel('Number of particles')
            plot.set_ylabel('Number of particles')
            plot.save_as_pdf('plots/n_minn%d_%d' % (minn, station_number))