Calendars
Construct and inspect Calendar objects.
Calendar
Bases: NestedScale
A nested time partition of a model year; key column timeslice.
__getitem__
__getitem__(idx: tuple) -> Calendar
x[timeframe, labels] is filter_calendar(x, timeframe, labels).
calendar_from_leaftable
calendar_from_leaftable(
leaftable: Any,
timeframes: Sequence[str] | str,
members: Mapping[str, Sequence[str]] | None = None,
name: str = "",
desc: str = "",
year_start: Mapping | None = None,
utc_offset_minutes: int = 0,
year_fraction: float = 1,
row_order: str = "nested",
**meta: Any,
) -> Calendar
Build a Calendar from a table with one row per leaf timeslice.
timeslice defaults to the timeframe labels joined with "_", weight
to share * 8760, and members to first-appearance order. Extra
keyword arguments become meta entries.
calendar_build
calendar_build(
*tokens: str,
name: str | None = None,
desc: str = "",
year_start: Mapping | None = None,
utc_offset_minutes: int = 0,
year_fraction: float = 1,
**meta: Any,
) -> Calendar
A calendar as the Cartesian product of tokens, coarsest first.
Shares are year_fraction times the product of the token shares; the
rows run in nested, chronological order: coarsest timeframe first.
A nontrivial year_start rotates the MONTH/QUARTER member order.
calendar
calendar(name: str, **kwargs: Any) -> Calendar
A calendar by catalog id ("m12_md365_h24") or token string
("d365_h24"); a y_ prefix marks a year-qualified calendar.
prune_calendar
prune_calendar(x: Calendar, timeframe: str) -> Calendar
Collapse to timeframe (or the single "ANNUAL" root), summing share
and weight; renamed "name@TF".