SaveExp.Rd 4.15 KB
Newer Older
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CST_SaveExp.R
\name{SaveExp}
\alias{SaveExp}
\title{Save a multidimensional array with metadata to data in NetCDF format}
\usage{
SaveExp(
  data,
  destination = "./",
  Dates = NULL,
  coords = NULL,
Eva Rifà's avatar
Eva Rifà committed
  varname = NULL,
Eva Rifà's avatar
Eva Rifà committed
  startdates = NULL,
  dat_dim = "dataset",
  sdate_dim = "sdate",
  ftime_dim = "time",
  var_dim = "var",
  memb_dim = "member",
Eva Rifà's avatar
Eva Rifà committed
  single_file = FALSE,
Eva Rifà's avatar
Eva Rifà committed
  extra_string = NULL
Eva Rifà's avatar
Eva Rifà committed
\item{data}{A multi-dimensional array with named dimensions.}
\item{destination}{A character string indicating the path where to store the 
NetCDF files.}

Eva Rifà's avatar
Eva Rifà committed
\item{Dates}{An named array of dates with the corresponding sdate and forecast 
time dimension.}
\item{coords}{A named list with elements of the coordinates corresponding to 
the dimensions of the data parameter. The names and length of each element 
must correspond to the names of the dimensions. 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.}

Eva Rifà's avatar
Eva Rifà committed
\item{varname}{A character string indicating the name of the variable to be 
\item{metadata}{A named list where each element is a variable containing the
corresponding information. The information must be contained in a list of 
lists for each variable.}
\item{Datasets}{A vector of character string indicating the names of the 
datasets.}

Eva Rifà's avatar
Eva Rifà committed
\item{startdates}{A vector of dates indicating the initialization date of each 
simulations.}

\item{dat_dim}{A character string indicating the name of dataset dimension. 
By default, it is set to 'dataset'. It can be NULL if there is no dataset  
dimension.}

\item{sdate_dim}{A character string indicating the name of the start date 
dimension. By default, it is set to 'sdate'. It can be NULL if there is no
start date dimension.}

\item{ftime_dim}{A character string indicating the name of the forecast time
dimension. By default, it is set to 'time'. It can be NULL if there is no 
forecast time dimension.}

\item{var_dim}{A character string indicating the name of variable dimension. 
By default, it is set to 'var'. It can be NULL if there is no variable  
dimension.}

\item{memb_dim}{A character string indicating the name of the member dimension.
By default, it is set to 'member'. It can be NULL if there is no member 
dimension.}

\item{single_file}{A logical value indicating if all object is saved in a 
unique file (TRUE) or in separated directories (FALSE). When it is FALSE, 
Eva Rifà's avatar
Eva Rifà committed
the array is separated for Datasets, variable and start date. It is FALSE  
by default.}
\item{extra_string}{A character string to be include as part of the file name, 
for instance, to identify member or realization. It would be added to the 
file name between underscore characters.}
If single_file is TRUE only one file is created. If single_file is 
Eva Rifà's avatar
Eva Rifà committed
FALSE multiple files are created. When multiple files are created, each file 
contains the data subset for each start date, variable and dataset. Files 
with different variables and Datasets are stored in separated directories.
The path will be created with the name of the variable and each start date.
NetCDF file for each starting date are saved into the 
 folder tree: \cr
 destination/Dataset/variable/.
This function allows to save a data array with metadata into a 
NetCDF file, allowing to reload the saved data using \code{Start} function 
from StartR package. If the original 's2dv_cube' object has been created from 
Eva Rifà's avatar
Eva Rifà committed
\code{CST_Load()}, then it can be reloaded with \code{Load()}.
\dontrun{
data <- lonlat_temp$exp$data
Eva Rifà's avatar
Eva Rifà committed
lon <- lonlat_temp$exp$coords$lon
lat <- lonlat_temp$exp$coords$lat
coords <- list(lon = lon, lat = lat)
Datasets <- lonlat_temp$exp$attrs$Datasets
Eva Rifà's avatar
Eva Rifà committed
varname <- 'tas'
Dates <- lonlat_temp$exp$attrs$Dates
Eva Rifà's avatar
Eva Rifà committed
metadata <- lonlat_temp$exp$attrs$Variable$metadata
SaveExp(data = data, destination = destination, coords = coords, 
       Datasets = Datasets, varname = varname, Dates = Dates, 
       metadata = metadata, single_file = TRUE, ftime_dim = 'ftime', 
Eva Rifà's avatar
Eva Rifà committed
       var_dim = NULL)
\author{
Perez-Zanon Nuria, \email{nuria.perez@bsc.es}
}