-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from lindsayplatt/pipeline_new_projected_GLM
Add pipeline changes to run annual metrics for new GCM GLM outputs
- Loading branch information
Showing
9 changed files
with
231 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
R_LIBS_USER="/cxfs/projects/usgs/water/iidd/data-sci/lake-temp/lake-temperature-out/Rlib_3_6":"/opt/ohpc/pub/usgs/libs/gnu8/R/3.6.3/lib64/R/library" | ||
R_LIBS_USER="/caldera/projects/usgs/water/iidd/datasci/lake-temp/lake-temperature-out/Rlib_3_6":"/home/software/tallgrass/arc/apps/R/3.6.3/lib64/R/library" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
#' Indicate all files from a single directory into a single hash table | ||
indicate_dir_files <- function(out_ind, file_dir, file_pattern) { | ||
files_to_indicate <- list.files(path = file_dir, | ||
pattern = file_pattern, | ||
full.names = TRUE) | ||
sc_indicate(out_ind, data_file = files_to_indicate) | ||
} | ||
|
||
#' Use `out_dir` if you are copying multiple files and saving | ||
#' a hash table as the ind. Leave as `NULL` if you are only | ||
#' copying and saving one file. | ||
copy_caldera_files <- function(out_ind, files_in, out_dir = NULL) { | ||
|
||
if(is.null(out_dir)) { | ||
files_out <- as_data_file(out_ind) | ||
} else { | ||
files_out <- file.path(out_dir, basename(files_in)) | ||
} | ||
|
||
file.copy(from = files_in, to = files_out) | ||
sc_indicate(out_ind, data_file = files_out) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Visualize output | ||
|
||
plot_annual_metric_summaries <- function(target_name, in_file, target_dir, model_id_colname) { | ||
|
||
if(!dir.exists(target_dir)) dir.create(target_dir) | ||
|
||
annual_metrics_data <- readr::read_csv(in_file) | ||
|
||
cols2plot <- names(annual_metrics_data)[which(!grepl(sprintf("site_id|GCM|year|_dt|_date|%s", model_id_colname), names(annual_metrics_data)))] | ||
|
||
annual_metrics_long <- annual_metrics_data %>% | ||
select(-matches("_dt|_date")) %>% | ||
pivot_longer(all_of(cols2plot), names_to = "metric") | ||
|
||
plot_groups <- split(cols2plot, ceiling(seq_along(cols2plot)/10)) | ||
files_out <- purrr::map(plot_groups, function(i) { | ||
p <- annual_metrics_long %>% | ||
filter(metric %in% i) %>% | ||
ggplot(aes(x = year, y = value)) + | ||
facet_grid(metric ~ ., scales = "free_y") + | ||
geom_point(alpha = 0.2, stroke = 0, shape = 16, size = 2) | ||
ggsave(sprintf("%s/%s_THROUGH_%s.png", target_dir, i[1], i[10]), | ||
plot = p, width = 5, height = 8) | ||
}) | ||
|
||
scipiper::sc_indicate(target_name, data_file = unlist(files_out)) | ||
} | ||
|
||
|
||
|