Пример #1
0
rr = np.random.triangular(rmin, rmax, rmax, n_events)
phiphi = np.random.uniform(0, 2 * np.pi, n_events)
xx = rr * np.cos(phiphi)
yy = rr * np.sin(phiphi)
zz = np.random.uniform(zmin, zmax, n_events)

points = np.array([xx, yy, zz]).T
x_receiver = np.array([0., 0., -5.])

results_C0s_cpp = np.zeros((n_events, 2))
n_freqs = 256//2 + 1
# n_freqs = 5
results_A_cpp = np.zeros((n_events, 2, n_freqs))
t_start = time.time()
ff = np.linspace(0, 500*units.MHz, n_freqs)
# tt = 0
for iX, x in enumerate(points):
#     t_start2 = time.time()
    r = ray.ray_tracing(ice)
    r.set_start_and_end_point(x, x_receiver)
#     tt += (time.time() - t_start2)
    r.find_solutions()
    if(r.has_solution()):
        for iS in range(r.get_number_of_solutions()):
            results_C0s_cpp[iX, iS] = r.get_results()[iS]['C0']

results_C0s_cpp_ref = io_utilities.read_pickle("reference_C0.pkl", encoding='latin1')
testing.assert_allclose(results_C0s_cpp, results_C0s_cpp_ref)

print('T05unit_test_c0_SP passed without issues')
Пример #2
0
rr = np.random.triangular(rmin, rmax, rmax, n_events)
phiphi = np.random.uniform(0, 2 * np.pi, n_events)
xx = rr * np.cos(phiphi)
yy = rr * np.sin(phiphi)
zz = np.random.uniform(zmin, zmax, n_events)

points = np.array([xx, yy, zz]).T
x_receiver = np.array([0., 0., -5.])

results_C0s_cpp = np.zeros((n_events, 10))
n_freqs = 256 // 2 + 1
# n_freqs = 5
results_A_cpp = np.zeros((n_events, 2, n_freqs))
t_start = time.time()
ff = np.linspace(0, 500 * units.MHz, n_freqs)
# tt = 0
for iX, x in enumerate(points):
    #     t_start2 = time.time()
    r = ray.ray_tracing(x, x_receiver, ice, n_reflections=2)
    #     tt += (time.time() - t_start2)
    r.find_solutions()
    if (r.has_solution()):
        for iS in range(r.get_number_of_solutions()):
            results_C0s_cpp[iX, iS] = r.get_results()[iS]['C0']

results_C0s_cpp_ref = io_utilities.read_pickle("reference_C0_MooresBay.pkl",
                                               encoding='latin1')
testing.assert_allclose(results_C0s_cpp, results_C0s_cpp_ref, rtol=1.e-6)

print('T06unit_test_C0_mooresbay passed without issues')
Пример #3
0
            continue
        vertex = np.array([fin['xx'][iE], fin['yy'][iE], fin['zz'][iE]])
        #         print(fin.keys())
        #         l1 = fin['launch_vectors'][iE][3] / units.deg
        l2 = fin['station_101']['launch_vectors'][iE][j * 4 + 3]

        #         r1 = ray.ray_tracing(vertex, x1, med, log_level=logging.DEBUG)
        # #         r1.find_solutions()
        #         r1.set_solution(fin['ray_tracing_C0'][iE][3], fin['ray_tracing_C1'][iE][3], fin['ray_tracing_solution_type'][iE][3])
        #         path1 = r1.get_path(0)

        zen, az = fin['zeniths'][iE], fin['azimuths'][iE]
        v = hp.spherical_to_cartesian(zen, az)

        if (plot):
            r2 = ray.ray_tracing(vertex, x2, med, log_level=logging.INFO)
            r2.set_solution(
                fin['station_101']['ray_tracing_C0'][iE][iC],
                fin['station_101']['ray_tracing_C1'][iE][iC],
                fin['station_101']['ray_tracing_solution_type'][iE][iC])
            path2 = r2.get_path(0)
            #         ax.plot3D(path1.T[0], path1.T[1], path1.T[2], label='path 1')
            ax.plot3D(path2.T[0],
                      path2.T[1],
                      path2.T[2],
                      label='path {}'.format(j))
            ax.plot3D([vertex[0], vertex[0] + 500 * v[0]],
                      [vertex[1], vertex[1] + 500 * v[1]],
                      [vertex[2], vertex[2] + 500 * v[2]],
                      '--',
                      label='shower direction')
Пример #4
0
              cmap=plt.get_cmap('Blues'), weights=weights)
cb = plt.colorbar(h[3], ax=ax)
cb.set_label("weighted number of events")
ax.set_aspect('equal')
ax.set_xlabel("r [m]")
ax.set_ylabel("z [m]")
fig.tight_layout()

mask = (zz < -2000 * units.m) & (rr < 5000 * units.m)
for i in np.array(range(len(xx)))[mask]:
#     C0 = fin['ray_tracing_C0'][i][0][0]
#     C1 = fin['ray_tracing_C1'][i][0][0]
    print('weight = {:.2f}'.format(weights[i]))
    x1 = np.array([xx[i], yy[i], zz[i]])
    x2 = np.array([0, 0, -5])
    r = ray.ray_tracing(x1, x2, medium.southpole_simple())
    r.find_solutions()
    C0 = r.get_results()[0]['C0']
    x1 = np.array([-rr[i], zz[i]])
    x2 = np.array([0, -5])
    r2 = ray.ray_tracing_2D(medium.southpole_simple())
    yyy, zzz = r2.get_path(x1, x2, C0)

    launch_vector = fin['launch_vectors'][i][0][0]
    print(launch_vector)
    zenith_nu = fin['zeniths'][i]
    print(zenith_nu / units.deg)

    fig, ax = plt.subplots(1, 1)
    ax.plot(-rr[i], zz[i], 'o')
    ax.plot([-rr[i], -rr[i] + 100 * np.cos(zenith_nu)], [zz[i], zz[i] + 100 * np.sin(zenith_nu)], '-C0')
phiphi = np.random.uniform(0, 2 * np.pi, n_events)
xx = rr * np.cos(phiphi)
yy = rr * np.sin(phiphi)
zz = np.random.uniform(zmin, zmax, n_events)

points = np.array([xx, yy, zz]).T
x_receiver = np.array([0., 0., -5.])

results_C0s_cpp = np.zeros((n_events, 10))
n_freqs = 256 // 2 + 1
# n_freqs = 5
results_A_cpp = np.zeros((n_events, 2, n_freqs))
t_start = time.time()
ff = np.linspace(0, 500 * units.MHz, n_freqs)
# tt = 0
for iX, x in enumerate(points):
    #     t_start2 = time.time()
    r = ray.ray_tracing(ice, n_reflections=2)
    r.set_start_and_end_point(x, x_receiver)
    #     tt += (time.time() - t_start2)
    r.find_solutions()
    if (r.has_solution()):
        for iS in range(r.get_number_of_solutions()):
            results_C0s_cpp[iX, iS] = r.get_results()[iS]['C0']

results_C0s_cpp_ref = io_utilities.read_pickle("reference_C0_MooresBay.pkl",
                                               encoding='latin1')
testing.assert_allclose(results_C0s_cpp, results_C0s_cpp_ref, rtol=1.e-6)

print('T06unit_test_C0_mooresbay passed without issues')
Пример #6
0
points = np.array([xx, yy, zz]).T
x_receiver = np.array([0., 0., -5.])

nsol = 6
results_D = np.zeros((n_events, nsol))
results_D_analytic = np.zeros((n_events, nsol))
results_T = np.zeros((n_events, nsol))
results_T_analytic = np.zeros((n_events, nsol))

