Beispiel #1
0
def flip_photons(
    data: pd.DataFrame,
    edges_of_lines_dim: np.array,
    lines: np.array,
    num_of_pixels: int,
):
    """
    Receives {data} and flips every odd line by finding the mean time diff between the first 256 lines of {data},
    and subtracting that mean from the odd lines.
    """
    # add each photon bin in the lines dimension
    idx = np.searchsorted(edges_of_lines_dim, data["abs_time"], side="right")
    data["bin_of_dim0"] = idx - 1
    mean_line_diff = lines.diff().iloc[:num_of_pixels].mean().astype(int)
    odd_lines = data.loc[data["bin_of_dim0"] % 2 == 1, "time_rel_line"]
    data.loc[data["bin_of_dim0"] % 2 == 1,
             "time_rel_line"] = mean_line_diff - odd_lines

    # clean up
    data.drop(columns=["bin_of_dim0"])
    return data