R/periods.R

############### SUB ANNUAL PERIODS

#' @rdname Period-class
#' @export
all.periods <- list(Jan = new("Period",
                              id = "Jan",
                              name = "January",
                              abbreviation = "Jan",
                              index = 1,
                              padded.index = "01",
                              contains = "Jan",
                              days = 31,
                              days.leap = 31,
                              col = viridis::turbo(12)[1]),
                    Feb = new("Period",
                              id = "Feb",
                              name = "February",
                              abbreviation = "Feb",
                              index = 2,
                              padded.index = "02",
                              contains = "Feb",
                              days = 28,
                              days.leap = 29,
                              col = viridis::turbo(12)[2]),
                    Mar = new("Period",
                              id = "Mar",
                              name = "March",
                              abbreviation = "Mar",
                              index = 3,
                              padded.index = "03",
                              contains = "Mar",
                              days = 31,
                              days.leap = 31,
                              col = viridis::turbo(12)[3]),
                    Apr = new("Period",
                              id = "Apr",
                              name = "April",
                              abbreviation = "Apr",
                              index = 4,
                              padded.index = "04",
                              contains = "Apr",
                              days = 30,
                              days.leap = 30,
                              col = viridis::turbo(12)[4]),
                    May = new("Period",
                              id = "May",
                              name = "May",
                              abbreviation = "May",
                              index = 5,
                              padded.index = "05",
                              contains = "May",
                              days = 31,
                              days.leap = 31,
                              col = viridis::turbo(12)[5]),
                    Jun = new("Period",
                              id = "Jun",
                              name = "June",
                              abbreviation = "Jun",
                              index = 6,
                              padded.index = "06",
                              contains = "Jun",
                              days = 30,
                              days.leap = 30,
                              col = viridis::turbo(12)[6]),
                    Jul = new("Period",
                              id ="Jul",
                              name = "July",
                              abbreviation = "Jul",
                              index = 7,
                              padded.index = "07",
                              contains = "Jul",
                              days = 31,
                              days.leap = 31,
                              col = viridis::turbo(12)[7]),
                    Aug = new("Period",
                              id = "Aug",
                              name = "August",
                              abbreviation = "Aug",
                              index = 8,
                              padded.index = "08",
                              contains = "Aug",
                              days = 31,
                              days.leap = 31,
                              col = viridis::turbo(12)[8]),
                    Sep = new("Period",
                              id = "Sep",
                              name = "September",
                              abbreviation = "Sep",
                              index = 9,
                              padded.index = "09",
                              contains = "Sep",
                              days = 30,
                              days.leap = 30,
                              col = viridis::turbo(12)[9]),
                    Oct = new("Period",
                              id = "Oct",
                              name = "October",
                              abbreviation = "Oct",
                              index = 10,
                              padded.index = "10",
                              contains = "Oct",
                              days = 31,
                              days.leap = 31,
                              col = viridis::turbo(12)[10]),
                    Nov = new("Period",
                              id = "Nov",
                              name = "November",
                              abbreviation = "Nov",
                              index = 11,
                              padded.index = "11",
                              contains = "Nov",
                              days = 30,
                              days.leap = 30,
                              col = viridis::turbo(12)[11]),
                    Dec = new("Period",
                              id = "Dec",
                              name = "December",
                              abbreviation = "Dec",
                              index = 12,
                              padded.index = "12",
                              contains = "Dec",
                              days = 31,
                              days.leap = 31,
                              col = "maroon4"),
                    DJF = new("Period",
                              id = "DJF",
                              name = "Winter",
                              abbreviation = "DJF",
                              index = c(12,1,2),
                              padded.index = c("12", "01", "02"),
                              contains = c("Dec", "Jan", "Feb"),
                              days = 60,
                              days.leap = 61,
                              col = viridis::turbo(4)[1]),
                    MAM = new("Period",
                              id = "MAM",
                              name = "Spring",
                              abbreviation = "MAM",
                              index = c(3,4,5),
                              padded.index = c("03", "04", "05"),
                              contains = c("Mar", "Apr", "May"),
                              days = 62,
                              days.leap = 62,
                              col = viridis::turbo(4)[2]),
                    JJA = new("Period",
                              id = "JJA",
                              name = "Summer",
                              abbreviation = "JJA",
                              index = c(6,7,8),
                              padded.index = c("07", "08", "09"),
                              contains = c("Jun", "Jul", "Aug"),
                              days = 62,
                              days.leap = 62,
                              col = viridis::turbo(4)[3]),          
                    SON = new("Period",
                              id = "SON",
                              name = "Autumn",
                              abbreviation = "SON",
                              index = c(9,10,11),
                              padded.index = c("09", "10", "11"),
                              contains = c("Sep", "Oct", "Nov"),
                              days = 61,
                              days.leap = 61,
                              col = viridis::turbo(4)[4]),
                    Annual = new("Period",
                                 id = "Annual",
                                 name = "Annual",
                                 abbreviation = "Ann",
                                 index = seq(1,12,1),
                                 padded.index = "Annual",
                                 contains = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug","Sep", "Oct", "Nov", "Dec"), 
                                 days = 365,
                                 days.leap = 366,
                                 col = "black"
                    )
                    
)

# subsets of periods
#' @rdname Period-class
#' @format List of\code{Period} objects
#' @export
periods <- all.periods

#' @rdname Period-class
#' @export
all.months <- all.periods[1:12]

#' @rdname Period-class
#' @export
all.seasons <- all.periods[13:16]

#' @rdname Period-class
#' @export
annual <- all.periods[17]
MagicForrest/DGVMTools documentation built on Aug. 23, 2024, 8:05 a.m.