Пример #1
0
def SAD_CROSS_GOOD(forward, num_bins=50):
    d = rd.read_h5py_file()
    d = rd.cut_selection(d, 9, 0, forward)
    # E_e=rd.extract_parameter(d, 3)
    # E_g=rd.extract_parameter(d, 1)
    c = 2.998e8
    m = 511 / c**2
    # a_E=np.arccos( 1 - (E_e/E_g*m*c**2/(E_e+E_g)) )
    # a_P=rd.calculate_angles(d)
    # a=np.array([])
    # for i in range(len(a_E)):
    #     if abs(a_E[i]-a_P[i])<0.01:
    #         a=np.append(a,a_P[i])
    margin = 0.01
    d = d[abs(
        np.arccos(1 - (d[:, 3] / d[:, 1] * m * c**2 / (d[:, 3] + d[:, 1]))) -
        np.arccos(-1 * (-d[:, 9] + d[:, 15]) / d[:, 24])) <= margin]
    a = rd.calculate_angles(d)
    n, bins, patches = plt.hist(a, num_bins)
    if forward:
        D = pd.NF
        x_min = at.fsad_min
        x_max = at.fsad_max
    else:
        D = pd.NB
        x_min = at.bsad_min
        x_max = at.bsad_max
    D = D * np.amax(n) / np.amax(D)
    rd.plot_points(D, x_min, x_max)
    plt.xlabel("Scattering Angle [rad]")
    plt.ylabel("Frequency [Counts/Bins]")
Пример #2
0
def plot_flight_angle(d, return_values=False, num_bins=100):
    a = rd.calculate_angles(d)
    if return_values:
        n, bins = np.histogram(a, num_bins)
        x_dist = bins[:-1] + (bins[1] - bins[0]) / 2
        return x_dist, n
    n, bins, patches = plt.hist(a, num_bins)
    x_dist = bins[:-1] + (bins[1] - bins[0]) / 2
    return x_dist, n
def plot_ang_dist(forward, num_bins=100, data_array=None):
    d = rd.read_h5py_file()
    d = rd.cut_selection(d, 9, 0, forward)
    a = rd.calculate_angles(d)
    a = data_array if not type(data_array) == type(None) else a
    n, bins, patches = plt.hist(a, num_bins)
    if forward:
        D = NF
        x_min = at.fsad_min
        x_max = at.fsad_max
    else:
        D = NB
        x_min = at.bsad_min
        x_max = at.bsad_max
    D = D * np.amax(n) / np.amax(D)
    rd.plot_points(D, x_min, x_max, 2.0)
Пример #4
0
def plot_flight_angle_sum(remove_fast=True,
                          return_values=False,
                          num_bins=50,
                          lims=(0, 0.7)):
    sim_d, sim_t = (raw_sim_data,
                    sim_times) if not remove_fast else (raw_sim_data[:-1],
                                                        sim_times[:-1])
    x = np.linspace(lims[0], lims[1], num_bins)
    x_dist = x[:-1] + (x[1] - x[0]) / 2
    n = [np.zeros(len(x) - 1) for i in range(len(sim_d))]
    for i in range(len(n)):
        n[i] = (np.histogram(rd.calculate_angles(sim_d[i]), bins=x)[0] /
                sim_times[i] * np.min(sim_t))
    ns = np.zeros(len(n[0]))
    for i in n:
        ns += i
    if return_values:
        return x, n
    n2, bins, patches = plt.hist(x_dist, bins=x, weights=ns)
    return x, n2
def plot_histogram_and_optimized_distribution(num_bins=100, forward=True):
    d = rd.read_h5py_file()
    d = rd.cut_selection(d, 9, 0, forward)
    data_array = rd.calculate_angles(d)
    if forward:
        distribution_points, x_min, x_max = fsad, fsad_min, fsad_max
    else:
        distribution_points, x_min, x_max = bsad, bsad_min, bsad_max
    n, bins = plot_histogram_and_distribution(data_array, distribution_points,
                                              x_min, x_max, num_bins)
    x_data = bins[:-1] + (bins[1] - bins[0]) / 2
    y_data = n

    if forward:
        popt, pcov = curve_fit(fsad_correction, x_data, y_data)
        #plt.plot(x_data,fsad_correction(x_data,*popt),color="C8",lw=3.0)
    else:
        popt, pcov = curve_fit(bsad_correction, x_data, y_data)
        #plt.plot(x_data,bsad_correction(x_data,*popt),color="C8",lw=3.0)
    #plt.xlabel("Scattering Angle [rad]")
    #plt.ylabel("Frequency [Counts/Bin]")
    return popt, pcov
Пример #6
0
def SAD_E_vs_Pos(forward, size=100, data_array=None):
    d = rd.read_h5py_file() if type(data_array) == None else data_array
    d = rd.cut_selection(d, 9, 0, forward)
    E_e = rd.extract_parameter(d, 3)
    E_g = rd.extract_parameter(d, 1)
    c = 2.998e8
    m = 511 / c**2
    a_E = np.arccos(1 - (E_e / E_g * m * c**2 / (E_e + E_g)))
    a_P = rd.calculate_angles(d)
    c = 0
    while c < len(a_E):
        if np.isnan(a_E[c]):
            a_E = np.delete(a_E, c)
            a_P = np.delete(a_P, c)
            c += -1
        c += 1
    plt.hist2d(a_E, a_P, bins=(size, size))
    if forward:
        x = np.linspace(at.fsad_min, at.fsad_max, size)
        plt.plot(x, x, color="C1")
    else:
        x = np.linspace(at.bsad_min, at.bsad_max, size)
        plt.plot(x, x, color="C1")