-
Notifications
You must be signed in to change notification settings - Fork 1
/
_shared.r
executable file
·53 lines (45 loc) · 1.56 KB
/
_shared.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
# - INIT -----------------------------------------------------------------------
options(repos = "https://cran.wu.ac.at/")
if (!'librarian' %in% rownames(installed.packages())) install.packages("librarian")
loadPackages = librarian::shelf
loadPackages(
'data.table', 'zoo', 'glue', 'lubridate', 'jsonlite', 'httr', 'xml2', 'googledrive', 'clock'
)
source("_storage.r")
# - GLOB -----------------------------------------------------------------------
g = modifyList(read_json("config.json"), list(
entsoe = list(
params = list(
protocol = "sftp",
server = "sftp-transparency.entsoe.eu/"
),
fileTypes = list(
generation = "AggregatedGenerationPerType_16.1.B_C",
load = "ActualTotalLoad_6.1.A",
dayAheadPrices = "DayAheadPrices_12.1.D",
netPositions = "ImplicitAllocationsNetPositionsDaily_12.1.E"
)
), gie = list(
params = list()
), aggm = list(
params = list()
)
))
# - CREDS ----------------------------------------------------------------------
creds = read_json(g$f$creds)
invisible(sapply(names(creds), function(n) {
g[[n]]$params <<- modifyList(g[[n]]$params, creds[[n]])
}))
rm(creds)
# - HELPERS --------------------------------------------------------------------
removeLastDays = function(d, days = 1) {
d[date <= max(date, na.rm = TRUE) - days, ]
}
# logging
l = function (..., iL = 0, nL = TRUE) {
iS = paste(rep(" ", iL), collapse = "")
m = paste0(iS, paste0(...))
if (nL)
m = paste0(m, "\n")
cat(m)
}