Module: WrfLibrary::ApparentTemperature

Defined in:
lib/wrf_library/apparent_temperature.rb

Overview

module to calculate the apparent temperature, more specific the australian apparent temperature as described in en.wikipedia.org/wiki/Apparent_temperature. The apparent temperature takes the water vapor pressure, the wind speed in 10 m and the air temperature to calculate the temperature. For lower temperatures the apparent temperatures the results are related to the wind chill while higher temperature are related to heat indices

Class Method Summary collapse

Class Method Details

.calculate_apparent_temperature(temperature, wind_speed, humidity, pressure) ⇒ Float

calculates the apparent temperature

Parameters:

  • temperature (Float)

    the air temperature in degree celcius

  • wind_speed (Float)

    the wind speed in kilometer per hour

  • humidity (Float)

    the vapor mixing ratio in kg/kg

  • pressure (Float)

    the air pressure in hectopascal

Returns:

  • (Float)

    the apparent temperature



16
17
18
# File 'lib/wrf_library/apparent_temperature.rb', line 16

def self.calculate_apparent_temperature(temperature, wind_speed, humidity, pressure)
  temperature + 0.33 * calculate_water_vapour_pressure(temperature, pressure, humidity) - 0.7 * wind_speed - 4.0
end

.calculate_relative_humidity(temperature, pressure, humidity) ⇒ Float

calculates the relative humidity

Parameters:

  • temperature (Float)

    the air temperature in degree celcius

  • humidity (Float)

    the vapor mixing ratio in kg/kg

  • pressure (Float)

    the air pressure in hectopascal

Returns:

  • (Float)

    the relative humidity in %



32
33
34
35
36
37
# File 'lib/wrf_library/apparent_temperature.rb', line 32

def self.calculate_relative_humidity(temperature, pressure, humidity)
  saturation_pressure = calculate_saturation_pressure(temperature)
  partial_pressure = 0.622 * saturation_pressure / pressure
  rel_hum_pre = humidity * 100 / partial_pressure
  [ rel_hum_pre, 100.0 ].min
end

.calculate_saturation_pressure(temperature) ⇒ Float

calculates the water vapour pressure

Parameters:

  • temperature (Float)

    the air temperature

Returns:

  • (Float)

    the water vapour pressure



23
24
25
# File 'lib/wrf_library/apparent_temperature.rb', line 23

def self.calculate_saturation_pressure(temperature)
  6.1094 * Math.exp((17.685 * temperature) / (temperature + 243.04))
end

.calculate_water_vapour_pressure(temperature, pressure, humidity) ⇒ Float

calculates the water vapor pressure for the current condition

Parameters:

  • temperature (Float)

    the air temperature in degree celcius

  • humidity (Float)

    the vapor mixing ratio in kg/kg

  • pressure (Float)

    the air pressure in hectopascal

Returns:

  • (Float)

    the water vapor pressure



44
45
46
47
# File 'lib/wrf_library/apparent_temperature.rb', line 44

def self.calculate_water_vapour_pressure(temperature, pressure, humidity)
  relative_humidity = calculate_relative_humidity(temperature, pressure, humidity)
  6.105 * (relative_humidity / 100) * Math.exp((17.27 * temperature) / (temperature + 237.7))
end