Skip to content

Commit 10339ee

Browse files
authored
improve performance of ephemeris dataframe assembly (#529)
1 parent 9ead2f2 commit 10339ee

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docs/sphinx/source/whatsnew/v0.6.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Enhancements
9292
:func:`~pvlib.singlediode.bishop88_mpp`.
9393
* Add PVSyst thin-film recombination losses for CdTe and a:Si (:issue:`163`)
9494
* Python 3.7 officially supported. (:issue:`496`)
95+
* Improve performance of solarposition.ephemeris. (:issue:`512`)
9596

9697

9798
Bug fixes

pvlib/solarposition.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -690,13 +690,14 @@ def ephemeris(time, latitude, longitude, pressure=101325, temperature=12):
690690
ApparentSunEl = SunEl + Refract
691691

692692
# make output DataFrame
693-
DFOut = pd.DataFrame(index=time)
693+
DFOut = pd.DataFrame(index=time_utc)
694694
DFOut['apparent_elevation'] = ApparentSunEl
695695
DFOut['elevation'] = SunEl
696696
DFOut['azimuth'] = SunAz
697697
DFOut['apparent_zenith'] = 90 - ApparentSunEl
698698
DFOut['zenith'] = 90 - SunEl
699699
DFOut['solar_time'] = SolarTime
700+
DFOut.index = time
700701

701702
return DFOut
702703

pvlib/test/test_solarposition.py

+13
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@ def test_ephemeris_physical_dst(expected_solpos):
260260
assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns])
261261

262262

263+
def test_ephemeris_physical_no_tz(expected_solpos):
264+
times = pd.date_range(datetime.datetime(2003,10,17,19,30,30),
265+
periods=1, freq='D')
266+
ephem_data = solarposition.ephemeris(times, golden_mst.latitude,
267+
golden_mst.longitude,
268+
pressure=82000,
269+
temperature=11)
270+
expected_solpos.index = times
271+
expected_solpos = np.round(expected_solpos, 2)
272+
ephem_data = np.round(ephem_data, 2)
273+
assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns])
274+
275+
263276
def test_get_solarposition_error():
264277
times = pd.date_range(datetime.datetime(2003,10,17,13,30,30),
265278
periods=1, freq='D', tz=golden.tz)

0 commit comments

Comments
 (0)