move jawbone into my. from private provider

This commit is contained in:
Dima Gerasimov 2019-12-11 22:28:35 +00:00
parent 809281d5d7
commit cd804091c3
4 changed files with 22 additions and 14 deletions

View file

@ -7,8 +7,10 @@ from typing import Tuple, Iterator, List, Union
from my_configuration.holidays_data import HOLIDAYS_DATA from my_configuration.holidays_data import HOLIDAYS_DATA
# pip3 install workalendar
from workalendar.europe import UnitedKingdom # type: ignore from workalendar.europe import UnitedKingdom # type: ignore
cal = UnitedKingdom() # TODO FIXME specify in config cal = UnitedKingdom() # TODO FIXME specify in config
# TODO that should depend on country/'location' of residence I suppose?
Dateish = Union[datetime, date, str] Dateish = Union[datetime, date, str]

View file

@ -7,9 +7,10 @@ from pathlib import Path
import logging import logging
import pytz import pytz
from kython.klogging import setup_logzero from my_configuration import paths
BDIR = Path('/L/backups/jawbone')
BDIR = paths.jawbone.export_dir
PHASES_FILE = BDIR / 'phases.json' PHASES_FILE = BDIR / 'phases.json'
SLEEPS_FILE = BDIR / 'sleeps.json' SLEEPS_FILE = BDIR / 'sleeps.json'
GRAPHS_DIR = BDIR / 'graphs' GRAPHS_DIR = BDIR / 'graphs'
@ -108,7 +109,7 @@ from matplotlib.figure import Figure # type: ignore
from matplotlib.axes import Axes # 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
def hhmm(time: datetime): def hhmm(time: datetime):
@ -296,6 +297,8 @@ def test_tz():
def main(): def main():
# TODO eh. vendorize klogging already?
from kython.klogging import setup_logzero
setup_logzero(get_logger()) setup_logzero(get_logger())
test_tz() test_tz()
# print(get_dataframe()) # print(get_dataframe())

View file

@ -1,11 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# TODO # TODO
from kython import * from pathlib import Path
# from kython.plotting import * # from kython.plotting import *
from csv import DictReader from csv import DictReader
from itertools import islice from itertools import islice
from typing import Dict from typing import Dict, Any, NamedTuple, Dict
# sleep = [] # sleep = []
# with open('2017.csv', 'r') as fo: # with open('2017.csv', 'r') as fo:
@ -14,15 +14,15 @@ from typing import Dict
# sleep # sleep
# print(line) # print(line)
import numpy as np import numpy as np # type: ignore
import matplotlib.pyplot as plt import matplotlib.pyplot as plt # type: ignore
from numpy import genfromtxt from numpy import genfromtxt # type: ignore
import matplotlib.pylab as pylab import matplotlib.pylab as pylab # type: ignore
pylab.rcParams['figure.figsize'] = (32.0, 24.0) pylab.rcParams['figure.figsize'] = (32.0, 24.0)
pylab.rcParams['font.size'] = 10 pylab.rcParams['font.size'] = 10
jawboneDataFeatures = "Jawbone/features.csv" # Data File Path jawboneDataFeatures = Path(__file__).parent / 'features.csv' # Data File Path
featureDesc: Dict[str, str] = {} featureDesc: Dict[str, str] = {}
for x in genfromtxt(jawboneDataFeatures, dtype='unicode', delimiter=','): for x in genfromtxt(jawboneDataFeatures, dtype='unicode', delimiter=','):
featureDesc[x[0]] = x[1] featureDesc[x[0]] = x[1]
@ -87,7 +87,9 @@ def iter_useful(data_file: str):
# TODO <<< hmm. these files do contain deep and light sleep?? # TODO <<< hmm. these files do contain deep and light sleep??
# also steps stats?? # also steps stats??
p = Path('/L/backups/jawbone/old_csv') from my_configuration import paths
p = paths.jawbone.export_dir / 'old_csv'
# TODO with_my? # TODO with_my?
files = [ files = [
p / "2015.csv", p / "2015.csv",
@ -95,7 +97,8 @@ files = [
p / "2017.csv", p / "2017.csv",
] ]
useful = concat(*(list(iter_useful(f)) for f in files)) from kython import concat, parse_date
useful = concat(*(list(iter_useful(str(f))) for f in files))
# for u in useful: # for u in useful:
# print(f"{u.total} {u.asleep_time} {u.awake_time}") # print(f"{u.total} {u.asleep_time} {u.awake_time}")
@ -108,7 +111,7 @@ dates = [parse_date(u.date, yearfirst=True, dayfirst=False) for u in useful]
# TODO don't need this anymore? it's gonna be in dashboards package # TODO don't need this anymore? it's gonna be in dashboards package
from kython.plotting import plot_timestamped from kython.plotting import plot_timestamped
for attr, lims, mavg, fig in [ for attr, lims, mavg, fig in [ # type: ignore
('light', (0, 400), 5, None), ('light', (0, 400), 5, None),
('deep', (0, 600), 5, None), ('deep', (0, 600), 5, None),
('total', (200, 600), 5, None), ('total', (200, 600), 5, None),
@ -127,7 +130,7 @@ for attr, lims, mavg, fig in [
if mavg is not None: if mavg is not None:
mavgs.append((mavg, 'green')) mavgs.append((mavg, 'green'))
fig = plot_timestamped( fig = plot_timestamped(
dts, dts, # type: ignore
[getattr(u, attr) for u in useful], [getattr(u, attr) for u in useful],
marker='.', marker='.',
ratio=(16, 4), ratio=(16, 4),