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 class 'missing,character,character'
moduleMetadata(module, path, defineModuleListItems)
# S4 method for class 'missing,character,missing'
moduleMetadata(module, defineModuleListItems)
# S4 method for class '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")
)
A simList
simulation object, generally produced by simInit
.
Character string. Your module's name.
Character string specifying the file path to modules directory.
Default is to use the spades.modulePath
option.
A vector of metadata entries to return values about.
A list of module metadata, matching the structure in defineModule()
.
## 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/Rtmp45trFG/sampleModules'
#> )
#> Paths set to:
#> options(
#> rasterTmpDir = '/tmp/Rtmp45trFG/SpaDES/scratch/raster'
#> reproducible.cachePath = '/tmp/Rtmp45trFG/reproducible/cache'
#> spades.inputPath = '/tmp/Rtmp45trFG/SpaDES/inputs'
#> spades.outputPath = '/tmp/Rtmp45trFG/SpaDES/outputs'
#> spades.modulePath = '/tmp/Rtmp45trFG/sampleModules'
#> spades.scratchPath = '/tmp/Rtmp45trFG/SpaDES/scratch'
#> )
#> terra::terraOptions(tempdir = '/tmp/Rtmp45trFG/SpaDES/scratch/terra'
#> Nov21 04:22:37 simInit Using setDTthreads(1). To change: 'options(spades.DTthreads = X)'.
#> Nov21 04:22:37 simInit The following .globals were used:
#> Nov21 04:22:37 simInit Key: <global, module>
#> Nov21 04:22:37 simInit module global
#> Nov21 04:22:37 simInit <char> <char>
#> Nov21 04:22:37 simInit 1: caribouMovement stackName
#> Elpsed time for simInit: 0.07747102 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)