Skip to content

Commit 80496ab

Browse files
committed
rename, clean docs, add pw test
1 parent 62cf064 commit 80496ab

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

pvlib/atmosphere.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,32 +244,35 @@ def relativeairmass(zenith, model='kastenyoung1989'):
244244
return am
245245

246246

247-
def calc_pw(temp_air, relative_humidity):
247+
def gueymard94_pw(temp_air, relative_humidity):
248248
"""
249249
Calculates precipitable water (cm) from ambient air temperature (C)
250-
and relatively humidity (%) using an empirical model [1]. The model
251-
was developed by expanding Eq. 1 in [2]:
250+
and relatively humidity (%) using an empirical model [1-3]. The
251+
accuracy of this method is approximately 20% for moderate PW (1-3
252+
cm) and less accurate otherwise.
253+
254+
The model was developed by expanding Eq. 1 in [2]:
252255
.. math::
253256
254257
w = 0.1 H_v \rho_v
255258
256259
using Eq. 2 in [2]
257260
.. math::
258261
259-
\rho_v = 216.7 RH/T e_s
262+
\rho_v = 216.7 R_H e_s /T
260263
261264
H_v is the apparant water vapor scale height (km). The expression
262265
for H_v is Eq. 4 in [2]:
263266
.. math::
264267
265268
H_v = 0.4976 + 1.5265*T/273.15 + exp(13.6897*T/273.15 - 14.9188*(T/273.15)^3)
266269
267-
\rho_v is the surface water vapor density (g/m^3). In the
268-
expression \rho_v, e_s is the saturation water vapor pressure
269-
(millibar). The expression for e_s is Eq. 1 in [3]
270+
\rho_v is the surface water vapor density (g/m^3). In the expression
271+
\rho_v, e_s is the saturation water vapor pressure (millibar). The
272+
expression for e_s is Eq. 1 in [3]
270273
.. math::
271274
272-
e_s = exp(22.330 - 49.140*(100./T) - 10.922*(100./T).^2 - 0.39015*T/100)
275+
e_s = exp(22.330 - 49.140*(100/T) - 10.922*(100/T)^2 - 0.39015*T/100)
273276
274277
Parameters
275278
----------
@@ -296,17 +299,17 @@ def calc_pw(temp_air, relative_humidity):
296299
1294-1300.
297300
"""
298301

299-
T = temp_air + 273.15 # Convert to Kelvin
302+
T = temp_air + 273.15 # Convert to Kelvin
300303
RH = relative_humidity
301304

302-
#RH[RH>100 | RH<=0] = NaN; #Filter RH for unreasonable Values
305+
theta = T / 273.15
303306

304307
# Eq. 1 from Keogh and Blakers
305-
pw = ( 0.1 *
306-
(0.4976 + 1.5265*T/273.15 +
307-
np.exp(13.6897*T/273.15 - 14.9188*(T/273.15)**3)) *
308-
(216.7*RH/(100.*T)*np.exp(22.330 - 49.140*(100./T) -
309-
10.922*(100./T)**2 - 0.39015*T/100)))
308+
pw = (
309+
0.1 *
310+
(0.4976 + 1.5265*theta + np.exp(13.6897*theta - 14.9188*(theta)**3)) *
311+
(216.7*RH/(100*T)*np.exp(22.330 - 49.140*(100/T) -
312+
10.922*(100/T)**2 - 0.39015*T/100)))
310313

311314
pw = np.maximum(pw, 0.1)
312315

@@ -326,8 +329,9 @@ def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
326329
function:
327330
328331
.. math::
329-
M = coeff(1) + coeff(2)*AMa + coeff(3)*Pwat + coeff(4)*AMa^.5
330-
+ coeff(5)*Pwat^.5 + coeff(6)*AMa/Pwat
332+
333+
M = c_1 + c_2*AMa + c_3*Pwat + c_4*AMa^.5
334+
+ c_5*Pwat^.5 + c_6*AMa/Pwat
331335
332336
Default coefficients are determined for several cell types with
333337
known quantum efficiency curves, by using the Simple Model of the

pvlib/test/test_atmosphere.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import logging
2-
pvl_logger = logging.getLogger('pvlib')
3-
41
import datetime
2+
import itertools
53

64
import numpy as np
75
import pandas as pd
@@ -65,3 +63,16 @@ def test_absoluteairmass_numeric():
6563
def test_absoluteairmass_nan():
6664
np.testing.assert_equal(np.nan, atmosphere.absoluteairmass(np.nan))
6765

66+
67+
def test_gueymard94_pw():
68+
temp_air = np.array([0, 20, 40])
69+
relative_humidity = np.array([0, 30, 100])
70+
temps_humids = np.array(
71+
list(itertools.product(temp_air, relative_humidity)))
72+
pws = atmosphere.gueymard94_pw(temps_humids[:, 0], temps_humids[:, 1])
73+
74+
expected = np.array(
75+
[ 0.1 , 0.33702061, 1.12340202, 0.1 ,
76+
1.12040963, 3.73469877, 0.1 , 3.44859767, 11.49532557])
77+
78+
np.testing.assert_allclose(pws, expected, atol=0.01)

0 commit comments

Comments
 (0)