From 3d1cb1ef8d8778605c4a4b63a481e328dbe076bb Mon Sep 17 00:00:00 2001 From: Alton Campbell Date: Fri, 25 May 2018 11:31:29 -0600 Subject: [PATCH 1/2] added support for RH to VP conversions. --- refet/daily.py | 8 +++++++- refet/hourly.py | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/refet/daily.py b/refet/daily.py index 33e3c75..ad88300 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..ece0a03 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 From 7fbb7ca92cec4b3985f12358290f457856260f4c Mon Sep 17 00:00:00 2001 From: Alton Campbell Date: Fri, 25 May 2018 11:40:27 -0600 Subject: [PATCH 2/2] changed tabs to spaces. --- refet/daily.py | 12 ++++++------ refet/hourly.py | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/refet/daily.py b/refet/daily.py index ad88300..90bd65c 100644 --- a/refet/daily.py +++ b/refet/daily.py @@ -121,12 +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 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 ece0a03..b66b024 100644 --- a/refet/hourly.py +++ b/refet/hourly.py @@ -109,11 +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 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