You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
detect_clearsky should use inferred window length when comparing to samples_per_window #2542
Describe the bug detect_clearsky should use inferred window length when comparing to samples_per_window. Instead it uses the input window_length (default window_length=10). Relevant lines are linked below. Note that samples_per_window and the raise are before the if infer_limits block.
importnumpyasnpimportpandasaspdimportpvlibstart='2024-01-01'end='2025-01-01'freq='10min'times=pd.date_range(start=start, end=end, freq=freq)
x1=pd.Series(np.random.rand(len(times)), index=times)
x2=pd.Series(np.random.rand(len(times)), index=times)
# works if we change window_length, even though it'll be overridenpvlib.clearsky.detect_clearsky(x1, x2, infer_limits=True, window_length=30)
# failspvlib.clearsky.detect_clearsky(x1, x2, infer_limits=True)
$ python detect_clearsky_infer_bug.py
Traceback (most recent call last):
File "/home/wilhol/code/pvlib-python/detect_clearsky_infer_bug.py", line 17, in <module>
pvlib.clearsky.detect_clearsky(x1, x2, infer_limits=True)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/wilhol/code/pvlib-python/pvlib/clearsky.py", line 822, in detect_clearsky
raise ValueError(f"Samples per window of {samples_per_window}"
...<3 lines>...
f" window length to {3*sample_interval} or longer.")
ValueError: Samples per window of 1 found. Each window must contain at least 3 data points. Window length of 10 found; increase window length to 30.0 or longer.
Expected behavior samples_per_window and associated check should be calculated with respect to the inferred window length, if it exists.
Versions:
pvlib.__version__: 0.13.0
Additional context #2281 introduced the sample window check in an effort to make an error less mysterious. I think it was simply inserted a little too early in the function.
I’m interested in working on this issue. Would you like to assign this issue to me, or should I just open a pull request once I have the fix and tests ready?
Hi @aledelaoo , thanks for showing interest in contributing to pvlib!
Feel free to give it a shot. We don't use the assignment of issues feature (for now). If this is your first time contributing, I recommend you tackle an easier issue first (a typo, for example) and become familiar with the contributing guidelines. I don't know how proficient you are in Python, data analysis, nor open source. Should you find any trouble, please contact us at the mailing list: https://groups.google.com/g/pvlib-python
Activity
aledelaoo commentedon Aug 30, 2025
I’m interested in working on this issue. Would you like to assign this issue to me, or should I just open a pull request once I have the fix and tests ready?
echedey-ls commentedon Aug 30, 2025
Hi @aledelaoo , thanks for showing interest in contributing to pvlib!
Feel free to give it a shot. We don't use the assignment of issues feature (for now). If this is your first time contributing, I recommend you tackle an easier issue first (a typo, for example) and become familiar with the contributing guidelines. I don't know how proficient you are in Python, data analysis, nor open source. Should you find any trouble, please contact us at the mailing list: https://groups.google.com/g/pvlib-python