LakeEnsemblR

An R package that facilitates multi-model ensembles for lake thermodynamics.
https://github.com/aemon-j/lakeensemblr

Category: Hydrosphere
Sub Category: Freshwater and Hydrology

Last synced: about 13 hours ago
JSON representation

Repository metadata

An R package that facilitates multi-model ensembles for lake thermodynamics. Also includes tools for calibration, sensitivity analysis and data visualization.

README.Rmd

          ---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%", echo = TRUE, warning = FALSE, message=FALSE
)
```

# LakeEnsemblR LakeEnsemblR website


[![R-CMD-check](https://github.com/aemon-j/LakeEnsemblR/workflows/R-CMD-check/badge.svg)](https://github.com/aemon-j/LakeEnsemblR/actions) [![codecov](https://codecov.io/github/aemon-j/LakeEnsemblR/branch/master/graphs/badge.svg)](https://codecov.io/github/aemon-j/LakeEnsemblR/) [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![DOI](https://zenodo.org/badge/217581132.svg)](https://zenodo.org/badge/latestdoi/217581132)
[![Citation Badge](https://api.juleskreuer.eu/citation-badge.php?doi=10.1016/j.envsoft.2021.105101)](https://juleskreuer.eu/projekte/citation-badge/)


Tools for running an ensemble of lake models using standardised input data. Lake models currently incorporated are [Freshwater Lake Model (FLake)](http://www.flake.igb-berlin.de/), [General Lake Model (GLM)](http://aed.see.uwa.edu.au/research/models/GLM/), [General Ocean Turbulence Model (GOTM)](https://gotm.net/) (lake-branch), [Simstrat](https://www.eawag.ch/en/department/surf/projects/simstrat/), and [MyLake](https://github.com/biogeochemistry/MyLake_public).

You can find example setups here: https://github.com/aemon-j/LER_examples.

Check out our published paper [LakeEnsemblR: An R package that facilitates ensemble modelling of lakes](https://doi.org/10.1016/j.envsoft.2021.105101).

In v1.1, some changes occurred in the configuration file. If you want to adapt your existing setup, see: https://github.com/aemon-j/LakeEnsemblR/wiki/From-v1.0-to-v1.1
  

## Installation

Prior to installing the package, you will need to install the packages which run the models and the tools for manipulating model data from GitHub. It is recommended to do this each time before testing to ensure all packages are up-to-date as parallel development might be ongoing.

``` r
# install.packages("remotes")
remotes::install_github("GLEON/rLakeAnalyzer")
remotes::install_github("aemon-j/GLM3r", ref = "v3.1.1")
remotes::install_github("USGS-R/glmtools", ref = "ggplot_overhaul")
remotes::install_github("aemon-j/FLakeR", ref = "inflow")
remotes::install_github("aemon-j/GOTMr")
remotes::install_github("aemon-j/gotmtools")
remotes::install_github("aemon-j/SimstratR")
remotes::install_github("aemon-j/MyLakeR")
```

Following this you can install `LakeEnsemblR` from Github with:

``` r
remotes::install_github("aemon-j/LakeEnsemblR")
```

Should you run into unexpected installation issues, please have a look at this page: https://github.com/aemon-j/LakeEnsemblR/wiki/Installation-issues

### Visualize

You can download [PyNcView](http://sourceforge.net/projects/pyncview/), a cross-platform NetCDF viewer, for viewing the NetCDF output.

## Example model run

```{r copy-files,echo = TRUE,result = "hide",warning = FALSE,message=FALSE}

# 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

```

```{r, setup, include=FALSE}
knitr::opts_knit$set(root.dir = "example/feeagh")
```

```{r run-LER,result = "hide",warning = FALSE,message=FALSE}

# 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)
```


## Post-processing

```{r post-process}

# Load libraries for post-processing
library(gotmtools)
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 = 14) + 
  scale_colour_gradientn(limits = c(0, 21),
                         colours = rev(RColorBrewer::brewer.pal(11, "Spectral")))

p1

```

## Plot Ensemble output

```{r plot-ensemble}
# Plot ensemble mean at 0.9m
model = c("FLake", "GLM", "GOTM", "Simstrat", "MyLake")
plot_ensemble(ncdf = ncdf, model = model, var = "temp", depth = 0.9)

# Load watertemp from netCDF file as a list
wtemp <- load_var(ncdf = ncdf, var = "temp", return = "list")
names(wtemp)

# Plot residual diagnostic plots
plots <- plot_resid(var_list = wtemp) # Plot residuals - returns a list of plots
names(plots) #

# Plot residuals vs. depth ("res_depth")
plots[[2]]

