diff --git a/.github/ArgumentUsage.xlsx b/.github/ArgumentUsage.xlsx index 6a64457..9fb1cf4 100644 Binary files a/.github/ArgumentUsage.xlsx and b/.github/ArgumentUsage.xlsx differ diff --git a/.gitignore b/.gitignore index c34e6e9..6a85405 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ .httr-oauth .DS_Store .quarto -.vscode \ No newline at end of file +.vscode + +# ignore KiN nc files for now as most are too big to ship the package with +ExampleData/* \ No newline at end of file diff --git a/NAMESPACE b/NAMESPACE index 743e589..adfd710 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(Discovery_Library) export(Discovery_QuickFacts) export(Discovery_Read) export(Discovery_Variables) +export(Metrics_BootstrapQuantiles) export(Metrics_ETCCDI) export(NC_Read) export(NC_Write) @@ -51,6 +52,8 @@ importFrom(ncdf4,ncatt_put) importFrom(ncdf4,ncdim_def) importFrom(ncdf4,ncvar_def) importFrom(ncdf4,ncvar_put) +importFrom(ncdfCF,as_CF) +importFrom(ncdfCF,create_ncdf) importFrom(parallel,detectCores) importFrom(parallel,makeCluster) importFrom(progress,progress_bar) diff --git a/R/Discovery_Functionality.r b/R/Discovery_Functionality.r index 82a5b47..01b0d72 100644 --- a/R/Discovery_Functionality.r +++ b/R/Discovery_Functionality.r @@ -48,18 +48,24 @@ Discovery_DataSet.Check <- function(dataSet) { #' #' @export Discovery_Read <- function(dataSet = "NULL") { - owner <- "Clim-Hub" - repo <- "ClimHub" - branch <- "master" - path <- "product-metadata" + metadata_dir <- system.file("product-metadata", package = "ClimHub") + if (metadata_dir == "") { + stop("Could not locate 'product-metadata' directory in package 'ClimHub'.") + } Discovery_DataSet.Check(dataSet) - # URL of the raw JSON file - URL <- paste0("https://raw.githubusercontent.com/", owner, "/", repo, "/", branch, "/", path, "/", paste0(dataSet, ".json")) + json_file <- file.path(metadata_dir, paste0(dataSet, ".json")) + + # URL-based fallback kept for reference: + # owner <- "Clim-Hub" + # repo <- "ClimHub" + # branch <- "master" + # path <- "product-metadata" + # URL <- paste0("https://raw.githubusercontent.com/", owner, "/", repo, "/", branch, "/", path, "/", paste0(dataSet, ".json")) - # Read JSON content - json_data <- jsonlite::fromJSON(URL) + # Read JSON content from package files. + json_data <- jsonlite::fromJSON(json_file) # View the data json_data @@ -129,28 +135,21 @@ Discovery_Citation <- function(dataSet = "NULL") { #' #' @export Discovery_Library <- function() { - owner <- "Clim-Hub" - repo <- "ClimHub" - path <- "product-metadata" - - # Construct the URL - URL <- paste0("https://github.com/", owner, "/", repo, "/tree/master/", path) - - # Read the page - page <- rvest::read_html(URL) - - # Extract the embedded JSON metadata - raw_metadata <- page %>% - rvest::html_nodes("script") %>% # Extract all