From 33b67f668b89dce4f63a7ea4184f36fcbb6c125b Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:10:59 -0400 Subject: [PATCH 1/6] Fixes microsecond scaling issue in spa.julian_day_dt, and updates the test in tests_spa to check for correct scaling --- pvlib/spa.py | 2 +- pvlib/tests/test_spa.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pvlib/spa.py b/pvlib/spa.py index 6c99a03f0c..743df5ce8e 100644 --- a/pvlib/spa.py +++ b/pvlib/spa.py @@ -430,7 +430,7 @@ def julian_day_dt(year, month, day, hour, minute, second, microsecond): month = month+12 a = int(year/100) b = 2 - a + int(a * 0.25) - frac_of_day = (microsecond + (second + minute * 60 + hour * 3600) + frac_of_day = (microsecond / 1e6 + (second + minute * 60 + hour * 3600) ) * 1.0 / (3600*24) d = day + frac_of_day jd = (int(365.25 * (year + 4716)) + int(30.6001 * (month + 1)) + d + diff --git a/pvlib/tests/test_spa.py b/pvlib/tests/test_spa.py index 196acd72cb..b27a66feef 100644 --- a/pvlib/tests/test_spa.py +++ b/pvlib/tests/test_spa.py @@ -98,7 +98,8 @@ class SpaBase(object): """Test functions common to numpy and numba spa""" def test_julian_day_dt(self): - dt = times.tz_convert('UTC')[0] + # add 1us manually to the test timestamp + dt = times.tz_convert('UTC')[0] + pd.Timedelta(1, unit='us') year = dt.year month = dt.month day = dt.day @@ -106,7 +107,7 @@ def test_julian_day_dt(self): minute = dt.minute second = dt.second microsecond = dt.microsecond - assert_almost_equal(JD, + assert_almost_equal(JD + 1e-6 / (3600*24), # modify expected JD by 1us self.spa.julian_day_dt( year, month, day, hour, minute, second, microsecond), 6) From aa47ec7ddf703f3e9a41dc0afbee2d84d0c36744 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:19:15 -0400 Subject: [PATCH 2/6] Update v0.7.2.rst --- docs/sphinx/source/whatsnew/v0.7.2.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.7.2.rst b/docs/sphinx/source/whatsnew/v0.7.2.rst index 2eda805c1e..63387746b4 100644 --- a/docs/sphinx/source/whatsnew/v0.7.2.rst +++ b/docs/sphinx/source/whatsnew/v0.7.2.rst @@ -45,6 +45,8 @@ Bug fixes and various test functions. * Fix :py:func:`~pvlib.iotools.read_tmy3` so that when coerced to a single year the TMY3 index will be monotonically increasing. (:pull:`910`) +* Fix :py:func:`pvlib.spa.julian_day_dt` so that microseconds are scaled + correctly (:issue:`940') (:pull:`939`) Testing ~~~~~~~ @@ -60,6 +62,8 @@ Testing dependent iotools tests to repeat them on failure. (:pull:`919`) * Separate azure-pipelines.yml platform-specific tests to their own templates located in ``./ci/azure/``. (:pull:`926`) +* Updated test_julian_day_dt to check for correct microsecond scaling + (:issue:`940') (:pull:`939`) Documentation ~~~~~~~~~~~~~ From 34f635e6cbcd274a543699cedd24786f9c7a8426 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:20:28 -0400 Subject: [PATCH 3/6] Update v0.7.2.rst --- docs/sphinx/source/whatsnew/v0.7.2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.7.2.rst b/docs/sphinx/source/whatsnew/v0.7.2.rst index 63387746b4..ee0a28f5dd 100644 --- a/docs/sphinx/source/whatsnew/v0.7.2.rst +++ b/docs/sphinx/source/whatsnew/v0.7.2.rst @@ -62,8 +62,8 @@ Testing dependent iotools tests to repeat them on failure. (:pull:`919`) * Separate azure-pipelines.yml platform-specific tests to their own templates located in ``./ci/azure/``. (:pull:`926`) -* Updated test_julian_day_dt to check for correct microsecond scaling - (:issue:`940') (:pull:`939`) +* Updated test_julian_day_dt in spa_test to check for correct microsecond + scaling (:issue:`940') (:pull:`939`) Documentation ~~~~~~~~~~~~~ From ab57056def866525225ea75d503fdfa8f1483980 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:23:54 -0400 Subject: [PATCH 4/6] Update test_spa.py --- pvlib/tests/test_spa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/test_spa.py b/pvlib/tests/test_spa.py index b27a66feef..70b3b9090d 100644 --- a/pvlib/tests/test_spa.py +++ b/pvlib/tests/test_spa.py @@ -98,7 +98,7 @@ class SpaBase(object): """Test functions common to numpy and numba spa""" def test_julian_day_dt(self): - # add 1us manually to the test timestamp + # add 1us manually to the test timestamp (GH #940) dt = times.tz_convert('UTC')[0] + pd.Timedelta(1, unit='us') year = dt.year month = dt.month From a53ec8173aebda8237fa032f510ea06110b5bb42 Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:25:46 -0400 Subject: [PATCH 5/6] Update v0.7.2.rst --- docs/sphinx/source/whatsnew/v0.7.2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.7.2.rst b/docs/sphinx/source/whatsnew/v0.7.2.rst index ee0a28f5dd..995ec8fc88 100644 --- a/docs/sphinx/source/whatsnew/v0.7.2.rst +++ b/docs/sphinx/source/whatsnew/v0.7.2.rst @@ -46,7 +46,7 @@ Bug fixes * Fix :py:func:`~pvlib.iotools.read_tmy3` so that when coerced to a single year the TMY3 index will be monotonically increasing. (:pull:`910`) * Fix :py:func:`pvlib.spa.julian_day_dt` so that microseconds are scaled - correctly (:issue:`940') (:pull:`939`) + correctly (:issue:`940') (:pull:`942`) Testing ~~~~~~~ @@ -63,7 +63,7 @@ Testing * Separate azure-pipelines.yml platform-specific tests to their own templates located in ``./ci/azure/``. (:pull:`926`) * Updated test_julian_day_dt in spa_test to check for correct microsecond - scaling (:issue:`940') (:pull:`939`) + scaling (:issue:`940') (:pull:`942`) Documentation ~~~~~~~~~~~~~ From 1d684c7a8b004ff039cdcacbf4a118cce2c3762a Mon Sep 17 00:00:00 2001 From: ericf900 <61256041+ericf900@users.noreply.github.com> Date: Mon, 23 Mar 2020 13:59:06 -0400 Subject: [PATCH 6/6] Update v0.7.2.rst --- docs/sphinx/source/whatsnew/v0.7.2.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.7.2.rst b/docs/sphinx/source/whatsnew/v0.7.2.rst index 995ec8fc88..d49afad155 100644 --- a/docs/sphinx/source/whatsnew/v0.7.2.rst +++ b/docs/sphinx/source/whatsnew/v0.7.2.rst @@ -46,7 +46,7 @@ Bug fixes * Fix :py:func:`~pvlib.iotools.read_tmy3` so that when coerced to a single year the TMY3 index will be monotonically increasing. (:pull:`910`) * Fix :py:func:`pvlib.spa.julian_day_dt` so that microseconds are scaled - correctly (:issue:`940') (:pull:`942`) + correctly (:issue:`940`) (:pull:`942`) Testing ~~~~~~~ @@ -62,8 +62,6 @@ Testing dependent iotools tests to repeat them on failure. (:pull:`919`) * Separate azure-pipelines.yml platform-specific tests to their own templates located in ``./ci/azure/``. (:pull:`926`) -* Updated test_julian_day_dt in spa_test to check for correct microsecond - scaling (:issue:`940') (:pull:`942`) Documentation ~~~~~~~~~~~~~