def plot_nearest_neighbors(data, limit=None):
    global coincidences
    hisparc_group = data.root.hisparc.cluster_kascade.station_601
    kascade_group = data.root.kascade

    coincidences = KascadeCoincidences(data,
                                       hisparc_group,
                                       kascade_group,
                                       ignore_existing=True)

    #dt_opt = find_optimum_dt(coincidences, p0=-13, limit=1000)
    #print(dt_opt)

    graph = GraphArtist(axis='semilogy')
    styles = iter(['solid', 'dashed', 'dashdotted'])

    uncorrelated = None
    figure()
    #for shift in -12, -13, dt_opt, -14:
    for shift in -12, -13, -14:
        print("Shifting", shift)
        coincidences.search_coincidences(shift, dtlimit=1, limit=limit)
        print(".")
        dts = coincidences.coincidences['dt']
        n, bins, p = hist(abs(dts) / 1e9,
                          bins=linspace(0, 1, 101),
                          histtype='step',
                          label='%.3f s' % shift)
        n = [u if u else 1e-99 for u in n]
        graph.histogram(n, bins, linestyle=styles.next() + ',gray')
        if uncorrelated is None:
            uncorrelated = n, bins

    y, bins = uncorrelated
    x = (bins[:-1] + bins[1:]) / 2
    f = lambda x, N, a: N * exp(-a * x)
    popt, pcov = curve_fit(f, x, y)
    plot(x, f(x, *popt), label=r"$\lambda = %.2f$ Hz" % popt[1])
    graph.plot(x, f(x, *popt), mark=None)

    yscale('log')
    xlabel("Time difference [s]")
    graph.set_xlabel(r"Time difference [\si{\second}]")
    ylabel("Counts")
    graph.set_ylabel("Counts")
    legend()
    graph.set_ylimits(min=10)
    utils.saveplot()
    graph.save('plots/MAT-nearest-neighbors')
def plot_nearest_neighbors(data, limit=None):
    global coincidences
    hisparc_group = data.root.hisparc.cluster_kascade.station_601
    kascade_group = data.root.kascade

    coincidences = KascadeCoincidences(data, hisparc_group, kascade_group,
                                       ignore_existing=True)

    #dt_opt = find_optimum_dt(coincidences, p0=-13, limit=1000)
    #print dt_opt

    graph = GraphArtist(axis='semilogy')
    styles = iter(['solid', 'dashed', 'dashdotted'])

    uncorrelated = None
    figure()
    #for shift in -12, -13, dt_opt, -14:
    for shift in -12, -13, -14:
        print "Shifting", shift
        coincidences.search_coincidences(shift, dtlimit=1, limit=limit)
        print "."
        dts = coincidences.coincidences['dt']
        n, bins, p = hist(abs(dts) / 1e9, bins=linspace(0, 1, 101),
                          histtype='step', label='%.3f s' % shift)
        n = [u if u else 1e-99 for u in n]
        graph.histogram(n, bins, linestyle=styles.next() + ',gray')
        if uncorrelated is None:
            uncorrelated = n, bins

    y, bins = uncorrelated
    x = (bins[:-1] + bins[1:]) / 2
    f = lambda x, N, a: N * exp(-a * x)
    popt, pcov = curve_fit(f, x, y)
    plot(x, f(x, *popt), label=r"$\lambda = %.2f$ Hz" % popt[1])
    graph.plot(x, f(x, *popt), mark=None)

    yscale('log')
    xlabel("Time difference [s]")
    graph.set_xlabel(r"Time difference [\si{\second}]")
    ylabel("Counts")
    graph.set_ylabel("Counts")
    legend()
    graph.set_ylimits(min=10)
    utils.saveplot()
    graph.save('plots/MAT-nearest-neighbors')
Beispiel #3
0
    def search_for_coincidences(self):
        hisparc = self.hisparc_group
        kascade = self.kascade_group

        try:
            coincidences = KascadeCoincidences(self.data, hisparc, kascade)
        except RuntimeError, msg:
            print msg
            return