def get_differences(apStar_filename):
    image = fits.open(apStar_filename)
    N_visits = image[0].header['NVISITS']
    data_index = 1
    error_index = 2
    mask_index = 3
    differences = []
    for (i, j) in combinations(range(N_visits), 2):
        di = image[data_index].data[(i + 2), :]
        dj = image[data_index].data[(j + 2), :]
        sigma = np.sqrt(((image[error_index].data[(i + 2), :] ** 2) + (image[error_index].data[(j + 2), :] ** 2)))
        ok = (((((di > 0) * (dj > 0)) * np.isfinite(((di * dj) * sigma))) * (image[mask_index].data[(i + 2), :] == 0)) * (image[mask_index].data[(j + 2), :] == 0))
        differences.extend(((di - dj) / sigma)[ok])
    differences = np.array(differences).flatten()
    return differences
def get_differences(apStar_filename):
    image = fits.open(apStar_filename)
    N_visits = image[0].header['NVISITS']
    data_index = 1
    error_index = 2
    mask_index = 3
    differences = []
    for (i, j) in combinations(range(N_visits), 2):
        di = image[data_index].data[(i + 2), :]
        dj = image[data_index].data[(j + 2), :]
        sigma = np.sqrt(((image[error_index].data[(i + 2), :] ** 2) + (image[error_index].data[(j + 2), :] ** 2)))
        ok = (((((di > 0) * (dj > 0)) * np.isfinite(((di * dj) * sigma))) * (image[mask_index].data[(i + 2), :] == 0)) * (image[mask_index].data[(j + 2), :] == 0))
        differences.extend(((di - dj) / sigma)[ok])
    differences = np.array(differences).flatten()
    return differences