Skip to content

Commit 5b4e441

Browse files
committed
remove unneeded conversion to Series
1 parent 05d8bc1 commit 5b4e441

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

pvlib/clearsky.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -825,17 +825,6 @@ def detect_clearsky(measured, clearsky, times=None, window_length=10,
825825
# be polite about returning the same type as was input
826826
ispandas = isinstance(measured, pd.Series)
827827

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-
839828
sample_interval, samples_per_window = _get_sample_intervals(times,
840829
window_length)
841830

@@ -845,13 +834,13 @@ def detect_clearsky(measured, clearsky, times=None, window_length=10,
845834

846835
# calculate measurement statistics
847836
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)
849838
meas_line_length = _line_length_windowed(
850-
meas, H, samples_per_window, sample_interval)
839+
measured, H, samples_per_window, sample_interval)
851840

852841
# calculate clear sky statistics
853842
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)
855844

856845
# find a scaling factor for the clear sky time series that minimizes the
857846
# 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,
861850
# at least 50% of the day being identified as clear.
862851
alpha = 1
863852
for iteration in range(max_iterations):
864-
scaled_clear = alpha * clear
853+
scaled_clear = alpha * clearsky
865854
clear_line_length = _line_length_windowed(
866855
scaled_clear, H, samples_per_window, sample_interval)
867856

868857
line_diff = meas_line_length - clear_line_length
869858
slope_max_diff = _max_diff_windowed(
870-
meas - scaled_clear, H, samples_per_window)
859+
measured - scaled_clear, H, samples_per_window)
871860
# evaluate comparison criteria
872861
c1 = np.abs(meas_mean - alpha*clear_mean) < mean_diff
873862
c2 = np.abs(meas_max - alpha*clear_max) < max_diff
@@ -878,16 +867,16 @@ def detect_clearsky(measured, clearsky, times=None, window_length=10,
878867
clear_windows = c1 & c2 & c3 & c4 & c5 & c6
879868

880869
# create array to return
881-
clear_samples = np.full_like(meas, False, dtype='bool')
870+
clear_samples = np.full_like(measured, False, dtype='bool')
882871
# find the samples contained in any window classified as clear
883872
idx = _clear_sample_index(clear_windows, samples_per_window, 'center',
884873
H)
885874
clear_samples[idx] = True
886875

887876
# find a new alpha
888877
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]
891880

892881
def rmse(alpha):
893882
return np.sqrt(np.mean((clear_meas - alpha*clear_clear)**2))

0 commit comments

Comments
 (0)