as.s2dv_cube {CSTools} | R Documentation |
Conversion of 'startR_array' or 'list' objects to 's2dv_cube'
Description
This function converts data loaded using Start function from startR package or Load from s2dv into an 's2dv_cube' object.
Usage
as.s2dv_cube(object, remove_attrs_coords = FALSE, remove_null = FALSE)
Arguments
object |
An object of class 'startR_array' generated from function
|
remove_attrs_coords |
A logical value indicating whether to remove the attributes of the coordinates (TRUE) or not (FALSE). The default value is FALSE. |
remove_null |
Optional. A logical value indicating whether to remove the
elements that are NULL (TRUE) or not (FALSE) of the output object. It is
only used when the object is an output from function |
Value
The function returns an 's2dv_cube' object to be easily used with
functions with the prefix CST
from CSTools and CSIndicators packages.
The object is mainly a list with the following elements:
'data', array with named dimensions;
'dims', named vector of the data dimensions;
'coords', list of named vectors with the coordinates corresponding to the dimensions of the data parameter;
'attrs', named list with elements:
'Dates', array with named temporal dimensions of class 'POSIXct' from time values in the data;
'Variable', has the following components:
'varName', character vector of the short variable name. It is usually specified in the parameter 'var' from the functions Start and Load;
'metadata', named list of elements with variable metadata. They can be from coordinates variables (e.g. longitude) or main variables (e.g. 'var');
'Datasets', character strings indicating the names of the datasets;
'source_files', a vector of character strings with complete paths to all the found files involved in loading the data;
'when', a time stamp of the date issued by the Start() or Load() call to obtain the data;
'load_parameters', it contains the components used in the arguments to load the data from Start() or Load() functions.
Author(s)
Perez-Zanon Nuria, nuria.perez@bsc.es
Nicolau Manubens, nicolau.manubens@bsc.es
See Also
s2dv_cube
, CST_Start
,
Start
and CST_Load
Examples
## Not run:
# Example 1: convert an object from startR::Start function to 's2dv_cube'
library(startR)
repos <- '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc'
data <- Start(dat = repos,
var = 'tas',
sdate = c('20170101', '20180101'),
ensemble = indices(1:5),
time = 'all',
latitude = indices(1:5),
longitude = indices(1:5),
return_vars = list(latitude = 'dat', longitude = 'dat', time = 'sdate'),
retrieve = TRUE)
data <- as.s2dv_cube(data)
# Example 2: convert an object from s2dv::Load function to 's2dv_cube'
startDates <- c('20001101', '20011101', '20021101',
'20031101', '20041101', '20051101')
data <- Load(var = 'tas', exp = 'system5c3s',
nmember = 2, sdates = startDates,
leadtimemax = 3, latmin = 10, latmax = 30,
lonmin = -10, lonmax = 10, output = 'lonlat')
data <- as.s2dv_cube(data)
## End(Not run)