Skip to content

Commit fd24c71

Browse files
KonstantinTrwholmgren
authored andcommitted
Pyephem args missmatch (#381)
* fix for issue #343 Now, passed 'offset' parameter are used instead of it's default value. * test for issue #343 * solar_position_method passed to basic_chain wasn't used causing execution of solarposition.get_solarposition with default 'nrel_numpy' value in all cases. * Update modelchain.py doc string fixes for modelchain.basic_chain function * Update v0.5.1.rst * Update v0.5.1.rst * Update v0.5.1.rst * altitude arg was missing. Consequentially, pressure was passed to altitude and temperature was passed to pressure. * Test for get_solarposition with method='pyephem' Should prevent args mismatch described in #374 This function is basically a copy of test_get_solarposition_no_kwargs modified to call get_solarposition with method='pyephem' * Update v0.5.1.rst * Now we pass keyword arguments instead of positional to be safe and consistent. * decorate test_get_solarposition_method_pyephem with @requires_ephem
1 parent 487e0e8 commit fd24c71

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Bug fixes
1414
arg to solarposition.get_solarposition
1515
* Removed unnecessary calculations of alpha_prime in spa.solar_position_numpy
1616
and spa.solar_position_loop
17+
* Fixed args mismatch for solarposition.pyephem call
18+
from solarposition.get_solarposition with method='pyephem'
1719

1820
Enhancements
1921
~~~~~~~~~~~~

pvlib/solarposition.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ def get_solarposition(time, latitude, longitude,
105105
pressure, temperature,
106106
how='numpy', **kwargs)
107107
elif method == 'pyephem':
108-
ephem_df = pyephem(time, latitude, longitude, pressure, temperature,
109-
**kwargs)
108+
ephem_df = pyephem(time, latitude, longitude,
109+
altitude=altitude,
110+
pressure=pressure,
111+
temperature=temperature, **kwargs)
110112
elif method == 'ephemeris':
111113
ephem_df = ephemeris(time, latitude, longitude, pressure, temperature,
112114
**kwargs)

pvlib/test/test_solarposition.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,19 @@ def test_get_solarposition_no_kwargs(expected_solpos):
354354
assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns])
355355

356356

357+
@requires_ephem
358+
def test_get_solarposition_method_pyephem(expected_solpos):
359+
times = pd.date_range(datetime.datetime(2003, 10, 17, 13, 30, 30),
360+
periods=1, freq='D', tz=golden.tz)
361+
ephem_data = solarposition.get_solarposition(times, golden.latitude,
362+
golden.longitude,
363+
method='pyephem')
364+
expected_solpos.index = times
365+
expected_solpos = np.round(expected_solpos, 2)
366+
ephem_data = np.round(ephem_data, 2)
367+
assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns])
368+
369+
357370
def test_nrel_earthsun_distance():
358371
times = pd.DatetimeIndex([datetime.datetime(2015, 1, 2),
359372
datetime.datetime(2015, 8, 2),]

0 commit comments

Comments
 (0)