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.7.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:`942`)

Testing
~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion pvlib/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down
5 changes: 3 additions & 2 deletions pvlib/tests/test_spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@
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 (GH #940)
dt = times.tz_convert('UTC')[0] + pd.Timedelta(1, unit='us')
year = dt.year
month = dt.month
day = dt.day
hour = dt.hour
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)
Expand Down