You are here

function _weather_format_relative_humidity in Weather 5.6

Same name and namespace in other branches
  1. 5 weather.module \_weather_format_relative_humidity()
  2. 6.5 weather.module \_weather_format_relative_humidity()

Calculate the relative humidity

Parameters

float Temperature (must be Celsius):

float Dewpoint (must be Celsius):

Return value

string Formatted representation

1 call to _weather_format_relative_humidity()
theme_weather in ./weather.module
Custom theme function for the weather block output

File

./weather.module, line 1261
Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world

Code

function _weather_format_relative_humidity($temperature, $dewpoint) {
  $e = 6.11 * pow(10, 7.5 * $dewpoint['celsius'] / (237.7 + $dewpoint['celsius']));
  $es = 6.11 * pow(10, 7.5 * $temperature['celsius'] / (237.7 + $temperature['celsius']));
  return t('!rel_humidity%', array(
    '!rel_humidity' => max(0, min(100, round(100 * ($e / $es), 0))),
  ));
}