Module to disaggregate generation and consumption from import (net consumption) and export (net generation) profiles, or a net load profile. Generation is based on average PV profiles, optionally per area (for instance by postal code), corrected for installation size, tilt and orientation. These are calculated based on the SunDance algorithm.
The SunDance algorithm disaggregates solar generation from net meter data.
For a more detailed example, see the notebook examples/example_usage.ipynb.
from sundael import PVDisaggregator
pv = PVDisaggregator(pv_ratio=pv_ratio)
result = pv.disaggregate(net_consumption, net_generation)
Visualize the results.
# Show one example of "Klant 63"
import hvplot.pandas
idx = "Klant 63"
pd.concat(
(
result["consumption"].loc[idx].rename("consumption"),
result["generation"].loc[idx].rename("generation") * -1,
),
axis=1
).fillna(0).hvplot(width=1200, title=idx)
Defaults are managed through a Pydantic config object in src/sundael/config.py.
from sundael.config import PVConfig
# Start from package defaults and override only what you need.
config = PVConfig(latitude=52.1, longitude=5.1)Use this config in the disaggregator:
from sundael import PVDisaggregator
pv = PVDisaggregator(pv_ratio=pv_ratio, config=config)
result = pv.disaggregate(netload=netload)To get a local copy up and running, follow these steps:
- Clone the repository
git clone https://github.com/Alliander/sundael- Install dependencies
uv syncThe pre-commit hook runs ruff and mypy checks before you commit to the repository. First, install pre-commit if you haven't done so already:
pip install pre-commitThen, install the hook:
pre-commit installThe pre-commit hook ensures your code adheres to standards. If, for a certain commit, you want to skip the checks, pass a --no-verify flag to git commit.
In short, we use Conventional Commits for commit messages and follow conventional Python code guidelines, including PEP8. See CONTRIBUTING.md for more details.
Run pytest:
uv run pytest
We use ruff for linting and code quality. It replaces other tools such as black, isort and flake8 (and is really fast).
Note
For Visual Studio Code you can install the ruff extension and enable linting and auto-formatting on save.
Before you publish your changes, run the code quality checks that are done in the workflow, to prevent unexpected failed runs:
uv run ruff check .
uv run mypy .To format code with ruff:
uv run ruff format .To automatically fix any errors:
uv run ruff check --fix .This project is licensed under the Mozilla Public License, Version 2.0, see LICENSE for details.
Please read CODE_OF_CONDUCT, CONTRIBUTING and PROJECT GOVERNANCE for details on the process for submitting pull requests to us.
Please read SUPPORT for how to get in touch with the sundael project.
