Skip to content

Learn from unclipped hours and apply k before the AC clip - #10

Merged
JustAnotherPU merged 1 commit into
mainfrom
clip-learning
Nov 15, 2026
Merged

JustAnotherPU merged 1 commit into
mainfrom
clip-learning

Conversation

@JustAnotherPU

Copy link
Copy Markdown
Owner

Fixes #5.

Two changes:

  1. curtailment.clip_limit_kw, opt-in. Hours where the forecast reaches 70 % of this limit are left out of learning, so an oversized array's flat tops are no longer learned as lost yield. I first filtered on the measured value (an hour at 97 % of the limit) and dropped it: with hourly forecast error, the hours kept near the limit are the ones where the forecast was too high, and g comes out low. Filtering on the forecast does not have that bias. It stays off by default because on a hybrid that charges the battery above its AC rating, an hour at the AC limit is real production.
  2. k before the clip. run() applies k to the unclipped ensemble mean and clips once: P50 is clip(mean × k), no longer clip(mean(clip)) × k. learn() clips its ensemble after the mean too, so the quantile ratios are computed the same way they are applied.

One change applies to everyone, with or without the option: on hours where the expectation is above the AC limit, P10/P25 now come from the unclipped expectation, so they move up toward the limit. Before, P10 was 0.6 × the limit on an hour that would clip even on a poor day.

Left for later:

  • The KNMI correction still scales after the clip (apply_knmi multiplies the clipped bands, and its ratio is built from the clipped p50). It's the same kind of problem and predates this PR.
  • Horizon learning has no clipping filter, same as on main.
  • The limit applies to the sum of the arrays, so one inverter clipping on a multi-inverter setup is not seen.

Tests: 7 in tests/test_clipping.py. On main, 6 fail; the 7th pins today's behaviour without the option. One of them adds 15 % hourly forecast error: filtering on the measured value gave g = 0.84 for a true 0.90, filtering on the forecast gives 0.90 ± 0.02. The full suite passes on Python 3.11 and 3.12. I have not run it on a real clipping roof: ours never clips (highest hour 11.4 kW, limit 12 kW).

- New opt-in curtailment.clip_limit_kw. Hours where the forecast reaches
  70 % of it are left out of learning, so an oversized array's flat tops
  are not learned as lost yield. The hours are picked on the forecast:
  dropping hours measured at the limit would keep the ones where the
  forecast was too high, which pulls g low. Off by default:
  on a hybrid that charges the battery above its AC rating, an hour at the
  AC limit is real production.
- run() applies k to the unclipped ensemble mean and clips once, so P50 is
  clip(mean x k) instead of clip(mean(clip)) x k. P10/P25/P90 are scaled
  from the unclipped expectation. learn() clips its ensemble after the
  mean, the same way, so the ratios stay on the same footing.

Fixes #5
@JustAnotherPU
JustAnotherPU merged commit e2cbbaf into main Nov 15, 2026
2 checks passed
@JustAnotherPU
JustAnotherPU deleted the clip-learning branch November 15, 2026 14:29
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.

AC clipping is learned as lost yield on oversized arrays

1 participant