d_numeric = 0
d_analytic = 0
t_numeric = 0
t_analytic = 0
for iX, x in enumerate(points):
    r = ray.ray_tracing(x, x_receiver, ice, log_level=logging.WARNING, n_reflections=1)
    r.find_solutions()
    if(r.has_solution()):
        for iS in range(r.get_number_of_solutions()):
            t_start = time.time()
            results_D[iX, iS] = r.get_path_length(iS, analytic=False)
            d_numeric += time.time() - t_start
            t_start = time.time()
            results_D_analytic[iX, iS] = r.get_path_length(iS, analytic=True)
            d_analytic += time.time() - t_start


            t_start = time.time()
            results_T[iX, iS] = r.get_travel_time(iS, analytic=False)
            t_numeric += time.time() - t_start
            t_start = time.time()
Пример #7
0
receive_vectors = np.zeros((4, 2, 3)) * np.nan
ray_tracing_C0 = np.zeros((4, 2)) * np.nan
ray_tracing_C1 = np.zeros((4, 2)) * np.nan
ray_tracing_solution_type = np.zeros((4, 2), dtype=np.int) * np.nan
travel_times = np.zeros((4, 2)) * np.nan
travel_distances = np.zeros((4, 2)) * np.nan

ice = medium.southpole_simple()

lss = ['-', '--', ':']
colors = ['b','g','r']
fig, ax = plt.subplots(1, 1)
ax.plot(x1[0], x1[2], 'ko')
for i, x in enumerate([x2, x3, x4, x5]):
    print('finding solutions for ', x)
    r = ray.ray_tracing(x1,x,ice)
    r.find_solutions()
    if(r.has_solution()):
        for iS in range(r.get_number_of_solutions()):
            ray_tracing_C0[i, iS] = r.get_results()[iS]['C0']
            ray_tracing_solution_type[i, iS] = r.get_solution_type(iS)
            print("     Solution %d, Type %d: "%(iS,ray_tracing_solution_type[i, iS]))
            R = r.get_path_length(iS)  # calculate path length
            T = r.get_travel_time(iS)  # calculate travel time
            print("     Ray Distance %.3f and Travel Time %.3f"%(R/units.m,T/units.ns))
            receive_vector = r.get_receive_vector(iS)
            receive_vectors[i, iS] = receive_vector
            zenith, azimuth = hp.cartesian_to_spherical(*receive_vector)
            print("     Receiving Zenith %.3f and Azimuth %.3f "%(zenith/units.deg, azimuth/units.deg))

            #to readout the actual trace, we have to flatten to 2D
Пример #8
0
yy = rr * np.sin(phiphi)
zz = np.random.uniform(zmin, zmax, n_events)

points = np.array([xx, yy, zz]).T
x_receiver = np.array([0., 0., -5.])

results_C0s_cpp = np.zeros((n_events, 2))
n_freqs = 256 // 2 + 1
# n_freqs = 5
results_A_cpp = np.zeros((n_events, 2, n_freqs))
t_start = time.time()
ff = np.linspace(0, 500 * units.MHz, n_freqs)
# tt = 0
for iX, x in enumerate(points):
    #     t_start2 = time.time()
    r = ray.ray_tracing(x, x_receiver, ice)
    #     tt += (time.time() - t_start2)
    r.find_solutions()
    if (r.has_solution()):
        for iS in range(r.get_number_of_solutions()):
            results_C0s_cpp[iX, iS] = r.get_results()[iS]['C0']
            results_A_cpp[iX, iS] = r.get_attenuation(iS, ff)
t_cpp = time.time() - t_start
print("CPP time = {:.1f} seconds = {:.2f}ms/event".format(
    t_cpp, 1000. * t_cpp / n_events))
# print("CPP time = {:.1f} seconds = {:.2f}ms/event".format(tt, 1000. * tt / n_events))

results_C0s_python = np.zeros((n_events, 2))
results_A_python = np.zeros((n_events, 2, n_freqs))
ray.cpp_available = False
t_start = time.time()
Пример #9
0
for evt in eventReader.run():
    for station in evt.get_stations():
        station_id = station.get_id()
        t = station.get_station_time()
        det.update(t)
        d = evt.get_first_sim_shower().get_parameter(shp.vertex)[2]
        if (np.any(np.isclose(d, dds, atol=5))):
            dds = np.delete(dds, np.argwhere(np.isclose(d, dds, atol=5)))
        else:
            continue
#         if(d > -800):
#             continue

# calcualte expected angles
        r = ray.ray_tracing(pos_spice + np.array([0, 0, d]),
                            pos_SP1,
                            medium.southpole_simple(),
                            log_level=logging.WARNING)
        r.find_solutions()
        if (not r.has_solution()):
            continue

        results['depth'].append(d)
        rvec = r.get_receive_vector(0)
        zen, az = hp.cartesian_to_spherical(*rvec)
        az = hp.get_normalized_angle(az)
        results['exp'].append((zen, az))
        print("{} depth = {:.1f}m -> {:.2f} {:.2f} (solution type {})".format(
            t, d, zen / units.deg, az / units.deg, r.get_solution_type(0)))

        channelResampler.run(evt, station, det, 50 * units.GHz)
        channelBandPassFilter.run(evt,
Пример #10
0
points = np.array([xx, yy, zz]).T
x_receiver = np.array([0., 0., -5.])

nsol = 6
results_D = np.zeros((n_events, nsol))
results_D_analytic = np.zeros((n_events, nsol))
results_T = np.zeros((n_events, nsol))
results_T_analytic = np.zeros((n_events, nsol))

d_numeric = 0
d_analytic = 0
t_numeric = 0
t_analytic = 0
for iX, x in enumerate(points):
    r = ray.ray_tracing(ice, log_level=logging.WARNING, n_reflections=1)
    r.set_start_and_end_point(x, x_receiver)
    r.find_solutions()
    if (r.has_solution()):
        for iS in range(r.get_number_of_solutions()):
            t_start = time.time()
            results_D[iX, iS] = r.get_path_length(iS, analytic=False)
            d_numeric += time.time() - t_start
            t_start = time.time()
            results_D_analytic[iX, iS] = r.get_path_length(iS, analytic=True)
            d_analytic += time.time() - t_start

            t_start = time.time()
            results_T[iX, iS] = r.get_travel_time(iS, analytic=False)
            t_numeric += time.time() - t_start
            t_start = time.time()
Пример #11
0
dds = -1 * np.arange(500, 1800, 100)
for evt in eventReader.run():
    for station in evt.get_stations():
        station_id = station.get_id()
        t = station.get_station_time()
        det.update(t)
        d = evt.get_first_sim_shower().get_parameter(shp.vertex)[2]
        if (np.any(np.isclose(d, dds, atol=5))):
            dds = np.delete(dds, np.argwhere(np.isclose(d, dds, atol=5)))
        else:
            continue
#         if(d > -800):
#             continue

# calcualte expected angles
        r = ray.ray_tracing(medium.southpole_simple(),
                            log_level=logging.WARNING)
        r.set_start_and_end_point(pos_spice + np.array([0, 0, d]), pos_SP1)
        r.find_solutions()
        if (not r.has_solution()):
            continue

        results['depth'].append(d)
        rvec = r.get_receive_vector(0)
        zen, az = hp.cartesian_to_spherical(*rvec)
        az = hp.get_normalized_angle(az)
        results['exp'].append((zen, az))
        print("{} depth = {:.1f}m -> {:.2f} {:.2f} (solution type {})".format(
            t, d, zen / units.deg, az / units.deg, r.get_solution_type(0)))

        channelResampler.run(evt, station, det, 50 * units.GHz)
        channelBandPassFilter.run(evt,