diff --git a/Tage.xlsx b/Tage.xlsx new file mode 100644 index 0000000..ccdce79 Binary files /dev/null and b/Tage.xlsx differ diff --git a/kalender-t1.xlsx b/kalender-t1.xlsx new file mode 100644 index 0000000..ab27e7f Binary files /dev/null and b/kalender-t1.xlsx differ diff --git a/kalender-t2.xlsx b/kalender-t2.xlsx new file mode 100644 index 0000000..37de807 Binary files /dev/null and b/kalender-t2.xlsx differ diff --git a/kalender-t3.xlsx b/kalender-t3.xlsx new file mode 100644 index 0000000..38d210f Binary files /dev/null and b/kalender-t3.xlsx differ diff --git a/r-scripts/data/data.Rproj b/r-scripts/data/data.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/r-scripts/data/data.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/r-scripts/data/distribution.R b/r-scripts/data/distribution.R new file mode 100644 index 0000000..9dd72f2 --- /dev/null +++ b/r-scripts/data/distribution.R @@ -0,0 +1,41 @@ +library(tidyverse, warn.conflicts = FALSE) +library(DBI, warn.conflicts = FALSE) +library(tidyr, warn.conflicts = FALSE) +library(dplyr, warn.conflicts = FALSE) + +HOME <- Sys.getenv("HOME") +Sys.setenv(PGHOST = "db.mainscnt.eu", + PGDATABASE = "power", + PGPORT = 5432, + PGUSER = "wn", + PGSSLMODE = "verify-ca", + PGSSLKEY = paste(HOME, "/keys/psql/wn-postgresql-client-2.key", sep=""), + PGSSLCERT = paste(HOME, "/keys/psql/wn-postgresql-client-2.crt", sep=""), + PGSSLROOTCERT = paste(HOME, "/keys/psql/postgres-ca.crt", sep="")) + + +con <- dbConnect(RPostgres::Postgres()) + +YEAR <- 2022 +res <- dbSendQuery(con, " + select + date_trunc('day', time)::date as day, + avg(temperature) as temperature + from room_climate_measurement_t + where + category = 'Outdoor' and + location = 'Outdoor' and + extract('hour' from time) = 12 and + extract('year' from time) = $1 + group by day + order by day +") +dbBind(res, list(YEAR)) +distribution <- dbFetch(res) +dbClearResult(res) + +g <- ggplot(data = distribution, aes(x = temperature)) + + geom_histogram(binwidth = 1) + +print(g) + diff --git a/r-scripts/data/distribution.pdf b/r-scripts/data/distribution.pdf new file mode 100644 index 0000000..0868870 Binary files /dev/null and b/r-scripts/data/distribution.pdf differ diff --git a/simulation/gradient.png b/simulation/gradient.png new file mode 100644 index 0000000..7385c92 Binary files /dev/null and b/simulation/gradient.png differ diff --git a/simulation/simulate.py b/simulation/simulate.py new file mode 100644 index 0000000..c980a69 --- /dev/null +++ b/simulation/simulate.py @@ -0,0 +1,91 @@ +import png +import psycopg +import json + +COLORS = ( + (128, 0, 0), + (130, 40, 40), + (141, 83, 59), + (153, 102, 117), + (153, 102, 169), + (128, 0, 128), + (101, 0, 155), + (72, 0, 225), + (4, 0, 208), + (0, 68, 220), + (1, 114, 226), + (1, 159, 232), + (11, 175, 162), + (23, 179, 77), + (0, 212, 28), + (0, 255, 0), + (128, 255, 0), + (200, 255, 0), + (255, 255, 0), + (255, 219, 0), + (255, 182, 0), + (255, 146, 0), + (255, 109, 0), + (255, 73, 0), + (255, 0, 0), + (255, 0, 128), + (255, 105, 180), + (255, 0, 255), + (168, 0, 185) +) + + +conn = psycopg.connect("dbname=power") +with conn: + with conn.cursor() as cur: + cur.execute(""" + select + date_trunc('day', time)::date::varchar as day, + avg(temperature)::int as temperature + from room_climate_measurement_t + where + category = 'Outdoor' and + location = 'Outdoor' and + extract('hour' from time) = 12 and + extract('year' from time) = 2022 + group by day + order by day + """) + res = cur.fetchall() + temperatures = [ x[1] for x in res ] + # print(json.dumps(temperatures)) +conn.close() + +min_t = min(temperatures) +max_t = max(temperatures) +span_t = max_t - min_t +# print(f"{min_t=}, {max_t=}, {span_t=}") + +temperatures = [ int(x/2) for x in temperatures ] +min_t = min(temperatures) +max_t = max(temperatures) +span_t = max_t - min_t +# print(f"{min_t=}, {max_t=}, {span_t=}") + +temperatures = [ x - min_t for x in temperatures ] +min_t = min(temperatures) +max_t = max(temperatures) +span_t = max_t - min_t +# print(f"{min_t=}, {max_t=}, {span_t=}") + + +height = 350 + +img = [] +for i in range(height): + row = () + for t in temperatures: + for j in range(3): + row += COLORS[t] + img.append(row) + +width = len(temperatures) * 3 + +with open('temperature.png', 'wb') as f: + w = png.Writer(width, height, greyscale=False) + w.write(f, img) diff --git a/simulation/t.py b/simulation/t.py new file mode 100644 index 0000000..77f530a --- /dev/null +++ b/simulation/t.py @@ -0,0 +1,20 @@ +import png + +width = 2400 +height = 1000 +img = [] + +for y in range(height): + row = () + for x in range(int(width/3)): + row = row + (255, 0, 0) + for x in range(int(width/3)): + row = row + (0, 255, 0) + for x in range(int(width/3)): + row = row + (0, 0, 255) + img.append(row) + +with open('gradient.png', 'wb') as f: + w = png.Writer(width, height, greyscale=False) + w.write(f, img) + diff --git a/simulation/temperature.png b/simulation/temperature.png new file mode 100644 index 0000000..f8ab2e4 Binary files /dev/null and b/simulation/temperature.png differ