
#2011, Eulalie Sauthier, Master Thesis

# Plot les graphes qui comparent les précipitations et les glaciers 
prec_lp<-read.csv("Glaciers/résumé/4st_sion.csv") #importe les données de précipitations
prec_lp<-prec_lp[3]
glaciers_vs <-read.csv("Glaciers/résumé/glaciers_vs_up.csv") #importe les données de glaciers
glaciers_vs<-glaciers_vs[2:7]
star_gl<-1864 #date de départ
out<-monthtoyear(prec_lp) #transforme les données mensuelles en annuelles
prec_lp_ts<-ts(out,start=(star_gl),end=(2010),freq=1) #série temporelle
color=rainbow(17) #palette de couleurs
	
pdf("../Image/Glaciers_sion_part_1.pdf")#génère la figure 1
par(mfrow = c(3, 1))
plot(prec_lp_ts,type="h",col="black",ylab=colnames(prec_lp)) 
box(which = "figure")
plot(ts(glaciers_vs[ ,1], start=c(star_gl,1)),col=color[1],type="h",ylab=colnames(glaciers_vs)[1] )
box(which = "figure")
plot(ts(glaciers_vs[ ,2], start=c(star_gl,1)),col=color[2],type="h",ylab=colnames(glaciers_vs)[2])
box(which = "figure")
dev.off()

pdf("../Image/Glaciers_sion_part_2.pdf")#génère la figure 1
par(mfrow = c(3, 1))
plot(prec_lp_ts,type="h",col="black",ylab=colnames(prec_lp)) 
box(which = "figure")
plot(ts(glaciers_vs[ ,3], start=c(star_gl,1)),col=color[3],type="h",ylab=colnames(glaciers_vs)[3] )
box(which = "figure")
plot(ts(glaciers_vs[ ,4], start=c(star_gl,1)),col=color[4],type="h",ylab=colnames(glaciers_vs)[4])
box(which = "figure")
dev.off()

pdf("../Image/Glaciers_sion_part_3.pdf")#génère la figure 1
par(mfrow = c(3, 1))
plot(prec_lp_ts,type="h",col="black",ylab=colnames(prec_lp)) 
box(which = "figure")
plot(ts(glaciers_vs[ ,5], start=c(star_gl,1)),col=color[5],type="h",ylab=colnames(glaciers_vs)[5] )
box(which = "figure")
plot(ts(glaciers_vs[ ,6], start=c(star_gl,1)),col=color[6],type="h",ylab=colnames(glaciers_vs)[6])
box(which = "figure")
dev.off()
j<-1

#génère les scatters
for(j in 1:length(colnames(glaciers_vs))){
#glaciers_vs_ts<-0
glaciers_vs_ts<-ts(glaciers_vs[ ,j], start=c(star_gl,1))
scatter_p_vs_r(prec_lp_ts, glaciers_vs_ts, glaciers_vs, prec_lp,j,0,100,-250,200)
scatter_p_vs_gl_decal(prec_lp_ts, glaciers_vs_ts, glaciers_vs, prec_lp,j,0,100,-250,200)
}
