Returns a calendar in the form the package works on: the
timeslice names of each timeframe in the timeframe columns of the
timetable, no timeslice column, the columns share, weight and
width, and the slots tokens and units.
A calendar that keeps the labels of each timeframe in its timetable (
HOUR = "h00") and the names of the finest timeslices in atimeslicecolumn gets the timeslice names in the timeframe columns.A calendar without
widthgets the column, 1 for every timeslice, and a calendar withoutunitsgets the slot, withHOUR = 1when it has the timeframeHOUR.A finest timeframe named
HOURTYPEwhose timeslices have the share of one hour and their length inwidthis renamedHOUR. One whose timeslices carry their own length as the share is an ordinary timeframe and keeps its name.A calendar that holds the hours of an average day as blocks (a finest timeframe
DAYHOUR, each share the hours the timeslice stands for, weight 1, nowidthcolumn) becomes one of hours: the timeframe isHOUR, each share is one hour, the hours go toweightand the width isTimeslice names are kept. A message reports the conversion: per-timeslice data on the calendar is then that of one hour, so a model built on the block form has to be rebuilt, with its objects declared at
timeframe = "HOUR". The calendar of an interpolated scenario is left in the form its parameters were built from.
Value
An object of the class of x with its calendars in the current
form; x itself when they already are.
Details
The tokens are recovered from the labels of the old timetable before it is
rewritten; a timeframe whose labels belong to no registered token gets no
entry. Apart from the block form (above), the timeslice names, shares,
weights and every other slot are kept, so a model gives the same sets and
parameters on the upgraded calendar.
timeslices_in_frame is recounted and equals lengths(timeframes).
The upgrade is applied automatically where calendars enter the package:
load_model(), load_scenario(), newModel(), setCalendar(),
interpolate_model() and the functions that take a calendar as an
argument. Calling it directly is needed only for an object read by other
means (readRDS(), load()) and inspected before it is used.
The content hash of a model or scenario covers its calendar, so
model_hash() of an upgraded object differs from the hash recorded when it
was saved in the earlier form.
Examples
cal <- upgrade_model_calendar(calendars$s4_h24)
head(cal@timetable, 3)
#> ANNUAL SEASON HOUR share weight width
#> <char> <char> <char> <num> <num> <num>
#> 1: ANNUAL WIN WIN_h00 0.0001141553 90 1
#> 2: ANNUAL WIN WIN_h01 0.0001141553 90 1
#> 3: ANNUAL WIN WIN_h02 0.0001141553 90 1
cal@tokens
#> $SEASON
#> [1] "s4"
#>
#> $HOUR
#> [1] "h24"
#>
identical(upgrade_model_calendar(cal), cal)
#> [1] TRUE
