Skip to content

Commit

Permalink
rerunning forecast anomalies to replace NAs in files
Browse files Browse the repository at this point in the history
  • Loading branch information
emmamendelsohn committed Dec 8, 2023
1 parent 0304ded commit f7dd0cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions R/calculate_forecasts_anomalies.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ calculate_forecasts_anomalies <- function(ecmwf_forecasts_transformed,
existing_files <- list.files(forecasts_anomalies_directory)
if(save_filename %in% existing_files & !overwrite) {
message("file already exists, skipping download")
saved <- read_parquet(file.path(forecasts_anomalies_directory, save_filename))
saved_check <- col_na(saved)
if(!any(saved_check)) {
return(file.path(forecasts_anomalies_directory, save_filename))
}else{
message("NAs found, regenerating file")
}
}

# Open dataset to transformed data
Expand Down
5 changes: 4 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ all_targets <- function(env = parent.env(environment()), type = "tar_target") {
#
# tar_load_s3 <- function(target_name, ...) {
#
# }
# }

#' Get NAs
col_na <- function(df) purrr::map_lgl(df, ~any(is.na(.)))

0 comments on commit f7dd0cd

Please sign in to comment.