rgdal-dev / rasterwise

Hard-won lessons! Don't lose 'em!
4 stars 0 forks source link

stars testing #5

Open mdsumner opened 5 years ago

mdsumner commented 5 years ago

files <- fs::dir_ls("../rasterwise/extdata/", recursive = TRUE, glob = "*.nc")
x <- purrr::map(files, purrr::possibly(read_ncdf, NULL))
bad <- purrr::map_lgl(x, is.null)
sum(bad)  ## 1 is bad, for some reason the 1-dim first dimension of /rasterwise/extdata/R13352.nc is
          ## dropped even is collapse = FALSE (not TRUE for basic other cases)

ebad <- logical(length(bad))

for (i in seq_along(files)) {
  if (bad[i]) next;
  x <- purrr::map(ncmeta::nc_vars(files[i])$name, 
                  ~purrr::safely(read_ncdf)(files[i], var = .x))
  ibad <- purrr::map_lgl(x, ~!is.null(.x$error))
  if (any(ibad)) ebad[i] <- TRUE
}