diff --git a/refet/daily.py b/refet/daily.py index 33e3c75..90bd65c 100644 --- a/refet/daily.py +++ b/refet/daily.py @@ -97,7 +97,7 @@ def __init__(self, tmin, tmax, ea, rs, uz, zw, elev, lat, doy, continue elif unit.lower() not in [ 'k', 'kelvin', 'f', 'fahrenheit', - 'pa', + 'pa','rh','relative humidity', 'langleys', 'w m-2', 'w/m2', 'mph', 'ft', 'feet', @@ -121,6 +121,12 @@ def __init__(self, tmin, tmax, ea, rs, uz, zw, elev, lat, doy, elif variable == 'ea': if unit.lower() in ['pa']: self.ea /= 1000.0 + elif unit.lower() in ['rh','relative humidity']: + if self.ea.max() > 1.0: # check for percentage format + self.ea /= 100 + # use Teten's formula + self.ea = self.ea * (0.61078 ** (17.27 * ((self.tmin+self.tmax)/2) / ( + ((self.tmin+self.tmax)/2) + 237.3))) elif variable == 'rs': if unit.lower() in ['langleys']: self.rs *= 0.041868 diff --git a/refet/hourly.py b/refet/hourly.py index a4d8d10..b66b024 100644 --- a/refet/hourly.py +++ b/refet/hourly.py @@ -91,7 +91,7 @@ def __init__(self, tmean, ea, rs, uz, zw, elev, lat, lon, doy, time, continue elif unit.lower() not in [ 'k', 'kelvin', 'f', 'fahrenheit', - 'pa', + 'pa','rh','relative humidity', 'langleys', 'w m-2', 'w/m2', 'mph', 'ft', 'feet', @@ -109,6 +109,11 @@ def __init__(self, tmean, ea, rs, uz, zw, elev, lat, lon, doy, time, elif variable == 'ea': if unit.lower() in ['pa']: self.ea /= 1000.0 + elif unit.lower() in ['rh','relative humidity']: + if self.ea.max() > 1.0: # check for percentage format + self.ea /= 100 + # use Teten's formula + self.ea = self.ea * (0.61078 ** (17.27 * self.tmean / (self.tmean + 237.3))) elif variable == 'rs': if unit.lower() in ['langleys']: self.rs *= 0.041868