From 9975abb6eef915f02802d7c8df00a432441c7207 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 4 Jun 2021 11:56:09 -0600 Subject: [PATCH 1/3] add comments to _calc_stats --- pvlib/clearsky.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pvlib/clearsky.py b/pvlib/clearsky.py index 857c5dd202..2494da5be1 100644 --- a/pvlib/clearsky.py +++ b/pvlib/clearsky.py @@ -602,7 +602,20 @@ def _calc_d(aod700, p): def _calc_stats(data, samples_per_window, sample_interval, H): """ Calculates statistics for each window, used by Reno-style clear sky detection functions. Does not return the line length statistic - which is provided by _calc_windowed_stat and _line_length + which is provided by _calc_windowed_stat and _line_length. + + Calculations are done on a sliding window defined by the Hankel matrix H. + Columns in H define the indices for each window. Each window contains + samples_per_window index values. The first window starts with index 0; + the last window ends at the last index position in data. + + In the calculation of data_slope_nstd, a choice is made here where [1]_ is + ambiguous. data_slope_nstd is the standard deviation of slopes divided by + the mean GHI for each interval; see [1]_ Eq. 11. For intervals containing + e.g. 10 values, there are 9 slope values in the standard deviation, and the + mean is calculated using all 10 values. Eq. 11 in [1]_ is ambiguous if + the mean should be calculated using 9 points (left ends of each slope) + or all 10 points. Parameters ---------- @@ -624,6 +637,12 @@ def _calc_stats(data, samples_per_window, sample_interval, H): standard deviation of difference between data points in each window data_slope : Series difference between successive data points + + References + ---------- + .. [1] Reno, M.J. and C.W. Hansen, "Identification of periods of clear + sky irradiance in time series of GHI measurements" Renewable Energy, + v90, p. 520-531, 2016. """ data_mean = data.values[H].mean(axis=0) From ba438a782476401a89cb28afe0512c86ec0db125 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 4 Jun 2021 12:00:25 -0600 Subject: [PATCH 2/3] lint, whatsnew --- docs/sphinx/source/whatsnew/v0.9.0.rst | 2 ++ pvlib/clearsky.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.0.rst b/docs/sphinx/source/whatsnew/v0.9.0.rst index aeb600b100..91f5966258 100644 --- a/docs/sphinx/source/whatsnew/v0.9.0.rst +++ b/docs/sphinx/source/whatsnew/v0.9.0.rst @@ -181,6 +181,8 @@ Documentation * Add a gallery example showing how to appropriately use interval-averaged weather data for modeling. (:pull:`1152`) * Update documentation links in :py:func:`pvlib.iotools.get_psm3` +* Clarified how statistics are calculated for :py:func:`pvlib.clearsky.detect_clearsky` + (:issue`1070`, :pull:`1243`) Requirements ~~~~~~~~~~~~ diff --git a/pvlib/clearsky.py b/pvlib/clearsky.py index 2494da5be1..f5572c19bf 100644 --- a/pvlib/clearsky.py +++ b/pvlib/clearsky.py @@ -603,11 +603,11 @@ def _calc_stats(data, samples_per_window, sample_interval, H): """ Calculates statistics for each window, used by Reno-style clear sky detection functions. Does not return the line length statistic which is provided by _calc_windowed_stat and _line_length. - + Calculations are done on a sliding window defined by the Hankel matrix H. Columns in H define the indices for each window. Each window contains samples_per_window index values. The first window starts with index 0; - the last window ends at the last index position in data. + the last window ends at the last index position in data. In the calculation of data_slope_nstd, a choice is made here where [1]_ is ambiguous. data_slope_nstd is the standard deviation of slopes divided by From e7fe0d8d1d718c19ec3a78b39b73b7c216d0d49e Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 9 Jun 2021 10:07:41 -0600 Subject: [PATCH 3/3] Update docs/sphinx/source/whatsnew/v0.9.0.rst Co-authored-by: Will Holmgren --- docs/sphinx/source/whatsnew/v0.9.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.0.rst b/docs/sphinx/source/whatsnew/v0.9.0.rst index 91f5966258..7fcb18e83d 100644 --- a/docs/sphinx/source/whatsnew/v0.9.0.rst +++ b/docs/sphinx/source/whatsnew/v0.9.0.rst @@ -182,7 +182,7 @@ Documentation weather data for modeling. (:pull:`1152`) * Update documentation links in :py:func:`pvlib.iotools.get_psm3` * Clarified how statistics are calculated for :py:func:`pvlib.clearsky.detect_clearsky` - (:issue`1070`, :pull:`1243`) + (:issue:`1070`, :pull:`1243`) Requirements ~~~~~~~~~~~~