Created
January 9, 2021 20:49
-
-
Save vsee/a51d2ebc7376bbd38f3d58c87c2b5d1b to your computer and use it in GitHub Desktop.
Calculate the absolute humidity based on relative temperature in Celcius and relative humidity in percent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Calculate the absolute humidity based on relative temperature in Celcius | |
and relative humidity in percent. | |
Based on: | |
https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/ | |
Dry vs. Wet House based on Absolute Humidity: | |
https://www.youtube.com/watch?v=iiokj5gr4Jw&ab_channel=PeterWard | |
""" | |
import sys | |
import math | |
relT = float(sys.argv[1]) | |
relH = float(sys.argv[2]) | |
print("Relative Temperature " + str(relT) + " C") | |
print("Relative Humidity " + str(relH) + " %") | |
exponent = math.exp( (17.67*relT) / (relT + 243.5) ) | |
absH = (6.112 * exponent * relH * 18.02) / ((273.15+relT)*100*0.08314) | |
print("Absolute Humidity " + str(absH) + " g/m^3") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment