SaveExp.Rd 2.85 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 an experiment in a format compatible with CST_Load}
\usage{
SaveExp(
  data,
  coords = NULL,
  startdates = NULL,
  Dates = NULL,
  Dataset = NULL,
  var_name = NULL,
  metadata = NULL,
  unique_file = FALSE,
  extra_string = NULL
\item{data}{An multi-dimensional array with named dimensions (longitude, 
latitude, time, member, sdate).}
\item{destination}{A character string indicating the path where to store the 
NetCDF files.}

\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.}

\item{startdates}{A vector of dates indicating the initialization date of each 
simulations.}

\item{Dates}{A matrix of dates with the corresponding sdate and forecast time
dimension.}
\item{Dataset}{A vector of character string indicating the names of the 
datasets.}
\item{var_name}{A character string indicating the name of the variable to be 
saved.}
\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{unique_file}{A logical value indicating if all object is saved in a 
unique file (TRUE) or in separated directories (FALSE). When it is FALSE, 
the array is separated for dataset, variable and start date.}
\item{extra_string}{A character string to be include as part of the file name, 
for instance, to identify member or realization.}
The function creates as many files as sdates per dataset. Each file 
could contain multiple members. It would be added to the file name between 
underscore characters. The path will be created with the name of the variable 
and each Datasets.
This function is created for compatibility with CST_Load/Load for 
saving post-processed datasets such as those calibrated of downscaled with 
CSTools functions
\dontrun{
data <- lonlat_temp$exp$data
lon <- lonlat_temp$exp$lon
lat <- lonlat_temp$exp$lat
Dataset <- 'XXX'
var_name <- 'tas'
units <- 'k'
startdates <- lapply(1:length(lonlat_temp$exp$Datasets),
                        lonlat_temp$exp$Datasets[[x]]$InitializationDates[[1]]})[[1]]
Dates <- lonlat_temp$exp$Dates$start
dim(Dates) <- c(time = length(Dates)/length(startdates), sdate = length(startdates))
destination = './path/'
SaveExp(data, lon, lat, Dataset, var_name, units, startdates, Dates,
                   cdo_grid_name, projection, destination)
}
\author{
Perez-Zanon Nuria, \email{nuria.perez@bsc.es}
}