6.8. tracer.spectrum Submodule¶
6.8.1. tracer.spectrum.light_spectrum¶
- class optrace.tracer.spectrum.light_spectrum.LightSpectrum(spectrum_type='Blackbody', T=5500, **sargs)¶
Create a LightSpectrum, compared to the Spectrum parent class this provides rendering of spectra and the generation of random wavelengths. As well as two additional types (Blackbody and Histogram)
- Parameters:
- static render(wl, w, **kwargs)¶
Render a LightSpectrum from a list of wavelengths and powers. The resulting LightSpectrum has type “Histogram” and unit W/nm
- __call__(wl)¶
Get the spectrum values
- centroid_wavelength()¶
The centroid wavelength. This is the center of mass wavelength according to its spectral power. Another name would be “power-weighted average wavelength”.
- Returns:
centroid wavelength in nm
- Return type:
- color(rendering_intent='Ignore', clip=False, L_th=0.0, chroma_scale=0.0)¶
Get the sRGB color of the spectrum
- complementary_wavelength()¶
Complementary wavelength of the spectrum, that is the wavelength with the opposite hue.
- Returns:
complementary wavelength in nm if any exists, else np.nan
- Return type:
- dominant_wavelength()¶
Dominant wavelength of the spectrum, that is the wavelength with the same hue.
- Returns:
dominant wavelength in nm if any exists, else np.nan
- Return type:
- fwhm()¶
Return the full width half maximum (FWHM). The smallest distance to the half height is calculated on both sides of the highest peak in the spectrum.
- Returns:
FWHM
- Return type:
- peak_wavelength()¶
Peak wavelength of the spectrum. For a spectrum with a constant maximum region (Constant, Rectangle) or multiple maxima the first one is returned.
- Returns:
peak wavelength in nm
- Return type:
- random_wavelengths(N)¶
Generate random wavelengths following the spectral distribution.
- xyz()¶
Get the XYZ color of the spectrum
- Returns:
3 element array of XYZ values
- Return type:
6.8.2. tracer.spectrum.spectrum¶
- class optrace.tracer.spectrum.spectrum.Spectrum(spectrum_type='Gaussian', val=1.0, lines=None, line_vals=None, wl=550.0, wl0=400.0, wl1=600.0, wls=None, vals=None, func=None, mu=550.0, sig=50.0, unit=None, quantity=None, func_args={}, **kwargs)¶
Create a Spectrum object. Most of the time this class isn’t used, as there are specific subclasses.
- Parameters:
spectrum_type (str) – one of “spectrum_types”
val (float) – factor for types “Rectangle”, “Constant”, “Gaussian” etc.
wl (float) – wavelength for “Monochromatic” type
wl0 (float) – lower wavelength for “Rectangle” type
wl1 (float) – upper wavelength for “Rectangle” type
wls (ndarray) – wavelength list for “List” type
vals (ndarray) – values for “List” type
mu (float) – center wavelength for “Gaussian” type
sig (float) – standard deviation for “Gaussian” type
unit (str) – unit string
quantity (str) – quantity string
func (Callable[[ndarray], ndarray]) – spectrum function, must take a wavelength vector and return float values
func_args (dict) – dict of optional keyword arguments for func
kwargs – additional keyword arguments for the parent class
- __call__(wl)¶
get spectrum values
- get_desc(fallback=None)¶
get description :param fallback: unused parameter :return:
6.8.3. tracer.spectrum.transmission_spectrum¶
- class optrace.tracer.spectrum.transmission_spectrum.TransmissionSpectrum(spectrum_type='Gaussian', inverse=False, **sargs)¶
Define a TransmissionSpectrum object.
- Parameters:
- __call__(wl)¶
Get the spectrum values
- color(rendering_intent='Absolute', clip=True, L_th=0, chroma_scale=None)¶
Get the Spectrum sRGB color and the opacity.
- xyz()¶
Get the Spectrum XYZ Color under daylight D65
- Returns:
3 element XYZ color array
- Return type: