#' get_reflectance
#'
#' This is a function to get the reflectance for a specific output simulated by SCOPE.
#' @param SCOPE_dir the diretory patch of SCOPE
#' @param output_file default "reflectance.csv" output
#' @param Simulation_Name simulation name stating the directory name generated by the run_SCOPE function.
#' @return The result is a data.frame with all the predicted output per simulation name and date.
#' @examples
#' Examples of uses of the get_reflectance function
#' ###############
#' library(tidyverse)
#'
#' reflectance <- get_reflectance(SCOPE_dir = "D:/SCOPE-master/",
#' Simulation_Name = "pixel_1169")
#'
#' ggplot() +
#' geom_line(aes(y = reflectance[[1]]$X9, x = reflectance[[1]]$nm), colour="green") +
#' geom_line(aes(y = reflectance[[1]]$X35, x = reflectance[[1]]$nm), colour="darkgreen")
#'
#' @export
get_reflectance <- function(
SCOPE_dir = "D:/SCOPE-master/",
Simulation_Name,
output_file = "reflectance.csv"
){
Outputs_files <- list.files(paste0(path=grep(Simulation_Name,
list.dirs(path=paste0(SCOPE_dir, "output"),
full.names = TRUE,
recursive = FALSE),
value = TRUE),
"/", collapse = NULL, recycle0 = FALSE),
pattern= output_file,
full.names = TRUE)
reflectances <- lapply(1:length(Outputs_files),
function(i) readr::read_csv(Outputs_files[i], col_names = F, skip = 2,
readr::cols(.default = readr::col_double())))
reflectances_t <- lapply(1:length(Outputs_files),
function(i) tibble(data.frame("nm"=400:2400, t(data.frame(reflectances[[i]]))[1:2001,])))
return(reflectances_t)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.