Ejemplo n.º 1
0
root = io.find_root_folder(folder)

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

# Save location based on camera name
save_to_normalised_map = camera.filename_calibration("gain.npy")

# Get the ISO speed of these data from the folder name
ISO = io.split_iso(folder)
save_to_original_map = camera.filename_intermediaries(f"gain/gain_map_iso{ISO}.npy", makefolders=True)

# Load the data
names, means = io.load_means(folder)
names, stds = io.load_stds(folder)
print("Loaded data")

# Find pixels near saturation to mask later
fit_max = 0.95 * camera.saturation
mask = (means >= fit_max)

# Bias correction
means = camera.correct_bias(means)

# Use variance instead of standard deviation
variance = stds**2

# Make masked arrays that don't include non-linear values (near saturation)
means = np.ma.array(means, mask=mask)
variance = np.ma.array(variance, mask=mask)
Ejemplo n.º 2
0
import numpy as np
from sys import argv
from matplotlib import pyplot as plt
from spectacle import io, raw
from spectacle.gain import malus
from scipy.optimize import curve_fit

folder = argv[1]

angles, means = io.load_means(f"{folder}/stacks/linearity/",
                              retrieve_value=io.split_pol_angle)
angles, stds = io.load_stds(f"{folder}/stacks/linearity/",
                            retrieve_value=io.split_pol_angle)
colours = np.load(f"{folder}/stacks/colour.npy")

mean_reshaped = np.moveaxis(means, 0, 2)
stds_reshaped = np.moveaxis(stds, 0, 2)


def malus_amp(angles, amplitude, offset_angle, offset_intensity):
    I = offset_intensity + amplitude * malus(angles, offset_angle)
    return I


def fit(data):
    popt, pcov = curve_fit(malus_amp, angles, data, p0=[1000, 74, 1000])
    return popt[1]


x = np.arange(means.shape[2])
y = np.arange(means.shape[1])
Ejemplo n.º 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)