diff --git a/.gitattributes b/.gitattributes index 81490a9780..1cce3a387a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ pvlib/version.py export-subst # reduce the number of merge conflicts -docs/sphinx/source/whatsnew/v*.txt merge=union +docs/sphinx/source/whatsnew/* merge=union diff --git a/docs/sphinx/source/variables_style_rules.rst b/docs/sphinx/source/variables_style_rules.rst index f1d45cbe02..5baf80ec0c 100644 --- a/docs/sphinx/source/variables_style_rules.rst +++ b/docs/sphinx/source/variables_style_rules.rst @@ -15,8 +15,8 @@ There is a convention on consistent variable names throughout the library: For a definition and further explanation on the variables, common symbols and units refer to the following sources: -* `Reference Variable List by PVPMC `_ -* `IEC 61724:1998 -- Photovoltaic system performance monitoring - Guidelines for measurement, data exchange and analysis `_ ; the Indian Standard referencing the global IEC standard is available online: `IS/IEC 61724 (1998) `_ +* `Reference Variable List by PVPMC `_ +* `IEC 61724-1:2017 -- Photovoltaic system performance - Part 1: Monitoring `_ section: 3 -- Terms and definitions; the Indian Standard referencing the withdrawn earlier global IEC standard IEC 61724:1998 is available online: `IS/IEC 61724 (1998) `_ and can provide relevant contents. * Explanation of Solar irradiation and solar geometry by `SoDa Service `_ * `Acronyms, Terminology and Units `_ diff --git a/docs/sphinx/source/whatsnew/v0.5.1.rst b/docs/sphinx/source/whatsnew/v0.5.1.rst index bf928337dc..f1ef0be9be 100644 --- a/docs/sphinx/source/whatsnew/v0.5.1.rst +++ b/docs/sphinx/source/whatsnew/v0.5.1.rst @@ -12,6 +12,15 @@ Bug fixes * Remove condition causing Overflow warning from clearsky.haurwitz * modelchain.basic_chain now correctly passes 'solar_position_method' arg to solarposition.get_solarposition +* Fixed: `Variables and Symbols extra references not available `_ +* Removed unnecessary calculations of alpha_prime in spa.solar_position_numpy + 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) diff --git a/pvlib/solarposition.py b/pvlib/solarposition.py index 562f74192a..40b392b9ae 100644 --- a/pvlib/solarposition.py +++ b/pvlib/solarposition.py @@ -105,8 +105,10 @@ def get_solarposition(time, latitude, longitude, pressure, temperature, how='numpy', **kwargs) elif method == 'pyephem': - ephem_df = pyephem(time, latitude, longitude, pressure, temperature, - **kwargs) + ephem_df = pyephem(time, latitude, longitude, + altitude=altitude, + pressure=pressure, + temperature=temperature, **kwargs) elif method == 'ephemeris': ephem_df = ephemeris(time, latitude, longitude, pressure, temperature, **kwargs) diff --git a/pvlib/spa.py b/pvlib/spa.py index e1fa41913b..ac6374441f 100644 --- a/pvlib/spa.py +++ b/pvlib/spa.py @@ -952,7 +952,6 @@ def solar_position_loop(unixtime, loc_args, out): x = xterm(u, lat, elev) y = yterm(u, lat, elev) delta_alpha = parallax_sun_right_ascension(x, xi, H, delta) - alpha_prime = topocentric_sun_right_ascension(alpha, delta_alpha) delta_prime = topocentric_sun_declination(delta, x, y, xi, delta_alpha, H) H_prime = topocentric_local_hour_angle(H, delta_alpha) @@ -1064,7 +1063,6 @@ def solar_position_numpy(unixtime, lat, lon, elev, pressure, temp, delta_t, x = xterm(u, lat, elev) y = yterm(u, lat, elev) delta_alpha = parallax_sun_right_ascension(x, xi, H, delta) - alpha_prime = topocentric_sun_right_ascension(alpha, delta_alpha) delta_prime = topocentric_sun_declination(delta, x, y, xi, delta_alpha, H) H_prime = topocentric_local_hour_angle(H, delta_alpha) e0 = topocentric_elevation_angle_without_atmosphere(lat, delta_prime, diff --git a/pvlib/test/test_solarposition.py b/pvlib/test/test_solarposition.py index 0584dd744e..d92b9cf233 100644 --- a/pvlib/test/test_solarposition.py +++ b/pvlib/test/test_solarposition.py @@ -354,6 +354,19 @@ def test_get_solarposition_no_kwargs(expected_solpos): assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns]) +@requires_ephem +def test_get_solarposition_method_pyephem(expected_solpos): + times = pd.date_range(datetime.datetime(2003, 10, 17, 13, 30, 30), + periods=1, freq='D', tz=golden.tz) + ephem_data = solarposition.get_solarposition(times, golden.latitude, + golden.longitude, + method='pyephem') + 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_nrel_earthsun_distance(): times = pd.DatetimeIndex([datetime.datetime(2015, 1, 2), datetime.datetime(2015, 8, 2),]