create_example_netCDFs: Create example netCDFs for use by package

View source: R/functions_netCDF.R

create_example_netCDFsR Documentation

Create example netCDFs for use by package

Description

This function creates different netCDFs for all requested conditions:

  • data_str

  • type_timeaxis

Usage

create_example_netCDFs(
  path,
  data_str = c("xyzt", "xyt", "xyz", "xy", "szt", "st", "sz", "s"),
  type_timeaxis = c("timeseries", "climatology"),
  overwrite = FALSE
)

Arguments

path

A character string. The path to where the files will be written to disk.

data_str

A character string describing the dimensions of data where "xy" stands for x and y spatial dimensions if the spatial structure is gridded, while "s" stands for site if the spatial structure are discrete points; z stands for a vertical dimension; and t stands for a temporal dimension.

type_timeaxis

A character string. Describing if the time dimension represents a time series or a climatological time.

overwrite

A logical value. If TRUE, file will be overwritten if it already exists.

Value

A named list, invisibly, of full paths to the created files on disk.

Examples

tmp_nc <- create_example_netCDFs(tempdir(), "xyt", "timeseries")
data_xyt <- read_netCDF(
  tmp_nc[["xyt"]],
  method = "array",
  xy_names = c("x", "y")
)

if (requireNamespace("graphics")) {
  graphics::persp(
    x = data_xyt[["xyspace"]][["x"]],
    y = data_xyt[["xyspace"]][["y"]],
    z = data_xyt[["data"]][, , 15],
    theta = 30,
    phi = 30,
    expand = 0.5,
    col = "lightblue"
  )
}

unlink(unlist(tmp_nc))


DrylandEcology/rSW2st documentation built on Jan. 10, 2024, 6:22 p.m.