Peak shaving analysis for industrial load profiles
Project description
Peak Shaving Analyzer
This repository contains tools and utilities for analyzing and optimizing energy consumption with peak shaving strategies. The project includes data fetching, analysis, and visualization components, as well as Docker configurations for deployment.
Table of Contents
Overview
Peak shaving is a strategy to reduce energy costs by minimizing peak demand utilizing energy storage systems. This project provides tools to optimize a given consumption time series with peak-shaving reducing capacity costs and visualizing results using Grafana.
Features
- Peak shaving optimization using FINE by FZJ
- Easy configuration of many parameters
- Support for dynamic prices
- Inclusion of PV system integration with automatic retrieving of generation timeseries depending on location (with detection for leap years)
- Dockerized deployment with Grafana dashboards
- Example configurations for various scenarios
Installation
You can install peakshaving-analyzer using pip. Choose the appropriate installation method based on your needs:
Using pip
To install the core package:
pip install peakshaving-analyzer
Timescale Database and Grafana Dashboards
If you want to benefit from a supported database and integrated Grafana dashboards for scenario analysis, you can use the provided Docker Compose file.
Follow these steps:
- Clone the repository and navigate to its directory:
git clone https://github.com/NOWUM/peakshaving-analyzer.git
cd peakshaving-analyzer
- Start the database and Grafana using the following command:
docker compose up -d
This will launch a container for TimescaleDB and Grafana with preconfigured dashboards for analysis. You can access the Grafana dashboards at http://localhost:3000.
Usage
You can use Peak Shaving Analyzer flexibly – either with a YAML configuration file, directly from Python code or use the OpenEnergyDataServer. Results can be saved locally as files or in a database.
Using the CLI
Use psa -h to see the usage of the CLI tool and it's options.
Loading the Configuration
1. Load from YAML configuration file:
from peakshaving_analyzer import PeakShavingAnalyzer, load_yaml_config
config = load_yaml_config("/path/to/your/config.yml")
2. Load from OEDS:
from peakshaving_analyzer import PeakShavingAnalyzer, load_oeds_config
config = load_oeds_config(load_oeds_config(con="your/database/uri", profile_id=id_to_analyze))
3. Load from a Python dictionary:
Please note that a lot of configuration is done by the loaders, so it's best to use one of the provided loaders.
from peakshaving_analyzer import PeakShavingAnalyzer, Config
config_dict = {
"name": "MyScenario",
"consumption_timeseries": [...],
# further parameters
}
config = Config(config_dict)
Initialize the Peakshaving Analyzer and run it:
Running the optimize() method will return a Results object.
psa = PeakShavingAnalyzer(config=config)
results = psa.optimize(solver="your_prefered_solver")
Saving Results
Results objects can be printed to std-out, written to file (.csv, .yaml, .json) or converted to python objects.
1. Save as file (e.g. CSV, YAML, ...):
results = psa.optimize()
results.to_csv("results.csv")
results.to_json("results.json")
results.to_yaml("results.yaml")
For saving the timeseries, please use the following functions:
results = psa.optimize()
results.timeseries_to_csv("timeseries.csv")
results.timeseries_to_json("timeseries.json")
2. Save to database (TimescaleDB): If you use the Docker environment, results are automatically written to TimescaleDB. You can also trigger saving explicitly:
results = psa.optimize()
results.to_sql(connection="your/database/uri")
3. Use as Python object:
After optimization, results are available as a Python object for further processing:
results = psa.optimize()
# Access individual values
print(results.total_yearly_costs_eur)
# print everything
results.print()
# convert to dict or dataframe
results_dict = results.to_dict()
results_dataframe = results.to_dataframe()
4. Plot the resulting timeseries:
The resulting timeseries (storage charging / discharging, state of charge, PV generation, grid usage, ...) can be easily plotted:
results = psa.optimize()
results.plot_timeseries()
results.plot_consumption_timeseries()
results.plot_storage_timeseries()
For more details on configuration, see the example files in the examples directory.
Examples
In the examples directory are four examples:
- A scenario examining only a storage system using hourly values with a fixed, non-dynamic price for the used energy.
- A scenario examining only a storage system using quarterhouly values with a fixed, non-dynamic price for the used energy.
- A scenario examining only a storage system using quarterhourly values with a dynamic, time-depended price for the used energy.
- A scenario examining a storage system as well as a photovoltaic system using hourly values with a dynamic, time-depended price for the used energy.
You can run these examples with python3 ./examples/example/main.py from the base directory.
License
This project is licensed under the terms of the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file peakshaving_analyzer-0.1.10.tar.gz.
File metadata
- Download URL: peakshaving_analyzer-0.1.10.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2915a7738dd8cdd05acaf310fe70e0f08f37643ddda17e425388d7efbf6b7fe
|
|
| MD5 |
29edb665f61230dd4628e9df9878d038
|
|
| BLAKE2b-256 |
d48c81afb08c87d40cc0879ff803d3115c7b76fefc982fbac38d3828ab8250df
|
Provenance
The following attestation bundles were made for peakshaving_analyzer-0.1.10.tar.gz:
Publisher:
publish.yml on NOWUM/peakshaving-analyzer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
peakshaving_analyzer-0.1.10.tar.gz -
Subject digest:
e2915a7738dd8cdd05acaf310fe70e0f08f37643ddda17e425388d7efbf6b7fe - Sigstore transparency entry: 629952013
- Sigstore integration time:
-
Permalink:
NOWUM/peakshaving-analyzer@c6f4034497ba769ae50ad75437d450027cb10c6c -
Branch / Tag:
refs/tags/v0.1.10 - Owner: https://github.com/NOWUM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c6f4034497ba769ae50ad75437d450027cb10c6c -
Trigger Event:
release
-
Statement type:
File details
Details for the file peakshaving_analyzer-0.1.10-py3-none-any.whl.
File metadata
- Download URL: peakshaving_analyzer-0.1.10-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08795d931ffff6a49a688f690d43d169c308ce70401e63f437759d1f659f6a98
|
|
| MD5 |
439702cddc300b6b937222e282e85f87
|
|
| BLAKE2b-256 |
5abab7bb15a4949678baacea06b4d1039254f9c0003cdfc7e1b83eb084bc37d1
|
Provenance
The following attestation bundles were made for peakshaving_analyzer-0.1.10-py3-none-any.whl:
Publisher:
publish.yml on NOWUM/peakshaving-analyzer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
peakshaving_analyzer-0.1.10-py3-none-any.whl -
Subject digest:
08795d931ffff6a49a688f690d43d169c308ce70401e63f437759d1f659f6a98 - Sigstore transparency entry: 629952016
- Sigstore integration time:
-
Permalink:
NOWUM/peakshaving-analyzer@c6f4034497ba769ae50ad75437d450027cb10c6c -
Branch / Tag:
refs/tags/v0.1.10 - Owner: https://github.com/NOWUM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c6f4034497ba769ae50ad75437d450027cb10c6c -
Trigger Event:
release
-
Statement type: