| SimulationResults | R Documentation |
R6 class for encapsulating and dynamically generating
spatially-explicit simulation results, as well as optional re-generated
Generator outputs.
poems::GenericClass -> poems::GenericModel -> poems::SpatialModel -> SimulationResults
attachedA list of dynamically attached attributes (name-value pairs).
model_attributesA vector of model attribute names.
regionA Region (or inherited class) object specifying the study region.
coordinatesData frame (or matrix) of X-Y population (WGS84) coordinates in longitude (degrees West) and latitude (degrees North) (get and set), or distance-based coordinates dynamically returned by region raster (get only).
time_stepsNumber of simulation time steps.
burn_in_stepsOptional number of initial 'burn-in' time steps to be ignored.
occupancy_maskOptional binary mask array (matrix), data frame, or raster (stack) for each cell at each time-step of the simulation including burn-in.
allNested simulation results for all cells.
parentParent simulation results for individual cells.
defaultDefault value/attribute utilized when applying primitive metric functions (e.g. max) to the results.
attribute_aliasesA list of alternative alias names for model attributes (form: alias = "attribute") to be used with the set and get attributes methods.
error_messagesA vector of error messages encountered when setting model attributes.
warning_messagesA vector of warning messages encountered when setting model attributes.
new()Initialization method sets attributes from a results list or file, and sets object attributes individually and/or from a list.
SimulationResults$new(results = NULL, parent = NULL, ...)
resultsA list containing results or a file path to simulation results.
parentParent simulation results for individual cells (used when nesting a simulation results clone for all cells).
...Parameters passed via a params list or individually.
new_clone()Creates a new (re-initialized) object of the current (inherited) object class with optionally passed parameters.
SimulationResults$new_clone(...)
...Parameters passed via the inherited class constructor (defined in initialize and run via new).
New object of the current (inherited) class.
get_attribute_names()Returns an array of all attribute names including public and private model attributes, as well as attached attributes, error and warning messages.
SimulationResults$get_attribute_names(all = FALSE)
allBoolean to indicate if a nested list for all cells (when present) should be also listed (default is FALSE).
Array of all attribute names with optional inclusion of attribute names of nested results for all cells.
get_attributes()Returns a list of values for selected attributes or attribute aliases (when array of parameter names provided) or all attributes (when no params).
SimulationResults$get_attributes(params = NULL, remove_burn_in = TRUE)
paramsArray of attribute names to return (all when NULL).
remove_burn_inBoolean to indicate whether or not to remove burn-in steps from the attribute values (default = TRUE; mostly for internal use).
List of selected or all attributes values.
set_attributes()Sets given attributes (optionally via alias names) individually and/or from a list.
SimulationResults$set_attributes(params = list(), ...)
paramsList of parameters/attributes.
...Parameters/attributes passed individually.
clone()The objects of this class are cloneable with this method.
SimulationResults$clone(deep = FALSE)
deepWhether to make a deep clone.
# U Island example region
coordinates <- data.frame(
x = rep(seq(177.01, 177.05, 0.01), 5),
y = rep(seq(-18.01, -18.05, -0.01), each = 5)
)
template_raster <- Region$new(coordinates = coordinates)$region_raster # full extent
template_raster[][-c(7, 9, 12, 14, 17:19)] <- NA # make U Island
region <- Region$new(template_raster = template_raster)
raster::plot(region$region_raster,
main = "Example region (indices)",
xlab = "Longitude (degrees)", ylab = "Latitude (degrees)",
colNA = "blue"
)
# Sample results occupancy (ignore cell 2 in last 3 time steps)
occupancy_raster <- region$raster_from_values(array(1, c(7, 13)))
occupancy_raster[region$region_indices][2, 11:13] <- 0
occupancy_raster[region$region_indices]
# Simulation example results
example_results <- list(abundance = region$raster_from_values(
t(apply(
matrix(11:17), 1,
function(n) c(rep(n, 3), round(n * exp(-(0:9) / log(n))))
))
))
example_results$abundance[region$region_indices]
# Simulation results object
sim_results <- SimulationResults$new(
region = region,
time_steps = 13,
burn_in_steps = 3,
occupancy_mask = occupancy_raster
)
# Clone (for each simulation results)
results_clone <- sim_results$new_clone(results = example_results)
results_clone$get_attribute("abundance")
results_clone$get_attribute("abundance")[region$region_indices]
results_clone$all$get_attribute("abundance")
results_clone$get_attribute("all$abundance")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.