Skip to content

Commit 4329ac4

Browse files
cwhansewholmgren
andauthored
Clarify statistics for detect_clearsky (#1243)
* add comments to _calc_stats * lint, whatsnew * Update docs/sphinx/source/whatsnew/v0.9.0.rst Co-authored-by: Will Holmgren <william.holmgren@gmail.com> Co-authored-by: Will Holmgren <william.holmgren@gmail.com>
1 parent 68b3b31 commit 4329ac4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ Documentation
181181
* Add a gallery example showing how to appropriately use interval-averaged
182182
weather data for modeling. (:pull:`1152`)
183183
* Update documentation links in :py:func:`pvlib.iotools.get_psm3`
184+
* Clarified how statistics are calculated for :py:func:`pvlib.clearsky.detect_clearsky`
185+
(:issue:`1070`, :pull:`1243`)
184186

185187
Requirements
186188
~~~~~~~~~~~~

pvlib/clearsky.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,20 @@ def _calc_d(aod700, p):
602602
def _calc_stats(data, samples_per_window, sample_interval, H):
603603
""" Calculates statistics for each window, used by Reno-style clear
604604
sky detection functions. Does not return the line length statistic
605-
which is provided by _calc_windowed_stat and _line_length
605+
which is provided by _calc_windowed_stat and _line_length.
606+
607+
Calculations are done on a sliding window defined by the Hankel matrix H.
608+
Columns in H define the indices for each window. Each window contains
609+
samples_per_window index values. The first window starts with index 0;
610+
the last window ends at the last index position in data.
611+
612+
In the calculation of data_slope_nstd, a choice is made here where [1]_ is
613+
ambiguous. data_slope_nstd is the standard deviation of slopes divided by
614+
the mean GHI for each interval; see [1]_ Eq. 11. For intervals containing
615+
e.g. 10 values, there are 9 slope values in the standard deviation, and the
616+
mean is calculated using all 10 values. Eq. 11 in [1]_ is ambiguous if
617+
the mean should be calculated using 9 points (left ends of each slope)
618+
or all 10 points.
606619
607620
Parameters
608621
----------
@@ -624,6 +637,12 @@ def _calc_stats(data, samples_per_window, sample_interval, H):
624637
standard deviation of difference between data points in each window
625638
data_slope : Series
626639
difference between successive data points
640+
641+
References
642+
----------
643+
.. [1] Reno, M.J. and C.W. Hansen, "Identification of periods of clear
644+
sky irradiance in time series of GHI measurements" Renewable Energy,
645+
v90, p. 520-531, 2016.
627646
"""
628647

629648
data_mean = data.values[H].mean(axis=0)

0 commit comments

Comments
 (0)