def plot_N_vs_R(data): stations = range(501, 507) station_ids = range(6) cluster = clusters.ScienceParkCluster(stations) c_index = data.root.coincidences.c_index observables = data.root.coincidences.observables figure() #clf() global c_x, c_y if 'c_x' in globals(): scatter(c_x, c_y) else: stations_in_coincidence = [] for coincidence_events in c_index: stations = [observables[u]['station_id'] for u in coincidence_events] stations_in_coincidence.append(stations) c_x = [] c_y = [] for station1, station2 in itertools.combinations(station_ids, 2): condition = [station1 in u and station2 in u for u in stations_in_coincidence] N = sum(condition) R, phi = cluster.calc_r_and_phi_for_stations(station1, station2) scatter(R, N) c_x.append(R) c_y.append(N) print R, N, station1, station2 ldf = KascadeLdf() R = linspace(100, 500) E = linspace(1e14, 1e19, 100) F = E ** -2.7 N = [] for r in R: x = [] for f, e in zip(F, E): Ne = e / 1e15 * 10 ** 4.8 density = ldf.get_ldf_value_for_size(r, Ne) prob = 1 - exp(-.5 * density) x.append(f * prob) N.append(mean(x)) N = array(N) f = lambda x, S: S * interp(x, R, N) c_x = array(c_x) c_y = array(c_y) # WTF wrong with point at slightly less than 100 m? 501 / 502?? sc_x = c_x.compress(c_x >= 100) sc_y = c_y.compress(c_x >= 100) popt, pcov = curve_fit(f, sc_x, sc_y, p0=(1e45)) plot(R, f(R, popt[0])) #ylim(0, 150000) ylim(0, 500000) xlim(0, 500) xlabel("Distance [m]") ylabel("Number of coincidences") utils.saveplot() utils.savedata([sc_x, sc_y], suffix='data') utils.savedata([R, f(R, popt[0])], suffix='fit')
def plot_N_vs_R(data): stations = range(501, 507) station_ids = range(6) cluster = clusters.ScienceParkCluster(stations) c_index = data.root.coincidences.c_index observables = data.root.coincidences.observables figure() #clf() global c_x, c_y if 'c_x' in globals(): scatter(c_x, c_y) else: stations_in_coincidence = [] for coincidence_events in c_index: stations = [ observables[u]['station_id'] for u in coincidence_events ] stations_in_coincidence.append(stations) c_x = [] c_y = [] for station1, station2 in itertools.combinations(station_ids, 2): condition = [ station1 in u and station2 in u for u in stations_in_coincidence ] N = sum(condition) R, phi = cluster.calc_r_and_phi_for_stations(station1, station2) scatter(R, N) c_x.append(R) c_y.append(N) print R, N, station1, station2 ldf = KascadeLdf() R = linspace(100, 500) E = linspace(1e14, 1e19, 100) F = E**-2.7 N = [] for r in R: x = [] for f, e in zip(F, E): Ne = e / 1e15 * 10**4.8 density = ldf.get_ldf_value_for_size(r, Ne) prob = 1 - exp(-.5 * density) x.append(f * prob) N.append(mean(x)) N = array(N) f = lambda x, S: S * interp(x, R, N) c_x = array(c_x) c_y = array(c_y) # WTF wrong with point at slightly less than 100 m? 501 / 502?? sc_x = c_x.compress(c_x >= 100) sc_y = c_y.compress(c_x >= 100) popt, pcov = curve_fit(f, sc_x, sc_y, p0=(1e45)) plot(R, f(R, popt[0])) #ylim(0, 150000) ylim(0, 500000) xlim(0, 500) xlabel("Distance [m]") ylabel("Number of coincidences") utils.saveplot() utils.savedata([sc_x, sc_y], suffix='data') utils.savedata([R, f(R, popt[0])], suffix='fit')