Skip to main content

Solar production and power consumption forecasting package.

Project description

☀️ KPower Forecast 📈

PyPI version Python versions CI License: AGPL-3.0 Code style: black

Production-grade solar production and power consumption forecasting.

Built with Facebook Prophet and powered by Open-Meteo. KPower Forecast provides a high-level API for training and predicting energy metrics with physics-informed corrections.


✨ Key Features

  • 🔋 Dual Mode: Specialized logic for both Solar Production and Energy Consumption.
  • 🌓 Night Masking: Physics-informed clamping using solar elevation to eliminate "ghost production" at night.
  • 🌡️ Weather Integration: Automatic fetching and resampling of temperature, cloud cover, and radiation.
  • 🤖 Prophet Optimized: Pre-configured regressors for maximum accuracy.
  • 💾 Smart Persistence: Automatic serialization of models to skip retraining when possible.
  • ❄️ Heat Pump Mode: Optional temperature correlation for energy consumption models.

🚀 Quick Start

Installation

pip install kpower-forecast

☀️ Solar Production Forecast

from kpower_forecast import KPowerForecast
import pandas as pd

# 1. Initialize for your location
kp = KPowerForecast(
    model_id="rooftop_solar",
    latitude=46.0569,
    longitude=14.5058,
    forecast_type="solar"
)

# 2. Train with your history
# history_df = pd.DataFrame({'ds': [...], 'y': [...]})
# kp.train(history_df)

# 3. Predict the next 7 days
forecast = kp.predict(days=7)
print(forecast[['ds', 'yhat']].head())

🏠 Energy Consumption Forecast

kp_cons = KPowerForecast(
    model_id="house_meter",
    latitude=46.0569,
    longitude=14.5058,
    forecast_type="consumption",
    heat_pump_mode=True # Accounts for heating/cooling loads
)

🛠️ Advanced Configuration

Parameter Type Default Description
model_id str required Unique ID for model persistence
latitude float required Location Latitude
longitude float required Location Longitude
interval_minutes `int" 15 Data resolution (15 or 60)
storage_path str "./data" Directory for saved models
heat_pump_mode bool False Enable temperature regressor for consumption

🔢 Versioning

This project follows a custom Date-Based Versioning scheme: YYYY.MM.Patch (e.g., 2026.2.1)

  • YYYY: Year of release.
  • MM: Month of release (no leading zero, 1-12).
  • Patch: Incremental counter for releases within the same month.

Enforcement

  • CI Validation: Every Pull Request is checked against scripts/validate_version.py to ensure adherence.
  • Consistency: Both pyproject.toml and src/kpower_forecast/__init__.py must match exactly.

🧪 Development & Testing

We use uv for lightning-fast dependency management.

# Clone and setup
git clone https://github.com/akorenc/kpower-forecast
cd kpower-forecast
uv sync --all-extras

# Run tests
uv run pytest

# Linting
uv run ruff check .

📄 License

Distributed under the GNU Affero General Public License v3.0. See LICENSE for more information.


Made with ❤️ for a greener future.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kpower_forecast-2026.2.2.tar.gz (91.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kpower_forecast-2026.2.2-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file kpower_forecast-2026.2.2.tar.gz.

File metadata

  • Download URL: kpower_forecast-2026.2.2.tar.gz
  • Upload date:
  • Size: 91.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for kpower_forecast-2026.2.2.tar.gz
Algorithm Hash digest
SHA256 f8a7c70019b1d532ce504507a3dd15a5019a3589c19d6bf0a1d55d359618bbbd
MD5 df3360f0bab55c5ace0c686e5c3fb98d
BLAKE2b-256 a27d2f383a127cd93b8212d92e6acb630bcd1ca2895aec4c0f145b1a9e35a973

See more details on using hashes here.

File details

Details for the file kpower_forecast-2026.2.2-py3-none-any.whl.

File metadata

  • Download URL: kpower_forecast-2026.2.2-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for kpower_forecast-2026.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 29cf5d767d6b5516a36dbd01b580533162dd08b6a62678d6cc6b4c65af40d6ae
MD5 94893355ee7a04e532064888bee1cc44
BLAKE2b-256 5270dfeb31ca18dd8249b0d38498e41ad348adde7aca7a33c75f9bcaf32a0b40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page