Skip to contents

Introduction

The Lake Ecosystem Research New Zealand Model Platform (LERNZmp) is a web platform that provides a user-friendly interface to the lake ecosystem model output for New Zealand lakes. The platform is designed to provide a simple way to explore the model output across multiple lakes and also to compare the model results with observed data.

The platform is located here: LERNZmp. Select and load a lake model output on the “Overview” tab. The model output can be downloaded in the “Download Models” tab. This downloads a “.zip” folder containing the model output for the selected lake(s) as “.rds” files and a lake metadata file “LERNZmp_lake_metadata.csv”.

Using LERNZmp output with AEME

Once you have downloaded the LERNZmp model output and unzipped the folder, you should a similar file structure to the following:

list.files("lernzmp")
#> [1] "LERNZmp_lake_metadata.csv" "LID11133.rds"             
#> [3] "LID40102.rds"

LERNZmp metadata

The metadata file contains information about the all the lakes in the LERNZmp platform. This includes the lake ID, name surface area (ha), region, geomorphic type, depth, depth measurement (measured or predicted), data (no data/minimal data/limited and irregular/periodic but sparse/seasonal but detailed) and lernzmp file name.

metadata <- read.csv("lernzmp/LERNZmp_lake_metadata.csv")
head(metadata)
#>        ID            Name   Area     Region Geomorphic.type Depth
#> 1   LID 1           Onoke 622.34 Wellington       Shoreline  8.72
#> 2   LID 3 Kohangapiripiri  10.82 Wellington       Shoreline 14.43
#> 3   LID 4     Kohangatera  21.31 Wellington       Shoreline 14.80
#> 4 LID 119         LID 119  41.87 Wellington        Riverine  3.55
#> 5 LID 195         Nganoke   3.10 Wellington        Riverine  3.74
#> 6 LID 229          Pounui  45.95 Wellington        Tectonic    NA
#>   Depth.measurement         Data aeme_file
#> 1          Measured Minimal Data      LID1
#> 2         Predicted      No data      LID3
#> 3         Predicted      No data      LID4
#> 4         Predicted      No data    LID119
#> 5         Predicted      No data    LID195
#> 6         Predicted      No data    LID229

RDS files

RDS files are binary files that store R objects, such as data sets, and are a native format for R. RDS files preserve data types and classes and are generally smaller than their text file counterparts. The AEME objects are an S4 object of the class Aeme. This object class an store model configuration, inputs and outputs and allows for the easy transfer of a lake model setup.

The lakes included in this example have ID’s LID11133 and LID40102. We will filter the metadata to examine these two lakes.

metadata <- metadata |> 
  dplyr::filter(aeme_file %in% c("LID11133", "LID40102"))
metadata
#>          ID    Name    Area        Region Geomorphic.type Depth
#> 1 LID 11133 Rotorua 8060.23 Bay of Plenty        Volcanic 45.27
#> 2 LID 40102  Rotoma 1113.68 Bay of Plenty        Volcanic 89.13
#>   Depth.measurement                  Data aeme_file
#> 1          Measured Seasonal but Detailed  LID11133
#> 2          Measured Seasonal but Detailed  LID40102

These are lakes Rotorua (LID11133) and Rotoma (LID40102), respectively.

Build AEME models

We will now build AEME models for these two lakes using the LERNZmp model output. We will first load the AEME object from the “.rds” files.

The Aeme object contains the lake metadata, model output, and model controls. More details can be found vignette("intro-aeme"). It is an S4 object of the class Aeme.

First, make sure to install the AEME package.

# install.packages("pak")
pak::pak("limnotrack/AEME")

Once installed, load the AEME package.

library(AEME)
#> 
#> Attaching package: 'AEME'
#> The following object is masked from 'package:stats':
#> 
#>     time

Now, we will load the AEME object for Lake Rotorua (LID11133).

aeme <- readRDS("lernzmp/LID11133.rds")
class(aeme)
#> [1] "Aeme"
#> attr(,"package")
#> [1] "AEME"

It can be printed to the console to see the contents of the object.

