Skip to content

v2.0.4: opt-in profile anomaly filter + nameplate_kwp metadata#60

Merged
damonrand merged 1 commit into
mainfrom
feature/profile-filter-and-nameplate
Apr 30, 2026
Merged

v2.0.4: opt-in profile anomaly filter + nameplate_kwp metadata#60
damonrand merged 1 commit into
mainfrom
feature/profile-filter-and-nameplate

Conversation

@damonrand
Copy link
Copy Markdown
Contributor

Summary

Two related, backwards-compatible additions to the simulator's Profile config:

  • maxEnergyPerIntervalKwh — opt-in defensive filter for corrupt meter data. When set, csvProfile rows with |energy| above the threshold are NaN'd and linearly interpolated. When unset (default), raw values pass through unchanged.
  • nameplateKwp — display-only metadata. Engine never reads it. Useful when csvProfile already carries real kWh values (no scaling) but downstream tools need the system size.

No behaviour change for any existing simulate.yaml.

Why opt-in (not always-on)

A previous proposal on fix/anomalous-profile-data (commit c0f3c59) added an always-on 500 kWh/HH filter. This PR keeps the filter logic but inverts the default. Rationale: bad upstream meter data should surface loudly in sim output (e.g. a 25 GWh annual load on a 33-home community is visible at a glance) rather than be silently rewritten — silent interpolation across hours/days of corrupt rows can mask a broken pipeline that someone needs to investigate. Opt-in makes the workaround a deliberate, per-profile acknowledgement rather than a hidden constant.

When activated, the WARNING log surfaces count, value range, and first/last bad timestamps so operators can chase the source.

Backwards compatibility

  • Existing YAML configs: no change. Both new fields are Optional[float] and default to None.
  • nameplateKwp is independent of the existing scaling pathways (scalingFactor, profiled+scaled num plots, profiled+scaled size kwp). Setting it alone never triggers scaling.

Test plan

  • All existing tests pass (8 → 13 with the 5 new ones for filter behaviour).
  • Local rebuild against real WLCE 2025/202507/202512/202601/202602 data — known meter glitch (8.5M kWh/HH from 2025-11-21) is filtered correctly when maxEnergyPerIntervalKwh: 500 is set on the load profile, and untouched when the field is omitted.
  • HMCE 202512 rebuild (which also adds nameplateKwp: 210) produces output byte-identical to pre-PR for the metadata-only field — confirmed engine ignores it for math.
  • Reviewer to confirm threshold default of None is the right choice for a published PyPI release (vs e.g. a sensible global default like 5000 for safety net).

Notes for release

  • Bumps version 2.0.32.0.4 in pyproject.toml.
  • Adds an entry to the merge log in CLAUDE.md (PR number TBD until merge).

Two related additions to Profile (simulator config), both
backwards-compatible — no behaviour change for existing simulate.yaml
configs.

## maxEnergyPerIntervalKwh — opt-in defensive filter

When set on a Profile in YAML, csvProfile rows with |energy| above
the threshold are replaced with NaN and linearly interpolated
(ffill/bfill at edges). When unset (default), raw values pass
through unchanged.

Design choice: opt-in over always-on. Bad upstream meter data should
surface loudly in sim output rather than be quietly rewritten — a
silent interpolation across hours/days of corrupt rows can mask a
broken pipeline that someone needs to investigate. The opt-in field
makes the workaround a deliberate, per-profile acknowledgement
("this site has a known glitch — cap it") rather than a hidden
constant.

The WARNING log surfaces count, range, and the first/last bad
timestamps so operators can chase the source.

Origin: design adapted from c0f3c59 (`fix/anomalous-profile-data`),
which proposed an always-on 500 kWh/HH filter. This refactor keeps
the filter logic but inverts the default and makes the threshold
configurable.

## nameplateKwp — display-only metadata

Optional[float] on Profile, never read by the engine for math.
Useful when csvProfile carries already-scaled real kWh values (no
scalingFactor) but downstream tools (skypro-fresh dashboards, etc.)
still need to display the nameplate system size.

Independent of the existing scaling pathways: scalingFactor /
profiledNumPlots+scaledNumPlots / profiledSizeKwp+scaledSizeKwp.
nameplateKwp doesn't pair with anything and doesn't trigger
scaling.

## Tests

5 tests covering the opt-in semantics — filter off by default,
threshold-on with mid-series anomaly + interpolation, clean data
unchanged, edge anomaly with ffill/bfill, negative-direction
anomaly. Adds the missing __init__.py so `unittest discover` picks
the file up.
@damonrand damonrand merged commit c93be55 into main Apr 30, 2026
2 checks passed
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.

1 participant