From f4a82976d43a79d1243e8c0c071aeafdd0816409 Mon Sep 17 00:00:00 2001 From: Will Holmgren Date: Fri, 30 Jun 2017 11:45:41 -0700 Subject: [PATCH 1/2] add explicit tests for aoi and aoi projection functions --- docs/sphinx/source/whatsnew/v0.4.6.rst | 6 ++++++ pvlib/test/test_irradiance.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.4.6.rst b/docs/sphinx/source/whatsnew/v0.4.6.rst index e123236231..d7417c65b2 100644 --- a/docs/sphinx/source/whatsnew/v0.4.6.rst +++ b/docs/sphinx/source/whatsnew/v0.4.6.rst @@ -24,6 +24,12 @@ Documentation ~~~~~~~~~~~~~ +Testing +~~~~~~~ + +* Added explicit tests for aoi and aoi_projection functions. + + Contributors ~~~~~~~~~~~~ diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index 8ab1b1e45f..45d411cb29 100755 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -422,3 +422,22 @@ def test_dni(): assert_series_equal(dni, pd.Series([float('nan'), float('nan'), 573.685662283, 146.190220008, 573.685662283])) + + +@pytest.mark.parametrize( + 'surface_tilt,surface_azimuth,solar_zenith,solar_azimuth,aoi_expected,aoi_proj_expected', [ + (0, 0, 0, 0, 0, 1), + (30, 180, 30, 180, 0, 1), + (30, 180, 150, 0, 180, -1), + (90, 0, 30, 60, 75.52248781407006, 0.25), + (90, 0, 30, 170, 119.49870423110367, -0.49240387650610395)]) +def test_aoi_and_aoi_projection(surface_tilt, surface_azimuth, solar_zenith, + solar_azimuth, aoi_expected, + aoi_proj_expected): + aoi = irradiance.aoi(surface_tilt, surface_azimuth, solar_zenith, + solar_azimuth) + assert_allclose(aoi, aoi_expected, atol=1e-6) + + aoi_projection = irradiance.aoi_projection( + surface_tilt, surface_azimuth, solar_zenith, solar_azimuth) + assert_allclose(aoi_projection, aoi_proj_expected, atol=1e-6) From e09c6ee631378a95471e2ab2635f29054cd0b294 Mon Sep 17 00:00:00 2001 From: Will Holmgren Date: Mon, 3 Jul 2017 16:39:26 -0700 Subject: [PATCH 2/2] make expected values consistent with atol specification --- pvlib/test/test_irradiance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/test/test_irradiance.py b/pvlib/test/test_irradiance.py index 45d411cb29..ba4a1ba74c 100755 --- a/pvlib/test/test_irradiance.py +++ b/pvlib/test/test_irradiance.py @@ -429,8 +429,8 @@ def test_dni(): (0, 0, 0, 0, 0, 1), (30, 180, 30, 180, 0, 1), (30, 180, 150, 0, 180, -1), - (90, 0, 30, 60, 75.52248781407006, 0.25), - (90, 0, 30, 170, 119.49870423110367, -0.49240387650610395)]) + (90, 0, 30, 60, 75.5224878, 0.25), + (90, 0, 30, 170, 119.4987042, -0.4924038)]) def test_aoi_and_aoi_projection(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, aoi_expected, aoi_proj_expected):