#!/usr/bin/env python
# coding: utf-8
# # !!! D . R . A . F . T !!!
# # Luminance
# The [Luminance](http://en.wikipedia.org/wiki/Luminance) $L_v$ is the quantity defined by the formula: [1]
#
# $$
# \begin{equation}
# L_v=\cfrac{d\Phi_v}{dAcos\theta d\Omega}
# \end{equation}
# $$
#
# where $d\Phi_v$ is the [luminous flux](http://en.wikipedia.org/wiki/Luminous_flux) transmitted by an elementary beam passing through the given point and propagating in the solid angle, $d\Omega$, containing the given direction. $dA$ is the area of a section of that beam containing the given point. $\theta$ is the angle between the normal to that section and the direction of the beam.
#
# $L_v$ unit is candela per square metre (or nits) $cd\cdot m^{-2}=lm\cdot m^{-2}\cdot sr^{-1}$.
#
# [Colour](https://github.com/colour-science/colour/) defines the following *luminance* computation methods:
# In[1]:
import colour
sorted(colour.LUMINANCE_METHODS.keys())
# > Note: `'astm2008'` and `'cie1976'` are convenient aliases for respectively `'ASTM D1535'` and `'CIE 1976'`.
# ## Newhall, Nickerson, and Judd (1943) Method
# Newhall, Nickerson, and Judd (1943) fitted a quintic-parabola function to the adjusted *Munsell-Sloan-Godlove* reflectances, the resulting equation computing *luminance* $R_Y$ as function of *Munsell* value $V$ is expressed as follows: [2]
#
# $$
# \begin{equation}
# R_Y=1.2219V-0.23111V^2+0.23951V^3-0.021009V^4+0.0008404V^5
# \end{equation}
# $$
#
# > See Also: The [Munsell Renotation System](../notation/munsell.ipynb) notebook for in-depth information about the *Munsell Renotation System*.
#
# The `colour.luminance_Newhall1943` definition is used to compute *luminance* $R_Y$:
# In[2]:
colour.colorimetry.luminance_Newhall1943(3.74629715382)
# > Note: Input *Munsell* value $V$ is in domain [0, 10], output *luminance* $R_Y$ is in domain [0, 100].
#
# The `colour.luminance` definition is implemented as a wrapper for various luminance computation methods:
# In[3]:
colour.colorimetry.luminance(3.74629715382, method='Newhall 1943')
# ## ASTM D1535-08$^{\epsilon 1}$ (2008) Method
# Since 1943, the reference white used for the *Munsell Renotation System* has changed.
#
# As a result the quintic-parabola function from Newhall, Nickerson, and Judd (1943) has been adjusted: Each coefficient of the function has been multiplied by 0.975, the reflectance factor of magnesium oxide with respect to the perfect reflecting diffuser and then rounded to five digits.
#
# The updated equation for computing *luminance* $Y$ as function of the *Munsell* value $V$ is expressed as follows: [3]
#
# $$
# \begin{equation}
# Y=1.1914V-0.22533V^2+0.23352V^3-0.020484V^4+0.00081939V^5
# \end{equation}
# $$
#
# > See Also: The [Munsell Renotation System](../notation/munsell.ipynb) notebook for in-depth information about the *Munsell Renotation System*.
#
# The `colour.luminance_ASTMD153508` definition is used to compute *luminance* $Y$:
# In[4]:
colour.colorimetry.luminance_ASTMD153508(3.74629715382)
# > Note: Input *Munsell* value $V$ is in domain [0, 10], output *luminance* $Y$ is in domain [0, 100].
#
# Using the `colour.luminance` wrapper definition:
# In[5]:
colour.luminance(3.74629715382, method='ASTM D1535')
# In[6]:
colour.luminance(3.74629715382, method='astm2008')
# ## CIE 1976 Method
# The *CIE $L^*a^*b^*$* approximately uniform colourspace defined in 1976 computes the *luminance* $Y$ quantity as follows: [4]
#
# $$
# \begin{equation}
# Y=\begin{cases}Y_n*\biggl(\cfrac{L^*+16}{116}\biggr)^3 & for\ L^*>\kappa*\epsilon\\
# Y_n*\biggl(\cfrac{L^*}{\kappa}\biggr) & for\ L^*<=\kappa*\epsilon
# \end{cases}
# \end{equation}
# $$
# where $Y_n$ is the reference white *luminance*.
# with
# $$
# \begin{equation}
# \begin{aligned}
# \epsilon&\ =\begin{cases}0.008856 & Actual\ CIE\ Standard\\
# 216\ /\ 24389 & Intent\ of\ the\ CIE\ Standard
# \end{cases}\\
# \kappa&\ =\begin{cases}903.3 & Actual\ CIE\ Standard\\
# 24389\ /\ 27 & Intent\ of\ the\ CIE\ Standard
# \end{cases}
# \end{aligned}
# \end{equation}
# $$
#
# The original $\epsilon$ and $\kappa$ constants values have been shown to exhibit discontinuity at the junction point of the two functions grafted together to create the *Lightness* $L^*$ function. [5]
#
# [Colour](https://github.com/colour-science/colour/) uses the rational values instead of the decimal values for these constants.
#
# > See Also: The [CIE $L^*a^*b^*$ Colourspace](../models/cie_lab.ipynb) notebook for in-depth information about the *CIE $L^*a^*b^*$* colourspace.
#
# The `colour.luminance_CIE1976` definition is used to compute *Luminance* $Y$:
# In[7]:
colour.colorimetry.luminance_CIE1976(37.9856290977)
# > Note: Input *Lightness* $L^*$ and and $Y_n$ are in domain [0, 100], output *luminance* $Y$ is in domain [0, 100].
#
# Using the `colour.luminance` wrapper definition:
# In[8]:
colour.luminance(37.9856290977, method='CIE 1976')
# In[9]:
colour.luminance(37.9856290977, method='cie1976')
# ## Fairchild and Wyble (2010) Method
# In[10]:
colour.colorimetry.luminance_Fairchild2010(24.902290269546651, 1.836)
# In[11]:
colour.luminance(24.902290269546651, method='Fairchild 2010', epsilon=1.836)
# ## Fairchild and Chen (2011) Method
# In[12]:
colour.colorimetry.luminance_Fairchild2011(26.459509817572265, 0.710)
# In[13]:
colour.luminance(26.459509817572265, method='Fairchild 2011', epsilon=0.710)
# ## Bibliography
# 1. ^ CIE. (n.d.). 17-711 luminance (in a given direction, at a given point of a real or imaginary surface) [Lv; L]. Retrieved July 09, 2014, from http://eilv.cie.co.at/term/711
# 2. ^ Newhall, S. M., Nickerson, D., & Judd, D. B. (1943). Final report of the OSA subcommittee on the spacing of the munsell colors. JOSA, 33(7), 385. doi:10.1364/JOSA.33.000385
# 3. ^ ASTM International. (n.d.). ASTM D1535-08e1 Standard Practice for Specifying Color by the Munsell System. doi:10.1520/D1535-08E01
# 4. ^ Wyszecki, G., & Stiles, W. S. (2000). CIE 1976 (L*u*v*)-Space and Color-Difference Formula. In *Color Science: Concepts and Methods, Quantitative Data and Formulae* (p. 167). Wiley. ISBN:978-0471399186
# 5. ^ Lindbloom, B. (2003). A Continuity Study of the CIE L* Function. Retrieved February 24, 2014, from http://brucelindbloom.com/LContinuity.html