Windchill Computation Function - NOAA

This function computes the theoretical windchill temperature in degrees Fahrenheit according to the NOAA (National Oceanic and Atmospheric Administration) formula.  Given the actual Fahrenheit temperature and the wind speed in statute miles per hour, it returns the equivalent windchill temperature in degrees Fahrenheit, rounded to the nearest degree.


/*
   ========================================================================
   This function computes the theoretical windchill temperature in degrees
   Fahrenheit according to the NOAA formula.

   ARGUMENTS:
   $TrueTempF    = True outdoor Fahrenheit temperature (-45 to +40)
   $WindSpeedMPH = Wind speed in statute miles per hour  (5 to 60)


   ERRORS:
   If either argument is out of valid range, then FALSE is returned to
   indicate the error.
   ========================================================================
*/

   function Windchill_Temp_F ($TrueTempF, $WindSpeedMPH)
{
   $F = floatval($TrueTempF);
   $W = floatval($WindSpeedMPH);

   if ($F < -45 or $F > 40 or $W < 5 or $W > 60) {return FALSE;}

   $u = pow($W, 0.16);
   $u = sprintf("%+2.0f", 35.74 + 0.6215*$F - 35.75*$u + 0.4275*$F*$u);

   return substr("   $u", -3);
}

The NOAA Formula:

Let:
= True outdoor temperature in degrees Fahrenheit (-45  to  +40).
W = Wind speed in statute miles per hour (5  to  60).

Then:
Windchill °F  =  35.74  +  0.6215 × F  -  35.75 × W 0.16  +  0.4275 × F × W 0.16


Reference:
http://www.nws.noaa.gov/om/windchill/
Jay Tanner - 2017