Skip to content

Commit

Permalink
Minor updates in dataInventory
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedia committed Jun 15, 2020
1 parent 87ff16a commit 74c25bd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions R/dataInventory.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dataInventory.R Get an overview of the contents of a dataset
# dataInventory.R Get an overview of the contents of a dataset
#
# Copyright (C) 2016 Santander Meteorology Group (http://www.meteo.unican.es)
# Copyright (C) 2020 Santander Meteorology Group (http://www.meteo.unican.es)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -42,10 +42,13 @@
#' print(di.stats$Summary.stats)
#' }
#' @seealso \code{\link{stationInfo}} for a quick overview of available stations in station datasets.
#' Further details are given in \code{\link{scanVarDimensions}}, which is the internal performing
#' the dimension info retrieval.
#' @export
#' @author J Bedia

dataInventory <- function(dataset, return.stats = FALSE) {
stopifnot(is.logical(return.stats))
if (dataset %in% suppressMessages(do.call("c", UDG.datasets()))) {
lf <- list.files(file.path(find.package("climate4R.UDG")), pattern = "datasets.*.txt", full.names = TRUE)
df <- lapply(lf, function(x) read.csv(x, stringsAsFactors = FALSE))
Expand All @@ -60,8 +63,8 @@ dataInventory <- function(dataset, return.stats = FALSE) {
} else {
gds <- tryCatch({openDataset(dataset)}, error = function(err) {NA})
nc <- tryCatch({gds$getNetcdfDataset()}, error = function(err) {NA})
grep.result <- tryCatch({grep("timeSeries",nc$getGlobalAttributes()$toString())}, error = function(err) {NULL})
if(!is.na(gds)) gds$close()
grep.result <- tryCatch({grep("timeSeries", nc$getGlobalAttributes()$toString())}, error = function(err) {NULL})
suppressWarnings(if (!is.na(gds)) gds$close())
if (length(grep.result) == 0 | is.null(grep.result)) {
out <- dataInventory.NetCDF(dataset)

Expand Down

0 comments on commit 74c25bd

Please sign in to comment.