aeme
#>             AEME 
#> -------------------------------------------------------------------
#>   Lake
#> Rotorua (ID: LID11133); Lat: -38.09; Lon: 176.27; Elev: 284.88m; Depth: 48.15m;
#> Area: 80659960 m2; Shape file: Absent
#> -------------------------------------------------------------------
#>   Time
#> Start: 2013-07-01; Stop: 2023-06-30; Time step: 3600
#>  Spin up (days): GLM: 1095; GOTM: 1095; DYRESM: 1095
#> -------------------------------------------------------------------
#>   Configuration
#>     Model controls: Present
#>           Physical   |   Biogeochemical
#> DY-CD    : Absent     |   Absent 
#> GLM-AED  : Present    |   Present
#> GOTM-WET : Present    |   Present
#> -------------------------------------------------------------------
#>   Observations
#> Lake: Present; Level: Absent
#> -------------------------------------------------------------------
#>   Input
#> Inital profile: Present; Inital depth: 48.148m; Hypsograph: Present (n=95);
#> Meteo: Present; Use longwave: TRUE; Kw: 0.5666667
#> -------------------------------------------------------------------
#>   Inflows
#> Data: Present; Scaling factors: DY-CD: 1; GLM-AED: 1; GOTM-WET: 1
#> -------------------------------------------------------------------
#>   Outflows
#> Data: Present; Scaling factors: DY-CD: 1; GLM-AED: 1; GOTM-WET: 1
#> -------------------------------------------------------------------
#>   Water balance
#> Method: 2; Use: obs; Modelled: Absent; Water balance: Present
#> -------------------------------------------------------------------
#>   Parameters: 
#> Number of parameters: 18
#> -------------------------------------------------------------------
#>   Output: 
#> Number of ensembles: 1
#> DY-CD:    1
#> GLM-AED:  1
#> GOTM-WET: 1

This allows for quick inspection of all the different slots within the Aeme object. The lake section has the lake metadata, the time section has the start, stop and spin-up dates, the configuration section has the model configuration which allows for the building of the AEME models locally.

