Exemplo n.º 1
0
import numpy as np
from sys import argv
from spectacle import io
from spectacle.general import RMS
from matplotlib import pyplot as plt

# Get the data folder from the command line
files = io.path_from_input(argv)
roots = [io.find_root_folder(file) for file in files]

save_to_rgbg2 = io.results_folder/"spectral_responses.pdf"
save_to_rgb = io.results_folder/"spectral_responses_RGB.pdf"
save_to_snr = io.results_folder/"spectral_responses_SNR.pdf"

# Get the camera metadata
cameras = [io.load_metadata(root) for root in roots]
print("Loaded metadata")

# Load the data
curves = [np.load(f) for f in files]
print("Loaded data")

# Check that all necessary data are available
assert len(cameras) == len(curves)

number_of_cameras = len(cameras)

# Line styles for the individual camera spectra
styles = ["-", "--", ":", "-."]

# Plot the spectral responses in the RGBG2 filters
Exemplo n.º 2
0
Command line arguments:
    * `folder_main`: folder containing RAW (and JPEG, if available) files which
    should be split into subfolders.
    * `blocksize`: the number of files to put in each folder (e.g. 10, 15).
"""

from sys import argv
from shutil import move
import os
from time import time
from spectacle import io

folder_main = io.path_from_input(argv[:2])
root = io.find_root_folder(folder_main)
camera = io.load_metadata(root)
raw_pattern = f"*{camera.image.raw_extension}"

blocksize = int(argv[2])
files = list(folder_main.glob(raw_pattern))
files = sorted(files)
blocks = len(files) // blocksize
for i in range(blocks):
    foldername = str(int(time() * 10000)) + str(i % 10)
    total_path = folder_main / foldername
    print(total_path)
    os.mkdir(total_path)
    files_block = files[blocksize * i:blocksize * (i + 1)]
    for file in files_block:
        move(str(file), total_path)
        withjpg = io.replace_suffix(file, ".jpg")
Exemplo n.º 3
0
import numpy as np
from sys import argv
from matplotlib import pyplot as plt
from spectacle import raw, io, plot, flat
from spectacle.general import gaussMd

meanfile = io.path_from_input(argv)
root, images, stacks, products, results = io.folders(meanfile)
phone = io.load_metadata(root)

colours = io.load_colour(stacks)

iso = 23
exposure_time = 1 / 3

try:
    mean = np.load(meanfile)
except OSError:
    mean = io.load_raw_image(meanfile)

bias = np.load(products / "bias.npy")
dark = np.load(products / "dark.npy")

corrected_ADU = mean - bias - dark * exposure_time  # ADU
print("Corrected for bias and dark current")

ISO_model = io.read_iso_model(products)
iso_normalization = ISO_model(iso)

corrected_exposure = (phone["camera"]["f-number"]**2 /
                      (exposure_time * iso_normalization)