def luminous_efficiency( spd, lef=PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer')): """ Returns the *luminous efficiency* of given spectral power distribution using given luminous efficiency function. Parameters ---------- spd : SpectralPowerDistribution test spectral power distribution lef : SpectralPowerDistribution, optional :math:`V(\lambda)` luminous efficiency function. Returns ------- numeric Luminous efficiency. Examples -------- >>> from colour import LIGHT_SOURCES_RELATIVE_SPDS >>> spd = LIGHT_SOURCES_RELATIVE_SPDS.get('Neodimium Incandescent') >>> luminous_efficiency(spd) # doctest: +ELLIPSIS 0.1994393... """ lef = lef.clone().align(spd.shape, extrapolation_left=0, extrapolation_right=0) spd = spd.clone() efficiency = (np.trapz(lef.values * spd.values, spd.wavelengths) / np.trapz(spd.values, spd.wavelengths)) return efficiency
def luminous_efficacy(spd, lef=PHOTOPIC_LEFS.get( 'CIE 1924 Photopic Standard Observer')): """ Returns the *luminous efficacy* in :math:`lm\cdot W^{-1}` of given spectral power distribution using given luminous efficiency function. Parameters ---------- spd : SpectralPowerDistribution test spectral power distribution lef : SpectralPowerDistribution, optional :math:`V(\lambda)` luminous efficiency function. Returns ------- numeric Luminous efficacy in :math:`lm\cdot W^{-1}`. Examples -------- >>> from colour import LIGHT_SOURCES_RELATIVE_SPDS >>> spd = LIGHT_SOURCES_RELATIVE_SPDS.get('Neodimium Incandescent') >>> luminous_efficacy(spd) # doctest: +ELLIPSIS 136.2170803... """ efficacy = K_M * luminous_efficiency(spd, lef) return efficacy
def luminous_flux(spd, lef=PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer'), K_m=K_M): """ Returns the *luminous flux* for given spectral power distribution using the given luminous efficiency function. Parameters ---------- spd : SpectralPowerDistribution test spectral power distribution lef : SpectralPowerDistribution, optional :math:`V(\lambda)` luminous efficiency function. K_m : numeric, optional :math:`lm\cdot W^{-1}` maximum photopic luminous efficiency Returns ------- numeric Luminous flux Examples -------- >>> from colour import LIGHT_SOURCES_RELATIVE_SPDS >>> spd = LIGHT_SOURCES_RELATIVE_SPDS.get('Neodimium Incandescent') >>> luminous_flux(spd) # doctest: +ELLIPSIS 23807.6555273... """ lef = lef.clone().align(spd.shape, left=0, right=0) spd = spd.clone() * lef flux = K_m * np.trapz(spd.values, spd.wavelengths) return flux
def luminous_efficacy( spd, lef=PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer')): """ Returns the *luminous efficacy* in :math:`lm\cdot W^{-1}` of given spectral power distribution using given luminous efficiency function. Parameters ---------- spd : SpectralPowerDistribution test spectral power distribution lef : SpectralPowerDistribution, optional :math:`V(\lambda)` luminous efficiency function. Returns ------- numeric Luminous efficacy in :math:`lm\cdot W^{-1}`. Examples -------- >>> from colour import LIGHT_SOURCES_RELATIVE_SPDS >>> spd = LIGHT_SOURCES_RELATIVE_SPDS.get('Neodimium Incandescent') >>> luminous_efficacy(spd) # doctest: +ELLIPSIS 136.2170803... """ efficacy = K_M * luminous_efficiency(spd, lef) return efficacy
def mesopic_luminous_efficiency_function( Lp, source='Blue Heavy', method='MOVE', photopic_lef=PHOTOPIC_LEFS.get( 'CIE 1924 Photopic Standard Observer'), scotopic_lef=SCOTOPIC_LEFS.get( 'CIE 1951 Scotopic Standard Observer')): """ Returns the mesopic luminous efficiency function :math:`V_m(\lambda)` for given photopic luminance :math:`L_p`. Parameters ---------- Lp : numeric Photopic luminance :math:`L_p`. source : unicode, optional {'Blue Heavy', 'Red Heavy'}, Light source colour temperature. method : unicode, optional {'MOVE', 'LRC'}, Method to calculate the weighting factor. photopic_lef : SpectralPowerDistribution, optional :math:`V(\lambda)` photopic luminous efficiency function. scotopic_lef : SpectralPowerDistribution, optional :math:`V^\prime(\lambda)` scotopic luminous efficiency function. Returns ------- SpectralPowerDistribution Mesopic luminous efficiency function :math:`V_m(\lambda)`. Examples -------- >>> mesopic_luminous_efficiency_function(0.2) # doctest: +ELLIPSIS <colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...> """ photopic_lef_shape = photopic_lef.shape scotopic_lef_shape = scotopic_lef.shape shape = SpectralShape( max(photopic_lef_shape.start, scotopic_lef_shape.start), min(photopic_lef_shape.end, scotopic_lef_shape.end), max(photopic_lef_shape.steps, scotopic_lef_shape.steps)) spd_data = dict((i, mesopic_weighting_function( i, Lp, source, method, photopic_lef, scotopic_lef)) for i in shape) spd = SpectralPowerDistribution( '{0} Lp Mesopic Luminous Efficiency Function'.format(Lp), spd_data) return spd.normalise()
def luminous_efficacy(spd, lef=PHOTOPIC_LEFS.get( 'CIE 1924 Photopic Standard Observer')): """ Returns the *luminous efficacy* for given spectral power distribution using the given luminous efficiency function. Parameters ---------- spd : SpectralPowerDistribution test spectral power distribution lef : SpectralPowerDistribution, optional :math:`V(\lambda)` luminous efficiency function. Returns ------- numeric Luminous efficacy Examples -------- >>> from colour import LIGHT_SOURCES_RELATIVE_SPDS >>> spd = LIGHT_SOURCES_RELATIVE_SPDS.get('Neodimium Incandescent') >>> luminous_efficacy(spd) # doctest: +ELLIPSIS 0.1994393... """ lef = lef.clone().align(spd.shape, left=0, right=0) spd = spd.clone() efficacy = (np.trapz(lef.values * spd.values, spd.wavelengths) / np.trapz(spd.values, spd.wavelengths)) return efficacy
def mesopic_luminous_efficiency_function( Lp, source='Blue Heavy', method='MOVE', photopic_lef=PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer'), scotopic_lef=SCOTOPIC_LEFS.get('CIE 1951 Scotopic Standard Observer')): """ Returns the mesopic luminous efficiency function :math:`V_m(\lambda)` for given photopic luminance :math:`L_p`. Parameters ---------- Lp : numeric Photopic luminance :math:`L_p`. source : unicode, optional **{'Blue Heavy', 'Red Heavy'}**, Light source colour temperature. method : unicode, optional **{'MOVE', 'LRC'}**, Method to calculate the weighting factor. photopic_lef : SpectralPowerDistribution, optional :math:`V(\lambda)` photopic luminous efficiency function. scotopic_lef : SpectralPowerDistribution, optional :math:`V^\prime(\lambda)` scotopic luminous efficiency function. Returns ------- SpectralPowerDistribution Mesopic luminous efficiency function :math:`V_m(\lambda)`. Examples -------- >>> mesopic_luminous_efficiency_function(0.2) # doctest: +ELLIPSIS <colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...> """ photopic_lef_shape = photopic_lef.shape scotopic_lef_shape = scotopic_lef.shape shape = SpectralShape( max(photopic_lef_shape.start, scotopic_lef_shape.start), min(photopic_lef_shape.end, scotopic_lef_shape.end), max(photopic_lef_shape.steps, scotopic_lef_shape.steps)) wavelengths = shape.range() spd_data = dict( zip( wavelengths, mesopic_weighting_function(wavelengths, Lp, source, method, photopic_lef, scotopic_lef))) spd = SpectralPowerDistribution( '{0} Lp Mesopic Luminous Efficiency Function'.format(Lp), spd_data) return spd.normalise()
def mesopic_weighting_function(wavelength, Lp, source='Blue Heavy', method='MOVE', photopic_lef=PHOTOPIC_LEFS.get( 'CIE 1924 Photopic Standard Observer'), scotopic_lef=SCOTOPIC_LEFS.get( 'CIE 1951 Scotopic Standard Observer')): """ Calculates the mesopic weighting function factor at given wavelength :math:`\lambda` using the photopic luminance :math:`L_p`. Parameters ---------- wavelength : numeric or array_like Wavelength :math:`\lambda` to calculate the mesopic weighting function factor. Lp : numeric Photopic luminance :math:`L_p`. source : unicode, optional {'Blue Heavy', 'Red Heavy'}, Light source colour temperature. method : unicode, optional {'MOVE', 'LRC'}, Method to calculate the weighting factor. photopic_lef : SpectralPowerDistribution, optional :math:`V(\lambda)` photopic luminous efficiency function. scotopic_lef : SpectralPowerDistribution, optional :math:`V^\prime(\lambda)` scotopic luminous efficiency function. Returns ------- numeric or ndarray Mesopic weighting function factor. Examples -------- >>> mesopic_weighting_function(500, 0.2) # doctest: +ELLIPSIS 0.7052200... """ mesopic_x_luminance_values = sorted(MESOPIC_X_DATA.keys()) index = mesopic_x_luminance_values.index( closest(mesopic_x_luminance_values, Lp)) x = MESOPIC_X_DATA.get( mesopic_x_luminance_values[index]).get(source).get(method) Vm = ((1 - x) * scotopic_lef.get(wavelength) + x * photopic_lef.get(wavelength)) return Vm
def mesopic_weighting_function(wavelength, Lp, source='Blue Heavy', method='MOVE', photopic_lef=PHOTOPIC_LEFS.get( 'CIE 1924 Photopic Standard Observer'), scotopic_lef=SCOTOPIC_LEFS.get( 'CIE 1951 Scotopic Standard Observer')): """ Calculates the mesopic weighting function factor at given wavelength :math:`\lambda` using the photopic luminance :math:`L_p`. Parameters ---------- wavelength : numeric or array_like Wavelength :math:`\lambda` to calculate the mesopic weighting function factor. Lp : numeric Photopic luminance :math:`L_p`. source : unicode, optional **{'Blue Heavy', 'Red Heavy'}**, Light source colour temperature. method : unicode, optional **{'MOVE', 'LRC'}**, Method to calculate the weighting factor. photopic_lef : SpectralPowerDistribution, optional :math:`V(\lambda)` photopic luminous efficiency function. scotopic_lef : SpectralPowerDistribution, optional :math:`V^\prime(\lambda)` scotopic luminous efficiency function. Returns ------- numeric or ndarray Mesopic weighting function factor. Examples -------- >>> mesopic_weighting_function(500, 0.2) # doctest: +ELLIPSIS 0.7052200... """ mesopic_x_luminance_values = sorted(MESOPIC_X_DATA.keys()) index = mesopic_x_luminance_values.index( closest(mesopic_x_luminance_values, Lp)) x = MESOPIC_X_DATA.get( mesopic_x_luminance_values[index]).get(source).get(method) Vm = ((1 - x) * scotopic_lef.get(wavelength) + x * photopic_lef.get(wavelength)) return Vm
def luminous_flux(spd, lef=PHOTOPIC_LEFS.get( 'CIE 1924 Photopic Standard Observer'), K_m=K_M): """ Returns the *luminous flux* for given spectral power distribution using given luminous efficiency function. Parameters ---------- spd : SpectralPowerDistribution test spectral power distribution lef : SpectralPowerDistribution, optional :math:`V(\lambda)` luminous efficiency function. K_m : numeric, optional :math:`lm\cdot W^{-1}` maximum photopic luminous efficiency Returns ------- numeric Luminous flux. Examples -------- >>> from colour import LIGHT_SOURCES_RELATIVE_SPDS >>> spd = LIGHT_SOURCES_RELATIVE_SPDS.get('Neodimium Incandescent') >>> luminous_flux(spd) # doctest: +ELLIPSIS 23807.6555273... """ lef = lef.clone().align(spd.shape, extrapolation_left=0, extrapolation_right=0) spd = spd.clone() * lef flux = K_m * np.trapz(spd.values, spd.wavelengths) return flux
def RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(wavelength): """ Converts *Wright & Guild 1931 2 Degree RGB CMFs* colour matching functions into the *CIE 1931 2 Degree Standard Observer* colour matching functions. Parameters ---------- wavelength : numeric or array_like Wavelength :math:`\lambda` in nm. Returns ------- ndarray *CIE 1931 2 Degree Standard Observer* spectral tristimulus values. See Also -------- :attr:`colour.colorimetry.dataset.cmfs.RGB_CMFS` Notes ----- - Data for the *CIE 1931 2 Degree Standard Observer* already exists, this definition is intended for educational purpose. References ---------- .. [1] Wyszecki, G., & Stiles, W. S. (2000). Table 1(3.3.3). In Color Science: Concepts and Methods, Quantitative Data and Formulae (pp. 138–139). Wiley. ISBN:978-0471399186 Examples -------- >>> RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(700) # doctest: +ELLIPSIS array([ 0.0113577..., 0.004102 , 0. ]) """ cmfs = RGB_CMFS.get('Wright & Guild 1931 2 Degree RGB CMFs') rgb_bar = cmfs.get(wavelength) rgb = rgb_bar / np.sum(rgb_bar) M1 = np.array([[0.49000, 0.31000, 0.20000], [0.17697, 0.81240, 0.01063], [0.00000, 0.01000, 0.99000]]) M2 = np.array([[0.66697, 1.13240, 1.20063], [0.66697, 1.13240, 1.20063], [0.66697, 1.13240, 1.20063]]) xyz = dot_vector(M1, rgb) xyz /= dot_vector(M2, rgb) x, y, z = xyz[..., 0], xyz[..., 1], xyz[..., 2] V = PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer').clone() V.align(cmfs.shape) L = V.get(wavelength) x_bar = x / y * L y_bar = L z_bar = z / y * L xyz_bar = tstack((x_bar, y_bar, z_bar)) return xyz_bar
def mesopic_luminous_efficiency_function( Lp, source='Blue Heavy', method='MOVE', photopic_lef=PHOTOPIC_LEFS.get( 'CIE 1924 Photopic Standard Observer'), scotopic_lef=SCOTOPIC_LEFS.get( 'CIE 1951 Scotopic Standard Observer')): """ Returns the mesopic luminous efficiency function :math:`V_m(\lambda)` for given photopic luminance :math:`L_p`. Parameters ---------- Lp : numeric Photopic luminance :math:`L_p`. source : unicode, optional **{'Blue Heavy', 'Red Heavy'}**, Light source colour temperature. method : unicode, optional **{'MOVE', 'LRC'}**, Method to calculate the weighting factor. photopic_lef : SpectralPowerDistribution, optional :math:`V(\lambda)` photopic luminous efficiency function. scotopic_lef : SpectralPowerDistribution, optional :math:`V^\prime(\lambda)` scotopic luminous efficiency function. Returns ------- SpectralPowerDistribution Mesopic luminous efficiency function :math:`V_m(\lambda)`. Examples -------- >>> print(mesopic_luminous_efficiency_function(0.2)) SpectralPowerDistribution(\ '0.2 Lp Mesopic Luminous Efficiency Function', (380.0, 780.0, 1.0)) """ photopic_lef_shape = photopic_lef.shape scotopic_lef_shape = scotopic_lef.shape shape = SpectralShape( max(photopic_lef_shape.start, scotopic_lef_shape.start), min(photopic_lef_shape.end, scotopic_lef_shape.end), max(photopic_lef_shape.interval, scotopic_lef_shape.interval)) wavelengths = shape.range() spd_data = dict(zip(wavelengths, mesopic_weighting_function( wavelengths, Lp, source, method, photopic_lef, scotopic_lef))) spd = SpectralPowerDistribution( '{0} Lp Mesopic Luminous Efficiency Function'.format(Lp), spd_data) return spd.normalise()
def LED_4D(l_red, l_green, l_blue, l_yellow, T, a, h, spd4_name, image, Fi_4d, Fi_red, Fi_green, Fi_blue, Fi_yellow): spd_red0 = aprocsimate_CIA(l_red[0], l_red[1]) spd_green0 = aprocsimate_CIA(l_green[0], l_green[1]) spd_blue0 = aprocsimate_CIA(l_blue[0], l_blue[1]) spd_yellow0 = aprocsimate_CIA(l_yellow[0], l_yellow[1]) spd_red = colour_spectr(spd_red0, 'red') spd_green = colour_spectr(spd_green0, 'green') spd_blue = colour_spectr(spd_blue0, 'blue') spd_yellow = colour_spectr(spd_yellow0, 'yellow') blackbody_spd = colour.blackbody_spd(T) #single_spd_plot(blackbody_spd) cmfs = colour.STANDARD_OBSERVERS_CMFS[ 'CIE 1931 2 Degree Standard Observer'] # # # # Calculating the sample spectral power distribution *CIE XYZ* tristimulus values. blackbody_spd.normalise() XYZ_blackbody = colour.spectral_to_XYZ(blackbody_spd, cmfs) XYZ_red = colour.spectral_to_XYZ(spd_red, cmfs) XYZ_green = colour.spectral_to_XYZ(spd_green, cmfs) XYZ_blue = colour.spectral_to_XYZ(spd_blue, cmfs) XYZ_yellow = colour.spectral_to_XYZ(spd_yellow, cmfs) XYZ_blackbody[0] = XYZ_blackbody[0] - XYZ_yellow[0] * a XYZ_blackbody[1] = XYZ_blackbody[1] - XYZ_yellow[1] * a XYZ_blackbody[2] = XYZ_blackbody[2] - XYZ_yellow[2] * a #print(XYZ_blackbody,XYZ_red,XYZ_green,XYZ_blue) XYZ = np.vstack((XYZ_red, XYZ_green, XYZ_blue)) XYZ = XYZ.transpose() XYZ = np.linalg.inv(XYZ) XYZ_blackbody = XYZ_blackbody.transpose() abc = np.dot(XYZ, XYZ_blackbody) abca = [abc[0], abc[1], abc[2], a] #abca=abca/max(abca) spd_4 = [spd_red, spd_green, spd_blue, spd_yellow] spd_4d = spectr_LED4(abca, spd_red0, spd_green0, spd_blue0, spd_yellow0) b1, b2, b3, b4 = abca[0], abca[1], abca[2], abca[3] c1 = 1 c2 = (b2 / b1) * (l_red[0] / l_green[0]) c3 = (b3 / b1) * (l_red[0] / l_blue[0]) c4 = (b4 / b1) * (l_red[0] / l_yellow[0]) h1, h2, h3, h4 = h[0], h[1], h[2], h[3] h_sum = (c1 * h1 + c2 * h2 + c3 * h3 + c4 * h4) / (c1 + c2 + c3 + c4) multi_spd_plot(spd_4, bounding_box=[300, 800, 0, 1], filename=spd4_name) image.append(spd4_name) from colour.colorimetry import PHOTOPIC_LEFS lef = PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer') lef_4d = lef.clone().align(spd_4d.shape, extrapolation_left=0, extrapolation_right=0) lef_red = lef.clone().align(spd_red.shape, extrapolation_left=0, extrapolation_right=0) lef_green = lef.clone().align(spd_green.shape, extrapolation_left=0, extrapolation_right=0) lef_blue = lef.clone().align(spd_blue.shape, extrapolation_left=0, extrapolation_right=0) lef_yellow = lef.clone().align(spd_yellow.shape, extrapolation_left=0, extrapolation_right=0) #import numpy as np #spd_4d Fi_max_4d = (683 * np.trapz(lef_4d.values * spd_4d.values, spd_4d.wavelengths)) k_4d = Fi_4d / Fi_max_4d Fe_4d = (k_4d * np.trapz(spd_4d.values, spd_4d.wavelengths)) F_4d = [Fi_max_4d, k_4d, Fe_4d, Fi_4d] #spd_red Fi_max_red = ( 683 * np.trapz(lef_red.values * spd_red.values, spd_red.wavelengths)) k_red = Fi_red / Fi_max_red Fe_red = (k_red * np.trapz(spd_red.values, spd_red.wavelengths)) F_red = [Fi_max_red, k_red, Fe_red, Fi_red] #spd_green Fi_max_green = ( 683 * np.trapz(lef_green.values * spd_green.values, spd_green.wavelengths)) k_green = Fi_green / Fi_max_green Fe_green = (k_green * np.trapz(spd_green.values, spd_green.wavelengths)) F_green = [Fi_max_green, k_green, Fe_green, Fi_green] #spd_blue Fi_max_blue = ( 683 * np.trapz(lef_blue.values * spd_blue.values, spd_blue.wavelengths)) k_blue = Fi_blue / Fi_max_blue Fe_blue = (k_blue * np.trapz(spd_blue.values, spd_blue.wavelengths)) F_blue = [Fi_max_blue, k_blue, Fe_blue, Fi_blue] #spd_yellow Fi_max_yellow = (683 * np.trapz(lef_yellow.values * spd_yellow.values, spd_yellow.wavelengths)) k_yellow = Fi_yellow / Fi_max_yellow Fe_yellow = (k_yellow * np.trapz(spd_yellow.values, spd_yellow.wavelengths)) F_yellow = [Fi_max_yellow, k_yellow, Fe_yellow, Fi_yellow] return spd_4, spd_4d, h_sum, image, abca, F_4d, F_red, F_green, F_blue, F_yellow
def RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(wavelength): """ Converts *Wright & Guild 1931 2 Degree RGB CMFs* colour matching functions into the *CIE 1931 2 Degree Standard Observer* colour matching functions. Parameters ---------- wavelength : numeric Wavelength :math:`\lambda` in nm. Returns ------- ndarray, (3,) *CIE 1931 2 Degree Standard Observer* spectral tristimulus values. Raises ------ KeyError If wavelength :math:`\lambda` is not available in the colour matching functions. See Also -------- :attr:`colour.colorimetry.dataset.cmfs.RGB_CMFS` Notes ----- - Data for the *CIE 1931 2 Degree Standard Observer* already exists, this definition is intended for educational purpose. References ---------- .. [1] **Wyszecki & Stiles**, *Color Science - Concepts and Methods Data and Formulae - Second Edition*, Wiley Classics Library Edition, published 2000, ISBN-10: 0-471-39918-3, pages 138, 139. Examples -------- >>> RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(700) # doctest: +ELLIPSIS array([ 0.0113577..., 0.004102 , 0. ]) """ cmfs = RGB_CMFS.get('Wright & Guild 1931 2 Degree RGB CMFs') r_bar, g_bar, b_bar = cmfs.r_bar.get(wavelength), cmfs.g_bar.get( wavelength), cmfs.b_bar.get(wavelength) if None in (r_bar, g_bar, b_bar): raise KeyError(('"{0} nm" wavelength not available in "{1}" colour ' 'matching functions with "{2}" shape!').format( wavelength, cmfs.name, cmfs.shape)) r = r_bar / (r_bar + g_bar + b_bar) g = g_bar / (r_bar + g_bar + b_bar) b = b_bar / (r_bar + g_bar + b_bar) x = ((0.49000 * r + 0.31000 * g + 0.20000 * b) / (0.66697 * r + 1.13240 * g + 1.20063 * b)) y = ((0.17697 * r + 0.81240 * g + 0.01063 * b) / (0.66697 * r + 1.13240 * g + 1.20063 * b)) z = ((0.00000 * r + 0.01000 * g + 0.99000 * b) / (0.66697 * r + 1.13240 * g + 1.20063 * b)) V = PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer').clone() V.align(cmfs.shape) L = V.get(wavelength) x_bar = x / y * L y_bar = L z_bar = z / y * L return np.array([x_bar, y_bar, z_bar])
def RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(wavelength): """ Converts *Wright & Guild 1931 2 Degree RGB CMFs* colour matching functions into the *CIE 1931 2 Degree Standard Observer* colour matching functions. Parameters ---------- wavelength : numeric Wavelength :math:`\lambda` in nm. Returns ------- ndarray, (3,) *CIE 1931 2 Degree Standard Observer* spectral tristimulus values. Raises ------ KeyError If wavelength :math:`\lambda` is not available in the colour matching functions. See Also -------- :attr:`colour.colorimetry.dataset.cmfs.RGB_CMFS` Notes ----- - Data for the *CIE 1931 2 Degree Standard Observer* already exists, this definition is intended for educational purpose. References ---------- .. [1] Wyszecki, G., & Stiles, W. S. (2000). Table 1(3.3.3). In Color Science: Concepts and Methods, Quantitative Data and Formulae (pp. 138–139). Wiley. ISBN:978-0471399186 Examples -------- >>> RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(700) # doctest: +ELLIPSIS array([ 0.0113577..., 0.004102 , 0. ]) """ cmfs = RGB_CMFS.get('Wright & Guild 1931 2 Degree RGB CMFs') r_bar, g_bar, b_bar = cmfs.r_bar.get(wavelength), cmfs.g_bar.get( wavelength), cmfs.b_bar.get(wavelength) if None in (r_bar, g_bar, b_bar): raise KeyError(('"{0} nm" wavelength not available in "{1}" colour ' 'matching functions with "{2}" shape!').format( wavelength, cmfs.name, cmfs.shape)) r = r_bar / (r_bar + g_bar + b_bar) g = g_bar / (r_bar + g_bar + b_bar) b = b_bar / (r_bar + g_bar + b_bar) x = ((0.49000 * r + 0.31000 * g + 0.20000 * b) / (0.66697 * r + 1.13240 * g + 1.20063 * b)) y = ((0.17697 * r + 0.81240 * g + 0.01063 * b) / (0.66697 * r + 1.13240 * g + 1.20063 * b)) z = ((0.00000 * r + 0.01000 * g + 0.99000 * b) / (0.66697 * r + 1.13240 * g + 1.20063 * b)) V = PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer').clone() V.align(cmfs.shape) L = V.get(wavelength) x_bar = x / y * L y_bar = L z_bar = z / y * L return np.array([x_bar, y_bar, z_bar])
def mesopic_weighting_function(wavelength, Lp, source='Blue Heavy', method='MOVE', photopic_lef=PHOTOPIC_LEFS.get( 'CIE 1924 Photopic Standard Observer'), scotopic_lef=SCOTOPIC_LEFS.get( 'CIE 1951 Scotopic Standard Observer')): """ Calculates the mesopic weighting function factor at given wavelength :math:`\lambda` using the photopic luminance :math:`L_p`. Parameters ---------- wavelength : numeric Wavelength :math:`\lambda` to calculate the mesopic weighting function factor. Lp : numeric Photopic luminance :math:`L_p`. source : unicode, optional {'Blue Heavy', 'Red Heavy'}, Light source colour temperature. method : unicode, optional {'MOVE', 'LRC'}, Method to calculate the weighting factor. photopic_lef : SpectralPowerDistribution, optional :math:`V(\lambda)` photopic luminous efficiency function. scotopic_lef : SpectralPowerDistribution, optional :math:`V^\prime(\lambda)` scotopic luminous efficiency function. Returns ------- numeric Mesopic weighting function factor. Raises ------ KeyError If wavelength :math:`\lambda` is not available in either luminous efficiency function. Examples -------- >>> mesopic_weighting_function(500, 0.2) # doctest: +ELLIPSIS 0.7052200... """ for function in (photopic_lef, scotopic_lef): if function.get(wavelength) is None: raise KeyError( ('"{0} nm" wavelength not available in "{1}" ' 'luminous efficiency function with "{2}" shape!').format( wavelength, function.name, function.shape)) mesopic_x_luminance_values = sorted(MESOPIC_X_DATA.keys()) index = mesopic_x_luminance_values.index( closest(mesopic_x_luminance_values, Lp)) x = MESOPIC_X_DATA.get( mesopic_x_luminance_values[index]).get(source).get(method) Vm = ((1 - x) * scotopic_lef.get(wavelength) + x * photopic_lef.get(wavelength)) return Vm
def mesopic_weighting_function( wavelength, Lp, source='Blue Heavy', method='MOVE', photopic_lef=PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer'), scotopic_lef=SCOTOPIC_LEFS.get('CIE 1951 Scotopic Standard Observer')): """ Calculates the mesopic weighting function factor at given wavelength :math:`\lambda` using the photopic luminance :math:`L_p`. Parameters ---------- wavelength : numeric Wavelength :math:`\lambda` to calculate the mesopic weighting function factor. Lp : numeric Photopic luminance :math:`L_p`. source : unicode ('Blue Heavy', 'Red Heavy'), Light source colour temperature. method : unicode ('MOVE', 'LRC'), Method to calculate the weighting factor. photopic_lef : SpectralPowerDistribution :math:`V(\lambda)` photopic luminous efficiency function. scotopic_lef : SpectralPowerDistribution :math:`V^\prime(\lambda)` scotopic luminous efficiency function. Returns ------- numeric Mesopic weighting function factor. Raises ------ KeyError If wavelength :math:`\lambda` is not available in either luminous efficiency function. Examples -------- >>> mesopic_weighting_function(500, 0.2) # doctest: +ELLIPSIS 0.7052200... """ for function in (photopic_lef, scotopic_lef): if function.get(wavelength) is None: raise KeyError( ('"{0} nm" wavelength not available in "{1}" ' 'luminous efficiency function with "{2}" shape!').format( wavelength, function.name, function.shape)) mesopic_x_luminance_values = sorted(MESOPIC_X_DATA.keys()) index = mesopic_x_luminance_values.index( closest(mesopic_x_luminance_values, Lp)) x = MESOPIC_X_DATA.get( mesopic_x_luminance_values[index]).get(source).get(method) Vm = ((1 - x) * scotopic_lef.get(wavelength) + x * photopic_lef.get(wavelength)) return Vm