8000 Correct day angle in ASCE extraterrestrial irradiance model (#712) · soareshpaulo/pvlib-python@e5bcf68 · GitHub
[go: up one dir, main page]

Skip to content

Commit e5bcf68

Browse files
authored
Correct day angle in ASCE extraterrestrial irradiance model (pvlib#712)
* change day angle equation for asce model * update whatsnew * add reference * add offset kwarg to _calculate_simple_day_angle * add method kwarg to test
1 parent 6331d60 commit e5bcf68

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

docs/sphinx/source/whatsnew/v0.6.2.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Bug fixes
4747
near horizon. (:issue:`656`)
4848
* Fixed numpy warnings in :py:func:`~pvlib.tracking.singleaxis` when
4949
comparing NaN values to limits. (:issue:`622`)
50+
* Fixed a bug in the day angle equation for the ASCE
51+
extraterrestrial irradiance model. (:issue:`211`)
5052
* Silenced divide by 0 irradiance warnings in
5153
:py:func:`~pvlib.irradiance.klucher` and
5254
:py:func:`~pvlib.pvsystem.calcparams_desoto`. (:issue:`698`)

pvlib/irradiance.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def get_extra_radiation(datetime_or_doy, solar_constant=1366.1,
8080
8181
[4] Duffie, J. A. and Beckman, W. A. 1991. Solar Engineering of
8282
Thermal Processes, 2nd edn. J. Wiley and Sons, New York.
83+
84+
[5] ASCE, 2005. The ASCE Standardized Reference Evapotranspiration
85+
Equation, Environmental and Water Resources Institute of the American
86+
Civil Engineers, Ed. R. G. Allen et al.
8387
"""
8488

8589
to_doy, to_datetimeindex, to_output = \
@@ -88,7 +92,8 @@ def get_extra_radiation(datetime_or_doy, solar_constant=1366.1,
8892
# consider putting asce and spencer methods in their own functions
8993
method = method.lower()
9094
if method == 'asce':
91-
B = solarposition._calculate_simple_day_angle(to_doy(datetime_or_doy))
95+
B = solarposition._calculate_simple_day_angle(to_doy(datetime_or_doy),
96+
offset=0)
9297
RoverR0sqrd = 1 + 0.033 * np.cos(B)
9398
elif method == 'spencer':
9499
B = solarposition._calculate_simple_day_angle(to_doy(datetime_or_doy))

pvlib/solarposition.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,19 +988,21 @@ def nrel_earthsun_distance(time, how='numpy', delta_t=67.0, numthreads=4):
988988
return dist
989989

990990

991-
def _calculate_simple_day_angle(dayofyear):
991+
def _calculate_simple_day_angle(dayofyear, offset=1):
992992
"""
993993
Calculates the day angle for the Earth's orbit around the Sun.
994994
995995
Parameters
996996
----------
997997
dayofyear : numeric
998+
offset : int, default 1
999+
For the Spencer method, offset=1; for the ASCE method, offset=0
9981000
9991001
Returns
10001002
-------
10011003
day_angle : numeric
10021004
"""
1003-
return (2. * np.pi / 365.) * (dayofyear - 1)
1005+
return (2. * np.pi / 365.) * (dayofyear - offset)
10041006

10051007

10061008
def equation_of_time_spencer71(dayofyear):

pvlib/test/test_irradiance.py

Lines changed: 4 additions & 4 deletions
93
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_deprecated_07():
9090
value = 1383.636203
9191

9292

-
@pytest.mark.parametrize('input, expected', [
93+
@pytest.mark.parametrize('testval, expected', [
9494
(doy, value),
9595
(np.float64(doy), value),
9696
(dt_date, value),
@@ -103,9 +103,9 @@ def test_deprecated_07():
103103
])
104104
@pytest.mark.parametrize('method', [
105105
'asce', 'spencer', 'nrel', pytest.param('pyephem', marks=requires_ephem)])
106-
def test_get_extra_radiation(input, expected, method):
107-
out = irradiance.get_extra_radiation(input)
108-
assert_allclose(out, expected, atol=1)
106+
def test_get_extra_radiation(testval, expected, method):
107+
out = irradiance.get_extra_radiation(testval, method=method)
108+
assert_allclose(out, expected, atol=10)
109109

110110

111111
def test_get_extra_radiation_epoch_year():

0 commit comments

Comments
 (0)
0