ncwrite: Write CMIP5 nc file

View source: R/ncwrite.R

ncwriteR Documentation

Write CMIP5 nc file

Description

Write CMIP5 nc file

Usage

ncwrite(
  lst,
  file,
  var.units = NULL,
  var.longname = NULL,
  prec = "float",
  dims = NULL,
  dimnames_last = NULL,
  range = c(-180, 180, -90, 90),
  dates = NULL,
  calendar = "gregorian",
  missval = -9999L,
  compression = 1,
  scale,
  offset,
  attrs,
  overwrite = FALSE,
  verbose = FALSE
)

ncwrite_raster2(r, file, dims = NULL, dimnames_last, overwrite = TRUE, ...)

Arguments

lst

A named list of 3d arrays, which have the dimension of ⁠[nlon, nlat, ntime]⁠. image(lst[[1]][,,1]) should looks normal.

file

Name of the netCDF file to be created.

var.units

untis of variables in lst

var.longname

longname of variables in lst

prec

Precision of the created variable. Valid options: 'short' 'integer' 'float' 'double' 'char' 'byte'. See the special note below for how to create a character variable (strings). short: -32768 - 32768.

range

A numeric vector, ⁠[lon_min, lon_max, lat_min, lat_max]⁠.

dates

A Date or POSIXct object, specified corresponding date

missval

The variable's missing value. If NO missing value is desired, pass a NULL, or omit this argument entirely. If a NaN missing value is desired, pass an NA.

compression

If set to an integer between 1 (least compression) and 9 (most compression), this enables compression for the variable as it is written to the file. Turning compression on forces the created file to be in netcdf version 4 format, which will not be compatible with older software that only reads netcdf version 3 files.

scale, offset

If the variable in the netCDF file has a scale and/or offset attribute defined, the returned data are automatically and silently scaled and/or offset as requested. Then you should just leave scale = 1, and offset = 0.

attrs

A named list of global attributes, e.g. title, author, souce, references, institution.

verbose

Print debugging information.

r

raster2 object returned by ncwrite()

...

other parameters to ncwrite

varname

variable name in the data of r

See Also

ncread_cmip(), ncdf4::ncvar_def()

Examples

## Not run: 
range_china = c(70, 140, 15, 55)
ncwrite(list(Tmin = arr[,,1:2]), "Tmin.nc", "degC", range = range_china,
     prec = "short", scale = 0.01, offset = 10,
     dates = dates)

## End(Not run)


rpkgs/nctools documentation built on Sept. 24, 2023, 9:23 p.m.