Ejemplo n.º 1
0
                                            unpack=True)

# Normalise the SMARTS2 reference spectrum to its value at 500 nm
smartsx /= smartsx[wvl == 500]
smartsy /= smartsy[wvl == 500]
smartsz /= smartsz[wvl == 500]

# Use only the whole wavelengths (for compatibility with other data)
ind = np.where(wvl % 1 == 0)
wvl = wvl[ind]
smartsx = smartsx[ind]
smartsy = smartsy[ind]
smartsz = smartsz[ind]

# Smooth the SMARTS2 data
smartsx_smooth = gauss1d(smartsx, 5)

# Generate a normalised blackbody spectrum
BB = blackbody(wvl)
BB /= BB[wvl == 500]

# Plot the blackbody and SMARTS2 spectra for comparison
plt.plot(wvl, BB, c='k', label="Black-body")
plt.plot(wvl, smartsx, c='r', label="SMARTS2 (Diffuse)")
plt.plot(wvl, smartsx_smooth, c='b', label="SMARTS2 (smoothed)")
plt.xlim(390, 700)
plt.legend(loc="best")
plt.savefig(root / "analysis/spectral_response/SMARTS_vs_BB.pdf")
plt.show()

# Load the iSPEX wavelength solution
Ejemplo n.º 2
0
import numpy as np
from matplotlib import pyplot as plt
from spectacle.general import gauss1d
from spectacle import io

wvl, with_grating = np.genfromtxt("reference_spectra/with_grating.txt",
                                  skip_header=14,
                                  unpack=True)
wvl, without_grating = np.genfromtxt("reference_spectra/without_grating.txt",
                                     skip_header=14,
                                     unpack=True)

with_grating = gauss1d(with_grating, 5)
without_grating = gauss1d(without_grating, 5)

with_grating -= with_grating[wvl < 350].mean()  # background subtraction
without_grating -= without_grating[wvl < 350].mean()

transmission_raw = with_grating / without_grating

wavelengths = np.arange(390, 702, 2)
transmission = np.interp(wavelengths, wvl, transmission_raw)

plt.plot(wvl, with_grating, c='r')
plt.plot(wvl, without_grating, c='k')
plt.show()

plt.plot(wavelengths, transmission)
plt.xlim(390, 700)
plt.ylim(0., 1.)
plt.xlabel("Wavelength (nm)")
Ejemplo n.º 3
0
# Load the input spectrum
# input_spectrum = np.loadtxt("input_data/lamp_spectrum.txt", skiprows=14)  # Halogen lamp
# input_spectrum = np.loadtxt("input_data/haldeut_spectrum.txt", skiprows=13)  # Halogen-deuterium lamp
input_spectrum = np.loadtxt("input_data/fluorescent_spectrum.txt", skiprows=13)  # Fluorescent lamp
# input_spectrum = np.loadtxt("input_data/cie_d65.txt", skiprows=1, usecols=[0,1])  # Daylight
# input_spectrum = np.stack([np.linspace(380, 800, 1500), np.ones(1500)]).T  # Equal-energy spectrum

# Create the source spectrum, fully unpolarised
wavelength_step = 0.3
wavelengths = np.arange(385, 800, wavelength_step)
source_wavelengths = input_spectrum[:,0]
source_intensity = input_spectrum[:,1].copy()
source_intensity = source_intensity / np.nanmax(source_intensity)
source_intensity = np.interp(wavelengths, source_wavelengths, source_intensity, left=0, right=0)
source_intensity = gauss1d(source_intensity, sigma=5)
source = stokes.Stokes_nm(source_intensity, 0, 0, 0)

# Create the input and output polarisers at 0 and 90 degrees, respectively
polariser_0 = elements.Linear_polarizer_general(0.9, 0.005, 0)
polariser_90 = elements.Linear_polarizer_general(0.9, 0.005, 90)

# Propagate the source light through the input polariser
after_polariser_0 = np.einsum("ij,wj->wi", polariser_0, source)

# Retardances to loop over
retardances_relative = np.linspace(0, 5, nr_retardances)
retardances_absolute = retardances_relative * 560.

# Integral of RGB intensities
integral_SRF = np.zeros((3,len(retardances_relative)))
Ejemplo n.º 4
0
import numpy as np
from matplotlib import pyplot as plt
from spex import stokes, elements
from spectacle.general import gauss1d, gaussMd

# Load the input spectrum
input_spectrum = np.loadtxt("input_data/lamp_spectrum.txt", skiprows=14)

# Create the source spectrum, fully unpolarised
wavelength_step = 0.3
wavelengths = np.arange(385, 800, wavelength_step)
source_wavelengths = input_spectrum[:, 0]
source_intensity = gauss1d(input_spectrum[:, 1], sigma=5)
source_intensity = source_intensity / np.nanmax(source_intensity)
source_intensity = np.interp(wavelengths, source_wavelengths, source_intensity)
source = stokes.Stokes_nm(source_intensity, 0, 0, 0)

# Load the SRFs
SRF_path = r"C:\Users\Burggraaff\SPECTACLE_data\iPhone_SE\calibration\iPhone_SE_spectral_response.csv"
SRF = np.loadtxt(SRF_path, delimiter=",")
SRF_wavelengths = SRF[:, 0]
SRF_RGB = SRF[:, 1:4]

# Interpolate the SRFs to the source spectrum wavelengths
SRF_RGB_interp = np.stack([
    np.interp(wavelengths, SRF_wavelengths, SRF, left=0, right=0)
    for SRF in SRF_RGB.T
])

# Create the input and output polarisers at 0 and 90 degrees, respectively
polariser_0 = elements.Linear_polarizer_general(0.9, 0.005, 0)