Package: tsam
tsam - Time Series Aggregation Moduletsam 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.
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.The documentation of the tsam code can be foundhere.Featuresflexible handling of multidimensional time-series via the pandas moduledifferent 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 pyomohypertuning of aggregation parameters to find the optimal combination of the number of segments inside a period and the number of typical periodsnovel representation methods, keeping statistical attributes, such as the distributionflexible integration of extreme periods as own cluster centersweighting for the case of multidimensional time-series to represent their relevanceInstallationDirectly install via pip as follows:pip install tsamAlternatively, clone a local copy of the repository to your computergit clone https://github.com/FZJ-IEK3-VSA/tsam.gitThen install tsam via pip as followcd tsam
pip install .Or install directly via python aspython setup.py installIn order to use the k-medoids clustering, make sure that you have installed a MILP solver. As defaultHiGHSis used. Nevertheless, in case you have access to a license we recommend commercial solvers (e.g. Gurobi or CPLEX) since they have a better performance.ExamplesBasic workflowA small example how tsam can be used is decribed as followsimportpandasaspdimporttsam.timeseriesaggregationastsamRead in the time series data set with pandasraw=pd.read_csv('testdata.csv',index_col=0)Initialize an aggregation object and define the length of a single period, the number of typical periods, the number of segments in each period, the aggregation method and the representation method - here duration/distribution representation which contains the minimum and maximum value of the original time seriesaggregation=tsam.TimeSeriesAggregation(raw,noTypicalPeriods=8,hoursPerPeriod=24,segmentation=True,noSegments=8,representationMethod="distributionAndMinMaxRepresentation",distributionPeriodWise=FalseclusterMethod='hierarchical')Run the aggregation to typical periodstypPeriods=aggregation.createTypicalPeriods()Store the results as .csv filetypPeriods.to_csv('typperiods.csv')Detailed examplesAfirst exampleshows the capabilites of tsam as jupyter notebook.Asecond exampleshows in more detail how to access the relevant aggregation results required for paramtrizing e.g. an optimization.The example time series are based on a departmentpublicationand thetest reference years of the DWD.LicenseMIT LicenseCopyright (C) 2016-2022 Leander Kotzur (FZJ IEK-3), Maximilian Hoffmann (FZJ IEK-3), Peter Markewitz (FZJ IEK-3), Martin Robinius (FZJ IEK-3), Detlef Stolten (FZJ IEK-3)You should have received a copy of the MIT License along with this program.
If not, seehttps://opensource.org/licenses/MITThe core developer team sits in theInstitute of Energy and Climate Research - Techno-Economic Energy Systems Analysis (IEK-3)belonging to theForschungszentrum Jülich.Citing and further readingIf you want to use tsam in a published work,please kindly citeour latest journal articles:Hoffmann et al. (2022):The Pareto-Optimal Temporal Aggregation of Energy System ModelsIf you are further interested in the impact of time series aggregation on the cost-optimal results on different energy system use cases, you can find a publication which validates the methods and describes their cababilites via the followinglink. A second publication introduces a method how to model state variables (e.g. the state of charge of energy storage components) between the aggregated typical periods which can be foundhere. Finally yet importantly the potential of time series aggregation to simplify mixed integer linear problems is investigatedhere.The publications about time series aggregation for energy system optimization models published alongside the development of tsam are listed below:Hoffmann et al. (2021):The Pareto-Optimal Temporal Aggregation of Energy System Models(open access manuscript to be foundhere)Hoffmann et al. (2021):Typical periods or typical time steps? A multi-model analysis to determine the optimal temporal aggregation for energy system modelsHoffmann et al. (2020):A Review on Time Series Aggregation Methods for Energy System ModelsKannengießer et al. (2019):Reducing Computational Load for Mixed Integer Linear Programming: An Example for a District and an Island Energy SystemKotzur et al. (2018):Time series aggregation for energy system design: Modeling seasonal storage(open access manuscript to be foundhere)Kotzur et al. (2018):Impact of different time series aggregation methods on optimal energy system design(open access manuscript to be foundhere)AcknowledgementThis 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 theBMWi/BMWkfunded projectMETIS.