-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskyline_graph_v2.r
78 lines (65 loc) · 1.77 KB
/
skyline_graph_v2.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
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
# INTRODUCTION DONNEES ATTRIBUTAIRES SQL
library (RODBC)
library (plotrix)
library (reshape)
ch = odbcConnect("PostgreSQL35W",uid="hug",pwd="hug")
sql=
"
/*
select a.gid, nom_station, azimut, angle from stations.station_meteo_skyline a
join stations.geo_station_meteofrance b on a.gid=b.gid
*/
select gid, gid nom_station, azimut, angle from stations.station_meteo_skyline_v2
"
data=sqlQuery(ch, paste(sql, collapse=' '))
close(ch)
mylim <- ceiling(max(data[,4])/20)*20
#data2 <- cast(data, nom_station ~ azimut, value = "angle")
for (sta in unique(data[,1])){
png(
file=paste0("C:/Users/hugues.francois/Desktop/github/skyline/graph_",sta,".png"),
width = 800, height=600, res=150
)
mylay<-layout(matrix(c(
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3)
,18,2))
#layout.show(mylay)
par(mar = c(0,0,0,0))
plot.new()
mtext(unique(data[data[,1]==sta,2]), cex=1, line =-4)
par(mar=c(2,2,0,1), cex.axis=.6)
data2 <- cast(data[data[,1]==sta,2:4], nom_station ~ azimut, value = "angle")
radial.plot(
mylim-data2[,2:length(data2)],
labels=c("N","NE","E","SE","S","SW","W","NW"),
rp.type="p",
radial.lim=c(0,mylim),
radial.labels=rev(pretty(c(0,mylim))),
boxed.radial=F,
grid.unit ="°",
line.col="#648bda",
lwd = 2,
start=pi/2,
clockwise = T,
poly.col="#648bda50"
)
par(mar=c(2,4,0,1))
plot(data[data[,1]==sta,3], data[data[,1]==sta,4],
type = "l",
col="#648bda",
lwd = 2,
axes=F,
ylim=c(0,mylim),
xlab = NA,
ylab = NA,
xlim=c(0,360)
)
axis(side = 1, tck = -.02, labels = NA)
axis(side=1, line = -.8, lwd = 0, cex.axis =.7, font.lab=2)
mtext(side=1, line=1.2, cex=.6, "Azimuts (degrees)")
axis(side = 2, tck = -.02, labels = NA)
axis(side=2, line = -.6, lwd = 0, cex.axis =.7, font.lab=2)
mtext(side=2, line=1.4, cex=.6, "Skyline angle (degrees)")
dev.off()
}