Skip to content

Commit

Permalink
Adding basic ea pressure conversions
Browse files Browse the repository at this point in the history
Only Pa to kPa for now.
  • Loading branch information
cgmorton committed May 2, 2018
1 parent 1e556d1 commit 0ba9438
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions refet/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +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',
'langleys', 'w m-2', 'w/m2',
'mph',
'ft', 'feet',
Expand All @@ -117,6 +118,9 @@ def __init__(self, tmin, tmax, ea, rs, uz, zw, elev, lat, doy,
self.tmin *= (5.0 / 9)
elif unit.lower() in ['k', 'kelvin']:
self.tmin -= 273.15
elif variable == 'ea':
if unit.lower() in ['pa']:
self.ea /= 1000.0
elif variable == 'rs':
if unit.lower() in ['langleys']:
self.rs *= 0.041868
Expand Down
4 changes: 4 additions & 0 deletions refet/hourly.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,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',
'langleys', 'w m-2', 'w/m2',
'mph',
'ft', 'feet',
Expand All @@ -103,6 +104,9 @@ def __init__(self, tmean, ea, rs, uz, zw, elev, lat, lon, doy, time,
self.tmean *= (5.0 / 9)
elif unit.lower() in ['k', 'kelvin']:
self.tmean -= 273.15
elif variable == 'ea':
if unit.lower() in ['pa']:
self.ea /= 1000.0
elif variable == 'rs':
if unit.lower() in ['langleys']:
self.rs *= 0.041868
Expand Down
10 changes: 10 additions & 0 deletions tests/test_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ def test_refet_daily_tmax_k():
input_units={'tmax': 'K'}).etr()
assert float(etr) == pytest.approx(d_args['etr_asce'])


def test_refet_daily_ea_pa():
etr = Daily(
tmin=d_args['tmin'], tmax=d_args['tmax'], ea=d_args['ea'] * 1000,
rs=d_args['rs'], uz=d_args['uz'], zw=s_args['zw'],
elev=s_args['elev'], lat=s_args['lat'], doy=d_args['doy'],
input_units={'ea': 'Pa'}).etr()
assert float(etr) == pytest.approx(d_args['etr_asce'])


def test_refet_daily_rs_langleys():
etr = Daily(
tmin=d_args['tmin'], tmax=d_args['tmax'], ea=d_args['ea'],
Expand Down
8 changes: 8 additions & 0 deletions tests/test_hourly.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ def test_refet_hourly_tmean_k():
time=h_args['time'], input_units={'tmean': 'K'}).etr()
assert float(etr) == pytest.approx(h_args['etr_asce'])

def test_refet_hourly_ea_pa():
etr = Hourly(
tmean=h_args['tmean'], ea=h_args['ea'] * 1000, rs=h_args['rs'],
uz=h_args['uz'], zw=s_args['zw'], elev=s_args['elev'],
lat=s_args['lat'], lon=s_args['lon'], doy=h_args['doy'],
time=h_args['time'], input_units={'ea': 'Pa'}).etr()
assert float(etr) == pytest.approx(h_args['etr_asce'])

def test_refet_hourly_rs_langleys():
etr = Hourly(
tmean=h_args['tmean'], ea=h_args['ea'], rs=h_args['rs'] / 0.041868,
Expand Down

0 comments on commit 0ba9438

Please sign in to comment.