Stata program to get relative humidity given temperature and dew point
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
program define gen_relative_humidity | |
* Calculate relative humidity given dry bulb temperature and dew point | |
syntax, DRYbulbtemp(varname) DEWpoint(varname) [GENerate(string)] | |
* Inputs in F | |
local T `drybulbtemp' | |
local TD `dewpoint' | |
if "`generate'" == "" { | |
local generate "rel_humidity" | |
} | |
capture drop `generate' | |
* Calculate relative humidity from dry bulb temperature and humidity | |
* http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html | |
tempvar TC TDC | |
gen `TC' = (5/9) * (`T' - 32) | |
gen `TDC' = (5/9) * (`TD' - 32) | |
gen `generate' = 100*(exp((17.625*`TDC')/(243.04+`TDC'))/exp((17.625*`TC')/(243.04+`TC'))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment