Skip to content

Commit

Permalink
DESCRIPTION file; date length checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellmanware committed Jul 23, 2024
1 parent de63f53 commit 5524e1f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Config/Needs/website: tidyverse/tidytemplate
Config/testhat/edition: 3
License: MIT + file LICENSE
URL: https://github.com/NIEHS/amadeus,
BugReports: https://github.com/NIEHS/amadeus/issues
BugReports: https://github.com/NIEHS/amadeus/issues
3 changes: 3 additions & 0 deletions R/calculate_covariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,9 @@ calc_lagged <- function(
locs_id,
time_id = "time",
geom = FALSE) {
#### check years
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### geom and from
if (geom && !("SpatVector" %in% class(from))) {
stop(
Expand Down
27 changes: 27 additions & 0 deletions R/download.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ download_aqs <-
download_permit(acknowledgement = acknowledgement)
#### 2. check for null parameters
check_for_null_parameters(mget(ls()))
#### check years
stopifnot(length(year) == 2)
year <- year[order(year)]
#### 3. directory setup
directory_original <- download_sanitize_path(directory_to_save)
directories <- download_setup_dir(directory_original, zip = TRUE)
Expand Down Expand Up @@ -480,6 +483,9 @@ download_geos <- function(
download_permit(acknowledgement = acknowledgement)
#### 2. check for null parameters
check_for_null_parameters(mget(ls()))
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### 3. directory setup
download_setup_dir(directory_to_save)
directory_to_save <- download_sanitize_path(directory_to_save)
Expand Down Expand Up @@ -908,6 +914,9 @@ download_merra2 <- function(
#### directory setup
download_setup_dir(directory_to_save)
directory_to_save <- download_sanitize_path(directory_to_save)
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### check for null parameters
check_for_null_parameters(mget(ls()))
#### check if collection is recognized
Expand Down Expand Up @@ -1209,6 +1218,9 @@ download_narr <- function(
download_permit(acknowledgement = acknowledgement)
#### 2. check for null parameters
check_for_null_parameters(mget(ls()))
#### check years
stopifnot(length(year) == 2)
year <- year[order(year)]
#### 3. directory setup
download_setup_dir(directory_to_save)
directory_to_save <- download_sanitize_path(directory_to_save)
Expand Down Expand Up @@ -1870,6 +1882,9 @@ download_hms <- function(
download_permit(acknowledgement = acknowledgement)
#### 2. check for null parameters
check_for_null_parameters(mget(ls()))
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### 3. directory setup
directory_original <- download_sanitize_path(directory_to_save)
directories <- download_setup_dir(directory_original, zip = TRUE)
Expand Down Expand Up @@ -2252,6 +2267,9 @@ download_modis <- function(
#### 2. directory setup
download_setup_dir(directory_to_save)
directory_to_save <- download_sanitize_path(directory_to_save)
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]

#### 3. check for NASA earth data token
if (is.null(nasa_earth_data_token)) {
Expand Down Expand Up @@ -2588,6 +2606,9 @@ download_tri <- function(
#### 2. directory setup
download_setup_dir(directory_to_save)
directory_to_save <- download_sanitize_path(directory_to_save)
#### check years
stopifnot(length(year) == 2)
year <- year[order(year)]
#### 3. define measurement data paths
url_download <-
"https://data.epa.gov/efservice/downloads/tri/mv_tri_basic_download/"
Expand Down Expand Up @@ -3466,6 +3487,9 @@ download_gridmet <- function(
download_permit(acknowledgement = acknowledgement)
#### check for null parameters
check_for_null_parameters(mget(ls()))
#### check years
stopifnot(length(year) == 2)
year <- year[order(year)]
#### directory setup
download_setup_dir(directory_to_save)
directory_to_save <- download_sanitize_path(directory_to_save)
Expand Down Expand Up @@ -3605,6 +3629,9 @@ download_terraclimate <- function(
download_permit(acknowledgement = acknowledgement)
#### check for null parameters
check_for_null_parameters(mget(ls()))
#### check years
stopifnot(length(year) == 2)
year <- year[order(year)]
#### directory setup
download_setup_dir(directory_to_save)
directory_to_save <- download_sanitize_path(directory_to_save)
Expand Down
18 changes: 18 additions & 0 deletions R/process.R
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,9 @@ process_hms <- function(
path <- download_sanitize_path(path)
#### check for variable
check_for_null_parameters(mget(ls()))
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### identify file paths
paths <- list.files(
path,
Expand Down Expand Up @@ -1795,6 +1798,9 @@ process_narr <- function(
path <- download_sanitize_path(path)
#### check for variable
check_for_null_parameters(mget(ls()))
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### identify file paths
data_paths <- list.files(
path,
Expand Down Expand Up @@ -2023,6 +2029,9 @@ process_geos <-
path <- download_sanitize_path(path)
#### check for variable
check_for_null_parameters(mget(ls()))
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### identify file paths
paths <- list.files(
path,
Expand Down Expand Up @@ -2212,6 +2221,9 @@ process_merra2 <-
path <- download_sanitize_path(path)
#### check for variable
check_for_null_parameters(mget(ls()))
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### identify file paths
paths <- list.files(
path,
Expand Down Expand Up @@ -2396,6 +2408,9 @@ process_gridmet <- function(
...) {
#### directory setup
path <- download_sanitize_path(path)
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
#### check for variable
check_for_null_parameters(mget(ls()))
variable_checked <- process_variable_codes(
Expand Down Expand Up @@ -2562,6 +2577,9 @@ process_terraclimate <- function(
path <- download_sanitize_path(path)
#### check for variable
check_for_null_parameters(mget(ls()))
#### check dates
stopifnot(length(date) == 2)
date <- date[order(as.Date(date))]
variable_checked <- process_variable_codes(
variables = variable,
source = "terraclimate"
Expand Down

0 comments on commit 5524e1f

Please sign in to comment.