getNetCDF: getNetCDF

Description Usage Arguments Details Value Author(s) Examples

Description

Loads selected variables in a specified netCDF data file into a data.frame.

Usage

1
2
getNetCDF(fname, VarList = standardVariables(), Start = 0, End = 0,
  F = 0)

Arguments

fname

string, full-path file name, e.g., "/scr/raf_data/PREDICT/PREDICTrf01.nc"

VarList

vector of variable names to load from the netCDF file. Use "ALL" to load everything except vector variables like the size distributions. (This option may produce quite large data.frames.) The default is the list given by standardVariables (). SPECIAL NOTE: Some variable names have a suffix indicating the location on the aircraft, like _LWI (left-wing inboard). To avoid having to supply these, a partial name can be supplied, like "CONCD_", and the routine will find the first matching variable and use that variable name. These can always be overridden by providing the full name; this is just a convenience to avoid having to look up where a particular measurement was installed in a given project.

Start

An optional numeric giving the desired start time in HHMMSS format

End

An optional numeric giving the desired end time in HHMMSS format

F

An optional numeric entered in the data.frame as a column 'RF' all set to this integer. This may be useful when the resulting data.frame is combined with others, to have a variable distinguishing different flights.

Details

'Time' is converted to a POSIXct variable, and other variables specified in VarList are included in the data.frame. By default, the entire file is loaded, but optional arguments Start and End can limit the time range. After reading the data, the netCDF file is closed before returning the data.frame to the calling program. The global attributes in the netCDF file are loaded as attributes of the returned data.frame, and attributes of each requested variable are also assigned to that column in the data.frame from the variable attributes in the netCDF file. When working with attributes, it is a feature of R data.frames that subsetting loses all the assigned variable attributes. To preserve them, copy them via A <- attributes (Data$VAR), remove A$dim (e.g., A$dim <- NULL), and re-assign via attributes (DataNew$VAR) <- A. The function does handle some multi-dimensional variables (e.g., CCDP, CFSSP, the size distributions measured by the CDP and FSSP); these are returned as data.frame variables that are columns in the returned more general data.frame. They are two-dimensional, with the first dimension matching the rows in the returned data.frame and the second having a length equal to the measured size distribution (e.g., 30 for the CDP, 15 for the FSSP). The values are the number concentration in each bin, and the variable is assigned an attribute "BinSize" that contains the mid-points of the bins in the size distribution. The returned values are concentrations per bin (units /cm^3) and, for BinSize, diameter in micrometers. The returned size distribution does not include the legacy first bin in the netCDF files; the first bin is the first measurement. The routine does work for 25-Hz files, for which it returns with fractional-second times.

Value

data.frame containing the specified variables as columns, along with 'Time' and optionally the flight number 'RF'. The netCDF-file attributes and variable attributes are assigned to the data.frame and columns, respectively.

Author(s)

William Cooper

Examples

1
2
## Not run: D <- getNetCDF ("PathToFile.nc", c("Var1", "Var2", "Var3"))
## Not run: D <- getNetCDF ("PathToFile.nc", c("Var1", "Var2"), 133000, 143000, 5)

WilliamCooper/Ranadu documentation built on July 10, 2019, 12:40 a.m.