R/read_ncdf.R

Defines functions read_ncdf

Documented in read_ncdf

#' read_ncdf
#'
#' Import the contents of a NetCDF file as a `tibble`.
#'
#' @param path character
#' @param ... reserved for future use
#' @param verbose logical
#'
#' @return
#' @export
#'
#' @importFrom tidync tidync hyper_tibble
read_ncdf <- function(
  path,
  ...,
  verbose = getOption("verbose")
) {

  msg <- function (...) if(isTRUE(verbose)) {
    message("[read_ncdf_data] ", ...)
  }

  ncdf_object <-
    tidync::tidync(path)

  ncdf_data <-
    as_tibble(
      tidync::hyper_tibble(
        ncdf_object))

  attr(ncdf_data, "path") <-
    path

  return(ncdf_data)

}
BAAQMD/tbltools documentation built on Feb. 29, 2024, 5:45 a.m.