#> Building simulation for Rotorua [2024-11-18 05:20:59]
#> Building existing configuration for Rotorua [2024-11-18 05:20:59]
#> Missing state variables in inflows: CHM_oxy, NIT_don, NIT_pon, CAR_doc, CAR_poc, SIL_rsi, PHY_cyano, PHY_green, PHY_diatom, NCS_ss1
#> Added default values for missing variables.
#> Missing state variables in inflows: CHM_oxy, NIT_don, NIT_pon, CAR_doc, CAR_poc, SIL_rsi, PHY_cyano, PHY_green, PHY_diatom, NCS_ss1
#> Added default values for missing variables.
#> Missing state variables in inflows: CHM_oxy, NIT_don, NIT_pon, CAR_doc, CAR_poc, SIL_rsi, PHY_cyano, PHY_green, PHY_diatom, NCS_ss1
#> Added default values for missing variables.
#> Missing state variables in inflows: CHM_oxy, NIT_don, NIT_pon, CAR_doc, CAR_poc, SIL_rsi, PHY_cyano, PHY_green, PHY_diatom, NCS_ss1
#> Added default values for missing variables.
#> Missing state variables in inflows: CHM_oxy, NIT_don, NIT_pon, CAR_doc, CAR_poc, SIL_rsi, PHY_cyano, PHY_green, PHY_diatom, NCS_ss1
#> Added default values for missing variables.
#> Missing state variables in inflows: CHM_oxy, NIT_don, NIT_pon, CAR_doc, CAR_poc, SIL_rsi, PHY_cyano, PHY_green, PHY_diatom, NCS_ss1
#> Added default values for missing variables.
#> Missing state variables in inflows: CHM_oxy, NIT_pon, CAR_doc, CAR_poc, SIL_rsi, PHY_cyano, PHY_green, PHY_diatom, NCS_ss1
#> Added default values for missing variables.
#> No water level present. Using constant water level.
#> Correcting water balance using estimated outflows (method = 2).
#> Calculating lake level using lake depth and a sinisoidal function.
#> Warning in dir.create(lake_dir, showWarnings = TRUE): 'aeme\LID11133_rotorua'
#> already exists
#> Building GLM3-AED2 model for lake rotorua
#> Copied in AED nml file
#>    oxy_initial = 312.5 replaced with 312.5
#>    frp_initial = 0.1614 replaced with 0.1614
#>    dop_initial = 0.3229 replaced with 0.3229
#>    pop_initial = 0.3229 replaced with 0.3229
#>    amm_initial = 1.1423 replaced with 1.1423
#>    nit_initial = 0.4284 replaced with 0.4284
#>    don_initial = 21.4183 replaced with 21.4183
#>    pon_initial = 7.1394 replaced with 7.1394
#>    doc_initial = 41.6285 replaced with 41.6285
#>    poc_initial = 16.6514 replaced with 16.6514
#>    rsi_initial = 1 replaced with 1
#> PHY_cyano 0.24022 replaced with 0.24022
#> PHY_green 0.300275 replaced with 0.300275
#> PHY_diatom 0.300275 replaced with 0.300275
#>    ss_initial = 3 replaced with 3,
#> Building GOTM-WET for lake rotorua
#> instances/abiotic_water/initialization/sO2W 10 replaced with 10
#> instances/abiotic_water/initialization/sPO4W 0.005 replaced with 0.005
#> instances/abiotic_water/initialization/sPDOMW 0.01 replaced with 0.01
#> instances/abiotic_water/initialization/sPPOMW 0.01 replaced with 0.01
#> instances/abiotic_water/initialization/sNH4W 0.016 replaced with 0.016
#> instances/abiotic_water/initialization/sNO3W 0.006 replaced with 0.006
#> instances/abiotic_water/initialization/sNDOMW 0.3 replaced with 0.3
#> instances/abiotic_water/initialization/sNPOMW 0.1 replaced with 0.1
#> instances/abiotic_water/initialization/sDDOMW 0.5 replaced with 0.5
#> instances/abiotic_water/initialization/sDPOMW 0.2 replaced with 0.2
#> instances/abiotic_water/initialization/sSiO2W 1 replaced with 1
#> instances/cyanobacteria/initialization/sDW 0.2 replaced with 0.2
#> instances/cyanobacteria/initialization/sNW 0.03 replaced with 0.03
#> instances/cyanobacteria/initialization/sPW 0.0019 replaced with 0.0019
#> instances/greens/initialization/sDW 0.1 replaced with 0.1
#> instances/greens/initialization/sNW 0.015 replaced with 0.015
#> instances/greens/initialization/sPW 0.00094 replaced with 0.00094
#> instances/diatoms/initialization/sDW 0.25 replaced with 0.25
#> instances/diatoms/initialization/sNW 0.038 replaced with 0.038
#> instances/diatoms/initialization/sPW 0.0024 replaced with 0.0024
#> instances/abiotic_water/initialization/sDIMW 3 replaced with 3
list.files("aeme", recursive = TRUE)
#>  [1] "LID11133_rotorua/glm_aed/aed2/aed2.nml"                  
#>  [2] "LID11133_rotorua/glm_aed/aed2/aed2_phyto_pars.nml"       
#>  [3] "LID11133_rotorua/glm_aed/aed2/aed2_zoop_pars.nml"        
#>  [4] "LID11133_rotorua/glm_aed/bcs/inflow_lumped.csv"          
#>  [5] "LID11133_rotorua/glm_aed/bcs/inflow_NZS4081641.csv"      
#>  [6] "LID11133_rotorua/glm_aed/bcs/inflow_NZS4083363.csv"      
#>  [7] "LID11133_rotorua/glm_aed/bcs/inflow_NZS4084132.csv"      
#>  [8] "LID11133_rotorua/glm_aed/bcs/inflow_NZS4084816.csv"      
#>  [9] "LID11133_rotorua/glm_aed/bcs/inflow_NZS4086165.csv"      
#> [10] "LID11133_rotorua/glm_aed/bcs/inflow_precip.csv"          
#> [11] "LID11133_rotorua/glm_aed/bcs/meteo_glm.csv"              
#> [12] "LID11133_rotorua/glm_aed/bcs/outflow_wbal.csv"           
#> [13] "LID11133_rotorua/glm_aed/glm3.nml"                       
#> [14] "LID11133_rotorua/gotm_wet/fabm.yaml"                     
#> [15] "LID11133_rotorua/gotm_wet/gotm.yaml"                     
#> [16] "LID11133_rotorua/gotm_wet/inputs/hypsograph.dat"         
#> [17] "LID11133_rotorua/gotm_wet/inputs/inf_chem_lumped.dat"    
#> [18] "LID11133_rotorua/gotm_wet/inputs/inf_chem_NZS4081641.dat"
#> [19] "LID11133_rotorua/gotm_wet/inputs/inf_chem_NZS4083363.dat"
#> [20] "LID11133_rotorua/gotm_wet/inputs/inf_chem_NZS4084132.dat"
#> [21] "LID11133_rotorua/gotm_wet/inputs/inf_chem_NZS4084816.dat"
#> [22] "LID11133_rotorua/gotm_wet/inputs/inf_chem_NZS4086165.dat"
#> [23] "LID11133_rotorua/gotm_wet/inputs/inf_chem_precip.dat"    
#> [24] "LID11133_rotorua/gotm_wet/inputs/inf_flow_lumped.dat"    
#> [25] "LID11133_rotorua/gotm_wet/inputs/inf_flow_NZS4081641.dat"
#> [26] "LID11133_rotorua/gotm_wet/inputs/inf_flow_NZS4083363.dat"
#> [27] "LID11133_rotorua/gotm_wet/inputs/inf_flow_NZS4084132.dat"
#> [28] "LID11133_rotorua/gotm_wet/inputs/inf_flow_NZS4084816.dat"
#> [29] "LID11133_rotorua/gotm_wet/inputs/inf_flow_NZS4086165.dat"
#> [30] "LID11133_rotorua/gotm_wet/inputs/inf_flow_precip.dat"    
#> [31] "LID11133_rotorua/gotm_wet/inputs/inf_salt_lumped.dat"    
#> [32] "LID11133_rotorua/gotm_wet/inputs/inf_salt_NZS4081641.dat"
#> [33] "LID11133_rotorua/gotm_wet/inputs/inf_salt_NZS4083363.dat"
#> [34] "LID11133_rotorua/gotm_wet/inputs/inf_salt_NZS4084132.dat"
#> [35] "LID11133_rotorua/gotm_wet/inputs/inf_salt_NZS4084816.dat"
#> [36] "LID11133_rotorua/gotm_wet/inputs/inf_salt_NZS4086165.dat"
#> [37] "LID11133_rotorua/gotm_wet/inputs/inf_salt_precip.dat"    
#> [38] "LID11133_rotorua/gotm_wet/inputs/inf_temp_lumped.dat"    
#> [39] "LID11133_rotorua/gotm_wet/inputs/inf_temp_NZS4081641.dat"
#> [40] "LID11133_rotorua/gotm_wet/inputs/inf_temp_NZS4083363.dat"
#> [41] "LID11133_rotorua/gotm_wet/inputs/inf_temp_NZS4084132.dat"
#> [42] "LID11133_rotorua/gotm_wet/inputs/inf_temp_NZS4084816.dat"
#> [43] "LID11133_rotorua/gotm_wet/inputs/inf_temp_NZS4086165.dat"
#> [44] "LID11133_rotorua/gotm_wet/inputs/inf_temp_precip.dat"    
#> [45] "LID11133_rotorua/gotm_wet/inputs/lyrs.dat"               
#> [46] "LID11133_rotorua/gotm_wet/inputs/meteo.dat"              
#> [47] "LID11133_rotorua/gotm_wet/inputs/meteo_swr.dat"          
#> [48] "LID11133_rotorua/gotm_wet/inputs/outf_wbal.dat"          
#> [49] "LID11133_rotorua/gotm_wet/inputs/s_prof_file.dat"        
#> [50] "LID11133_rotorua/gotm_wet/inputs/t_prof_file.dat"        
#> [51] "LID11133_rotorua/gotm_wet/output.yaml"

