documentation/03-initial-conditions.md

Vegetation initial conditions for ED2

Alexey Shiklomanov

Relevant ED2IN settings:

# UMBS coordinates are included as defaults
coords_prefix("path/to/prefix", "css")
#> [1] "path/to/prefix.lat45.5625lon-84.6975.css"

The cohort (css) and patch (pss) files are both space-delimited files. Their format is described in detail in the ED2 wiki, but briefly: The css file contains one row per cohort and describes (among other things) their size (diameter at breast height, dbh, in cm), stem density (n, in plants per m(^2)), and which patch they belong to. The pss file contains one row per patch, and describes, among other things, the patch’s area (as a fraction of the total site area, so 0-1) and age (in years since last disturbance).

Both of these files can be quickly generated from the inventory data distributed with fortedata with the ed4forte function fortedata2ed. For example, code like the following can be used to quickly run ED2 initialized from FoRTE inventory data:

# devtools::install_github("FoRTExperiment/fortedata")
library(ed4forte)
narr_ed <- here::here("unsynced-data", "ed-input-data", "NARR-ED2",
                      "ED_MET_DRIVER_HEADER")
outdir <- here::here("unsynced-data", "ed2-outputs", "forte-inits")
dir.create(outdir, showWarnings = FALSE, recursive = TRUE)

prefix <- file.path(outdir, "fortedata")
css_pss <- fortedata2ed(output_prefix = prefix)
p <- run_ed2(
  # NOTE: 4.5 year simulation -- could take a few minutes...
  outdir, "2000-06-01", "2005-01-01",
  ED_MET_DRIVER_DB = narr_ed,
  IED_INIT_MODE = 6,
  # Only include North pine (6), late conifer (8), and early (9), mid (10), and
  # late (11) temperate hardwoods.
  INCLUDE_THESE_PFT = c(6, 8:11),
  SFILIN = prefix
)
get_status(p)
p$wait()

Note that because this run features multiple patches, the logic in read_monthly_dir for binding these together will not work, so we will have to pull out and combine variables by hand. The somewhat janky code below does this.

getvar <- function(f, v) {
  nc <- ncdf4::nc_open(f)
  on.exit(ncdf4::nc_close(nc), add = TRUE)
  ncdf4::ncvar_get(nc, v)
}
files <- list.files(outdir, "analysis-E", full.names = TRUE)

dat <- tibble::tibble(
  dates = stringr::str_extract(files, "[[:digit:]]{4}-[[:digit:]]{2}") %>%
    paste0("-01") %>%
    as.Date(),
  hite = lapply(files, getvar, "HITE"),
  dbh = lapply(files, getvar, "DBH"),
  pft = lapply(files, getvar, "PFT")
)

library(ggplot2)
dat %>%
  tidyr::unnest(c(hite, dbh, pft)) %>%
  # Structure doesn't change that often. Let's look at July of every year.
  dplyr::filter(lubridate::month(dates) == 7) %>%
  dplyr::group_by(dates) %>%
  dplyr::mutate(icohort = dplyr::row_number()) %>%
  dplyr::ungroup() %>%
  ggplot() +
  aes(x = icohort, xend = icohort, yend = 0, y = hite, size = dbh, color = factor(pft)) +
  geom_segment(size = 1) +
  geom_point() +
  facet_wrap(vars(dates)) +
  scale_color_brewer(palette = "Set1") +
  theme(axis.text.x = element_blank()) +
  ggtitle("Height and DBH, by cohort and PFT, for five ED2 simulation years.")

In this plot, we can start to see how ED2 works. Both the total number of cohorts, and the number of patches (groups of cohorts), changes over the course of the run, as ED2 fuses similar cohorts and patches when there are too many (see ED2IN variables MAXCOHORTS and MAXPATCHES) or splits them when there are relatively few. Also, we can see recruitment of new seedlings – even over the course of 5 years, some small new trees of different PFTs appear in the understory.



FoRTExperiment/ed4forte documentation built on March 21, 2020, 6:54 p.m.