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.
Metadata
Release files for tsam 4.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tsam-4.1.1.tar.gz | 7.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tsam-4.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.4 MB
Release files / tsam-4.1.1.tar.gz
| Download URL | tsam-4.1.1.tar.gz |
|---|---|
| Size | 7.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
758d9f961f0437727cf56cb51b041d64ff32cd5044177e50ec18a7e98eb94f92
|
|
BLAKE2b-256 checksum How to use checksums |
90fed019e93e71cc01009fa36345f20d2de4b4002925d8cb7d420b2523451c8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / tsam-4.1.1-py3-none-any.whl
| Download URL | tsam-4.1.1-py3-none-any.whl |
|---|---|
| Size | 117.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6abee2d17f14f4423dc05fe642d20cd44a62cabfde7dba74a5bc794491c17443
|
|
BLAKE2b-256 checksum How to use checksums |
00f2abc6a93eae3d6b6ddc8dcfc157e81aff32ce1d4743b4ff0c945d4d22d947
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency log