1 | #!/usr/bin/env Rscript |
---|
2 | args = commandArgs(trailingOnly=TRUE) |
---|
3 | |
---|
4 | require(reshape2) |
---|
5 | require(ggplot2) |
---|
6 | require(grid) |
---|
7 | require(gridExtra) |
---|
8 | require(plyr) |
---|
9 | require(dplyr) |
---|
10 | require(data.table) |
---|
11 | |
---|
12 | ############################################################################################## |
---|
13 | # initialisation variables |
---|
14 | ############################################################################################# |
---|
15 | bo=c(0,0,0,17,18,6,19,8,9,10,20,21,13,14,15,16) |
---|
16 | names=c('','','','','P.Sylvestris','P.Pinaster','PiceaSp','','','QuercusIlex','','BetulaSp','FagusSyl.','QuercusRob.','PopulusSp','') |
---|
17 | leaftype=c('','','','','','','','','','','','Deciduous','Deciduous','Deciduous','Deciduous','') |
---|
18 | monthOrder <- c("janv.","févr.","mars","avril","mai","juin","juil.","août","sept.","oct.","nov.","déc.") |
---|
19 | LatOrderSite <- c('RU-Cok','FI-Kaa','FI-Sod','SE-Deg','SE-Fla','IS-Gun','FI-Hyy','RU-Zot','SE-Sk2','SE-SK1','SE-Nor','UK-Gri','DK-Fou','RU-Fyo','SE-Faj','UK-ESa','UK-EBu','UK-AMo','DK-Lva','DK-Ris','DK-Sor','RU-Ha2','RU-Ha1','RU-Ha3','NL-Lut','IE-Ca1','PL-wet','NL-Loo','NL-Hor','NL-Haa','IE-Dri','NL-Ca1','NL-Lan','UK-Her','NL-Mol','UK-PL3','BE-Bra','DE-Meh','UK-Tad','UK-Ham','DE-Obe','DE-Geb','DE-Hai','DE-Tha','DE-Gri','DE-Kli','BE-Jal','BE-Lon','DE-Wet','BE-Vie','DE-Bay','CZ-BK1','SK-Tat','CZ-wet','FR-Gri','FR-Hes','FR-Fon','HU-Mat','CH-Lae','CH-Oe2','CH-Oe1','CH-Dav','AT-Neu','HU-Bug','IT-Ren','IT-Mal','IT-MBo','IT-Lav','FR-Lq1','FR-Lq2','IT-LMa','IT-PT1','IT-Cas','FR-LBr','IT-Non','FR-Pue','IT-SRo','IT-Lec','IT-Pia','IT-Ro1','IT-Ro2','ES-VDA','IT-Amp','IT-Col','IT-Cpz','IT-Cp2','IT-BCi','ES-LMa','ES-ES1','ES-ES2','PT-Esp','PT-Mi1','PT-Mi2') |
---|
20 | site.sp=list( |
---|
21 | P.Sylvestris=c('NL-Loo','FI-Hyy','FI-Sod'), |
---|
22 | P.Pinaster=c('IT-SRo','FR-LBr'), |
---|
23 | PiceaSp=c('DE-Bay','DE-Tha ','DE-Wet','IT-Ren','RU-Fyo','SE-Nor','SE-Fla'), |
---|
24 | QuercusIlex=c('FR-Pue','IT-Cpz','PT-Mi1'), |
---|
25 | BetulaSp=c(''), |
---|
26 | FagusSyl.=c('FR-Hes','DE-Hai','IT-Col','DK-Sor'), |
---|
27 | QuercusRob.=c('IT-Non','FR-Fon','IT-Ro1','IT-Ro2'), |
---|
28 | PopulusSp=c('IT-PT1') |
---|
29 | ) |
---|
30 | |
---|
31 | en.mo <- c( |
---|
32 | janv.="January", |
---|
33 | févr.="Febuary", |
---|
34 | mars ="March", |
---|
35 | avril="April", |
---|
36 | mai="May", |
---|
37 | juin="June", |
---|
38 | juil.="July", |
---|
39 | août="August", |
---|
40 | sept.="September", |
---|
41 | oct.="October", |
---|
42 | nov.="November", |
---|
43 | déc.="December") |
---|
44 | |
---|
45 | vol.thres <- list( |
---|
46 | PiceaSp=list( |
---|
47 | YC1=list(DE=c(644,886,26,34,645,944,30,36)), |
---|
48 | YC2=list(DE=c(613,842,22,30,785,958,29,31)), |
---|
49 | YC3=list(DE=c(579,795,25,32,689,1021,28,34)), |
---|
50 | YC4=list(DE=c(543,747,24,31,715,1065,27,32)), |
---|
51 | YC5=list(DE=c(505,698,23,30,746,1117,26,31)), |
---|
52 | YC6=list(DE=c(467,648,22,29,780,1173,25,30)), |
---|
53 | YC7=list(DE=c(427,598,21,28,821,1238,24,29)), |
---|
54 | YC8=list(DE=c(387,547,20,26,872,1320,22,27)), |
---|
55 | YC9=list(DE=c(346,496,19,25,934,1418,21,26)), |
---|
56 | YC10=list(DE=c(304,445,18,24,1011,1541,20,24)), |
---|
57 | YC11=list(DE=c(262,394,16,22,1115,1701,18,23)), |
---|
58 | YC12=list(DE=c(220,343,14,20,1266,1939,20,21)), |
---|
59 | YC13=list(DE=c(177,291,12,18,1496,2309,15,19)), |
---|
60 | YC14=list(DE=c(131,238,10,15,2361,3911,15,19)) |
---|
61 | ) |
---|
62 | ) |
---|
63 | |
---|
64 | ############################################################################################ |
---|
65 | climate.final <- fread('climate.final.txt') |
---|
66 | climate.final2 <- fread('climate_final.txt', fill=TRUE, na.string=c("Inf","-Inf","NA")) |
---|
67 | print(summary(climate.final2 )) |
---|
68 | |
---|
69 | Info.Site <- fread('site_info.txt') |
---|
70 | |
---|
71 | clim.sum <- NULL; clim.sum2 <-NULL; LAI.sum <- NULL; PS.sum <- NULL; WSM.sum <- NULL |
---|
72 | LAI.doy <- NULL; RDI.sum=NULL; GPP.doy=NULL; tot.sum=NULL |
---|
73 | |
---|
74 | for(i in args[-c(1:6)]){ |
---|
75 | |
---|
76 | Table.Summary <- fread(paste0(args[2],'Table.Summary_',i,'.txt')) |
---|
77 | ############################################################################################ |
---|
78 | |
---|
79 | new=NULL |
---|
80 | for (j in LatOrderSite ) { |
---|
81 | if (file.exists(paste0(args[1],j,'_ALL.nc'))==FALSE) next |
---|
82 | else new <- c(new,j) |
---|
83 | } |
---|
84 | LatOrderSite <- new |
---|
85 | print(LatOrderSite) |
---|
86 | ########################################################################################### |
---|
87 | # REshape data to montly value only |
---|
88 | ############################################################################################ |
---|
89 | |
---|
90 | if(args[5]=="M"){ |
---|
91 | |
---|
92 | attach(Table.Summary) |
---|
93 | ob <-melt(tapply(GPP,list(Month,Var2,Site),quantile,probs=0.75), value.name ='GPP75') |
---|
94 | ob2 <-melt(tapply(GPP,list(Month,Var2,Site),quantile,probs=0.25), value.name ='GPP25') |
---|
95 | obf <- merge(ob,ob2,c('Var1','Var2','Var3')) |
---|
96 | names(obf) <- c('Month','PFT','Site','GPP75','GPP25') |
---|
97 | obf <- subset(obf, PFT %in% c(5,6,7,10,12,13,14,15,16,17,18,19,20,21)) |
---|
98 | clim <- merge(obf,climate.final,c('Month','Site')) |
---|
99 | clim$Month <- factor(clim$Month,levels=monthOrder) |
---|
100 | clim$Version <- i |
---|
101 | detach(Table.Summary) |
---|
102 | clim.sum <- rbind(clim.sum,clim) |
---|
103 | |
---|
104 | Table.Sub <- subset(Table.Summary, Month %in% c("juin","juil.","août")) |
---|
105 | attach(Table.Sub) |
---|
106 | ob <-melt(tapply(NPP/GPP,list(Var2,Site),quantile,probs=0.75,na.rm=TRUE), value.name ='Ratio75') |
---|
107 | ob2 <-melt(tapply(NPP/GPP,list(Var2,Site),quantile,probs=0.25,na.rm=TRUE), value.name ='Ratio25') |
---|
108 | obf <- merge(ob,ob2,c('Var1','Var2')) |
---|
109 | names(obf) <- c('PFT','Site','Ratio75','Ratio25') |
---|
110 | obf <- subset(obf, PFT %in% c(5,6,7,10,12,13,14,15,16,17,18,19,20,21)) |
---|
111 | clim2 <- merge(obf,climate.final,c('Site')) |
---|
112 | clim2 <- subset(clim2, Month=='mai') |
---|
113 | clim2$Version <- i |
---|
114 | detach(Table.Sub) |
---|
115 | clim.sum2 <- rbind(clim.sum2,clim2) |
---|
116 | |
---|
117 | attach(Table.Summary) |
---|
118 | ob <-melt(tapply(LAI,list(Month,Var2,Site),max,na.rm=TRUE), value.name ='LAI75') |
---|
119 | ob2 <-melt(tapply(LAI,list(Month,Var2,Site),min,na.rm=TRUE), value.name ='LAI25') |
---|
120 | obf <- merge(ob,ob2,c('Var1','Var2','Var3')) |
---|
121 | names(obf) <- c('Month','PFT','Site','LAI75','LAI25') |
---|
122 | obf <- subset(obf, PFT %in% c(5,6,7,10,12,13,14,15,16,17,18,19,20,21)) |
---|
123 | LAII <- merge(obf,climate.final,c('Month','Site')) |
---|
124 | LAII$Month <- factor(LAII$Month,levels=monthOrder) |
---|
125 | LAII$Version <- i |
---|
126 | detach(Table.Summary) |
---|
127 | LAI.sum <- rbind(LAI.sum,LAII) |
---|
128 | |
---|
129 | } |
---|
130 | |
---|
131 | if(args[5]=="D"){ |
---|
132 | |
---|
133 | Table.Sub <- Table.Summary |
---|
134 | attach(Table.Sub) |
---|
135 | ob <-melt(tapply(LAI,list(Var2,Site,DOY),max,na.rm=TRUE), value.name ='LAIMax') |
---|
136 | ob2 <-melt(tapply(LAI,list(Var2,Site,DOY),min,na.rm=TRUE), value.name ='LAIMin') |
---|
137 | obf <- merge(ob,ob2,c('Var1','Var2','Var3')) |
---|
138 | names(obf) <- c('PFT','Site','DOY','LAIMax','LAIMin') |
---|
139 | LAII <- subset(obf, PFT %in% c(5,6,7,10,12,13,14,15,16,17,18,19,20,21)) |
---|
140 | LAII <- merge(obf,climate.final2,c('Site','DOY')) |
---|
141 | LAII <- merge(LAII,Info.Site,'Site') |
---|
142 | LAII$Version <- i |
---|
143 | detach(Table.Sub) |
---|
144 | LAI.doy <- rbind(LAI.doy,LAII) |
---|
145 | |
---|
146 | |
---|
147 | Table.Sub <- Table.Summary |
---|
148 | attach(Table.Sub) |
---|
149 | ob <-melt(tapply(GPP,list(Var2,Site,DOY),max,na.rm=TRUE), value.name ='GPPMax') |
---|
150 | ob2 <-melt(tapply(GPP,list(Var2,Site,DOY),min,na.rm=TRUE), value.name ='GPPMin') |
---|
151 | ob3 <-melt(tapply(GPP,list(Var2,Site,DOY),median,na.rm=TRUE), value.name ='GPPMed') |
---|
152 | obf <- merge(ob,ob2,c('Var1','Var2','Var3')) |
---|
153 | obf <- merge(obf,ob3,c('Var1','Var2','Var3')) |
---|
154 | names(obf) <- c('PFT','Site','DOY','GPPMax','GPPMin','GPPMed') |
---|
155 | LAII <- subset(obf, PFT %in% c(5,6,7,10,12,13,14,15,16,17,18,19,20,21)) |
---|
156 | LAII <- merge(obf,climate.final2,c('Site','DOY')) |
---|
157 | LAII <- merge(LAII,Info.Site,c('Site')) |
---|
158 | LAII$Version <- i |
---|
159 | detach(Table.Sub) |
---|
160 | GPP.doy <- rbind(GPP.doy,LAII) |
---|
161 | |
---|
162 | |
---|
163 | TS <- Table.Summary[,c('Year','DOY','PLANT_STATUS','Var2','Site')] |
---|
164 | TS <- subset(TS, (PLANT_STATUS==5 & DOY>150) | PLANT_STATUS==3 ) |
---|
165 | TS1 <- TS %>% group_by(Var2,Site,Year) %>% slice(which(PLANT_STATUS==3)[1]) |
---|
166 | TS1[,'Phenology'] <- 'budburst' |
---|
167 | TS2 <- TS %>% group_by(Var2,Site,Year) %>% slice(which(PLANT_STATUS==5)[1]) |
---|
168 | TS2[,'Phenology'] <- 'leaf senescence' |
---|
169 | TS <- rbind(TS1,TS2) |
---|
170 | |
---|
171 | |
---|
172 | attach(TS) |
---|
173 | ob <-melt(tapply(DOY,list(Phenology,Var2,Site),max,na.rm=TRUE), value.name ='PSmax') |
---|
174 | ob2 <-melt(tapply(DOY,list(Phenology,Var2,Site),min,na.rm=TRUE), value.name ='PSmin') |
---|
175 | obf <- merge(ob,ob2,c('Var1','Var2','Var3')) |
---|
176 | names(obf) <- c('Phenology','PFT','Site','PSmax','PSmin') |
---|
177 | obf <- subset(obf, PFT %in% c(5,6,7,10,12,13,14,15,16,17,18,19,20,21)) |
---|
178 | PS <- merge(obf,climate.final,c('Site')) |
---|
179 | PS <- unique(PS[,c('Phenology','PFT','Site','PSmax','PSmin','Lat')]) |
---|
180 | PS[,'Site'] <- factor(PS[,'Site'],levels=rev(LatOrderSite)) |
---|
181 | PS$Version <- i |
---|
182 | detach(TS) |
---|
183 | PS.sum <- rbind(PS.sum,PS) |
---|
184 | |
---|
185 | tot.tab = merge(Table.Summary,Info.Site,'Site') |
---|
186 | tot.tab$Version <- i |
---|
187 | tot.sum <- rbind(tot.sum,tot.tab) |
---|
188 | |
---|
189 | } |
---|
190 | |
---|
191 | } |
---|
192 | print('Reformating done !') |
---|
193 | |
---|
194 | ############################################################################################ |
---|
195 | # forestry graphics |
---|
196 | ############################################################################################ |
---|
197 | if(args[5]=="M"){ |
---|
198 | |
---|
199 | pdf(paste0('Forestry_Eval_',args[6],'.pdf'),width=16,height=10) |
---|
200 | for(i in 7){ |
---|
201 | STR.bot <- NULL |
---|
202 | fm='DE' |
---|
203 | ycorder <- c('YC1','YC2','YC3','YC4','YC5','YC6','YC7','YC8','YC9','YC10','YC11','YC12','YC13','YC14') |
---|
204 | for(j in ycorder){ |
---|
205 | vol.bot.min <- vol.thres[[names[[i]]]][[j]][[fm]][1]/10000 |
---|
206 | vol.bot.max <- vol.thres[[names[[i]]]][[j]][[fm]][2]/10000 |
---|
207 | STR.b <- subset(Table.Summary, Var2==i & WOOD_VOL > vol.bot.min & WOOD_VOL < vol.bot.max & Site %in% c('DE-Hai','DE-Tha','DE-Wet','DE-Bay')) |
---|
208 | if(nrow(STR.b) == 0) next |
---|
209 | STR.b[,"Yield"] <- j |
---|
210 | STR.b[,"ind.min"] <- vol.thres[[names[[i]]]][[j]][[fm]][5] |
---|
211 | STR.b[,"ind.max"] <- vol.thres[[names[[i]]]][[j]][[fm]][6] |
---|
212 | STR.b[,"dg.min"] <- vol.thres[[names[[i]]]][[j]][[fm]][3] |
---|
213 | STR.b[,"dg.max"] <- vol.thres[[names[[i]]]][[j]][[fm]][4] |
---|
214 | STR.b[,"H.min"] <- vol.thres[[names[[i]]]][[j]][[fm]][7] |
---|
215 | STR.b[,"H.max"] <- vol.thres[[names[[i]]]][[j]][[fm]][8] |
---|
216 | STR.bot <- rbind(STR.bot,STR.b) |
---|
217 | } |
---|
218 | STR.bot[,"Yield"] <- factor(STR.bot[,"Yield"],levels=ycorder) |
---|
219 | x2= ggplot(STR.bot,aes(as.factor(Site), IND*10000, linetype=Version))+ |
---|
220 | geom_boxplot(fill="grey50")+ ylim(0,14000)+ |
---|
221 | geom_hline(aes(yintercept = ind.max),linetype = 2, colour='red',size=1.5)+ |
---|
222 | geom_hline(aes(yintercept = ind.min),linetype = 2, colour='red',size=1.5)+ |
---|
223 | xlab("") + ylab("number of individue (tree/ha)") + coord_flip()+ facet_grid(.~Yield) |
---|
224 | x3= ggplot(STR.bot,aes(as.factor(Site), DIAMETER_DOM*100, linetype=Version))+ |
---|
225 | geom_boxplot(fill="grey50")+ ylim(0,40) + |
---|
226 | geom_hline(aes(yintercept = dg.max),linetype = 2, colour='red',size=1.5)+ |
---|
227 | geom_hline(aes(yintercept = dg.min),linetype = 2, colour='red',size=1.5)+ |
---|
228 | xlab("") + ylab("dominant diameter (cm)") + coord_flip()+ facet_grid(.~Yield) |
---|
229 | x4= ggplot(STR.bot,aes(as.factor(Site), HEIGHT_DOM, linetype=Version))+ |
---|
230 | geom_boxplot(fill="grey50")+ ylim(0,25) + |
---|
231 | geom_hline(aes(yintercept = H.max),linetype = 2, colour='red',size=1.5)+ |
---|
232 | geom_hline(aes(yintercept = H.min),linetype = 2, colour='red',size=1.5)+ |
---|
233 | xlab("") + ylab("dominant height (m)") + coord_flip()+ facet_grid(.~Yield) |
---|
234 | grid.arrange(x2,x3,x4,nrow=3) |
---|
235 | } |
---|
236 | dev.off() |
---|
237 | |
---|
238 | ############################################################################################## |
---|
239 | # LAI WSM graphics V2 |
---|
240 | ############################################################################################## |
---|
241 | pdf(paste0('LAI-WSM_eval_',args[7],'.pdf'),width=16,height=10) |
---|
242 | for(i in c(5,7,12,13,14)){ |
---|
243 | subtable <- subset(LAI.sum, PFT==i & Lat<57 & Lat>=45) |
---|
244 | subtablebo <- subset(LAI.sum, PFT==bo[i] & Lat>=57 ) |
---|
245 | subtableso <- subset(LAI.sum, PFT==i & Lat<45 ) |
---|
246 | subtableBE <- subset(subtablebo, PFT==bo[i] & Site %in% site.sp[[names[i]]]) |
---|
247 | subtableTE <- subset(subtable, PFT==i & Site %in% site.sp[[names[i]]]) |
---|
248 | subtableME <- subset(subtableso, PFT==i & Site %in% site.sp[[names[i]]]) |
---|
249 | x1= ggplot(LAI.sum,aes(as.factor(Lat),y=LAI25, ymin=LAI25,ymax=LAI75,linetype=Version)) + |
---|
250 | theme_bw()+ ylim(0,10)+ |
---|
251 | geom_crossbar(data= subtablebo, fill="deepskyblue3",alpha=0.3,fatten=1)+ |
---|
252 | geom_crossbar(data= subtable, fill="chartreuse4",alpha=0.3,fatten=1)+ |
---|
253 | geom_crossbar(data= subtableso, fill="darkorange3",alpha=0.3,fatten=1) + |
---|
254 | geom_crossbar(data= subtableTE, fill="chartreuse4",fatten=1) + |
---|
255 | geom_crossbar(data= subtableME, fill="darkorange3",fatten=1) + |
---|
256 | geom_crossbar(data= subtableBE, fill="deepskyblue3",fatten=1)+ |
---|
257 | xlab("") + ylab("LAI in m2/m2") + scale_x_discrete(labels = rev(LatOrderSite)) + |
---|
258 | facet_grid(.~Month,labeller = labeller(Month=en.mo)) + coord_flip()+ |
---|
259 | theme(panel.spacing = unit(0, "lines"),strip.text.x = element_text(face = "bold",size=18)) |
---|
260 | subtable <- subset(WSM.sum, PFT==i & Lat<57 & Lat>=45) |
---|
261 | subtablebo <- subset(WSM.sum, PFT==bo[i] & Lat>=57 ) |
---|
262 | subtableso <- subset(WSM.sum, PFT==i & Lat<45 ) |
---|
263 | subtableBE <- subset(subtablebo, PFT==bo[i] & Site %in% site.sp[[names[i]]]) |
---|
264 | subtableTE <- subset(subtable, PFT==i & Site %in% site.sp[[names[i]]]) |
---|
265 | subtableME <- subset(subtableso, PFT==i & Site %in% site.sp[[names[i]]]) |
---|
266 | x2= ggplot(WSM.sum,aes(as.factor(Lat),y=WSM25, ymin=WSM25,ymax=WSM75,linetype=Version)) +theme_bw()+ |
---|
267 | geom_crossbar(data= subtablebo, fill="deepskyblue3",alpha=0.3,fatten=1)+ |
---|
268 | geom_crossbar(data= subtable, fill="chartreuse4",alpha=0.3,fatten=1)+ |
---|
269 | geom_crossbar(data= subtableso, fill="darkorange3",alpha=0.3,fatten=1) + |
---|
270 | geom_crossbar(data= subtableTE, fill="chartreuse4",fatten=1) + |
---|
271 | geom_crossbar(data= subtableME, fill="darkorange3",fatten=1) + |
---|
272 | geom_crossbar(data= subtableBE, fill="deepskyblue3",fatten=1)+ |
---|
273 | xlab("") + ylab("monthly average water stress") + ylim(0,1) + coord_flip() + |
---|
274 | scale_x_discrete(labels = rev(LatOrderSite)) + |
---|
275 | facet_grid(.~Month,labeller = labeller(Month=en.mo)) |
---|
276 | grid.arrange(x1,x2,nrow=2,top = textGrob(paste('PFT:',i,'called',names[i], "10% and 90% quantile of a 250 years simulation"),gp=gpar(fontsize=20,font=3))) |
---|
277 | } |
---|
278 | dev.off() |
---|
279 | ################################################################################################### |
---|
280 | } |
---|
281 | |
---|
282 | if(args[5]=="D" & args[6]=="SBG"){ |
---|
283 | |
---|
284 | ###################################################################### |
---|
285 | # Global analysis # |
---|
286 | ###################################################################### |
---|
287 | |
---|
288 | pdf(paste0('global_eval_',args[7],'.pdf'),width=16,height=10) |
---|
289 | for(i in c(10,13,14,5,6,7,18,19)){ |
---|
290 | datasp=subset(GPP.doy,PFT==i & PFT==SPE,Site) |
---|
291 | droplevels(datasp) |
---|
292 | nbsite = unique(datasp) |
---|
293 | nofacet = dim(nbsite)[1]>1 |
---|
294 | x1 = ggplot(subset(GPP.doy, PFT==SPE & PFT==i), aes(x=DOY,ymin=GPPMin,ymax=GPPMax,colour=Version)) + |
---|
295 | geom_ribbon(alpha=0.4,size=0.2)+ xlab("DOY") + ylab("GPP") + |
---|
296 | {if(nofacet)facet_wrap(.~Site, scales = "free")}+ |
---|
297 | geom_ribbon(aes(ymin=GPP.min,ymax=GPP.max),alpha=0.1,colour='black',size=0.2)+ |
---|
298 | geom_smooth(aes(y=GPP.med),colour='black',linetype=2,size=0.2,span = 0.3)+ |
---|
299 | geom_smooth(aes(y=GPPMed,colour=Version),linetype=2,size=0.2,span = 0.3) |
---|
300 | grid.arrange(x1,nrow=1,top = textGrob(paste('PFT:',i,'called',names[i],"Min and Max of 50 years simulation"),gp=gpar(fontsize=20,font=3))) |
---|
301 | |
---|
302 | x1 = ggplot(subset(LAI.doy, PFT==SPE & PFT==i), aes(x=DOY,ymin=LAIMin,ymax=LAIMax,colour=Version))+ |
---|
303 | geom_ribbon(alpha=0.4,size=0.2)+ xlab("DOY") + ylab("LAI") + |
---|
304 | geom_line(aes(y=LAImax),linetype=2,colour='black',size=0.2)+ |
---|
305 | geom_line(aes(y=LAImin),linetype=2,colour='black',size=0.2)+ |
---|
306 | {if(nofacet)facet_wrap(.~Site, scales = "free")} |
---|
307 | grid.arrange(x1,nrow=1,top = textGrob(paste('PFT:',i,'called',names[i],"Interannual Min and Max"),gp=gpar(fontsize=20,font=3))) |
---|
308 | |
---|
309 | x1 = ggplot(subset(tot.sum, Var2==SPE & Var2==i), aes(x=as.Date(Date),y=LAI, colour=Version))+ |
---|
310 | ylab("LAI") + geom_smooth(aes(linetype=Version),size=0.2,span = 0.1)+ |
---|
311 | {if(nofacet)facet_wrap(.~Site, scales = "free")}+ ylim(0,10) |
---|
312 | grid.arrange(x1,nrow=1,top = textGrob(paste('PFT:',i,'called',names[i]),gp=gpar(fontsize=20,font=3))) |
---|
313 | |
---|
314 | x1 = ggplot(subset(tot.sum, Var2==SPE & Var2==i), aes(x=as.Date(Date),y=GPP,colour=Version))+ |
---|
315 | ylab("GPP") + geom_smooth(aes(linetype=Version),size=0.2,span = 0.1)+ |
---|
316 | {if(nofacet)facet_wrap(.~Site, scales = "free")} |
---|
317 | grid.arrange(x1,nrow=1,top = textGrob(paste('PFT:',i,'called',names[i]),gp=gpar(fontsize=20,font=3))) |
---|
318 | |
---|
319 | x1 = ggplot(subset(tot.sum, Var2==SPE & Var2==i), aes(x=as.Date(Date),y=IND,colour=Version))+ |
---|
320 | ylab("IND") + geom_line(aes(linetype=Version),size=0.2)+ ylim(0,1.4)+ |
---|
321 | {if(nofacet)facet_wrap(.~Site, scales = "free")} |
---|
322 | x2 = ggplot(subset(tot.sum, Var2==SPE & Var2==i), aes(x=as.Date(Date),y=RDI,colour=Version))+ |
---|
323 | ylab("RDI") + geom_line(aes(linetype=Version),size=0.2)+ ylim(0.25,1)+ |
---|
324 | {if(nofacet)facet_wrap(.~Site, scales = "free")} |
---|
325 | grid.arrange(x1,x2,nrow=2,top = textGrob(paste('PFT:',i,'called',names[i]),gp=gpar(fontsize=20,font=3))) |
---|
326 | |
---|
327 | #If(leaftype(i)=='Deciduous'){ |
---|
328 | # x1 = ggplot(subset(PS.sum,PFT==i),aes(Site, y=PSmin, ymin=PSmin,ymax=PSmax,colour=Version)) + |
---|
329 | # geom_crossbar(aes(group=Phenology),fill='black',alpha=0.3,fatten=1)+ |
---|
330 | # geom_hline(yintercept = 90,linetype = 2)+ |
---|
331 | # geom_hline(yintercept = 130,linetype = 2)+ |
---|
332 | # geom_hline(yintercept = 310,linetype = 2)+ |
---|
333 | # geom_hline(yintercept = 285,linetype = 2)+ |
---|
334 | # xlab("") + ylab("DOY") + ylim(0,366) + coord_flip() |
---|
335 | # grid.arrange(x1,nrow=1,top = textGrob(paste('PFT:',i,'called',names[i], "Min and Max of 50 years simulation"),gp=gpar(fontsize=20,font=3))) |
---|
336 | #} |
---|
337 | |
---|
338 | } |
---|
339 | dev.off() |
---|
340 | |
---|
341 | } |
---|
342 | |
---|
343 | if(args[5]=="D" & args[6]=="SFR"){ |
---|
344 | |
---|
345 | } |
---|
346 | |
---|
347 | |
---|