Created
November 26, 2021 03:35
-
-
Save ethaniel/c0160bc12feab27dbd442264b40687c1 to your computer and use it in GitHub Desktop.
PHP script for converting relative humidity to absolute humidity
This file contains 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
<?php | |
// formulas courtesy of https://planetcalc.com/2167/ | |
$pressure = 1000; // Pressure in hPa | |
$temperature = 25; // Temperature in Celsius | |
$humidity = 75; // Relative Humidity in % | |
$e = 2.71828; | |
$tp = ($pressure * 133.322)/100; | |
$et = 6.112 * pow($e,((17.62*$temperature)/(243.12+$temperature))); | |
$fp = 1.0016 + 3.15 * pow(10,-6) * $tp - 0.074/$tp; | |
$ept = $fp*$et; | |
$e = ($humidity/100)*$ept; | |
$Rv = 461.5; | |
$T = $temperature + 273.15; | |
$absolute = ($e*100/($Rv*$T)); // absolute humidity | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment