예제 #1
0
plot.show_RGBG(RGB_gauss)

# Find the locations of the line peaks in every row
lines = wavelength.find_fluorescent_lines(RGB_gauss) + xmin

# Fit a parabola (smile) to the found positions
lines_fit = wavelength.fit_fluorescent_lines(lines, y)

# Plot the observed and fitted line positions
plot.plot_fluorescent_lines(y, lines, lines_fit)

# Fit a wavelength relation for each row
wavelength_fits = wavelength.fit_many_wavelength_relations(y, lines_fit)

# Fit a polynomial to the coefficients of the previous fit
coefficients, coefficients_fit = wavelength.fit_wavelength_coefficients(y, wavelength_fits)

# Save the coefficients to file
wavelength.save_coefficients(coefficients, saveto=save_to)
print(f"Saved wavelength coefficients to '{save_to}'")

# Convert the input spectrum to wavelengths and plot it, as a sanity check
wavelengths_cut = wavelength.calculate_wavelengths(coefficients, x, y)
wavelengths_split,_ = raw.pull_apart(wavelengths_cut, colors_cut)
RGBG,_ = raw.pull_apart(image_cut, colors_cut)

lambdarange, all_interpolated = wavelength.interpolate_multi(wavelengths_split, RGBG)

stacked = wavelength.stack(lambdarange, all_interpolated)
plot.plot_fluorescent_spectrum(stacked[0], stacked[1:])
예제 #2
0
corrected_exposure = (phone["camera"]["f-number"]**2 /
                      (exposure_time * iso_normalization)
                      ) * corrected_ADU  # norm. ADU sr^-1 s^-1
print("Corrected for exposure parameters")

corrected_edges = corrected_exposure[flat.clip_border]
colours_edges = colours[flat.clip_border]
flat_field_correction = io.read_flat_field_correction(products,
                                                      corrected_edges.shape)

corrected_flat = flat_field_correction * corrected_edges  # norm. ADU sr^-1 s^-1
print("Corrected for flat-field")

pixel_area_m = (phone["camera"]["pixel_size"] * 1e-6)**2
corrected_pixel_size = corrected_flat / pixel_area_m  # norm. ADU m^-2 sr^-1 s^-1
print("Corrected for pixel size")

effective_bandwidths = io.read_spectral_bandwidths(products) * 1e-9  # m
corrected_bandwidth = raw.multiply_RGBG(
    corrected_pixel_size, colours_edges,
    1 / effective_bandwidths)  # norm. ADU m^-2 sr^-1 s^-1 m^-1
print("Corrected for effective spectral bandwidths")

hc = 1.9864459e-25  # J m

corrected_RRU = hc * corrected_bandwidth  # RRU m^-2 sr^-1
print("Converted to energy")

corrected_RRU_RGBG, _ = raw.pull_apart(corrected_RRU, colours_edges)
plot.show_RGBG(corrected_RRU_RGBG)
예제 #3
0
            stack[ind_previous][color_pattern == j] = stack[j][color_pattern ==
                                                               j]
            to_remove.append(j)
        clean_stack = np.delete(stack, to_remove, axis=0)
    else:
        clean_stack = stack.copy()

    assert len(np.where(np.nansum(clean_stack, axis=0) != raw_img)[0]) == 0

    return clean_stack


folder = io.path_from_input(argv)
root = io.find_root_folder(folder)
results_readnoise = root / "results/readnoise"

# Load Camera object
camera = io.load_camera(root)
print(f"Loaded Camera object: {camera}")

isos, stds = io.load_stds(folder, retrieve_value=io.split_iso)
colours = camera.bayer_map

s = stds[isos.argmin()]

RGBG, _ = raw.pull_apart(s, colours)

unique_colours = np.unique(colours).shape[0]

RGB = pull_apart2(s, colours)
ratio = high_mean / low_mean
q_low, q_high = np.percentile(ratio.ravel(), 0.1), np.percentile(ratio.ravel(), 99.9)

plt.hist(ratio.ravel(), bins=np.linspace(q_low, q_high, 250))
plt.xlabel(f"ISO {high} / ISO {low}")
plt.title(f"Full data set\n$\mu = {ratio.mean():.2f}$, $\sigma = {ratio.std():.2f}$")
plt.show()
plt.close()

ratio_mean = ratio.mean(axis=0)
plt.hist(ratio_mean.ravel(), bins=np.linspace(q_low, q_high, 250))
plt.xlabel(f"ISO {high} / ISO {low}")
plt.title(f"Mean per pixel\n$\mu = {ratio_mean.mean():.2f}$, $\sigma = {ratio_mean.std():.2f}$")
plt.show()
plt.close()

ratio_mean_gauss = gaussMd(ratio_mean, 10)
plt.imshow(ratio_mean_gauss)
plt.colorbar()
plt.title("Mean ratio per pixel; Gauss $\sigma = 10$")
plt.show()
plt.close()

ratio_mean_RGBG,_ = raw.pull_apart(ratio_mean, colours)
ratio_mean_RGBG_gauss = gaussMd(ratio_mean_RGBG, (0,5,5))
vmin, vmax = np.percentile(ratio_mean_RGBG_gauss.ravel(), 0.1), np.percentile(ratio_mean_RGBG_gauss.ravel(), 99.9)
plot.show_RGBG(ratio_mean_RGBG_gauss, vmin=vmin, vmax=vmax)

print(f"RMS noise in images: {np.sqrt(np.mean(low_stds)**2) / np.mean(low_mean) * 100:.1f} %")
print(f"Mean deviation in ratio: {ratio.std()/ratio.mean() * 100:.1f} %")