Calculating the Dewpoint in Ruby
August 05, 2016
I needed this today; maybe it will help someone else.
# @param [Float] temp_c temperature in C
# @param [Float] humidity in percent, 0-100
def dewpoint(temp_c, humidity)
l = Math.log(humidity / 100.0)
m = 17.27 * temp_c
n = 237.3 + temp_c
b = (l + (m / n)) / 17.27
dewpoint_c = (237.3 * b) / (1 - b)
end