5,838
edits
|
=== Other weather derivatives ===
Although 'Apparent Temperature',
This PHP function calculates wind chill, apparent temperature, and feels like temperature. Note you might need to convert the units for the temperature and wind speed for the function from those reported by those recent history tags.
<pre>function Calculate_FeelsLike ($temp_degC, $wind_mph, $humidity)
{
$wind_kph = $wind_mph * 1.609344;
if($wind_kph <4.828)
{
$wind_chill = $temp_degC;
}else{
$wind_chill = 13.12 +0.6125 * $temp_degC - 11.37 * pow($wind_kph, 0.16) + 0.3965 * $temp_degC * pow($wind_kph, 0.16);
}
$vapour_pressure = (($humidity / 100) * 6.105) * exp(17.27 * $temp_degC / (237.7 + $temp_degC)) / 10;
$apparent_temp = -2.7 + (1.04 * $temp_degC) + (2 * $vapour_pressure) - ($wind_kph * 01.1805553);
if($temp_degC < 10)
{
$feels_like = $wind_chill;
}elseif($temp_degC > 20)
{
$feels_like = $apparent_temp;
}else{
$app_temp_mult = ($temp_degC - 10) / 10;
$wind_chill_mult = 1 - $app_temp_mult;
$feels_like = ($apparent_temp * $app_temp_mult) + ($wind_chill * $wind_chill_mult);
}
$return_array[0] = $apparent_temp;
$return_array[1] = $feels_like;
$return_array[2] = $wind_chill;
return $return_array;
}</pre>
=== During catch-up ===
| |||
edits