Skip to content

Commit

Permalink
Merge pull request #101 from addelany/main
Browse files Browse the repository at this point in the history
remove unused extensions
  • Loading branch information
addelany authored Jul 16, 2024
2 parents 64cef58 + a89bd72 commit 4d21a95
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 77 deletions.
4 changes: 1 addition & 3 deletions R/build_forecast_scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ build_forecast_scores <- function(table_schema,
"description" = description_string,
"stac_version"= "1.0.0",
"license"= "CC0-1.0",
"stac_extensions"= list("https://stac-extensions.github.io/scientific/v1.0.0/schema.json",
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json",
"https://stac-extensions.github.io/table/v1.2.0/schema.json"),
"stac_extensions"= list("https://stac-extensions.github.io/table/v1.2.0/schema.json"),
#"sci:doi": catalog_config$citation_doi,
'type' = 'Collection',
'links' = c(link_items, link_list),
Expand Down
221 changes: 147 additions & 74 deletions R/build_group_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ build_group_variables <- function(table_schema,
doi_values
){

if (is.null(group_var_vector)){
if (is.null(group_var_vector)){ ## building var json

aws_asset_link <- paste0('"',"s3://anonymous@",
aws_download_path,
Expand All @@ -62,7 +62,80 @@ build_group_variables <- function(table_schema,
aws_asset_description <- paste0("Use `arrow` for remote access to the database. This R code will return results for forecasts of the variable by the specific model .\n\n### R\n\n```{r}\n# Use code below\n\nall_results <- arrow::open_dataset(",aws_asset_link,")\ndf <- all_results |> dplyr::collect()\n\n```
\n\nYou can use dplyr operations before calling `dplyr::collect()` to `summarise`, `select` columns, and/or `filter` rows prior to pulling the data into a local `data.frame`. Reducing the data that is pulled locally will speed up the data download speed and reduce your memory usage.\n\n\n")

}else{

forecast_score <- list(
"id" = id_value,
"description" = description_string,
"stac_version"= "1.0.0",
"license"= "CC0-1.0",
"stac_extensions"= list("https://stac-extensions.github.io/table/v1.2.0/schema.json"),
'type' = 'Collection',
#"sci:publications" = NULL,
'links' = c(group_var_items,#generate_group_variable_items(variables = group_var_values)
list(
list(
"rel" = "parent",
"type"= "application/json",
"href" = '../collection.json'
),
list(
"rel" = "root",
"type" = "application/json",
"href" = '../collection.json'
),
list(
"rel" = "self",
"type" = "application/json",
"href" = 'collection.json'
),
list(
"rel" = "cite-as",
"href" = catalog_config$citation_doi_link
),
list(
"rel" = "about",
"href" = about_string,
"type" = "text/html",
"title" = about_title
),
list(
"rel" = "describedby",
"href" = dashboard_string,
"title" = dashboard_title,
"type" = "text/html"
)
)),
"title" = theme_title,
"extent" = list(
"spatial" = list(
#'bbox' = list(list(stac4cast::get_bbox(site_metadata = catalog_config$site_metadata_url, sites = group_sites)))),
'bbox' = list(stac4cast::get_bbox(site_metadata = catalog_config$site_metadata_url, sites = group_sites))),
"temporal" = list(
'interval' = list(list(
paste0(start_date,"T00:00:00Z"),
paste0(end_date,"T00:00:00Z"))
))
),
"table:columns" = stac4cast::build_table_columns_full_bucket(table_schema, table_description),
#"table:columns" = build_table_columns_full_bucket(table_schema, table_description),
'assets' = list(
'data' = list(
"href" = aws_href_link,
"type"= "application/x-parquet",
"title"= 'Database Access',
"roles" = list('data'),
"description"= aws_asset_description
),
'thumbnail' = list(
"href"= thumbnail_link,
"type"= "image/JPEG",
"roles" = list('thumbnail'),
"title"= thumbnail_title
)
)
)

}else{ ## building group json

aws_asset_link <- paste0('"',"s3://anonymous@",
aws_download_path,
Expand All @@ -77,84 +150,84 @@ build_group_variables <- function(table_schema,
group_var_vector <- paste0('"', paste(group_var_vector, collapse='", "'), '"')
aws_asset_description <- paste0("Use `arrow` for remote access to the database. This R code will return results for the NEON Ecological Forecasting Aquatics theme.\n\n### R\n\n```{r}\n# Use code below\n\nall_results <- arrow::open_dataset(",aws_asset_link,")\ndf <- all_results |>\n dplyr::filter(variable %in% c(", group_var_vector,")) |>\n dplyr::collect()\n\n```
\n\nYou can use dplyr operations before calling `dplyr::collect()` to `summarise`, `select` columns, and/or `filter` rows prior to pulling the data into a local `data.frame`. Reducing the data that is pulled locally will speed up the data download speed and reduce your memory usage.\n\n\n")
}

forecast_score <- list(
"id" = id_value,
"description" = description_string,
"stac_version"= "1.0.0",
"license"= "CC0-1.0",
"stac_extensions"= list("https://stac-extensions.github.io/scientific/v1.0.0/schema.json",
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json",
"https://stac-extensions.github.io/table/v1.2.0/schema.json"),
'type' = 'Collection',
"sci:doi" = catalog_config$citation_doi,
"sci:publications" = stac4cast::build_publication_items(citation_values, doi_values),
#"sci:publications" = NULL,
'links' = c(group_var_items,#generate_group_variable_items(variables = group_var_values)
list(
list(
"rel" = "parent",
"type"= "application/json",
"href" = '../collection.json'
),
list(
"rel" = "root",
"type" = "application/json",
"href" = '../collection.json'
),
list(
"rel" = "self",
"type" = "application/json",
"href" = 'collection.json'
),
list(
"rel" = "cite-as",
"href" = catalog_config$citation_doi_link
),
list(
"rel" = "about",
"href" = about_string,
"type" = "text/html",
"title" = about_title
),

forecast_score <- list(
"id" = id_value,
"description" = description_string,
"stac_version"= "1.0.0",
"license"= "CC0-1.0",
"stac_extensions"= list("https://stac-extensions.github.io/scientific/v1.0.0/schema.json",
"https://stac-extensions.github.io/table/v1.2.0/schema.json"),
'type' = 'Collection',
"sci:doi" = catalog_config$citation_doi,
"sci:publications" = stac4cast::build_publication_items(citation_values, doi_values),
#"sci:publications" = NULL,
'links' = c(group_var_items,#generate_group_variable_items(variables = group_var_values)
list(
"rel" = "describedby",
"href" = dashboard_string,
"title" = dashboard_title,
"type" = "text/html"
)
)),
"title" = theme_title,
"extent" = list(
"spatial" = list(
#'bbox' = list(list(stac4cast::get_bbox(site_metadata = catalog_config$site_metadata_url, sites = group_sites)))),
'bbox' = list(stac4cast::get_bbox(site_metadata = catalog_config$site_metadata_url, sites = group_sites))),
"temporal" = list(
'interval' = list(list(
paste0(start_date,"T00:00:00Z"),
paste0(end_date,"T00:00:00Z"))
))
),
"table:columns" = stac4cast::build_table_columns_full_bucket(table_schema, table_description),
#"table:columns" = build_table_columns_full_bucket(table_schema, table_description),
'assets' = list(
'data' = list(
"href" = aws_href_link,
"type"= "application/x-parquet",
"title"= 'Database Access',
"roles" = list('data'),
"description"= aws_asset_description
list(
"rel" = "parent",
"type"= "application/json",
"href" = '../collection.json'
),
list(
"rel" = "root",
"type" = "application/json",
"href" = '../collection.json'
),
list(
"rel" = "self",
"type" = "application/json",
"href" = 'collection.json'
),
list(
"rel" = "cite-as",
"href" = catalog_config$citation_doi_link
),
list(
"rel" = "about",
"href" = about_string,
"type" = "text/html",
"title" = about_title
),
list(
"rel" = "describedby",
"href" = dashboard_string,
"title" = dashboard_title,
"type" = "text/html"
)
)),
"title" = theme_title,
"extent" = list(
"spatial" = list(
#'bbox' = list(list(stac4cast::get_bbox(site_metadata = catalog_config$site_metadata_url, sites = group_sites)))),
'bbox' = list(stac4cast::get_bbox(site_metadata = catalog_config$site_metadata_url, sites = group_sites))),
"temporal" = list(
'interval' = list(list(
paste0(start_date,"T00:00:00Z"),
paste0(end_date,"T00:00:00Z"))
))
),
'thumbnail' = list(
"href"= thumbnail_link,
"type"= "image/JPEG",
"roles" = list('thumbnail'),
"title"= thumbnail_title
)
"table:columns" = stac4cast::build_table_columns_full_bucket(table_schema, table_description),
#"table:columns" = build_table_columns_full_bucket(table_schema, table_description),
'assets' = list(
'data' = list(
"href" = aws_href_link,
"type"= "application/x-parquet",
"title"= 'Database Access',
"roles" = list('data'),
"description"= aws_asset_description
),
'thumbnail' = list(
"href"= thumbnail_link,
"type"= "image/JPEG",
"roles" = list('thumbnail'),
"title"= thumbnail_title
)
)
)

}

dest <- destination_path
json <- file.path(dest, 'collection.json')
Expand Down

0 comments on commit 4d21a95

Please sign in to comment.