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

path <- system.file("sampleModules", package = "SpaDES.core")
sampleModules <- dir(path)
# turn off code checking -- don't need it here
opts <- options("spades.moduleCodeChecks" = FALSE,
                "spades.useRequire" = FALSE)

x <- moduleMetadata(sampleModules[3], path = path)
#> Assuming sim is a module name
#> defineParameter: 'startTime' is not of specified type 'numeric'.
#> defineParameter: '.plotInitialTime' is not of specified type 'numeric'.

# using simList
mySim <- simInit(
   times = list(start = 2000.0, end = 2001.0, timeunit = "year"),
   params = list(
     .globals = list(stackName = "landscape")
   ),
   modules = list("caribouMovement"),
   paths = list(modulePath = system.file("sampleModules", package = "SpaDES.core"))
)
#> Setting:
#>   options(
#>     spades.modulePath = '/tmp/RtmpdSgPsP/temp_libpath3e7be26f23d8b1/SpaDES.core/sampleModules'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/RtmpqFmubO/raster'
#>     reproducible.cachePath = '/tmp/RtmpqFmubO/Require/cache'
#>     spades.inputPath = '/tmp/RtmpPXaaDN/SpaDES/inputs'
#>     spades.outputPath = '/tmp/RtmpPXaaDN/SpaDES/outputs'
#>     spades.modulePath = '/tmp/RtmpdSgPsP/temp_libpath3e7be26f23d8b1/SpaDES.core/sampleModules'
#>   )
#> options('spades.useRequire' = FALSE), so not checking minimum package version requirements
#> Loading required package: SpaDES.tools
#> Loading required package: grid
#> 
#> Attaching package: ‘grid’
#> The following object is masked from ‘package:quickPlot’:
#> 
#>     gpar
#> Loading required package: raster
#> Loading required package: sp
#> The following .globals were used:
#>             module    global
#> 1: caribouMovement stackName
moduleMetadata(sim = mySim)
#> $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@canada.ca> [aut, cre]"
#> 
#> $version
#> [1] ‘1.6.0’
#> 
#> $spatialExtent
#> class      : Extent 
#> xmin       : NA 
#> xmax       : NA 
#> ymin       : NA 
#> ymax       : NA 
#> 
#> $timeframe
#> [1] NA NA
#> 
#> $timeunit
#> [1] "month"
#> 
#> $citation
#> list()
#> 
#> $documentation
#> list()
#> 
#> $reqdPkgs
#> $reqdPkgs[[1]]
#> [1] "grid"
#> 
#> $reqdPkgs[[2]]
#> [1] "raster"
#> 
#> $reqdPkgs[[3]]
#> [1] "sp"
#> 
#> $reqdPkgs[[4]]
#> [1] "stats"
#> 
#> $reqdPkgs[[5]]
#> [1] "SpaDES.tools"
#> 
#> 
#> $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  .plotInitialTime    numeric      2000  -Inf  Inf
#> 7     .plotInterval    numeric         1  -Inf  Inf
#> 8  .saveInitialTime    numeric        NA  -Inf  Inf
#> 9     .saveInterval    numeric        NA  -Inf  Inf
#> 10            .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                                                                                              time to schedule first plot event
#> 7                                                                                              time interval between plot events
#> 8                                                                                              time to schedule first save event
#> 9                                                                                              time interval between save events
#> 10 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            RasterStack     layername = "habitatQuality"      <NA>
#> 2    caribou SpatialPointsDataFrame Object holding caribou locations      <NA>
#> 
#> $outputObjects
#>   objectName            objectClass desc
#> 1    caribou SpatialPointsDataFrame   NA
#> 

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