Parent modules

  1. Recall the LCC2005 module we examined in exercise 4. What is different about this module compared to, e.g., the forestAge module? Hint: examine the module structure (metadata, events, functions, and .inputObjects sections).

    module.path <- file.path(dirname(tempdir()), "modules")
    downloadModule("LCC2005", module.path)
    openModules(c("LCC2005", "forestAge"), module.path)
  2. Identify the child modules used by this parent module.

  3. Examine the directory structure of the parent and child modules. How do they differ?

  4. Visually examine the data dependency relationships between these modules.

    setPaths(modulePath = module.path)
    
    times <- list(start = 2005.0, end = 2020.0, timeunit = "year")
    parameters <- list(
      .globals = list(burnStats = "fireStats"),
      fireSpreadLcc = list(drought = 1.2),
      caribouMovementLcc = list(
        N = 1e3,
        startTime = times$start + 1,
        glmInitialTime = NA_real_)
    )
    modules <- list("LCC2005")
    
    lcc05 <- simInit(times = times, modules = modules, params = parameters)
    
    moduleDiagram(lcc05)
    objectDiagram(lcc05)
  5. Visually inspect the completed events list:

    eventDiagram(lcc05)

    Uh oh! The simulation has been initialized, but it hasn’t yet been run so the completed events list is empty!

  6. Run the simulation and re-inspect (visually) the completed events list:

    lcc05_out <- spades(Copy(lcc05))
    eventDiagram(lcc05_out)

Create a new parent module

Recall from exercise 4:

Create a simple module that does one of the following:

  1. generates a random map (hint: see ?gaussMap) and updates the values in the raster cells;

  2. model population dynamics as subpopulations within each raster cell.

  1. Now it’s time to build the other module you didn’t build earlier.

  2. Create a new parent module that will link these two modules together.