% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CST_SaveNC.R
\name{CST_SaveNC}
\alias{CST_SaveNC}
\title{Save CSTools objects of class 's2dv_cube' in NCDF format}
\usage{
CST_SaveNC(data, destination)
}
\arguments{
\item{data}{an object of class \code{s2dv_cube}}

\item{destination}{a character string containing the file name in which to save the data with .nc extension.}
}
\description{
This function allows to save a object of class 's2dv_cube' in a .nc file.
}
\details{
It saves individual or a list of numerical and logical arrays. If an element is NULL, it won't be saved. Other classes will be stored in attributes.
}
\examples{
## BASICS
destination <- "../DataSaved1.nc"
additional = NULL
add_attributes = NULL
data <- 1 : 10 
dim(data) <- c(2, 5)
attr(data, 'class') <- 's2dv_cube'
CST_SaveNC(data, destination)

## BASICS
obj1 <- 1 : 10 
dim(obj1) <- c(a = 2, b = 5)
data <- list(obj1, obj1)
attr(data, 'class') <- 's2dv_cube'
CST_SaveNC(data, destination)

## BASICS
obj1 <- 1 : 10 
dim(obj1) <- c(aa = 2, bb = 5)
data <- list(rr = obj1, tt = obj1, xx = obj1)
attr(data, 'class') <- 's2dv_cube'
CST_SaveNC(data, destination)

## BASICS
obj1 <- 1 : 10 
dim(obj1) <- c(aa = 2, bb = 5)
data <- list(1 : 10, obj1, obj1)
attr(data, 'class') <- 's2dv_cube'
CST_SaveNC(data, destination)

## BASICS
obj1 <- 1 : 10 
dim(obj1) <- c(aa = 2, bb = 5)
data <- list(rr = as.character(obj1), tt = obj1, xx = obj1)
attr(data, 'class') <- 's2dv_cube'
CST_SaveNC(data, destination)

## BASICS
obj1 <- 1 : 10 
dim(obj1) <- c(aa = 2, bb = 5)
data <- list(rr = list(ss = list(sss = as.character(obj1), ssss = as.character(obj1))), 
            tt = obj1, xx = obj1)
attr(data, 'class') <- 's2dv_cube'
CST_SaveNC(data, destination)


temperature <- array(rnorm(100 * 50 * 10), dim = c(100, 50, 10)) 
names(dim(temperature)) <- c('longitude', 'latitude', 'time') 
data <- list(temperature = temperature, temperature2 = temperature)
attr(data, 'class') <- 's2dv_cube'
CST_SaveNC(data, destination)
data <- list(temperature = temperature) #falta nombre 
attr(data, 'class') <- 's2dv_cube'
CST_SaveNC(data, destination)


# WORKS:
sic_nohole <- array(rnorm(360*180*460), dim = c(lat = 180, lon = 360, time = 460))
lon <- as.numeric(0:359)
lat <- as.numeric(seq(-90, 90, length.out = 180))

names(dim(sic_nohole)) <- c('lat', 'lon','time')
metadata <- list(sic_nohole = list(units = '1'))
attr(sic_nohole, 'variables') <- metadata

dim(lon) <- length(lon)
names(dim(lon)) <- 'lon'
metadata <- list(lon = list(units = 'degrees_east'))
attr(lon, 'variables') <- metadata

dim(lat) <- length(lat)
names(dim(lat)) <- 'lat'
metadata <- list(lat = list(units = 'degrees_north'))
attr(lat, 'variables') <- metadata

datos <- list(sic_nohole, lon, lat)
attr(datos, 'class') <- 's2dv_cube'
CST_SaveNC(datos, './MEDSCOPE/tmp.nc')
attr(lonlat_prec, "class") <- 's2dv_cube'
CST_SaveNC(lonlat_prec, destination)

}
\author{
Perez-Zanon Nuria, \email{nuria.perez@bsc.es}
}
\seealso{
\code{\link[easyNCDF]{ArrayToNc}} and \code{\link{CST_Load}}
}

