MergeRefToExp {CSIndicators}R Documentation

Merge a Reference To Experiments

Description

Some indicators are defined for specific temporal periods (e.g.: summer from June 21st to September 21st). If the initialization forecast date is later than the one required for the indicator (e.g.: July 1st), the user may want to merge past observations, or other reference, to the forecast (or hindcast) to compute the indicator. The function MergeObs2Exp takes care of this steps.

Usage

MergeRefToExp(
  data1,
  dates1,
  start1,
  end1,
  data2,
  dates2,
  start2,
  end2,
  time_dim = "time",
  sdate_dim = "sdate",
  ncores = NULL
)

Arguments

data1

a multidimensional array with named dimensions.

dates1

a vector of dates or a multidimensional array of dates with named dimensions matching the dimensions on parameter 'data1'.

start1

a list to defined the initial date of the period to select from data1 by providing a list of two elements: the initial date of the period and the initial month of the period.

end1

a list to defined the final date of the period to select from data1 by providing a list of two elements: the final day of the period and the final month of the period.

data2

a multidimensional array with named dimensions.

dates2

a vector of dates or a multidimensional array of dates with named dimensions matching the dimensions on parameter 'data2'.

start2

a list to defined the initial date of the period to select from data2 by providing a list of two elements: the initial date of the period and the initial month of the period.

end2

a list to defined the final date of the period to select from data2 by providing a list of two elements: the final day of the period and the final month of the period.

time_dim

a character string indicating the name of the temporal dimension. By default, it is set to 'ftime'. More than one dimension name matching the dimensions provided in the object data$data can be specified. This dimension is required to subset the data in a requested period.

sdate_dim

a character string indicating the name of the dimension in which the initialization dates are stored.

ncores

an integer indicating the number of cores to use in parallel computation.

Value

A multidimensional array with named dimensions.

Examples

data_dates <- c(seq(as.Date("01-07-1993", "%d-%m-%Y", tz = 'UTC'),
                   as.Date("01-12-1993","%d-%m-%Y", tz = 'UTC'), "day"),
               seq(as.Date("01-07-1994", "%d-%m-%Y", tz = 'UTC'),
                   as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day"))
dim(data_dates) <- c(time = 154, sdate = 2)
ref_dates <- seq(as.Date("01-01-1993", "%d-%m-%Y", tz = 'UTC'),
                as.Date("01-12-1994","%d-%m-%Y", tz = 'UTC'), "day")
dim(ref_dates) <- c(time = 350, sdate = 2)
ref <- array(1001:1700, c(time = 350, sdate = 2))
data <- array(1:(2*154*2), c(time = 154, sdate = 2, member= 2))
new_data <- MergeRefToExp(data1 = ref, dates1 = ref_dates, start1 = list(21, 6),
                         end1 = list(30, 6), data2 = data, dates2 = data_dates,
                         start2 = list(1, 7), end = list(21, 9))

[Package CSIndicators version 0.0.1 Index]