Skip to content

Allow clip_filter for energy-based trend analyses#474

Merged
martin-springer merged 48 commits intodevelopmentfrom
allow-clip-filter-for-energy
Feb 4, 2026
Merged

Allow clip_filter for energy-based trend analyses#474
martin-springer merged 48 commits intodevelopmentfrom
allow-clip-filter-for-energy

Conversation

@martin-springer
Copy link
Collaborator

@martin-springer martin-springer commented Feb 3, 2026

Summary
This PR enables the clip_filter to be used in energy-based analyses by falling back to pv_energy when pv_power is not available. It also adds validation to ensure the data has sufficient time resolution for clipping detection.

Changes
analysis_chains.py

  • Modified TrendAnalysis._filter() to use pv_energy for clip filtering when pv_power is None
  • Added frequency validation that raises a ValueError if the median time step exceeds 60 minutes, as clipping detection requires sub-hourly data
  • Simplified the clip_filter logic by introducing a clip_data variable that selects the appropriate data source
    analysis_chains_test.py
  • Added test_clip_filter_frequency_error() to verify that the frequency validation raises an appropriate error for low-resolution data (e.g., 2-hour intervals)
    docs/sphinx/source/changelog/pending.rst
  • Added changelog entries under "Enhancements" section

Motivation

When users provide energy data directly (via pv_input="energy"), the pv_power attribute is None. Previously, this would cause the trend analysis to fail and raise a ValueError. This change allows clipping detection to work with energy data, provided the time resolution is adequate (≤60 minutes).

  • Code changes are covered by tests
  • Code changes have been evaluated for compatibility/integration with TrendAnalysis
  • [ ] New functions added to __init__.py
  • [ ] API.rst is up to date, along with other sphinx docs pages
  • Example notebooks are rerun and differences in results scrutinized
  • Updated changelog

@martin-springer martin-springer changed the base branch from development to pvlib_requirements February 3, 2026 18:30
@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.22%. Comparing base (b5fc7c4) to head (7462f46).

Additional details and impacted files
@@               Coverage Diff               @@
##           development     #474      +/-   ##
===============================================
- Coverage        96.26%   96.22%   -0.04%     
===============================================
  Files               12       12              
  Lines             2276     2279       +3     
===============================================
+ Hits              2191     2193       +2     
- Misses              85       86       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@martin-springer martin-springer changed the title [WIP] Allow clip filter for energy Allow clip_filter for energy-based analyses Feb 3, 2026
@martin-springer martin-springer changed the title Allow clip_filter for energy-based analyses Allow clip_filter for energy-based trend analyses Feb 3, 2026
Base automatically changed from pvlib_requirements to development February 4, 2026 21:26
@martin-springer martin-springer merged commit 5c674a9 into development Feb 4, 2026
19 checks passed
@martin-springer martin-springer deleted the allow-clip-filter-for-energy branch February 4, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants