-
Notifications
You must be signed in to change notification settings - Fork 1
/
draw_peabel.R
52 lines (40 loc) · 1.9 KB
/
draw_peabel.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
draw_peabel<-function(matrice_coefficienti,comando_plottaggio)
{
library("evd")
x<-seq(from=1, to=100,by=0.1)
nomi_dati<-gsub("X","",row.names(matrice_coefficienti))
colori<-c(NULL)
# colori<-c(colori,colors()[sample(10:150,10,replace=F)]) #Seleziona DIECI numeri casuali tra 10 e 150,
#, sceglie per quel valore il colore associato da colors() e lo immagazzina.
colori<-c("red","blue","green","gold","turquoise1","mediumpurple","orange3","coral")
leg_col<-colori[1:length(matrice_coefficienti[,1])]
if(comando_plottaggio=="Y")
{
plot(x,pgumbel(x,scale=as.numeric(matrice_coefficienti[1,1]),loc=as.numeric(matrice_coefficienti[1,2])),type="l",col=colori[1],xlab="Precipitazione [mm]",ylab="P[h]",main="Migliori curve di Gumbel approssimanti le precipitazioni cumulate")
legend(x="bottomright",legend=nomi_dati,col=leg_col,bty="n",lwd=2)
if(length(matrice_coefficienti[,1])>1)
{
for(i in 2:length(matrice_coefficienti[,1]))
{
lines(x,pgumbel(x,scale=as.numeric(matrice_coefficienti[i,1]),loc=as.numeric(matrice_coefficienti[i,2])),col=colori[i])
}
}
}
else if(comando_plottaggio=="N")
{
path<-file.path(paste(getwd()),"Gumbelplots","Best_fit/")
dir.create(path,recursive=TRUE,showWarnings=FALSE)
path<-paste(paste(path),"Gumbelbest","from", paste(nomi_dati[1]), "to", paste(nomi_dati[length(nomi_dati)]), ".pdf", sep="_")
pdf(file=path)
plot(x,pgumbel(x,scale=as.numeric(matrice_coefficienti[1,1]),loc=as.numeric(matrice_coefficienti[1,2])),type="l",col=colori[1],xlab="Precipitazione [mm]",ylab="P[h]",main="Migliori curve di Gumbel approssimanti le precipitazioni cumulate")
legend(x="bottomright",legend=nomi_dati,col=leg_col,bty="n",lwd=2)
if(length(matrice_coefficienti[,1])>1)
{
for(i in 2:length(matrice_coefficienti[,1]))
{
lines(x,pgumbel(x,scale=as.numeric(matrice_coefficienti[i,1]),loc=as.numeric(matrice_coefficienti[i,2])),col=colori[i])
}
}
dev.off()
}
}