nc_ingest: Ingest all the variables in a netCDF file

Description Usage Arguments Details Value See Also

View source: R/nc_ingest.R

Description

This function reads in all the variables in a netCDF file, names their dimensions, and attaches attributes to them such that they have approximately the same representation in R as they do in the netCDF file. If you're used to thinking about netCDF files, this will make them easier to work with, because it will allow you to write code like data <- nc$tmax[,nc$lon<300,] or if(nc$time@calendar == "noleap")

Usage

1
nc_ingest(netcdf, globalatts = FALSE)

Arguments

netcdf

An ncdf4 object (the result of ncdf4::nc_open), or the name of an existing netCDF file to be opened and ingested.

globalatts

Logical; if true, reads in global attributes in addition to data variables. (Defaults to FALSE.)

Details

This function reads in all variables and coordinate variables in a netcdf file and returns them in a list. It sets attributes on the variables matching the netcdf attributes; these can be accessed using the overloaded @ operator in this package.

Dimensions are named but not reordered to match the native netcdf ordering, because that difference is caused by the difference in how R and C order the most-rapidly-varying array indices, and changing the ordering would be both time-consuming and inefficient. Degenerate dimensions are culled.

There is currently no custom print method for the resulting object of this function. For a view of the contents of a netcdf file similar to what ncdump -h products, simply print the ncdf4 object produced by nc_open.

Value

An object of class 'nc' containing the variables in the netcdf file with named dimensions and attributes as in the netcdf file.

See Also

atsign


sethmcg/climod documentation built on Nov. 19, 2021, 11:12 p.m.