some wip
This commit is contained in:
parent
5a9d34b429
commit
3d28c3ca6e
2 changed files with 15 additions and 18 deletions
10
TODO.org
10
TODO.org
|
@ -1,6 +1,5 @@
|
||||||
https://github.com/crowoy/Health-Analysis
|
https://github.com/crowoy/Health-Analysis
|
||||||
https://github.com/joytafty-work/SleepModel
|
https://github.com/joytafty-work/SleepModel
|
||||||
https://github.com/carleshf/jawboneup2tex
|
|
||||||
https://github.com/search?l=Jupyter+Notebook&q=s_awakenings&type=Code&utf8=%E2%9C%93
|
https://github.com/search?l=Jupyter+Notebook&q=s_awakenings&type=Code&utf8=%E2%9C%93
|
||||||
https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/colifer.py
|
https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/colifer.py
|
||||||
https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/reportextenders/jawbone/jawbone_sleep.py
|
https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/reportextenders/jawbone/jawbone_sleep.py
|
||||||
|
@ -9,10 +8,7 @@ https://github.com/GlenCrawford/ruby_jawbone
|
||||||
* https://nyquist212.wordpress.com/2015/06/22/visualizing-jawbone-up-data-with-d3-js/
|
* https://nyquist212.wordpress.com/2015/06/22/visualizing-jawbone-up-data-with-d3-js/
|
||||||
|
|
||||||
|
|
||||||
* jawbone sleeps meta:
|
* TODO ok, so shoud really do a week of consistent bedtime/waking up to make some final decision on jawbone?
|
||||||
** time_created: apparently starto of sleep (leftmost point of plot)
|
|
||||||
** time_updated: rightmost point of plot
|
|
||||||
** details -> asleep_time, awake_time
|
|
||||||
|
|
||||||
|
* TODO figure out timezones
|
||||||
* TODO align multiple on the same plot/picture to see patterns
|
* TODO post on reddit? release and ask people to run against their data?
|
||||||
|
|
23
analyse.py
23
analyse.py
|
@ -70,6 +70,8 @@ def load_sleeps() -> List[SleepEntry]:
|
||||||
return [SleepEntry(js) for js in sleeps]
|
return [SleepEntry(js) for js in sleeps]
|
||||||
import numpy as np # type: ignore
|
import numpy as np # type: ignore
|
||||||
import matplotlib.pyplot as plt # type: ignore
|
import matplotlib.pyplot as plt # type: ignore
|
||||||
|
from matplotlib.figure import Figure # type: ignore
|
||||||
|
from matplotlib.axes import Axes # type: ignore
|
||||||
# pip install imageio
|
# pip install imageio
|
||||||
from imageio import imread # type: ignore
|
from imageio import imread # type: ignore
|
||||||
from scipy.misc import imresize # type: ignore
|
from scipy.misc import imresize # type: ignore
|
||||||
|
@ -85,8 +87,6 @@ def hhmm(time: datetime):
|
||||||
# return fromstart / tick
|
# return fromstart / tick
|
||||||
|
|
||||||
import matplotlib.dates as mdates # type: ignore
|
import matplotlib.dates as mdates # type: ignore
|
||||||
from matplotlib.figure import Figure # type: ignore
|
|
||||||
from matplotlib.axes import Axes # type: ignore
|
|
||||||
from matplotlib.ticker import MultipleLocator, FixedLocator # type: ignore
|
from matplotlib.ticker import MultipleLocator, FixedLocator # type: ignore
|
||||||
|
|
||||||
def plot_one(sleep: SleepEntry, fig: Figure, axes: Axes, xlims=None, showtext=True):
|
def plot_one(sleep: SleepEntry, fig: Figure, axes: Axes, xlims=None, showtext=True):
|
||||||
|
@ -166,11 +166,7 @@ import melatonin
|
||||||
dt = melatonin.get_data()
|
dt = melatonin.get_data()
|
||||||
# dt = {k: v for k, v in dt.items() if v is not None}
|
# dt = {k: v for k, v in dt.items() if v is not None}
|
||||||
|
|
||||||
sleeps = [sleeps_by_date[d] for d in dt if d in sleeps_by_date]
|
sleeps = list(sleeps_by_date.values()) # [sleeps_by_date[d] for d in dt if d in sleeps_by_date]
|
||||||
sleeps_count = len(sleeps)
|
|
||||||
|
|
||||||
|
|
||||||
fig: Figure = plt.figure(figsize=(15, sleeps_count * 1))
|
|
||||||
|
|
||||||
def predicate(sleep: SleepEntry):
|
def predicate(sleep: SleepEntry):
|
||||||
"""
|
"""
|
||||||
|
@ -182,15 +178,20 @@ def predicate(sleep: SleepEntry):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# sleeps = lfilter(predicate, sleeps)
|
sleeps = lfilter(predicate, sleeps)
|
||||||
|
sleeps_count = len(sleeps)
|
||||||
|
print(sleeps_count)
|
||||||
|
|
||||||
|
|
||||||
|
fig: Figure = plt.figure(figsize=(15, sleeps_count * 1))
|
||||||
|
|
||||||
axarr = fig.subplots(nrows=len(sleeps))
|
axarr = fig.subplots(nrows=len(sleeps))
|
||||||
for i, (sleep, axes) in enumerate(zip(sleeps, axarr)):
|
for i, (sleep, axes) in enumerate(zip(sleeps, axarr)):
|
||||||
plot_one(sleep, fig, axes, showtext=True)
|
plot_one(sleep, fig, axes, showtext=True)
|
||||||
used = dt[sleep.date_]
|
used = dt.get(sleep.date_, None)
|
||||||
sused: str
|
sused: str
|
||||||
color: str
|
color: str
|
||||||
used = True if used is None else False # TODO?
|
# used = True if used is None else False # TODO?
|
||||||
if used is True:
|
if used is True:
|
||||||
sused = "YES"
|
sused = "YES"
|
||||||
color = 'green'
|
color = 'green'
|
||||||
|
@ -199,7 +200,7 @@ for i, (sleep, axes) in enumerate(zip(sleeps, axarr)):
|
||||||
color = 'red'
|
color = 'red'
|
||||||
else:
|
else:
|
||||||
sused = "??"
|
sused = "??"
|
||||||
color = 'blue'
|
color = 'white'
|
||||||
axes.text(axes.get_xlim()[0], 20, sused)
|
axes.text(axes.get_xlim()[0], 20, sused)
|
||||||
axes.patch.set_alpha(0.5)
|
axes.patch.set_alpha(0.5)
|
||||||
axes.set_facecolor(color)
|
axes.set_facecolor(color)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue