wetbulb calculates the wetbulb temperature given pressure in hPa, dewpoint in degrees C, and temperature in degrees C.
Uses the psychrometric formula from the American Meteorological Society glossary. Vapor pressure calculations use the improved August-Roche-Magnus approximation, that is, equation 21 from:
Alduchov, O.A. and R.E. Eskridge, 1996: Improved Magnus Form Approximation of Saturation Vapor Pressure. J. Appl. Meteor., 35, 601-609, https://doi.org/10.1175/1520-0450(1996)035<0601:IMFAOS>2.0.CO;2
If you give this function dewpoint values greater than the dry bulb you'll get a warning and the theoretical result for this likely unrealistic scenario. I'm not sure you can make a wetbulb measurement in a supersaturated scenario, but the equations allow for it.
This function was derived by code originally written by Daniel Hueholt.