Data processing and plotting for 'Personal Flash' artworks.
https://www.nicolaellisandritherdon.com
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
60 lines
1.9 KiB
1 year ago
|
from bokeh.plotting import figure, output_file, save, show
|
||
|
from bokeh.models import Legend, ColumnDataSource
|
||
|
import bokeh.palettes
|
||
|
import pandas as pd
|
||
|
import numpy as np
|
||
|
import random
|
||
|
|
||
|
# Hour Slots, hardcoded to reduce duplicated processing of data.
|
||
|
x_vals = ["00", "01", "02", "03", "04", "05",
|
||
|
"06", "07", "08", "09", "10", "11",
|
||
|
"12", "13", "14", "15", "16", "17",
|
||
|
"18", "19", "20", "21", "22", "23",
|
||
|
"24"]
|
||
|
dates = []
|
||
|
y_vals = []
|
||
|
file_data = []
|
||
|
for month in range(6, 8, 1) :
|
||
|
for day in range(1, 31, 1) :
|
||
|
if (day < 10) :
|
||
|
d = f"0{day}"
|
||
|
else :
|
||
|
d = day
|
||
|
if day < 13 and month == 6 :
|
||
|
print(f"Skipping: data/light-meter-2-hourly-totals/2021-0{month}/2012-0{month}-{d}.csv")
|
||
|
else :
|
||
|
file_path = f"data/light-meter-2-hourly-totals/2021-0{month}/2021-0{month}-{d}.csv"
|
||
|
single_file = pd.read_csv (file_path, sep="," ,header=None,
|
||
|
index_col=False, dtype='unicode')
|
||
|
dates.append(f"2021-0{month}-{d}")
|
||
|
file_data.append(single_file.values[1:])
|
||
|
|
||
|
p = figure(title="Total Hourly Reading for Light Meter 2 (Tony)",
|
||
|
x_axis_label="Hour",
|
||
|
y_axis_label="Total Readings",
|
||
|
sizing_mode="stretch_both")
|
||
|
p.axis.major_label_text_font_size = "12px"
|
||
|
p.axis.major_label_standoff = 10
|
||
|
|
||
|
def random_colour():
|
||
|
r = random.randint(0,255)
|
||
|
g = random.randint(0,255)
|
||
|
b = random.randint(0,255)
|
||
|
rgb = [r,g,b]
|
||
|
return rgb
|
||
|
|
||
|
for day in dates :
|
||
|
for row in file_data :
|
||
|
y_vals = []
|
||
|
for data in row :
|
||
|
reading = data[1]
|
||
|
y_vals.append(reading)
|
||
|
p.line(x = np.asarray(x_vals).astype(str),
|
||
|
y = np.asarray(y_vals).astype(int),
|
||
|
# legend_label=f"{day}",
|
||
|
line_color=random_colour())
|
||
|
|
||
|
output_file("output/lm2-hourly-totals.html",
|
||
|
title="Total Hourly Reading for Light Meter 2")
|
||
|
save(p)
|