diff --git a/.gitignore b/.gitignore index 43ae0e2..3a9862e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ __pycache__/ *.py[cod] +venv/ +gc_wrapper/GC_DATA/ diff --git a/duration_comparison.py b/duration_comparison.py index 9d07fff..445e46e 100644 --- a/duration_comparison.py +++ b/duration_comparison.py @@ -1,5 +1,5 @@ try: - from GC_Wrapper import GC_wrapper as GC + from gc_wrapper.GC_Wrapper import GC_wrapper as GC except ImportError: pass diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b68957b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +plotly +pandas diff --git a/weight_trend.py b/weight_trend.py new file mode 100644 index 0000000..cd23d7e --- /dev/null +++ b/weight_trend.py @@ -0,0 +1,54 @@ +import pandas as pd +import numpy as np + +WEIGHT_RANGE = [75, 85] + + +def get_weight_measures(): + # query non-zero + data = pd.DataFrame(GC.seasonMeasures(group="Body")).query("WEIGHTKG != 0.0")[ + ["date", "WEIGHTKG"] + ] + weight = data["WEIGHTKG"].to_numpy().flatten() + weight_shifted = data["WEIGHTKG"].shift(periods=1) + weight_shifted.loc[0] = 0.0 + weight_shifted = weight_shifted.to_numpy().flatten() + change = weight - weight_shifted + indices = np.argwhere(change != 0.0).flatten() + weight = weight[indices] + date = ( + data["date"].loc[indices] - pd.to_datetime("1900-01-01").date() + ).dt.days.to_numpy() + return pd.DataFrame( + np.hstack([date.reshape([-1, 1]), weight.reshape([-1, 1])]), + columns=["date", "WEIGHTKG"], + ) + + +weight_data = get_weight_measures() +GC.setChart( + type=GC.CHART_LINE, + orientation=GC_VERTICAL, + legpos=GC_ALIGN_RIGHT, + stack=False, + animate=True, +) +settings = { + "symbol": GC_SYMBOL_CIRCLE, + "line": GC_LINE_SOLID, + "color": "red", + "opacity": 100, + "xaxis": "Date", + "yaxis": "Weight", + "size": 3, + "opengl": False, +} +GC.addCurve(name="Weight", x=weight_data["date"], y=weight_data["WEIGHTKG"], **settings) +GC.setAxis("Date", type=GC.AXIS_DATE) +GC.setAxis( + "Weight", + type=GC.AXIS_CONTINUOUS, + min=WEIGHT_RANGE[0], + max=WEIGHT_RANGE[1], + color="red", +)