Skip to content

Allowing spa_c() to use localized time index 0.4.5 #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 3, 2017
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