SaveExp {CSTools}R Documentation

Save an experiment in a format compatible with CST_Load

Description

This function is created for compatibility with CST_Load/Load for saving post-processed datasets such as those calibrated of downscaled with CSTools functions

Usage

SaveExp(
  data,
  lon,
  lat,
  Dataset,
  var_name,
  units,
  startdates,
  Dates,
  cdo_grid_name,
  projection,
  destination,
  extra_string = NULL
)

Arguments

data

an multi-dimensional array with named dimensions (longitude, latitude, time, member, sdate)

lon

vector of logitud corresponding to the longitudinal dimension in data

lat

vector of latitud corresponding to the latitudinal dimension in data

Dataset

a vector of character string indicating the names of the datasets

var_name

a character string indicating the name of the variable to be saved

units

a character string indicating the units of the variable

startdates

a vector of dates indicating the initialization date of each simulations

Dates

a matrix of dates with two dimension 'time' and 'sdate'.

cdo_grid_name

a character string indicating the name of the grid e.g.: 'r360x181'

projection

a character string indicating the projection name

destination

a character string indicating the path where to store the NetCDF files

extra_string

a character string to be include as part of the file name, for instance, to identify member or realization.

Value

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.

Author(s)

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

Examples

## Not run: 
data <- lonlat_data$exp$data
lon <- lonlat_data$exp$lon
lat <- lonlat_data$exp$lat
Dataset <- 'XXX'
var_name <- 'tas'
units <- 'k'
startdates <- lapply(1:length(lonlat_data$exp$Datasets),
                    function(x) {
                        lonlat_data$exp$Datasets[[x]]$InitializationDates[[1]]})[[1]]
Dates <- lonlat_data$exp$Dates$start
dim(Dates) <- c(time = length(Dates)/length(startdates), sdate = length(startdates))
cdo_grid_name = attr(lonlat_data$exp$lon, 'cdo_grid_name')
projection = attr(lonlat_data$exp$lon, 'projection')
destination = './path/'
SaveExp(data, lon, lat, Dataset, var_name, units, startdates, Dates,
                   cdo_grid_name, projection, destination)

## End(Not run)

[Package CSTools version 4.0.1 Index]