Parse and extract module metadata

moduleMetadata(
  sim,
  module,
  path = getOption("spades.modulePath", NULL),
  defineModuleListItems = c("name", "description", "keywords", "childModules", "authors",
    "version", "spatialExtent", "timeframe", "timeunit", "citation", "documentation",
    "reqdPkgs", "parameters", "inputObjects", "outputObjects")
)

# S4 method for missing,character,character
moduleMetadata(module, path, defineModuleListItems)

# S4 method for missing,character,missing
moduleMetadata(module, defineModuleListItems)

# S4 method for ANY,ANY,ANY
moduleMetadata(
  sim,
  module,
  path = getOption("spades.modulePath", NULL),
  defineModuleListItems = c("name", "description", "keywords", "childModules", "authors",
    "version", "spatialExtent", "timeframe", "timeunit", "citation", "documentation",
    "reqdPkgs", "parameters", "inputObjects", "outputObjects")
)

Arguments

sim

A simList simulation object, generally produced by simInit.

module

Character string. Your module's name.

path

Character string specifying the file path to modules directory. Default is to use the spades.modulePath option.

defineModuleListItems

A vector of metadata entries to return values about.

Value

A list of module metadata, matching the structure in defineModule().

See also

Author

Alex Chubaty

Examples

## turn off code checking -- don't need it here
opts <- options("spades.moduleCodeChecks" = FALSE,
                "spades.useRequire" = FALSE)

path <- getSampleModules(tempdir())
sampleModules <- dir(path)
x <- moduleMetadata(sampleModules[3], path = path)
#> Assuming sim is a module name

## using simList
if (require("SpaDES.tools", quietly = TRUE)) {
   mySim <- simInit(
      times = list(start = 2000.0, end = 2001.0, timeunit = "year"),
      params = list(
        .globals = list(stackName = "landscape")
      ),
      modules = list("caribouMovement"),
      paths = list(modulePath = path)
   )
   moduleMetadata(sim = mySim)
}
#> Setting:
#>   options(
#>     spades.modulePath = '/tmp/RtmpoLaiAE/sampleModules'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/RtmpoLaiAE/SpaDES/scratch/raster'
#>     reproducible.cachePath = '/tmp/RtmpoLaiAE/reproducible/cache'
#>     spades.inputPath = '/tmp/RtmpoLaiAE/SpaDES/inputs'
#>     spades.outputPath = '/tmp/RtmpoLaiAE/SpaDES/outputs'
#>     spades.modulePath = '/tmp/RtmpoLaiAE/sampleModules'
#>     spades.scratchPath = '/tmp/RtmpoLaiAE/SpaDES/scratch'
#>   )
#>   terra::terraOptions(tempdir = '/tmp/RtmpoLaiAE/SpaDES/scratch/terra'
#> Apr25 18:01:09 simInit Using setDTthreads(1). To change: 'options(spades.DTthreads = X)'.
#> Apr25 18:01:09 simInit The following .globals were used:
#> Apr25 18:01:09 simInit Key: <global, module>
#> Apr25 18:01:09 simInit             module    global
#> Apr25 18:01:09 simInit             <char>    <char>
#> Apr25 18:01:09 simInit 1: caribouMovement stackName
#> Elpsed time for simInit: 0.05587506 secs
#> $name
#> [1] "caribouMovement"
#> 
#> $description
#> [1] "Simulate caribou movement via correlated random walk."
#> 
#> $keywords
#> [1] "caribou"                         "individual based movement model"
#> [3] "correlated random walk"         
#> 
#> $childModules
#> character(0)
#> 
#> $authors
#> [1] "Eliot J B McIntire <eliot.mcintire@nrcan-rncan.gc.ca> [aut, cre]"
#> 
#> $version
#> [1] ‘1.6.1’
#> 
#> $spatialExtent
#> SpatExtent : 0, 0, 0, 0 (xmin, xmax, ymin, ymax)
#> 
#> $timeframe
#> [1] NA NA
#> 
#> $timeunit
#> [1] "month"
#> 
#> $citation
#> list()
#> 
#> $documentation
#> list()
#> 
#> $loadOrder
#> $loadOrder$after
#> NULL
#> 
#> $loadOrder$before
#> NULL
#> 
#> 
#> $reqdPkgs
#> $reqdPkgs[[1]]
#> [1] "grid"
#> 
#> $reqdPkgs[[2]]
#> [1] "terra"
#> 
#> $reqdPkgs[[3]]
#> [1] "sf"
#> 
#> $reqdPkgs[[4]]
#> [1] "stats"
#> 
#> $reqdPkgs[[5]]
#> [1] "SpaDES.tools (>= 2.0.0)"
#> 
#> 
#> $parameters
#>           paramName paramClass   default   min  max
#> 1         stackName  character landscape    NA   NA
#> 2   moveInitialTime    numeric      2001  2001 2001
#> 3      moveInterval    numeric         1     1    1
#> 4                 N    numeric       100    10 1000
#> 5             torus    logical     FALSE FALSE TRUE
#> 6            .plots  character    screen    NA   NA
#> 7  .plotInitialTime    numeric      2000  -Inf  Inf
#> 8     .plotInterval    numeric         1  -Inf  Inf
#> 9  .saveInitialTime    numeric        NA  -Inf  Inf
#> 10    .saveInterval    numeric        NA  -Inf  Inf
#> 11            .seed       list              NA   NA
#>                                                                                                                        paramDesc
#> 1                                                                                                        name of the RasterStack
#> 2                                                                                          time to schedule first movement event
#> 3                                                                                          time interval between movoment events
#> 4                                                                                                      initial number of caribou
#> 5                                                                                       should the map wrap around like a torus?
#> 6                                          A modular mechanism to create plots, using png, screen device or other. See `?Plots`.
#> 7                                                                                              time to schedule first plot event
#> 8                                                                                              time interval between plot events
#> 9                                                                                              time to schedule first save event
#> 10                                                                                             time interval between save events
#> 11 Named list of seeds to use for each event (names). E.g., `list('init' = 123)` will `set.seed(123)` for the `init` event only.
#> 
#> $inputObjects
#>   objectName objectClass                             desc sourceURL
#> 1  landscape  SpatRaster     layername = "habitatQuality"      <NA>
#> 2    caribou  SpatVector Object holding caribou locations      <NA>
#> 
#> $outputObjects
#>       objectName objectClass desc
#> 1        caribou  SpatVector   NA
#> 2 habitatQuality  SpatRaster   NA
#> 

# turn code checking back on -- don't need it here
options(opts)