forked from EcoForecast/PhenologyForecast
-
Notifications
You must be signed in to change notification settings - Fork 2
/
make.SS.plots.R
52 lines (40 loc) · 1.75 KB
/
make.SS.plots.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
make.SS.plots <- function(out,time,
rescaled_NDVI,rescaled_GCC,site.number,model){
source("ciEnvelope.R")
time_year = as.numeric(format(as.Date(time), "%Y"))
current.year = as.numeric(strftime(Sys.Date(),"%Y"))
if(!is.null(global_input_parameters$training.end.date)){
current.year = (as.numeric(strftime(global_input_parameters$training.end.date,"%Y"))+1)
}
years <- unique(time_year)
years <- years[years < current.year]
plot_file_name = paste('Jags.SS.out.site',as.character(site.number), model,'pdf',sep=".")
pdf(plot_file_name)
for(count in 1:length(years)){
YR = years[count]
II = which(time_year== YR)
rescaled_NDVI_one_year = rescaled_NDVI[II] # get ndvi just for ONE year
rescaled_GCC_one_year = rescaled_GCC[II] # get gcc just for ONE year
# delete leap days
if (length(II) == 185){
rescaled_NDVI_one_year = rescaled_NDVI_one_year[1:184]
rescaled_GCC_one_year = rescaled_GCC_one_year[1:184]
}
# NDVI and GCC
plot(182:365,out$ci[count,,2],type='l',ylim=c(0, 1),main=paste("SS model", as.character(YR)),
ylab="Rescaled NDVI, GCC",xlab="DOY")
ciEnvelope(182:365,out$ci[count,,1],out$ci[count,,3],col="lightBlue")
# if(!is.null(dim(rescaled_NDVI_one_year))){ # R is stupid with NAs...
points(182:365,rescaled_NDVI_one_year,pch="+",cex=0.8)
# }
# if(!is.null(dim(rescaled_GCC_one_year))){ # R is stupid with NAs...
points(182:365,rescaled_GCC_one_year,pch="o",cex=0.5)
# }
lines(182:365,out$ci[count,,2],type='l',lwd=2)
}
##### MCMC diagnostics
source("corr.and.MCMC.Diag.forSSModel.R")
#corr.and.MCMC.Diag.forSSModel(out)
pairs(out$parms[sample.int(nrow(out$parms),2500),],pch=".")
dev.off()
}