-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathviewPopResults.R
67 lines (52 loc) · 2.26 KB
/
viewPopResults.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
library(rsyncrosim)
library(ggplot2)
library(raster)
theme_set(theme_bw())
# Use the rsyncrosim package to access model results from the SyncroSim UI and
# do further analyses in R
# Set paths to library folder, library name, and scenario name
libDir <- "C:/Users/endicotts/Documents/gitprojects/ROFSyncSim/"
libName <- "ROFDemoS1"
scnName <- "Caribou - anthro"
# load library
cLib <- ssimLibrary(paste0(libDir, "/", libName))
# Get list of all results scenarios
allRes <- scenario(cLib, results = TRUE)
# get results scnID for the most recent result
exampleScn <- max(subset(allRes, grepl(paste0(scnName, " \\("), allRes$name))$scenarioId)
# Load result tables
rScn <- scenario(cLib, exampleScn)
distMetrics <- datasheet(rScn, "OutputDisturbanceMetrics")
popMetrics <- datasheet(rScn, "OutputPopulationMetrics")
# See changes in disturbance metrics over time
distMetricsPlot <- ggplot(data = distMetrics, aes(x = Timestep, y = Amount)) +
geom_line(size = 0.5) +
facet_wrap(~MetricTypeDistID, scales = "free", ncol = 1) +
xlab("Time") +
ylab("Response") +
theme(legend.position = "none")
distMetricsPlot
# change the N metric to log10 N
popMetrics$MetricTypeDemogID <- as.character(popMetrics$MetricTypeDemogID)
popMetrics$Amount[popMetrics$MetricTypeDemogID == "N"] <- log10(popMetrics$Amount[popMetrics$MetricTypeDemogID == "N"] + 0.001)
popMetrics$MetricTypeDemogID[popMetrics$MetricTypeDemogID == "N"] <- "log10N"
# See changes in demographic metrics over time
popMetricsPlot <- ggplot(data = popMetrics,
aes(x = Timestep, y = Amount, group = as.factor(Replicate),
colour = as.factor(Replicate))) +
geom_line(size = 0.5) +
facet_wrap(~MetricTypeDemogID , scales = "free") +
xlab("Time") +
ylab("Response") +
theme(legend.position = "none")
popMetricsPlot
# load raster results
myHabitatRasters <- datasheetRaster(rScn, "OutputSpatialHabitat")
# look at names to choose rasters to compare
names(myHabitatRasters)
fall2020 <- myHabitatRasters[[1]]
fall2060 <- myHabitatRasters[[5]]
# subtract to see the change in relative probability of selection
changeFall2060 <- fall2060 - fall2020
# beige areas show no change, yellow to red areas show lower probabilities of selection
plot(changeFall2060, col = hcl.colors(10, "Heat 2"))