@@ -825,17 +825,6 @@ def detect_clearsky(measured, clearsky, times=None, window_length=10,
825
825
# be polite about returning the same type as was input
826
826
ispandas = isinstance (measured , pd .Series )
827
827
828
- # for internal use, need a Series
829
- if not ispandas :
830
- meas = pd .Series (measured , index = times )
831
- else :
832
- meas = measured
833
-
834
- if not isinstance (clearsky , pd .Series ):
835
- clear = pd .Series (clearsky , index = times )
836
- else :
837
- clear = clearsky
838
-
839
828
sample_interval , samples_per_window = _get_sample_intervals (times ,
840
829
window_length )
841
830
@@ -845,13 +834,13 @@ def detect_clearsky(measured, clearsky, times=None, window_length=10,
845
834
846
835
# calculate measurement statistics
847
836
meas_mean , meas_max , meas_slope_nstd , meas_slope \
848
- = _calc_stats (meas , samples_per_window , sample_interval , H )
837
+ = _calc_stats (measured , samples_per_window , sample_interval , H )
849
838
meas_line_length = _line_length_windowed (
850
- meas , H , samples_per_window , sample_interval )
839
+ measured , H , samples_per_window , sample_interval )
851
840
852
841
# calculate clear sky statistics
853
842
clear_mean , clear_max , _ , clear_slope \
854
- = _calc_stats (clear , samples_per_window , sample_interval , H )
843
+ = _calc_stats (clearsky , samples_per_window , sample_interval , H )
855
844
856
845
# find a scaling factor for the clear sky time series that minimizes the
857
846
# RMSE between the clear times identified in the measured data and the
@@ -861,13 +850,13 @@ def detect_clearsky(measured, clearsky, times=None, window_length=10,
861
850
# at least 50% of the day being identified as clear.
862
851
alpha = 1
863
852
for iteration in range (max_iterations ):
864
- scaled_clear = alpha * clear
853
+ scaled_clear = alpha * clearsky
865
854
clear_line_length = _line_length_windowed (
866
855
scaled_clear , H , samples_per_window , sample_interval )
867
856
868
857
line_diff = meas_line_length - clear_line_length
869
858
slope_max_diff = _max_diff_windowed (
870
- meas - scaled_clear , H , samples_per_window )
859
+ measured - scaled_clear , H , samples_per_window )
871
860
# evaluate comparison criteria
872
861
c1 = np .abs (meas_mean - alpha * clear_mean ) < mean_diff
873
862
c2 = np .abs (meas_max - alpha * clear_max ) < max_diff
@@ -878,16 +867,16 @@ def detect_clearsky(measured, clearsky, times=None, window_length=10,
878
867
clear_windows = c1 & c2 & c3 & c4 & c5 & c6
879
868
880
869
# create array to return
881
- clear_samples = np .full_like (meas , False , dtype = 'bool' )
870
+ clear_samples = np .full_like (measured , False , dtype = 'bool' )
882
871
# find the samples contained in any window classified as clear
883
872
idx = _clear_sample_index (clear_windows , samples_per_window , 'center' ,
884
873
H )
885
874
clear_samples [idx ] = True
886
875
887
876
# find a new alpha
888
877
previous_alpha = alpha
889
- clear_meas = meas [clear_samples ]
890
- clear_clear = clear [clear_samples ]
878
+ clear_meas = measured [clear_samples ]
879
+ clear_clear = clearsky [clear_samples ]
891
880
892
881
def rmse (alpha ):
893
882
return np .sqrt (np .mean ((clear_meas - alpha * clear_clear )** 2 ))
0 commit comments