PopulationResults | R Documentation |
R6
class encapsulating and dynamically generating
spatially-explicit population_simulator
results, as well as optional
re-generated Generator
outputs.
poems::GenericClass
-> poems::GenericModel
-> poems::SpatialModel
-> poems::SimulationResults
-> PopulationResults
attached
A list of dynamically attached attributes (name-value pairs).
model_attributes
A vector of model attribute names.
region
A Region
(or inherited class) object specifying the study region.
coordinates
Data 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_steps
Number of simulation time steps.
burn_in_steps
Optional number of initial 'burn-in' time steps to be ignored.
occupancy_mask
Optional binary mask array (matrix), data frame, or raster (stack) for each cell at each time-step of the simulation including burn-in.
trend_interval
Optional time-step range (indices) for trend calculations (assumes indices begin after the burn-in when utilized).
abundance
Population abundance across simulation time-steps (summary list or replicate array).
abundance_stages
Population abundance for combined stages across simulation time-steps (list of summary lists or replicate arrays for each combined stage).
abundance_trend
Trend or average Sen's slope
of abundance (optionally across a time-step interval).
ema
Array of population expected minimum abundance (EMA) across simulation time-steps.
extirpation
Array of population extirpation times.
extinction_location
The weighted centroid of cells occupied in the time-step prior to the extirpation of all populations (if it occurred).
harvested
Number of animals harvested from each population across simulation time-steps (summary list or replicate array).
harvested_stages
Number of animals harvested from each population for combined stages across simulation time-steps (list of summary lists or replicate arrays for each combined stage).
occupancy
Array of the number of populations occupied at each time-step.
all
Nested simulation results for all cells.
parent
Parent simulation results for individual cells.
default
Default value/attribute utilized when applying primitive metric functions (e.g. max) to the results.
attribute_aliases
A list of alternative alias names for model attributes (form: alias = "attribute"
) to be used with the set and get attributes methods.
error_messages
A vector of error messages encountered when setting model attributes.
warning_messages
A vector of warning messages encountered when setting model attributes.
clone()
The objects of this class are cloneable with this method.
PopulationResults$clone(deep = FALSE)
deep
Whether 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 5 time steps)
occupancy_raster <- region$raster_from_values(array(1, c(7, 13)))
occupancy_raster[region$region_indices][2, 9:13] <- 0
occupancy_raster[region$region_indices]
# Population simulation example results
example_results <- list(abundance = t(apply(matrix(11:17), 1, function(n) {
c(rep(n, 3), round(n * exp(-(0:9) / 2)))
})))
example_results$harvested <- round(example_results$abundance * 0.3)
example_results
# Population results object
pop_results <- PopulationResults$new(
region = region,
time_steps = 13,
burn_in_steps = 3,
occupancy_mask = occupancy_raster,
trend_interval = 1:5
)
pop_results$get_attribute_names(all = TRUE)
# Clone (for each population simulation results)
results_clone <- pop_results$new_clone(results = example_results)
results_clone$all$get_attribute("abundance")
results_clone$get_attributes(c(
"abundance", "all$abundance",
"abundance_trend", "all$abundance_trend",
"all$ema", # only defined for all
"extirpation", "all$extirpation",
"all$extinction_location", # only defined for all
"harvested", "all$harvested",
"occupancy", "all$occupancy"
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.