complete first draft of package
[epclust.git] / old_C_code / stage2_UNFINISHED / src / unused / descriptive-32K.r
CommitLineData
ad642dc6
BA
1# File: descriptive-32K.r
2
3rm(list = ls())
4#library(dplyr)
5
6## Following lines allow to construct the data file
7## totconso-par-indiv.txt.
8## They are very time&memory-consumming
9#library(data.table)
10#d10 <- fread("~/tmp/data/2010.csv")
11#tot <- d10[, list(tot= sum(CPP_PUISSANCE_BRUTE),
12# min= min(CPP_PUISSANCE_BRUTE),
13# max= max(CPP_PUISSANCE_BRUTE),
14# sd = sd( CPP_PUISSANCE_BRUTE)),
15# by = FK_CCU_ID]
16# write.table(file = "~/tmp/data/totconso-par-indiv.txt", tot)
17
18tot <- read.table("~/tmp/data/totconso-par-indiv.txt")
19synchro <- read.table("~/tmp/data/syncrone2010.txt")
20mat_synchro <- matrix(c(synchro$V1[1:2], synchro$V1) / 1e6,
21 ncol = 48,
22 byrow = TRUE)
23
24xHour <- seq(1/2, 24, length.out = 48)
25xDate <- seq.Date(from = as.Date("2010/1/1"),
26 to = as.Date("2011/1/1"),
27 length.out = 365 * 48 - 2)
28
29# Filter infra daily
30plot(xDate, filter(synchro$V1 / 1e6, rep(1 / 48, 48)),
31 type = 'l',
32 main = 'Synchrone 2010',
33 ylab = 'Charge (en Mwh)',
34 xlab = 'Time')
35
36# Daily
37matplot(xHour, scale(t(mat_synchro)), type = 'l', lty = 1,
38 col = rgb(0, 0, 0, .25),
39 main = 'Synchrone jounalière (norm.)',
40 xlab = 'Heures', ylab = 'Charge (en Mwh)')
41
42
43tot_order <- tot[order(tot$tot), ]
44max_order <- tot[order(tot$max), ]
45
46## Mesures aberrantes ?
47tail(cbind(max_order[,1], max_order[,-1] / 1e3))
48
49
50## I want to recuperate ids: 186733, 191819, 193174
51## which corresponds to places 1, 2481, 3478
52# identiants <- read.table('~/tmp/data/identifs.txt')
53# match(c(186733, 191819, 193174), identiants$V1)
54
55#c186733 <- d10[, FK_CCU_ID == 186733]
56#c191819 <- d10[, FK_CCU_ID == 191819]
57#c193174 <- d10[, FK_CCU_ID == 193174]
58
59c186733 <- read.csv("~/tmp/data/c186733.csv")[, 4] / 1e3
60
61mat_186733 <- matrix(c(c186733[1:2], c186733),
62 ncol = 48,
63 byrow = TRUE)
64
65# Filter infra daily
66plot(xDate, filter(c186733, rep(1 / 48, 48)),
67 type = 'l',
68 main = "Consommation individuelle (2010)",
69 ylab = 'Charge (en Mwh)',
70 xlab = 'Temps')
71
72# Daily (raw)
73matplot(xHour, t(mat_186733), type = 'l', lty = 1,
74 col = rgb(0, 0, 0, .25),
75 #main = "Consommation individuelle journalière "
76 xlab = 'Heures', ylab = 'Charge (en Mwh)')
77
78# Daily (standarized)
79matplot(xHour, scale(t(mat_186733)), type = 'l', lty = 1,
80 col = rgb(0, 0, 0, .25),
81 xlab = 'Heures', ylab = 'Charge (en Mwh)')