s2dv_cube {CSTools}R Documentation

Creation of a 's2dv_cube' object

Description

This function allows to create an 's2dv_cube' object by passing information through its parameters. This function will be needed if the data hasn't been loaded using CST_Start or has been transformed with other methods. An 's2dv_cube' object has many different components including metadata. This function will allow to create 's2dv_cube' objects even if not all elements are defined and for each expected missed parameter a warning message will be returned.

Usage

s2dv_cube(
  data,
  coords = NULL,
  varName = NULL,
  metadata = NULL,
  Datasets = NULL,
  Dates = NULL,
  when = NULL,
  source_files = NULL,
  ...
)

Arguments

data

A multidimensional array with named dimensions, typically with dimensions: dataset, member, sdate, time, lat and lon.

coords

A list of named vectors with the coordinates corresponding to the dimensions of the data parameter. If any coordinate has dimensions, they will be set as NULL. If any coordinate is not provided, it is set as an index vector with the values from 1 to the length of the corresponding dimension. The attribute 'indices' indicates wether the coordinate is an index vector (TRUE) or not (FALSE).

varName

A character string indicating the abbreviation of the variable name.

metadata

A named list where each element is a variable containing the corresponding information. The information can be contained in a list of lists for each variable.

Datasets

Character strings indicating the names of the dataset. It there are multiple datasets it can be a vector of its names or a list of lists with additional information.

Dates

A POSIXct array of time dimensions containing the Dates.

when

A time stamp of the date when the data has been loaded. This parameter is also found in Load() and Start() functions output.

source_files

A vector of character strings with complete paths to all the found files involved in loading the data.

...

Additional elements to be added in the object. They will be stored in the end of 'attrs' element. Multiple elements are accepted.

Value

The function returns an object of class 's2dv_cube' with the following elements in the structure:

Author(s)

Perez-Zanon Nuria, nuria.perez@bsc.es

See Also

Load and CST_Start

Examples

exp_original <- 1:100
dim(exp_original) <- c(lat = 2, time = 10, lon = 5)
exp1 <- s2dv_cube(data = exp_original)
class(exp1)
coords <- list(lon = seq(-10, 10, 5), lat = c(45, 50))
exp2 <- s2dv_cube(data = exp_original, coords = coords) 
class(exp2)
metadata <- list(tas = list(level = '2m'))
exp3 <- s2dv_cube(data = exp_original, coords = coords,
                 varName = 'tas', metadata = metadata)
class(exp3)
Dates = as.POSIXct(paste0(rep("01", 10), rep("01", 10), 1990:1999), format = "%d%m%Y")
dim(Dates) <- c(time = 10)
exp4 <- s2dv_cube(data = exp_original, coords = coords,
                 varName = 'tas', metadata = metadata,
                 Dates = Dates)  
class(exp4)
exp5 <- s2dv_cube(data = exp_original, coords = coords,
                 varName = 'tas', metadata = metadata,
                 Dates = Dates, when = "2019-10-23 19:15:29 CET")  
class(exp5)
exp6 <- s2dv_cube(data = exp_original, coords = coords,
                 varName = 'tas', metadata = metadata,
                 Dates = Dates,
                 when = "2019-10-23 19:15:29 CET", 
                 source_files = c("/path/to/file1.nc", "/path/to/file2.nc"))
class(exp6)
exp7 <- s2dv_cube(data = exp_original, coords = coords,
                 varName = 'tas', metadata = metadata,
                 Dates = Dates,
                 when = "2019-10-23 19:15:29 CET", 
                 source_files = c("/path/to/file1.nc", "/path/to/file2.nc"),
                 Datasets = list(
                   exp1 = list(InitializationsDates = list(Member_1 = "01011990", 
                                                           Members = "Member_1"))))  
class(exp7)
dim(exp_original) <- c(dataset = 1, member = 1, time = 10, lat = 2, lon = 5)
exp8 <- s2dv_cube(data = exp_original, coords = coords,
                 varName = 'tas', metadata = metadata,
                 Dates = Dates, original_dates = Dates)  
class(exp8)

[Package CSTools version 5.2.0 Index]