Run AEME models

We will now run the AEME models for the two lakes. This will run the models with the configurations built in the path directory. The parallel argument is set to TRUE to run the models in parallel which can speed up the process.

aeme <- run_aeme(aeme = aeme, model = model, path = path, parallel = TRUE)
#> Running models in parallel... [2024-11-18 05:21:34]
#> Model run complete![2024-11-18 05:23:15]
#> Reading models in parallel... [2024-11-18 05:23:15]
#> Model reading complete![2024-11-18 05:23:45]
aeme
#>             AEME 
#> -------------------------------------------------------------------
#>   Lake
#> Rotorua (ID: LID11133); Lat: -38.09; Lon: 176.27; Elev: 284.88m; Depth: 48.15m;
#> Area: 80659960 m2; Shape file: Absent
#> -------------------------------------------------------------------
#>   Time
#> Start: 2013-07-01; Stop: 2023-06-30; Time step: 3600
#>  Spin up (days): GLM: 1095; GOTM: 1095; DYRESM: 1095
#> -------------------------------------------------------------------
#>   Configuration
#>     Model controls: Present
#>           Physical   |   Biogeochemical
#> DY-CD    : Absent     |   Absent 
#> GLM-AED  : Present    |   Present
#> GOTM-WET : Present    |   Present
#> -------------------------------------------------------------------
#>   Observations
#> Lake: Present; Level: Absent
#> -------------------------------------------------------------------
#>   Input
#> Inital profile: Present; Inital depth: 48.148m; Hypsograph: Present (n=95);
#> Meteo: Present; Use longwave: TRUE; Kw: 0.5666667
#> -------------------------------------------------------------------
#>   Inflows
#> Data: Present; Scaling factors: DY-CD: 1; GLM-AED: 1; GOTM-WET: 1
#> -------------------------------------------------------------------
#>   Outflows
#> Data: Present; Scaling factors: DY-CD: 1; GLM-AED: 1; GOTM-WET: 1
#> -------------------------------------------------------------------
#>   Water balance
#> Method: 2; Use: obs; Modelled: Absent; Water balance: Present
#> -------------------------------------------------------------------
#>   Parameters: 
#> Number of parameters: 18
#> -------------------------------------------------------------------
#>   Output: 
#> Number of ensembles: 1
#> DY-CD:    0
#> GLM-AED:  1
#> GOTM-WET: 1

In the “Output” section of the Aeme object, the “Number of ensembles” is set to 1 indicating that there is now output for each model in the Aeme object.

plot_output(aeme = aeme, model = model, var_sim = "HYD_temp")
#> Warning: Removed 332 rows containing missing values or values outside the scale range
#> (`geom_col()`).

plot_output(aeme = aeme, model = model, var_sim = "CHM_oxy")
#> Warning: Removed 332 rows containing missing values or values outside the scale range
#> (`geom_col()`).