Skip to content

improve performance of solarposition.ephemeris dataframe assembly #529

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 1 commit into from
Aug 14, 2018
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
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew/v0.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Enhancements
:func:`~pvlib.singlediode.bishop88_mpp`.
* Add PVSyst thin-film recombination losses for CdTe and a:Si (:issue:`163`)
* Python 3.7 officially supported. (:issue:`496`)
* Improve performance of solarposition.ephemeris. (:issue:`512`)


Bug fixes
Expand Down
3 changes: 2 additions & 1 deletion pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,14 @@ def ephemeris(time, latitude, longitude, pressure=101325, temperature=12):
ApparentSunEl = SunEl + Refract

# make output DataFrame
DFOut = pd.DataFrame(index=time)
DFOut = pd.DataFrame(index=time_utc)
DFOut['apparent_elevation'] = ApparentSunEl
DFOut['elevation'] = SunEl
DFOut['azimuth'] = SunAz
DFOut['apparent_zenith'] = 90 - ApparentSunEl
DFOut['zenith'] = 90 - SunEl
DFOut['solar_time'] = SolarTime
DFOut.index = time

return DFOut

Expand Down
13 changes: 13 additions & 0 deletions pvlib/test/test_solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ def test_ephemeris_physical_dst(expected_solpos):
assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns])


def test_ephemeris_physical_no_tz(expected_solpos):
times = pd.date_range(datetime.datetime(2003,10,17,19,30,30),
periods=1, freq='D')
ephem_data = solarposition.ephemeris(times, golden_mst.latitude,
golden_mst.longitude,
pressure=82000,
temperature=11)
expected_solpos.index = times
expected_solpos = np.round(expected_solpos, 2)
ephem_data = np.round(ephem_data, 2)
assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns])


def test_get_solarposition_error():
times = pd.date_range(datetime.datetime(2003,10,17,13,30,30),
periods=1, freq='D', tz=golden.tz)
Expand Down