From 67e2d233b09aab72a4e5b390fec1b08f02842c4a Mon Sep 17 00:00:00 2001 From: junos Date: Fri, 23 Jul 2021 16:42:16 +0200 Subject: [PATCH] Start exploring light data. --- exploration/expl_light.py | 73 +++++++++++++++++++++++++++++++++++++++ features/light.py | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 exploration/expl_light.py diff --git a/exploration/expl_light.py b/exploration/expl_light.py new file mode 100644 index 0000000..5dc000c --- /dev/null +++ b/exploration/expl_light.py @@ -0,0 +1,73 @@ +# --- +# jupyter: +# jupytext: +# formats: ipynb,py:percent +# text_representation: +# extension: .py +# format_name: percent +# format_version: '1.3' +# jupytext_version: 1.11.2 +# kernelspec: +# display_name: straw2analysis +# language: python +# name: straw2analysis +# --- + +# %% +import os +import sys + +import seaborn as sns +from tabulate import tabulate + +nb_dir = os.path.split(os.getcwd())[0] +if nb_dir not in sys.path: + sys.path.append(nb_dir) + +import participants.query_db + +# %% +from features.light import * + +# %% +df_light_nokia = get_light_data(["nokia_0000003"]) +print(df_light_nokia) + +# %% +participants_inactive_usernames = participants.query_db.get_usernames() +df_light_inactive = get_light_data(participants_inactive_usernames) + +# %% +df_light_inactive.accuracy.value_counts() + +# %% +df_light_inactive.double_light_lux.describe() + +# %% +df_light_plot = df_light_inactive.copy() +df_light_plot["double_light_lux"] = df_light_plot["double_light_lux"] + 1 +sns.displot( + data=df_light_plot, + x="double_light_lux", + binwidth=0.1, + log_scale=(True, False), + height=8, +) + +# %% [markdown] +# The official SensorManager Light constants are: +# * Cloudy sky: 100.0 +# * Full moon: 0.25 +# * No moon: 0.001 +# * Overcast: 10000.0 +# * Shade: 20000.0 +# * Sunlight: 110000.0 +# * Sunlight maximum: 120000.0 +# * Sunrise: 400.0 +# + +# %% +df_light_low = df_light_inactive[df_light_inactive["double_light_lux"] <= 10] +sns.displot(data=df_light_low, x="double_light_lux", binwidth=0.5, height=8) + +# %% diff --git a/features/light.py b/features/light.py index 4e781b5..64bc3ae 100644 --- a/features/light.py +++ b/features/light.py @@ -2,7 +2,7 @@ from collections.abc import Collection import pandas as pd -from config.models import Participant, LightSensor +from config.models import LightSensor, Participant from setup import db_engine, session