Writes one or multiple arrays with identical dimensions to a NetCDF file, creating multiple variables each with the same dimension.

write_nc2(
  obj,
  varnams = NA,
  filnam_template = NA,
  lonnam_template = "lon",
  latnam_template = "lat",
  lon = NA,
  lat = NA,
  z_dim = NA,
  time = NA,
  make_zdim = FALSE,
  make_tdim = FALSE,
  path = "./out.nc",
  verbose = FALSE,
  lonnam = "lon",
  latnam = "lat",
  zdimnam = "z",
  timenam = "time",
  units_lon = "degrees_east",
  units_lat = "degrees_north",
  units = "NA",
  units_time = "days since 2001-01-01",
  units_zdim = "",
  long_names = "NA",
  missing_value = -9999,
  att_title = "",
  att_history = ""
)

Arguments

obj

Either an rbeni-nc object or an array of size length(lon) x length(lat) x length(z_dim) x length(time). The order of lon (1st dim), lat (2nd dim), time (last dim) is mandatory. If it's an rbeni-nc object, then no additional aruguments are required.

varnams

A character string (or vector of strings) specifying the name(s) of the variable(s) that is/are written into the NetCDF output.

filnam_template

A character string specifying the file name of the template-NetCDF file from which all dimension information is read and used for the NetCDF file created here. Defaults to NA, meaning that all dimension information has to be spedifyed by the user. Othewise all dimension specification are overridden.

lonnam_template

Longitude name in the template file. Required only if !is.na(filnam_template).

latnam_template

Latitude name in the template file. Required only if !is.na(filnam_template).

lon

A vector containing the longitudes of the grid cell's mid-points. Defaults to seq(dim(var)[1]).

lat

A vector containing the latitudes of the grid cell's mid-points. Defaults to seq(dim(var)[2]).

z_dim

A vector containing the values of the z-dimension ("z", 3rd dimension). Defaults to NA (no z-dimension is written).

time

A vector containing the values of the time dimension. Defaults to NA (no time dimension is written).

make_zdim

Write a z-dimension. If var is 2-dimensional, and z_dim==NA, create a z-dimension of length 1.

make_tdim

Write a time dimension. If var is 2-dimensional, and time==NA, create a time dimension of length 1.

path

A character string specifying the file path of the NetCDF file to be written.

verbose

A boolean specifying whether messages are to be returned. Defaults to FALSE.

lonnam

Longitude name

latnam

Latitude name

zdimnam

Z-dimension name

timenam

Time dimension name

units_lon

Units of longitude

units_lat

Units of latitude

units

Units of variables.

units_time

Units of time dimension.

units_zdim

Units of z-dimension.

long_names

Long name of var.

missing_value

Missing value for all variables.

att_title

Global attribute "Title".

att_history

Global attribute "History".

Value

The path of the written NetCDF file.