ETHOS.TSAM - Time Series Aggregation Module
Time series aggregation for large optimization models — and any other time series.
📖 Read the full documentation at tsam.readthedocs.io.
ETHOS.TSAM is a python package which uses different machine learning algorithms for the aggregation of time series. The data aggregation can be performed in two freely combinable dimensions: By representing the time series by a user-defined number of typical periods or by decreasing the temporal resolution. ETHOS.TSAM was originally designed for reducing the computational load for large-scale energy system optimization models by aggregating their input data, but is applicable for all types of time series, e.g., weather data, load data, both simultaneously or other arbitrary groups of time series.
ETHOS.TSAM is part of the Energy Transformation PatHway Optimization Suite (ETHOS) at ICE-2. It is tightly integrated into ETHOS.FINE to reduce the temporal complexity of energy system models.
Features
- flexible handling of multidimensional time-series via the pandas module
- different aggregation methods implemented (averaging, k-means, exact k-medoids, hierarchical, k-maxoids, k-medoids with contiguity), which are based on scikit-learn, or self-programmed with pyomo
- hypertuning of aggregation parameters to find the optimal combination of the number of segments inside a period and the number of typical periods
- novel representation methods, keeping statistical attributes, such as the distribution
- flexible integration of extreme periods as own cluster centers
- weighting for the case of multidimensional time-series to represent their relevance
Installation
To avoid dependency conflicts, it is recommended that you install ETHOS.TSAM in its own environment. You can use either uv or conda/mamba to manage environments and installations. Before proceeding, you must install either UV or Conda/Mamba, or both.
Quick Install with uv
uv venv tsam_env
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install tsam
Or from conda-forge:
conda create -n tsam_env -c conda-forge tsam
conda and mamba can be used interchangeably
Development Installation
git clone https://github.com/FZJ-IEK3-VSA/tsam.git
cd tsam
Using uv (recommended)
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e ".[develop]"
Using conda-forge
conda env create -n tsam_env --file=environment.yml
conda activate tsam_env
pip install -e . --no-deps
Set up pre-commit hooks
pre-commit install
See CONTRIBUTING.md for detailed development guidelines.
MILP Solver for k-medoids
HiGHS is installed by default. For better performance on large problems, commercial solvers (Gurobi, CPLEX) are recommended if you have a license
Getting Started
Basic workflow
A small example how ETHOS.TSAM can be used is described as follows:
import pandas as pd
import tsam
Read in the time series data set with pandas
raw = pd.read_csv('testdata.csv', index_col=0, parse_dates=True)
Run the aggregation - specify the number of typical periods and configure clustering/segmentation options:
from tsam import aggregate, ClusterConfig, SegmentConfig
result = tsam.aggregate(
raw,
n_clusters=8,
period_duration='24h', # or 24, '1d'
cluster=ClusterConfig(
method='hierarchical',
representation='distribution_minmax',
),
segments=SegmentConfig(n_segments=8),
)
Access the results:
# Get the typical periods DataFrame
cluster_representatives = result.cluster_representatives
# Check accuracy metrics
print(f"RMSE: {result.accuracy.rmse.mean():.4f}")
# Reconstruct the original time series from typical periods
reconstructed = result.reconstructed
# Save results
cluster_representatives.to_csv('cluster_representatives.csv')
Coming from version 2 or 3?
The class-based TimeSeriesAggregation API has been removed in version 4 — use
tsam.aggregate() as shown above. The
migration guide maps every old
parameter, method, and default to its replacement.
Detailed examples
The documentation is built around runnable notebooks:
- Your first aggregation — the whole workflow end to end, as a Jupyter notebook.
- Optimization workflow — how to access the aggregation results needed to parameterize e.g. an optimization.
The example time series are based on a department publication and the test reference years of the DWD.
Citation
If you want to use ETHOS.TSAM in a published work, please kindly cite:
- Hoffmann et al. (2022):
The Pareto-Optimal Temporal Aggregation of Energy System Models
Further reading
The full list of publications behind ETHOS.TSAM and the aggregation methods it implements — with open-access links — is kept in one place in the documentation: Further reading.
Contributions and Support
All contributions are welcome:
- If you have a question, want to report a bug, or have a feature request, please open an Issue. We will then take care of the issue as soon as possible.
- If you want to contribute with additional features or code improvements, open a Pull request.
See CONTRIBUTING.md for development guidelines.
License
About Us
We are the Institute of Climate and Energy Systems – Jülich Systems Analysis (ICE-2) at the Forschungszentrum Jülich. Our work focuses on independent, interdisciplinary research in energy, bioeconomy, infrastructure, and sustainability. We support a just, greenhouse gas–neutral transformation through open models and policy-relevant science.
Code of Conduct
Please respect our code of conduct.
Acknowledgments
This work is supported by the Helmholtz Association under the Joint Initiative "Energy System 2050 – A Contribution of the Research Field Energy" and the program "Energy System Design" and within the BMWi/BMWk funded project METIS.
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 tsam-4.0.0.tar.gz.
File metadata
- Download URL: tsam-4.0.0.tar.gz
- Upload date:
- Size: 7.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0dbc4373a8209df8e04abfcddc1671071ba84fd8ec2523aef56072adcd925df
|
|
| MD5 |
cc3757cbfd7ca9359fbde09af5491492
|
|
| BLAKE2b-256 |
746f7da3db287c3681295e8c4e4651dd964f9fc33a5bbd1586ca88ac3e0d189b
|
Provenance
The following attestation bundles were made for tsam-4.0.0.tar.gz:
Publisher:
publish.yaml on FZJ-IEK3-VSA/tsam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsam-4.0.0.tar.gz -
Subject digest:
d0dbc4373a8209df8e04abfcddc1671071ba84fd8ec2523aef56072adcd925df - Sigstore transparency entry: 2328488382
- Sigstore integration time:
-
Permalink:
FZJ-IEK3-VSA/tsam@a7284f7ae5a88026b7cea67ace9ae2f8ad070377 -
Branch / Tag:
refs/tags/v4.0.0 - Owner: https://github.com/FZJ-IEK3-VSA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@a7284f7ae5a88026b7cea67ace9ae2f8ad070377 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tsam-4.0.0-py3-none-any.whl.
File metadata
- Download URL: tsam-4.0.0-py3-none-any.whl
- Upload date:
- Size: 110.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c70ca9bc9a11aa4baa7583e09b875b59d7719d71f9a753accfe3c4c08d283839
|
|
| MD5 |
3cf6c5ae4d0890d7c4778acb5542e2f5
|
|
| BLAKE2b-256 |
6ef899ace9a9b532859f8ffbd87a056009c80f615e5551989cf5e337b3320139
|
Provenance
The following attestation bundles were made for tsam-4.0.0-py3-none-any.whl:
Publisher:
publish.yaml on FZJ-IEK3-VSA/tsam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsam-4.0.0-py3-none-any.whl -
Subject digest:
c70ca9bc9a11aa4baa7583e09b875b59d7719d71f9a753accfe3c4c08d283839 - Sigstore transparency entry: 2328488673
- Sigstore integration time:
-
Permalink:
FZJ-IEK3-VSA/tsam@a7284f7ae5a88026b7cea67ace9ae2f8ad070377 -
Branch / Tag:
refs/tags/v4.0.0 - Owner: https://github.com/FZJ-IEK3-VSA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@a7284f7ae5a88026b7cea67ace9ae2f8ad070377 -
Trigger Event:
push
-
Statement type: