v2.0.4: opt-in profile anomaly filter + nameplate_kwp metadata#60
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related, backwards-compatible additions to the simulator's
Profileconfig: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(commitc0f3c59) 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
Optional[float]and default toNone.nameplateKwpis independent of the existing scaling pathways (scalingFactor,profiled+scaled num plots,profiled+scaled size kwp). Setting it alone never triggers scaling.Test plan
8.5M kWh/HHfrom 2025-11-21) is filtered correctly whenmaxEnergyPerIntervalKwh: 500is set on the load profile, and untouched when the field is omitted.nameplateKwp: 210) produces output byte-identical to pre-PR for the metadata-only field — confirmed engine ignores it for math.Noneis the right choice for a published PyPI release (vs e.g. a sensible global default like5000for safety net).Notes for release
2.0.3→2.0.4inpyproject.toml.CLAUDE.md(PR number TBD until merge).