diff --git a/rowers/dataprep.py b/rowers/dataprep.py index cac18cc6..adfd720b 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -31,6 +31,7 @@ import dask.dataframe as dd from dask.delayed import delayed import pyarrow.parquet as pq import pyarrow as pa +from pyarrow.lib import ArrowInvalid from django.utils import timezone from django.utils.timezone import get_current_timezone @@ -198,7 +199,12 @@ def get_video_data(w,groups=['basic'],mode='water'): if dict(rowingmetrics)[c]['numtype'] == 'integer': data[c] = df2[c].astype(int).tolist() else: - data[c] = df2[c].values.tolist() + sigfigs = dict(rowingmetrics)[c]['sigfigs'] + if (c != 'pace'): + da = ((10**sigfigs)*df2[c]).astype(int)/(10**sigfigs) + else: + da = df2[c] + data[c] = da.values.tolist() metrics[c] = { 'name': dict(rowingmetrics)[c]['verbose_name'], 'metric': c, @@ -1867,7 +1873,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True,workstrokesonly=True,comput else: try: df = pd.read_parquet(csvfilenames[0],columns=columns) - except OSError: + except (OSError,ArrowInvalid): rowdata,row = getrowdata(id=ids[0]) if rowdata and len(rowdata.df): data = dataprep(rowdata.df,id=ids[0],bands=True,otwpower=True,barchart=True) diff --git a/rowers/metrics.py b/rowers/metrics.py index 57d2ba77..242cfe56 100644 --- a/rowers/metrics.py +++ b/rowers/metrics.py @@ -56,7 +56,8 @@ rowingmetrics = ( 'ax_max': 1e5, 'mode':'both', 'type': 'basic', - 'group':'basic'}), + 'group':'basic', + 'sigfigs': -1}), ('hr',{ 'numtype':'integer', @@ -66,7 +67,8 @@ rowingmetrics = ( 'ax_max': 200, 'mode':'both', 'type': 'basic', - 'group':'athlete'}), + 'group':'athlete', + 'sigfigs':0,}), ('pace',{ 'numtype':'float', @@ -76,6 +78,7 @@ rowingmetrics = ( 'ax_max': 1.0e3*75, 'mode':'both', 'type': 'basic', + 'sigfigs': 1, 'group': 'basic'}), ('velo',{ @@ -86,6 +89,7 @@ rowingmetrics = ( 'ax_max': 8, 'default': 0, 'mode':'both', + 'sigfigs': 1, 'type':'pro', 'group': 'basic'}), @@ -106,6 +110,7 @@ rowingmetrics = ( 'ax_min': 15, 'ax_max': 45, 'mode':'both', + 'sigfigs': 1, 'type': 'basic', 'group':'basic'}), @@ -116,6 +121,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 1000, 'mode':'both', + 'sigfigs': 0, 'type': 'pro', 'group':'forcepower'}), @@ -126,6 +132,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 600, 'mode':'both', + 'sigfigs': 0, 'type': 'basic', 'group':'forcepower'}), @@ -136,6 +143,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 1200, 'mode':'both', + 'sigfigs': 0, 'type': 'pro', 'group':'forcepower'}), @@ -145,6 +153,7 @@ rowingmetrics = ( 'verbose_name': 'Peak Drive Force (N)', 'ax_min': 0, 'ax_max': 1500, + 'sigfigs': 0, 'mode':'both', 'type': 'pro', 'group':'forcepower'}), @@ -156,6 +165,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 2.5, 'mode':'rower', + 'sigfigs': 2, 'type': 'pro', 'group':'stroke'}), @@ -165,6 +175,7 @@ rowingmetrics = ( 'verbose_name': 'Average/Peak Force Ratio', 'ax_min': 0, 'ax_max': 1, + 'sigfigs': 2, 'mode':'both', 'type': 'pro', 'group': 'forcepower'}), @@ -175,6 +186,7 @@ rowingmetrics = ( 'verbose_name': 'Interval Distance (m)', 'ax_min': 0, 'ax_max': 1e5, + 'sigfigs': 0, 'mode':'both', 'type': 'basic', 'group':'basic'}), @@ -186,6 +198,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 1e5, 'mode':'both', + 'sigfigs': 0, 'type': 'basic', 'group':'basic'}), @@ -196,10 +209,12 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 4, 'default': 0, + 'sigfigs': 2, 'mode':'both', 'type': 'pro', 'group': 'stroke'}), + ('catch',{ 'numtype':'float', 'null':True, @@ -207,6 +222,7 @@ rowingmetrics = ( 'ax_min': -40, 'ax_max': -75, 'default': 0, + 'sigfigs': 0, 'mode':'water', 'type': 'pro', 'group': 'stroke'}), @@ -218,6 +234,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 20, 'default': 0, + 'sigfigs': 1, 'mode':'water', 'type': 'pro', 'group': 'stroke'}), @@ -229,6 +246,7 @@ rowingmetrics = ( 'ax_min': 20, 'ax_max': 55, 'default': 0, + 'sigfigs': 0, 'mode':'water', 'type': 'pro', 'group': 'stroke'}), @@ -240,6 +258,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 30, 'default': 0, + 'sigfigs': 0, 'mode':'water', 'type': 'pro', 'group': 'stroke'}), @@ -251,6 +270,7 @@ rowingmetrics = ( 'ax_min': -50, 'ax_max': 50, 'default': 0, + 'sigfigs': 0, 'mode':'water', 'type': 'pro', 'group':'stroke'}), @@ -263,6 +283,7 @@ rowingmetrics = ( 'ax_min': 40, 'ax_max': 140, 'default': 0, + 'sigfigs': 0, 'mode':'water', 'type': 'pro', 'group':'stroke'}), @@ -275,6 +296,7 @@ rowingmetrics = ( 'ax_min': 40, 'ax_max': 140, 'default': 0, + 'sigfigs': 0, 'mode':'water', 'type': 'pro', 'group':'stroke'}), @@ -286,6 +308,7 @@ rowingmetrics = ( 'ax_min': 20, 'ax_max': 55, 'default': 1.0, + 'sigfigs': 0, 'mode':'erg', 'type': 'pro', 'group':'stroke'}), @@ -297,6 +320,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 110, 'default': 0, + 'sigfigs': 0, 'mode':'water', 'type': 'pro', 'group':'forcepower'}), @@ -308,6 +332,7 @@ rowingmetrics = ( 'ax_min': 0, 'ax_max': 15, 'default': 0, + 'sigfigs': 1, 'mode':'both', 'type': 'basic', 'group':'basic'}), diff --git a/rowers/templates/embedded_video.html b/rowers/templates/embedded_video.html index 374bc716..d144fe0a 100644 --- a/rowers/templates/embedded_video.html +++ b/rowers/templates/embedded_video.html @@ -121,6 +121,7 @@ var player; var playing = false; var dataplaying = false; + var videotime = 0; var data = JSON.parse('{{ data|safe }}'); {% for id, metric in metrics.items %} @@ -229,6 +230,7 @@ } else { if (!dataplaying) { output.value = Math.round(datatime)-Math.round(videotime); + document.getElementById("time").innerHTML = Math.round(videotime); } } @@ -241,10 +243,12 @@ // call this function when player state changes function onPlayerStateChange(event) { - if (event.data == YT.PlayerState.PLAYING) { - - } else { - + if (event.data == YT.PlayerState.PLAYING && lock.checked) { + var dataplay = document.getElementById("dataplay").childNodes[0]; + dataplay.value = String.fromCharCode(10074,10074); + } else if (lock.checked) { + var dataplay = document.getElementById("dataplay").childNodes[0]; + dataplay.value = String.fromCharCode(9658); } } @@ -314,15 +318,43 @@