Skip to content

Instantly share code, notes, and snippets.

@mschwld
Created August 20, 2022 10:09
Show Gist options
  • Save mschwld/2850fbb8b41517e5aff57396ada6c595 to your computer and use it in GitHub Desktop.
Save mschwld/2850fbb8b41517e5aff57396ada6c595 to your computer and use it in GitHub Desktop.
Python Dewpoint from Temperature and Humidty, Celcius
#!/usr/bin/env python
import math
def dewpoint(r,T):
if(T<=0):
raise ValueError('Algorithm not suitable for the given temperature')
return (b * (math.log( (r/100)*6.1078*(10**((a*T)/(b+T))) /6.1078,10) ) /
(a - (math.log( (r/100)*6.1078*(10**((a*T)/(b+T))) /6.1078,10) )))
# Relative humidity, 0-100 %
relhum = 50
# Temperature in Degree Celcius, only > 0
temp = 20
print("Dewpoint: " + str(round(dewpoint(relhum,temp),1)) + "° Celcius")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment