@@ -683,22 +683,26 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
683
683
var_diff = 0.005 , slope_dev = 8 , max_iterations = 20 ,
684
684
return_components = False ):
685
685
"""
686
- Detects clear sky times according to the algorithm developed by Reno
687
- and Hansen for GHI measurements. The algorithm [1]_ was designed and
688
- validated for analyzing GHI time series only. Users may attempt to
689
- apply it to other types of time series data using different filter
690
- settings, but should be skeptical of the results.
686
+ Detects clear sky times using the algorithm developed by Reno
687
+ and Hansen.
691
688
692
- The algorithm detects clear sky times by comparing statistics for a
689
+ The algorithm [1]_ was designed and
690
+ validated for analyzing GHI time series. Jordan and Hansen [2]_ extended
691
+ the algorithm to plane-of-array (POA) irradiance measurements.
692
+
693
+ The algorithm [1]_ detects clear sky times by comparing statistics for a
693
694
measured time series and an expected clearsky time series.
694
695
Statistics are calculated using a sliding time window (e.g., 10
695
696
minutes). An iterative algorithm identifies clear periods, uses the
696
697
identified periods to estimate bias in the clearsky data, scales the
697
698
clearsky data and repeats.
698
699
699
- Clear times are identified by meeting 5 criteria. Default values for
700
+ Clear times are identified by meeting five criteria. Default values for
700
701
these thresholds are appropriate for 10 minute windows of 1 minute
701
- GHI data.
702
+ GHI data. For data at longer intervals, it is recommended
703
+ to set ``infer_limits=True`` to use the thresholds from [2]_.
704
+
705
+ For POA data, ``clearsky`` must be on the same plane as ``measured``.
702
706
703
707
Parameters
704
708
----------
@@ -713,8 +717,8 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
713
717
If True, does not use passed in kwargs (or defaults), but instead
714
718
interpolates these values from Table 1 in [2]_.
715
719
window_length : int, default 10
716
- Length of sliding time window in minutes. Must be greater than 2
717
- periods .
720
+ Length of sliding time window in minutes. Each window must contain at
721
+ least three data points .
718
722
mean_diff : float, default 75
719
723
Threshold value for agreement between mean values of measured
720
724
and clearsky in each interval, see Eq. 6 in [1]. [W/m2]
@@ -723,8 +727,6 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
723
727
clearsky values in each interval, see Eq. 7 in [1]. [W/m2]
724
728
lower_line_length : float, default -5
725
729
Lower limit of line length criterion from Eq. 8 in [1].
726
- Criterion satisfied when lower_line_length < line length difference
727
- < upper_line_length.
728
730
upper_line_length : float, default 10
729
731
Upper limit of line length criterion from Eq. 8 in [1].
730
732
var_diff : float, default 0.005
@@ -736,7 +738,7 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
736
738
change in successive values, see Eqs. 12 through 14 in [1].
737
739
max_iterations : int, default 20
738
740
Maximum number of times to apply a different scaling factor to
739
- the clearsky and redetermine clear_samples. Must be 1 or larger.
741
+ the clearsky and redetermine `` clear_samples`` . Must be 1 or larger.
740
742
return_components : bool, default False
741
743
Controls if additional output should be returned. See below.
742
744
@@ -748,19 +750,23 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
748
750
749
751
components : OrderedDict, optional
750
752
Dict of arrays of whether or not the given time window is clear
751
- for each condition. Only provided if return_components is True.
753
+ for each condition. Only provided if `` return_components`` is True.
752
754
753
755
alpha : scalar, optional
754
- Scaling factor applied to the clearsky_ghi to obtain the
755
- detected clear_samples. Only provided if return_components is
756
+ Scaling factor applied to ``clearsky`` to obtain the
757
+ detected `` clear_samples`` . Only provided if `` return_components`` is
756
758
True.
757
759
758
760
Raises
759
761
------
760
762
ValueError
761
- If measured is not a Series and times is not provided
763
+ If ``measured`` is not a Series and times is not provided.
764
+ ValueError
765
+ If a window contains less than three data points.
766
+ ValueError
767
+ If the measured data is not sufficient to fill a window.
762
768
NotImplementedError
763
- If timestamps are not equally spaced
769
+ If timestamps are not equally spaced.
764
770
765
771
References
766
772
----------
@@ -812,6 +818,13 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
812
818
sample_interval , samples_per_window = \
813
819
tools ._get_sample_intervals (times , window_length )
814
820
821
+ if samples_per_window < 3 :
822
+ raise ValueError (f"Samples per window of { samples_per_window } "
823
+ " found. Each window must contain at least 3 data"
824
+ " points."
825
+ f" Window length of { window_length } found; increase"
826
+ f" window length to { 3 * sample_interval } or longer." )
827
+
815
828
# if infer_limits, find threshold values using the sample interval
816
829
if infer_limits :
817
830
window_length , mean_diff , max_diff , lower_line_length , \
0 commit comments