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.4.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Bug fixes

* Fix pandas 0.20 incompatibilities in Location.get_clearsky,
solarposition.ephemeris (:issue:`325`)
* Fixes timezone issue in solarposition spa_c function (:issue:`237`)
* Added NREL Bird clear sky model. (:issue:`276`)
* Added lower accuracy formulas for equation of time, declination, hour angle
and solar zenith.
Expand All @@ -31,5 +32,6 @@ Contributors
~~~~~~~~~~~~

* Will Holmgren
* Marc Anoma
* Mark Mikofski
* Birgit Schachler
10 changes: 7 additions & 3 deletions pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0,

pvl_logger.debug('using built-in spa code to calculate solar position')

time_utc = time
# if localized, convert to UTC. otherwise, assume UTC.
try:
time_utc = time.tz_convert('UTC')
except TypeError:
time_utc = time

spa_out = []

Expand All @@ -193,7 +197,7 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0,
hour=date.hour,
minute=date.minute,
second=date.second,
timezone=0, # must input localized or utc time
timezone=0, # date uses utc time
latitude=latitude,
longitude=longitude,
elevation=altitude,
Expand All @@ -202,7 +206,7 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0,
delta_t=delta_t
))

spa_df = pd.DataFrame(spa_out, index=time_utc)
spa_df = pd.DataFrame(spa_out, index=time)

if raw_spa_output:
return spa_df
Expand Down