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 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