Newer
Older
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CST_SplitDim.R
\name{CST_SplitDim}
\alias{CST_SplitDim}
\title{Function to Split Dimension}
\usage{
CST_SplitDim(
data,
split_dim = "time",
indices = NULL,
freq = "monthly",
insert_ftime = NULL,
ftime_dim = "time",
sdate_dim = "sdate",
return_indices = FALSE
\item{data}{A 's2dv_cube' object}
\item{split_dim}{A character string indicating the name of the dimension to
\item{indices}{A vector of numeric indices or dates. If left at NULL, the
dates provided in the s2dv_cube object (element Dates) will be used.}
\item{freq}{A character string indicating the frequency: by 'day', 'month' and
'year' or 'monthly' (by default). 'month' identifies months between 1 and 12
independently of the year they belong to, while 'monthly' differenciates
months from different years.}
\item{new_dim_name}{A character string indicating the name of the new
dimension.}
\item{insert_ftime}{An integer indicating the number of time steps to add at
the begining of the time series.}
\item{ftime_dim}{A character string indicating the name of the forecast time
dimension. It is set as 'time' by default.}
\item{sdate_dim}{A character string indicating the name of the start date
dimension. It is set as 'sdate' by default.}
\item{return_indices}{A logical value that if it is TRUE, the indices
used in splitting the dimension will be returned. It is FALSE by default.}
This function split a dimension in two. The user can select the
dimension to split and provide indices indicating how to split that dimension
or dates and the frequency expected (monthly or by day, month and year). The
user can also provide a numeric frequency indicating the length of each
division.
Parameter 'insert_ftime' has been included for the case of using
daily data, requiring split the temporal dimensions by months (or similar) and
the first lead time doesn't correspondt to the 1st day of the month. In this
case, the insert_ftime could be used, to get a final output correctly
organized. E.g.: leadtime 1 is the 2nd of November and the input time series
extend to the 31st of December. When requiring split by month with
\code{inset_ftime = 1}, the 'monthly' dimension of length two will indicate
the month (position 1 for November and position 2 for December), dimension
'time' will be length 31. For November, the position 1 and 31 will be NAs,
while from positon 2 to 30 will be filled with the data provided. This allows
to select correctly days trhough time dimension.
\examples{
data <- 1 : 20
dim(data) <- c(time = 10, lat = 2)
data <-list(data = data)
class(data) <- 's2dv_cube'
indices <- c(rep(1,5), rep(2,5))
new_data <- CST_SplitDim(data, indices = indices)
time <- c(seq(ISOdate(1903, 1, 1), ISOdate(1903, 1, 4), "days"),
seq(ISOdate(1903, 2, 1), ISOdate(1903, 2, 4), "days"),
seq(ISOdate(1904, 1, 1), ISOdate(1904, 1, 2), "days"))
data <- list(data = data$data, Dates = time)
class(data) <- 's2dv_cube'
new_data <- CST_SplitDim(data, indices = time)
new_data <- CST_SplitDim(data, indices = time, freq = 'day')
new_data <- CST_SplitDim(data, indices = time, freq = 'month')
new_data <- CST_SplitDim(data, indices = time, freq = 'year')
}
\author{
Nuria Perez-Zanon, \email{nuria.perez@bsc.es}
}