SeasonSelect: Selects a season from daily data for multidimensional arrays

Description Usage Arguments Value Examples

View source: R/SeasonSelect.R

Description

This function selects the daily data corresponding to the specified season.

Usage

1
SeasonSelect(data, season, dates = NULL, timedim = NULL, calendar = NULL)

Arguments

data

A numeric multidimensional array containing daily data.

season

A charcater string indicating the season by the three months initials in capitals: 'DJF' for winter (summer), 'MAM' spring (autumn), 'JJA' for summer (winter) or 'SON' for autumn (spring) in the northern (southern) hemisphere.

dates

A vector of dates with a calendar attributes. If NULL (by default), the 'time' attributes of parameter 'data' are considered.

timedim

An integer number indicating the position of the time dimension in the parameter data. If NULL (by default), the dimension called 'time' in parameter data.

calendar

A character indicating the calendar type.

Value

A list of length 2:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Example with synthetic data:
data <- 1:(2 * 3 * (366 + 365) * 2)
dim(data) <- c(lon = 2, lat = 3, time = 366 + 365, model = 2)
time <- seq(ISOdate(1903,1,1), ISOdate(1904,12,31), "days")
time <- as.POSIXct(time, tz = "CET")
metadata <- list(time = list(standard_name = 'time', long_name = 'time', 
                            calendar = 'noleap',
                            units = 'days since 1970-01-01 00:00:00', prec = 'double', 
                            dim = list(list(name ='time', unlim = FALSE))))
attr(time, "variables") <- metadata
attr(data, 'Variables')$dat1$time <- time
attr(data, 'Variables')$dat2$time <- time
attr(data, 'Variables')$common[[2]]$dim[[3]]$len = length(time)
attr(data, 'Variables')$common[[2]]$dim[[3]]$vals <- time

a <- SeasonSelect(data = data, season = 'JJA')
str(a)

ClimProjDiags documentation built on Jan. 7, 2021, 5:10 p.m.