|
|
|
@ -6,7 +6,8 @@ from datetime import date, time, datetime, timedelta
|
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
from glob import glob
|
|
|
|
|
from typing import Sequence
|
|
|
|
|
from functools import reduce
|
|
|
|
|
from functools import reduce, cache
|
|
|
|
|
from bisect import bisect_right
|
|
|
|
|
|
|
|
|
|
VOLICU_CELKEM = 8_245_962
|
|
|
|
|
OKRSKU_CELKEM = 14_857
|
|
|
|
@ -129,13 +130,7 @@ def frametime_to_realtime(t):
|
|
|
|
|
delta *= 18
|
|
|
|
|
return START + delta
|
|
|
|
|
|
|
|
|
|
from bisect import bisect_right
|
|
|
|
|
def data_for_timestamp(ts) -> KolacovaData:
|
|
|
|
|
idx = bisect_right(casy, ts)
|
|
|
|
|
return po_sekundach[casy[idx-1]] # bisect_right vrací konzistentně hodnotu o jedna větší, než potřebujeme.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def visualize_data(data):
|
|
|
|
|
def visualize_data(data: KolacovaData):
|
|
|
|
|
# Tady se provede ta vizualizace, kterou děláme pořád dokolečka.
|
|
|
|
|
# FIXME: zase jsem to zkopíroval :-P
|
|
|
|
|
plt.clf()
|
|
|
|
@ -186,16 +181,21 @@ def visualize_data(data):
|
|
|
|
|
# save
|
|
|
|
|
return plt.gcf()
|
|
|
|
|
|
|
|
|
|
# Jen kvůli cachování výsledků…
|
|
|
|
|
@cache
|
|
|
|
|
def figure_podle_casu(ts: datetime):
|
|
|
|
|
return visualize_data(po_sekundach[ts])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# https://zulko.github.io/moviepy/getting_started/working_with_matplotlib.html
|
|
|
|
|
from moviepy.editor import VideoClip
|
|
|
|
|
from moviepy.video.io.bindings import mplfig_to_npimage
|
|
|
|
|
|
|
|
|
|
def make_frame(t):
|
|
|
|
|
# wtf is t?
|
|
|
|
|
data: KolacovaData
|
|
|
|
|
#data = data_for_timestamp(frametime_to_realtime(t))
|
|
|
|
|
data = data_for_timestamp(START + timedelta(seconds=t)*18)
|
|
|
|
|
fig = visualize_data(data)
|
|
|
|
|
ts = START + timedelta(seconds = t*18)
|
|
|
|
|
idx = bisect_right(casy, ts) - 1
|
|
|
|
|
fig = figure_podle_casu(casy[idx])
|
|
|
|
|
return mplfig_to_npimage(fig)
|
|
|
|
|
|
|
|
|
|
def make_anim():
|
|
|
|
|