# Analyse the netCDF output
out <- analyse_ncdf(ncdf, model = model, spin_up = 0)
names(out)
str <- out[["strat"]]
str[str$year == 2010, ]
stats <- out[["stats"]]
stats
```

See the [vignette](articles/lakeensemblr-overview.html) for further examples.


# How do I setup `LakeEnsemblR` for my lake?

Head on over to our [website](https://aemon-j.github.io/LakeEnsemblR/index.html) for guides on how to set up your lake for LakeEnsemblR

# How do I contribute new code back to the `LakeEnsemblR` project?

In order to contribute to this code, we recommend the following workflow:

1.  "fork" this repository to your own personal github account

2.  clone the github repository to your computer:

    $git clone 

3.  modify code or add new functionality, save the code

4.  add the repository master to a remote master called "upstream"

    $cd LakeEnsemblR

    $git remote add upstream 

5.  before pushing your changes to your repository, pull in the current version of the aemon-j master:

    $git fetch upstream

6.  merge these differences with your own "master" version:

    $git merge upstream/master

7.  push your changes to your github repository, in addition to changes made by pulling in the aemon-j master:

    $git push

8.  submit a pull request to aemon-j master using your account at github.com


# Information for macOS users

To ensure that all model binaries work, we advise you to install the specific macOS packages (currently in a separated branch):
```
remotes::install_github("aemon-j/GLM3r", ref = "macOS")
remotes::install_github("aemon-j/FLakeR", ref = "macOS")
remotes::install_github("aemon-J/GOTMr", ref = "macOS")
remotes::install_github("aemon-j/SimstratR", ref = "macOS")
```

Unfortunately, this means your version of GLM will differ compared to the one included in the executables for Windows and Linux. GLM on macOS will be version 3.2.0a8 (most recent one on January 13, 2022), Windows/Linux use 3.1.1. 

        

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 5 days ago

Total Commits: 1,001
Total Committers: 14
Avg Commits per committer: 71.5
Development Distribution Score (DDS): 0.723

Commits in past year: 65
Committers in past year: 4
Avg Commits per committer in past year: 16.25
Development Distribution Score (DDS) in past year: 0.215

Name Email Commits
tadhg.m t****e@d****e 277
Jorrit Mesman j****n@g****m 236
JFeldbauer j****r@p****e 230
tadhg-moore t****m@v****u 75
Robert l****a@g****m 61
Tadhg t****g@l****m 51
Rachel Pilla p****m@m****u 33
Jordan S Read j****d@u****v 20
aemon-j 4****j 8
JFeldbauer j****r@t****e 4
Stefano Zaghi s****i@g****m 3
adelany8 a****y@g****m 1
Jason Venkiteswaran j****n@g****m 1
Johannes Feldbauer s****3@t****e 1

Committer domains:


Issue and Pull Request metadata

Last synced: 5 months ago

Total issues: 12
Total pull requests: 7
Average time to close issues: 6 months
Average time to close pull requests: 1 day
Total issue authors: 10
Total pull request authors: 3
Average comments per issue: 2.42
Average comments per pull request: 0.14
Merged pull request: 4
Bot issues: 0
Bot pull requests: 0

Past year issues: 5
Past year pull requests: 5
Past year average time to close issues: about 23 hours
Past year average time to close pull requests: 3 days
Past year issue authors: 4
Past year pull request authors: 3
Past year average comments per issue: 0.0
Past year average comments per pull request: 0.2
Past year merged pull request: 2
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/aemon-j/lakeensemblr

Top Issue Authors

  • geo-hy (2)
  • MoBerg97 (2)
  • jorritmesman (1)
  • Bkemanga (1)
  • HLJ1129 (1)
  • ShenBoms (1)
  • Liluoq (1)
  • lifewangyiming (1)
  • simontye (1)
  • zgcao (1)

Top Pull Request Authors

  • jorritmesman (3)
  • tadhg-moore (3)
  • JFeldbauer (1)

Top Issue Labels

Top Pull Request Labels


Dependencies

DESCRIPTION cran
  • R >= 3.5 depends
  • FME * imports
  • RColorBrewer * imports
  • configr * imports
  • dplyr * imports
  • ggplot2 * imports
  • glmtools * imports
  • gotmtools * imports
  • import * imports
  • lubridate * imports
  • ncdf4 * imports
  • plyr * imports
  • reshape2 * imports
  • zoo * imports
  • FLakeR * suggests
  • GLM3r * suggests
  • GOTMr * suggests
  • MyLakeR * suggests
  • SimstratR * suggests
  • kableExtra * suggests
  • knitr * suggests
  • lintr * suggests
  • rmarkdown * suggests
  • rstudioapi * suggests
  • testthat * suggests
.github/workflows/build.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • codecov/codecov-action v1.2.1 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/codecov.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/lint.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4 composite
  • actions/checkout v3 composite
  • actions/download-artifact v4 composite
  • actions/upload-artifact v4 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite

Score: 6.628041376179533