def gauss_nan(data, *args, **kwargs):
    V = data.copy()
    V[np.isnan(data)] = 0
    VV = gaussMd(V, *args, **kwargs)

    W = np.ones_like(data)
    W[np.isnan(data)] = 0
    WW = gaussMd(W, *args, **kwargs)

    return VV / WW
示例#2
0
plt.xlim(bins_SNR[0], bins_SNR[-1])
plt.xlabel("Signal-to-noise ratio")
plt.ylabel("Counts")
plt.savefig(save_to_histogram_SNR)
plt.close()
print(f"Saved histogram of signal-to-noise ratio to '{save_to_histogram_SNR}'")

# Make Gaussian maps of the SNR
save_to_maps_SNR = savefolder / f"data_SNR_{label}.pdf"
camera.plot_gauss_maps(SNR,
                       colorbar_label="Signal-to-noise ratio",
                       saveto=save_to_maps_SNR)
print(f"Saved maps of signal-to-noise ratio to '{save_to_maps_SNR}'")

# Convolve the flat-field data with a Gaussian kernel to remove small-scale variations
flat_field_gauss = gaussMd(mean_normalised, 10)

# Make histograms of the raw, bias-corrected, normalised, and Gaussed data
save_to_histogram_data = savefolder / f"data_histogram_{label}.pdf"
data_sets = [mean_raw, mean_normalised, mean_bias_corrected, flat_field_gauss]
titles = ["Raw", "Normalised", "Bias-corrected", "Gaussed"]
bins_adu = np.linspace(0, camera.saturation, 250)
bins_flat = np.linspace(0, 1.05, 100)
bins_combined = [bins_adu, bins_flat, bins_adu, bins_flat]
fig, axs = plt.subplots(nrows=2,
                        ncols=2,
                        tight_layout=True,
                        sharex="col",
                        sharey="col")
for data, ax, title, bins in zip(data_sets, axs.ravel(), titles,
                                 bins_combined):
示例#3
0
plt.xlabel("Retardance in $\lambda$ at 560 nm")
plt.ylabel("RGB value (relative)")
plt.savefig("retardance_RGB.pdf", bbox_inches="tight")
plt.show()
plt.close()

plt.plot(
    retardances_relative,
    np.rad2deg(np.arctan2(integral_SRF_relative[0], integral_SRF_relative[2])))
plt.xlabel("Retardance in $\lambda$ at 560 nm")
plt.ylabel("R/B hue angle [degrees]")
plt.savefig("retardance_hue.pdf", bbox_inches="tight")
plt.show()
plt.close()

intensities_smooth = gaussMd(intensities, sigma=(0, 10))
derivative = np.diff(intensities_smooth, axis=1)


def stat(spectrum):
    inds = np.where((wavelengths >= 420) & (wavelengths <= 800))
    low = np.where(spectrum[inds] < 0.02)[0]
    steps = np.diff(low)
    nr_minima = len(np.where(steps > 5)[0])
    return nr_minima


statistic = [stat(spectrum) for spectrum in intensities_smooth]

plt.plot(retardances_relative, statistic)
plt.xlabel("Retardance in $\lambda$ at 560 nm")
示例#4
0
# Future command line arguments
save_to = io.results_folder / "RGBG.pdf"
colorbar_label = 40 * " " + "Read noise (ADU)"

# Load Camera object
cameras = [io.load_camera(root) for root in roots]
print(f"Loaded Camera objects: {cameras}")

# Load the data
data_all = [np.load(path) for path in files]

# Demosaick the data
RGBGs_all = [camera.demosaick(data) for data, camera in zip(data_all, cameras)]

# Convolve the data with a Gaussian kernel
gauss_all = [gaussMd(RGBG, sigma=(0, 5, 5)) for RGBG in RGBGs_all]

# Minimum and maximum of colourbars
vmin, vmax = analyse.symmetric_percentiles(gauss_all)

# Figure to hold the subplots
fig, axs = plt.subplots(ncols=4,
                        nrows=len(files),
                        sharex=True,
                        sharey=True,
                        figsize=(7, 1.695 * len(files)),
                        squeeze=False,
                        tight_layout=True,
                        gridspec_kw={
                            "wspace": 0,
                            "hspace": 0
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} %")