-
Notifications
You must be signed in to change notification settings - Fork 0
/
script_virtualSPP_NorthAmerica
131 lines (93 loc) · 5.58 KB
/
script_virtualSPP_NorthAmerica
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
rm(list=ls())
##loading the climate layers
setwd('/Users/matheusribeiro/aaa_Matheus_Ribeiro-2014-05-25/Producao Cientifica/em andamento/fossil_conservacao_sppVirtuais/climate/North_America')
env.stack.0k <- stack("NorthAm_0k_bio5.grd", "NorthAm_0k_bio6.grd", "NorthAm_0k_bio12.grd"); names(env.stack.0k) <- c('bio5', 'bio6', 'bio12')
env.stack.21k <- stack("NorthAm_21k_bio5.grd", "NorthAm_21k_bio6.grd", "NorthAm_21k_bio12.grd"); names(env.stack.21k) <- c('bio5', 'bio6', 'bio12')
env.stack.rcp45 <- stack("NorthAm_rcp45_bio5.grd", "NorthAm_rcp45_bio6.grd", "NorthAm_rcp45_bio12.grd"); names(env.stack.rcp45) <- c('bio5', 'bio6', 'bio12')
##creating virtual species
library('sdmvspecies')
#sp1 - warm/dry - arid
config.sp1 <- list(c("bio5", 40, 20), c("bio6", 0, 10), c("bio12", 400, 200))
sp1.0k <- artificialBellResponse(env.stack.0k, config.sp1)
sp1.21k <- artificialBellResponse(env.stack.21k, config.sp1)
sp1.rcp45 <- artificialBellResponse(env.stack.rcp45, config.sp1)
plot(stack(sp1.0k, sp1.21k, sp1.rcp45), main= 'sp1')
threshold <- 0.5
sp1 <- stack(sp1.0k > threshold, sp1.21k > threshold, sp1.rcp45 > threshold, sp1.0k > threshold & sp1.21k > threshold)
names(sp1) <- c("sp1 (Pres)", "sp1 (LGM)", "sp1 (Fut)", "sp1 (overlay Pes/LGM)")
plot(sp1)
length(which(values(sp1.0k) > threshold)); length(which(values(sp1.21k) > threshold)); length(which(values(sp1.rcp45) > threshold))
#sp2 - temperate/dry
config.sp2 <- list(c("bio5", 25, 10), c("bio6", -20, 20), c("bio12", 500, 300))
sp2.0k <- artificialBellResponse(env.stack.0k, config.sp2)
sp2.21k <- artificialBellResponse(env.stack.21k, config.sp2)
sp2.rcp45 <- artificialBellResponse(env.stack.rcp45, config.sp2)
plot(stack(sp2.0k, sp2.21k, sp2.rcp45), main= 'sp2')
threshold <- 0.5
sp2 <- stack(sp2.0k > threshold, sp2.21k > threshold, sp2.rcp45 > threshold, sp2.0k > threshold & sp2.21k > threshold)
names(sp2) <- c("sp2 (Pres)", "sp2 (LGM)", "sp2 (Fut)", "sp2 (overlay Pes/LGM)")
plot(sp2)
length(which(values(sp2.0k) > threshold)); length(which(values(sp2.21k) > threshold)); length(which(values(sp2.rcp45) > threshold))
#sp3 - cool/wet - temperate/wet
config.sp3 <- list(c("bio5", 25, 20), c("bio6", -25, 20), c("bio12", 1300, 700))
sp3.0k <- artificialBellResponse(env.stack.0k, config.sp3)
sp3.21k <- artificialBellResponse(env.stack.21k, config.sp3)
sp3.rcp45 <- artificialBellResponse(env.stack.rcp45, config.sp3)
plot(stack(sp3.0k, sp3.21k, sp3.rcp45), main= 'sp3')
threshold <- 0.5
sp3 <- stack(sp3.0k > threshold, sp3.21k > threshold, sp3.rcp45 > threshold, sp3.0k > threshold & sp3.21k > threshold)
names(sp3) <- c("sp3 (Pres)", "sp3 (LGM)", "sp3 (Fut)", "sp3 (overlay Pes/LGM)")
plot(sp3)
length(which(values(sp3.0k) > threshold)); length(which(values(sp3.21k) > threshold)); length(which(values(sp3.rcp45) > threshold))
#sp4 - hot-dry summer/cool-wet winner - mediterranean
#config.sp4 <- list(c("bio5", 30, 10), c("bio6", 0, 10), c("bio12", 800, 200))
#sp4.0k <- artificialBellResponse(env.stack.0k, config.sp4)
#sp4.21k <- artificialBellResponse(env.stack.21k, config.sp4)
#sp4.rcp45 <- artificialBellResponse(env.stack.rcp45, config.sp4)
#plot(stack(sp4.0k, sp4.21k, sp4.rcp45), main= 'sp4')
#threshold <- 0.5
#sp4 <- stack(sp4.0k > threshold, sp4.21k > threshold, sp4.rcp45 > threshold, sp4.0k > threshold & sp4.21k > threshold)
#names(sp4) <- c("sp4 (Pres)", "sp4 (LGM)", "sp4 (Fut)", "sp4 (overlay Pes/LGM)")
#plot(sp4)
#length(which(values(sp4.0k) > threshold)); length(which(values(sp4.21k) > threshold)); length(which(values(sp4.rcp45) > threshold))
#sp5 - generalist
config.sp5 <- list(c("bio5", 20, 30), c("bio6", -10, 30), c("bio12", 1000, 700))
sp5.0k <- artificialBellResponse(env.stack.0k, config.sp5)
sp5.21k <- artificialBellResponse(env.stack.21k, config.sp5)
sp5.rcp45 <- artificialBellResponse(env.stack.rcp45, config.sp5)
plot(stack(sp5.0k, sp5.21k, sp5.rcp45), main= c("sp5 (Pres)", "sp5 (LGM)", "sp5 (Fut)"))
threshold <- 0.5
sp5 <- stack(sp5.0k > threshold, sp5.21k > threshold, sp5.rcp45 > threshold, sp5.0k > threshold & sp5.21k > threshold)
names(sp5) <- c("sp5 (Pres)", "sp5 (LGM)", "sp5 (Fut)", "sp5 (overlay Pes/LGM)")
plot(sp5)
length(which(values(sp5.0k) > threshold)); length(which(values(sp5.21k) > threshold)); length(which(values(sp5.rcp45) > threshold))
##################################
######################
############
#array of species across a gradient
grad.bio5 <- c(0, 10, 20, 30)
grad.bio6 <- c(-40, -25, -10, 5)
grad.bio12 <- c(300, 700, 1100, 1500)
threshold <- 0.5
#threshold <- 0.2
#tol <- c(20, 20, 500) #tolerance generalist
tol <- c(30, 30, 700) #tolerance specialist
setwd('/Users/matheusribeiro/aaa_Matheus_Ribeiro-2014-05-25/Producao Cientifica/em andamento/fossil_conservacao_sppVirtuais/virtualSPP/North_America/tolerance_30_30_700/threshold_0.5')
for(i in grad.bio5){
for(j in grad.bio6){
for(k in grad.bio12){
config.sp <- list(c("bio5", i, tol[1]), c("bio6", j, tol[2]), c("bio12", k, tol[3]))
sp.0k <- artificialBellResponse(env.stack.0k, config.sp)
sp.21k <- artificialBellResponse(env.stack.21k, config.sp)
sp.rcp45 <- artificialBellResponse(env.stack.rcp45, config.sp)
pdf(paste(paste('virtualSuitability (', paste(i, j, k, sep= ' '), ')', sep=''), '.pdf', sep=''))
plot(stack(sp.0k, sp.21k, sp.rcp45), main= c("Pres", "LGM", "Fut"))
dev.off()
pdf(paste(paste('virtualTHR (', paste(i, j, k, sep= ' '), ')', sep=''), '.pdf', sep=''))
sp <- stack(sp.0k > threshold, sp.21k > threshold, sp.rcp45 > threshold, sp.0k > threshold & sp.21k > threshold)
names(sp) <- c("Pres", "LGM", "Fut", "overlap (Pes/LGM)")
plot(sp, main= c("Pres", "LGM", "Fut", "overlap (Pes/LGM)"))
dev.off()
}
}
}