3. Running LakeEnsemblR - aemon-j/LakeEnsemblR GitHub Wiki
Once you have your hypsograph, water temperature observations and meteorological files prepared tunning LakeEnsemblR is relatively straightforward.
# Install packages - Ensure all packages are up to date - parallel development ongoing
#install.packages("devtools")
devtools::install_github("aemon-j/GLM3r", ref = "v3.1.1")
devtools::install_github("USGS-R/glmtools", ref = "ggplot_overhaul")
devtools::install_github("aemon-j/FLakeR", ref = "inflow")
devtools::install_github("aemon-j/GOTMr")
devtools::install_github("aemon-j/gotmtools")
devtools::install_github("aemon-j/SimstratR")
devtools::install_github("aemon-j/MyLakeR")
# Load libraries
library(gotmtools)
library(LakeEnsemblR)
# Load LakeEnsemblR
library(LakeEnsemblR)
# Copy template folder
template_folder <- system.file("extdata/feeagh", package= "LakeEnsemblR")
dir.create("example") # Create example folder
file.copy(from = template_folder, to = "example", recursive = TRUE)
setwd("example/feeagh") # Change working directory to example folder
# Set config file & models
config_file <- 'LakeEnsemblR.yaml'
model <- c("FLake", "GLM", "GOTM", "Simstrat", "MyLake")
# Example run
# 1. Export settings - creates directories with all model setups and exports settings from the LER configuration file
export_config(config_file = config_file, model = model)
# 2. Run ensemble lake models
run_ensemble(config_file = config_file, model = model)
# Load libraries for post-processing
library(ggplot2)
## Plot model output using gotmtools/ggplot2
# Extract names of all the variables in netCDF
ncdf <- 'output/ensemble_output.nc'
vars <- gotmtools::list_vars(ncdf)
vars # Print variables
p1 <- plot_heatmap(ncdf)
p1
# Change the theme and increase text size for saving
p1 <- p1 +
theme_classic(base_size = 24) +
scale_colour_gradientn(limits = c(0, 21),
colours = rev(RColorBrewer::brewer.pal(11, "Spectral")))
# Save as a png file
ggsave('output/ensemble_heatmap.png', p1, dpi = 300,width = 384,height = 280, units = 'mm')