Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.9.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ Bug fixes
(:issue:`1241`, :pull:`1242`)
* Changed deprecated use of ``.astype()`` to ``.view()`` in :py:mod:`~pvlib.solarposition`.
(:pull:`1256`, :issue:`1261`, :pull:`1262`)
* Fix :py:func:`~pvlib.tracking.singleaxis` AOI wrong when sun behind module.
(:pull:`1273`, :issue:`1221`)

Testing
~~~~~~~
Expand Down
15 changes: 15 additions & 0 deletions pvlib/tests/test_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,18 @@ def test_slope_aware_backtracking():
np.testing.assert_allclose(
truetracking['tracker_theta'], expected_data['TrueTracking'],
rtol=1e-3, atol=1e-3)


def test_singleaxis_aoi_gh1221():
# vertical tracker
loc = pvlib.location.Location(40.1134, -88.3695)
dr = pd.date_range(
start='02-Jun-1998 00:00:00', end='02-Jun-1998 23:55:00', freq='5T',
tz='Etc/GMT+6')
sp = loc.get_solarposition(dr)
tr = pvlib.tracking.singleaxis(
sp['apparent_zenith'], sp['azimuth'], axis_tilt=90, axis_azimuth=180,
max_angle=0.001, backtrack=False)
fixed = pvlib.irradiance.aoi(90, 180, sp['apparent_zenith'], sp['azimuth'])
fixed[np.isnan(tr['aoi'])] = np.nan
assert np.allclose(tr['aoi'], fixed, equal_nan=True)
4 changes: 3 additions & 1 deletion pvlib/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ def singleaxis(apparent_zenith, apparent_azimuth,
sun_vec = np.array([xp, yp, zp])

# calculate angle-of-incidence on panel
aoi = np.degrees(np.arccos(np.abs(np.sum(sun_vec*panel_norm, axis=0))))
# TODO: use irradiance.aoi
projection = np.clip(np.sum(sun_vec*panel_norm, axis=0), -1, 1)
aoi = np.degrees(np.arccos(projection))

# Calculate panel tilt and azimuth in a coordinate system where the panel
# tilt is the angle from horizontal, and the panel azimuth is the compass
Expand Down