def getDewPoint( Tc=0, RH=93, minRH=( 0, 0.075 )[ 0 ] ):
""" Dewpoint from relative humidity and temperature
If you know the relative humidity and the air temperature,
and want to calculate the dewpoint, the formulas are as follows.
#First, if your air temperature is in degrees Fahrenheit, then you must convert it to degrees Celsius by using the Fahrenheit to Celsius formula.
# Tc = 5.0 / 9.0 * ( Tf - 32.0 )
#The next step is to obtain the saturation vapor pressure(Es) using this formula as before when air temperature is known.
Es = 6.11 * 10.0**( 7.5 * Tc / ( 237.7 + Tc ) )
#The next step is to use the saturation vapor pressure and the relative humidity to compute the actual vapor pressure(E) of the air. This can be done with the following formula.
#RH=relative humidity of air expressed as a percent. or except minimum(.075) humidity to abort error with math.log.
RH = RH or minRH #0.075
E = ( RH * Es ) / 100
#Note: math.log( ) means to take the natural log of the variable in the parentheses
#Now you are ready to use the following formula to obtain the dewpoint temperature.
DewPoint = ( -430.22 + 237.7 * math.log( E ) ) / ( -math.log( E ) + 19.08 )
#math domain error, because RH = 0%
DewPoint = 0 #minRH
#Note: Due to the rounding of decimal places, your answer may be slightly different from the above answer, but it should be within two degrees.
return str( int( DewPoint ) )
# Check Dew Point Calculator with http://www.dpcalc.org/
tCelsius = 10
for humidity in range( 101 ):
DewPoint = getDewPoint( tCelsius, humidity )