Returns a tidy data.frame from a single NetCDF file, optionally subsetting a single longitudinal band

ncfile_to_df(filnam, ilon = NA, varnam, lonnam, latnam, timenam, fgetdate)

Arguments

filnam

file name

ilon

An integer specifying an individual longitude index to subset. If provided, ilon overrides that the function extracts data for all longitude indices. If omitted (the default: ilon = NA), the function returns tidy data for all longitude indices.

varnam

The variable name(s) for which data is to be read from the NetCDF file.

lonnam

The dimension name of longitude in the NetCDF file.

latnam

The dimension name of latitude in the NetCDF file.

timenam

The name of dimension variable used for time in the NetCDF file.

fgetdate

A function to derive the date(s) used for the time dimension based on the file name.

Value

Tidy tibble containing the variables 'varnam'. Tibble contains columns 'lon' (double), 'lat' (double), and a nested column 'data'. Column 'data' contains requested variables (probably as doubles) and might contain a column 'datetime' (as string). Note that the datetime is defined by package CFtime and can contain dates such as "2021-02-30 12:00:00", which are valid for 360-day calendars but not for POSIXt. Because of that these dates need to be parsed separately.