Returns a tidy data.frame from a list of NetCDF file(s), optionally subsetting a single a longitudinal band

nclist_to_df_byilon(
  nclist,
  ilon,
  outdir,
  fileprefix,
  varnam,
  lonnam,
  latnam,
  timenam,
  fgetdate,
  overwrite
)

Arguments

nclist

A vector of character strings specifying the complete paths to files.

ilon

An integer specifying an individual longitude index to subset. If provided, only longitude index 'ilon' is extracted. If omitted (ilon = NA), the function returns tidy data for all longitude indexes.

outdir

A character string specifying output directory where data frames are written using the save statement. If omitted (defaults to NA), a tidy data frame containing all data is returned.

fileprefix

A character string specifying the file name prefix.

varnam

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

lonnam

The dimension name of longitude in the NetCDF files.

latnam

The dimension name of latitude in the NetCDF files.

timenam

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

fgetdate

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

overwrite

A logical indicating whether time series files are to be overwritten.

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. If !is.na(outdir), then an RDS file is generated in outdir and column 'data' of return value contains a status message only instead of data.