Skip to content

Commit 8e1fe41

Browse files
authored
make ModelChain use solar_position_method argument (#379)
* add method to get_solar_position calls * update whatsnew
1 parent 449e86b commit 8e1fe41

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Bug fixes
1717
and spa.solar_position_loop
1818
* Fixed args mismatch for solarposition.pyephem call
1919
from solarposition.get_solarposition with method='pyephem'
20+
arg to solarposition.get_solarposition (:issue:`370`)
21+
* ModelChain.prepare_inputs and ModelChain.complete_irradiance now
22+
correctly pass the 'solar_position_method' argument to
23+
solarposition.get_solarposition (:issue:`377`)
2024

2125
Enhancements
2226
~~~~~~~~~~~~

pvlib/modelchain.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,8 @@ def complete_irradiance(self, times=None, weather=None):
674674
self.weather = weather
675675
if times is not None:
676676
self.times = times
677-
self.solar_position = self.location.get_solarposition(self.times)
677+
self.solar_position = self.location.get_solarposition(
678+
self.times, method=self.solar_position_method)
678679
icolumns = set(self.weather.columns)
679680
wrn_txt = ("This function is not safe at the moment.\n" +
680681
"Results can be too high or negative.\n" +
@@ -683,10 +684,12 @@ def complete_irradiance(self, times=None, weather=None):
683684

684685
if {'ghi', 'dhi'} <= icolumns and 'dni' not in icolumns:
685686
logging.debug('Estimate dni from ghi and dhi')
687+
clearsky = self.location.get_clearsky(
688+
times, solar_position=self.solar_position)
686689
self.weather.loc[:, 'dni'] = pvlib.irradiance.dni(
687690
self.weather.loc[:, 'ghi'], self.weather.loc[:, 'dhi'],
688691
self.solar_position.zenith,
689-
clearsky_dni=self.location.get_clearsky(times).dni,
692+
clearsky_dni=clearsky['dni'],
690693
clearsky_tolerance=1.1)
691694
elif {'dni', 'dhi'} <= icolumns and 'ghi' not in icolumns:
692695
warnings.warn(wrn_txt, UserWarning)
@@ -753,7 +756,8 @@ def prepare_inputs(self, times=None, irradiance=None, weather=None):
753756
if times is not None:
754757
self.times = times
755758

756-
self.solar_position = self.location.get_solarposition(self.times)
759+
self.solar_position = self.location.get_solarposition(
760+
self.times, method=self.solar_position_method)
757761

758762
self.airmass = self.location.get_airmass(
759763
solar_position=self.solar_position, model=self.airmass_model)

0 commit comments

Comments
 (0)