knitr::opts_chunk$set(echo = TRUE)
These data are used for internal checks to be sure that data requested from the POWER dataset are valid. The POWER list of parameters that can be queried is available as an API query from the POWER server.
The list structure will be
parameters
HOURLY_AG
parameter_1
...parameter_n
DAILY_AG
parameter_1
...parameter_n
MONTHLY_AG
parameter_1
...parameter_n
CLIMATOLOGY_AG
parameter_1
...parameter_n
HOURLY_RE
parameter_1
...parameter_n
DAILY_RE
parameter_1
...parameter_n
MONTHLY_RE
parameter_1
...parameter_n
CLIMATOLOGY_RE
parameter_1
...parameter_n
HOURLY_SB
parameter_1
...parameter_n
DAILY_SB
parameter_1
...parameter_n
MONTHLY_SB
parameter_1
...parameter_n
CLIMATOLOGY_SB
parameter_1
...parameter_n
...and so on.
Using purrr::map2
and jsonlite::fromJSON()
read the JSON file into R creating a single, nested list and reorder it alphabetically by parameter name.
library(purrr) library(jsonlite) temporal_api <- c("HOURLY", "DAILY", "MONTHLY", "CLIMATOLOGY") community <- c("AG", "RE", "SB") # create all combinations vals <- expand.grid(temporal_api, community, stringsAsFactors = FALSE) # create equal length vectors for purrr::map2 temporal_api <- vals[, 1] community <- vals[, 2] base_url <- "https://power.larc.nasa.gov/api/system/manager/parameters?" power_pars <- map2( .x = temporal_api, .y = community, .f = ~ fromJSON(sprintf( "%stemporal=%s&community=%s", base_url, .x, .y )) ) names(power_pars) <- paste(temporal_api, community, sep = "_") # create a list of vectors for each temporal API/par combination for easier # checking and validation parameters <- vector(mode = "list", length = length(power_pars)) names(parameters) <- names(power_pars) for (i in names(power_pars)) { parameters[[i]] <- names(power_pars[[i]]) } parameters <- map(.x = parameters, .f = sort)
nasapower
packageUsing usethis::use_data()
save the list as an R data object for use in the nasapower package.
These values will not be exposed to the user and so will not be documented as previously.
Users will be be pointed to functions to interact directly with the POWER APIs to query information for the temporal API/community combinations or for the parameters themselves.
usethis::use_data(parameters, overwrite = TRUE, internal = TRUE)
sessioninfo::session_info()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.