Search code examples
javascriptcolorsastronomy

B-V to Kelvin formula


Whilst looking for a "B-V color index to temperature conversion formula"

I found this javascript:

   var C1 = 3.979145;
   var C2 = -0.654499;
   var C3 = 1.74069;
   var C4 = -4.608815;
   var C5 = 6.7926;
   var C6 = -5.39691;
   var C7 = 2.19297;
   var C8 = -.359496;
   bmv = parseFloat(BV);
   with (Math) {
           logt=
              C1
             +C2*bmv
             +C3*pow(bmv,2)
             +C4*pow(bmv,3)
             +C5*pow(bmv,4)
             +C6*pow(bmv,5)
             +C7*pow(bmv,6)
             +C8*pow(bmv,7);

          t=pow(10,logt);
   }

Which is supposed to convert B-V color index to temperature. Does anyone understand how this is working and if the output value is an approximation for temperature in celcius or kelvin?

Is it something to do with products of logarithms?


Solution

  • I think temperatures are in Kelvin because its very common for astronomers to use Kelvin rather than Celcius.

    Look here.

    And,

    if logbaseX = Y then X = baseY

     log10(t)= C1 +C2*bmv +C3*pow(bmv,2) +C4*pow(bmv,3)
              +C5*pow(bmv,4) +C6*pow(bmv,5) +C7*pow(bmv,6) 
              +C8*pow(bmv,7); 
    
     t = pow(10,log10(t));
    

    Also, this formula is very much related to Taylor Series.

    // Horners algorithm for polynomials 
    function Horner(a,n,x)
    {
        var result = a[n];
        var i = n - 1;
        while( i >= 0)
        { 
           result = result*x + a[i];
           i-=1; 
        }
        return result;
    }
    

    In your case,

    Array Cs = {C1,C2,C3,C4,C5,C6,C7,C8};
    var temperature = Horner(Cs,8,bmv);