{ Compute correlated color temperature. Used by scripts illumcal, reflcal. Input is SPD curve convolved with CIE standard response curves to compute u_k and v_k. } mk(i) = select(i, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500, 525, 550, 575, 600); ut(i) = select(i, 0.180060, 0.180660, 0.181330, 0.182080, 0.182930, 0.183880, 0.184940, 0.186110, 0.187400, 0.188800, 0.190320, 0.194620, 0.199620, 0.205250, 0.211420, 0.218070, 0.225110, 0.232470, 0.240100, 0.247020, 0.255910, 0.264000, 0.272180, 0.280390, 0.288630, 0.296850, 0.305050, 0.313200, 0.321290, 0.329310, 0.337240); vt(i) = select(i, 0.263520, 0.265890, 0.268460, 0.271190, 0.274070, 0.277090, 0.280210, 0.283420, 0.286680, 0.289970, 0.293260, 0.301410, 0.309210, 0.316470, 0.323120, 0.329090, 0.334390, 0.339040, 0.343080, 0.346550, 0.349510, 0.352000, 0.354070, 0.355770, 0.357140, 0.358230, 0.359070, 0.359680, 0.360110, 0.360380, 0.360510); tt(i) = select(i, -0.243410, -0.254790, -0.268760, -0.285390, -0.304700, -0.326750, -0.351560, -0.379150, -0.409550, -0.442780, -0.478880, -0.582040, -0.704710, -0.849010, -1.018200, -1.216800, -1.451200, -1.729800, -2.063700, -2.468100, -2.964100, -3.581400, -4.363300, -5.376200, -6.726200, -8.595500, -11.324000, -15.628000, -23.325000, -40.770000, -116.450000); dti(j) = ( (v_k - vt(j)) - tt(j) * (u_k - ut(j)) ) / sqrt(1+tt(j)*tt(j)); T(i) = 1e6/(mk(i)+dti(i)/(dti(i)-dti(i+1))*(mk(i+1)-mk(i))); temp(k) = if(dti(k)/dti(k+1), temp(k+1), T(k)); cct = temp(1);