Skip to contents

Converts a calendar saved by an earlier version of the package. Four things are converted; a calendar that needs none is returned as is.

Usage

upgrade_calendar(calendar)

Arguments

calendar

A Calendar, in the current or an earlier form.

Value

A Calendar in the current form.

Details

  • The earlier layout. Such a calendar stores bare labels in its timeframe columns (h00) and identifies its rows by a separate timeslice column. The result holds the members of each timeframe in its column (m01_h00), with the finest timeframe as the leaf column. The leaf ids are the former timeslice values, row for row.

  • The timeframes DAYHOUR and HOURTYPE. The hours of an average day were held as DAYHOUR for a time, and the hour-type blocks of hp3 as HOURTYPE; both are HOUR, in the leaftable, the members, the tokens and the other per-timeframe metadata. Member names stay as they are. A calendar of hour-type blocks stored in an earlier form keeps the hours its blocks had then (DAY h06-h16 and h21, NIGHT h22-h05, PEAK h17-h20: 12, 8 and 4 hours) and their order; the assignment is recorded in meta$hour_blocks, and datetimes are matched by it. Only a freshly built design has the present blocks.

  • Share, width and weight. A leaftable without the column total is in the earlier arrangement, where share was the part of the year a timeslice stands for and weight that part in hours. The part of the year is kept and stated as share (one unit), width and weight (see Calendar): an hour of an average day becomes one hour with the days it stands for as its weight, a block of hp3 one hour times its hours per day times its days, and any other timeslice its own unit. A timeslice stored with weight 0 keeps it. A stored width is not read: its meaning changed between versions. The units used are recorded in meta$units, and the coverage of a subset is re-keyed to total.

  • The coverage class. representative is averaged.

The time every timeslice stands for and the rest of the metadata are unchanged. A stored subset that carries no record of its source (see calendar_source()) is left without one; the record it has is carried over.

The functions of the package apply the same conversion to their calendar argument, so an old object keeps working without an explicit call; upgrade_calendar() is for converting a stored object once and saving it again.

Where the old timeslice values are not the _-joined labels of the row, the labels of the finest timeframe cannot be read off the new member names; they are kept in meta$member_labels.

See also

calendar_from_leaftable(), which accepts a table of bare labels.

Examples

cal <- calendar("m12_h24")
identical(upgrade_calendar(cal), cal)
#> [1] TRUE