diff --git a/docs/sphinx/source/whatsnew/v0.5.1.rst b/docs/sphinx/source/whatsnew/v0.5.1.rst index 08d7fdb287..b0a81d3e9c 100644 --- a/docs/sphinx/source/whatsnew/v0.5.1.rst +++ b/docs/sphinx/source/whatsnew/v0.5.1.rst @@ -16,6 +16,10 @@ Bug fixes and spa.solar_position_loop * Fixed args mismatch for solarposition.pyephem call from solarposition.get_solarposition with method='pyephem' + arg to solarposition.get_solarposition (:issue:`370`) +* ModelChain.prepare_inputs and ModelChain.complete_irradiance now + correctly pass the 'solar_position_method' argument to + solarposition.get_solarposition (:issue:`377`) Enhancements ~~~~~~~~~~~~ diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index e940bd57ce..d7bea7f153 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -674,7 +674,8 @@ def complete_irradiance(self, times=None, weather=None): self.weather = weather if times is not None: self.times = times - self.solar_position = self.location.get_solarposition(self.times) + self.solar_position = self.location.get_solarposition( + self.times, method=self.solar_position_method) icolumns = set(self.weather.columns) wrn_txt = ("This function is not safe at the moment.\n" + "Results can be too high or negative.\n" + @@ -683,10 +684,12 @@ def complete_irradiance(self, times=None, weather=None): if {'ghi', 'dhi'} <= icolumns and 'dni' not in icolumns: logging.debug('Estimate dni from ghi and dhi') + clearsky = self.location.get_clearsky( + times, solar_position=self.solar_position) self.weather.loc[:, 'dni'] = pvlib.irradiance.dni( self.weather.loc[:, 'ghi'], self.weather.loc[:, 'dhi'], self.solar_position.zenith, - clearsky_dni=self.location.get_clearsky(times).dni, + clearsky_dni=clearsky['dni'], clearsky_tolerance=1.1) elif {'dni', 'dhi'} <= icolumns and 'ghi' not in icolumns: warnings.warn(wrn_txt, UserWarning) @@ -753,7 +756,8 @@ def prepare_inputs(self, times=None, irradiance=None, weather=None): if times is not None: self.times = times - self.solar_position = self.location.get_solarposition(self.times) + self.solar_position = self.location.get_solarposition( + self.times, method=self.solar_position_method) self.airmass = self.location.get_airmass( solar_position=self.solar_position, model=self.airmass_model)