timescales

Nested timeframes and calendars for optimization and simulation models

timescales is the time-domain package of the optimal2050 modeling stack, and the temporal companion to geoscales. It succeeds timeslices.

A Calendar is a nested time partition of a model year: a flat table of weighted leaf slices plus the ordered timeframes that produced them. Anything derivable from it — composite ids, parent/child tables, regularity — is computed on demand rather than stored.

recast() is the central verb: values on slices of one calendar become values on slices of another, routed through a shared instant grid, so aggregation and disaggregation are a single operation.

Documentation by language

This is a multi-language project. The R implementation is complete; the C++ core and Python bindings are planned.

Language Status Documentation
R Available R reference and articles
C++ Phase 2 — planned
Python Phase 3 — planned

A single implementation defines the behaviour, and language-agnostic golden fixtures under specs/ will keep the ports honest.

Getting started

# install.packages("remotes")
remotes::install_github("optimal2050/timescales")
library(timescales)

cal_m <- calendar_build("m12")   # twelve months
cal_q <- calendar_build("q4")    # four quarters

x <- data.frame(slice = sprintf("m%02d", 1:12), load = seq(100, 210, length.out = 12))
recast(x, from = cal_m, to = cal_q, year = 2021, rule = "weighted_mean")

See Getting started for the tour, Concepts for the vocabulary, and Data structures for the object layout.

Project

Released under the Apache License 2.0.