some fixes, after manual testing
This commit is contained in:
@@ -186,10 +186,12 @@ def remove_nulls_pl(data):
|
|||||||
data = data.select(pl.all().forward_fill())
|
data = data.select(pl.all().forward_fill())
|
||||||
data = data.select(pl.all().backward_fill())
|
data = data.select(pl.all().backward_fill())
|
||||||
data = data.fill_nan(None)
|
data = data.fill_nan(None)
|
||||||
|
|
||||||
data = data.select(cs.by_dtype(pl.NUMERIC_DTYPES)).collect()
|
data = data.select(cs.by_dtype(pl.NUMERIC_DTYPES)).collect()
|
||||||
data = data[[s.name for s in data if not s.is_infinite().sum()]]
|
data = data[[s.name for s in data if not s.is_infinite().sum()]]
|
||||||
data = data[[s.name for s in data if not (s.null_count() == data.height)]]
|
data = data[[s.name for s in data if not (s.null_count() == data.height)]]
|
||||||
|
|
||||||
|
|
||||||
if not data.is_empty():
|
if not data.is_empty():
|
||||||
try:
|
try:
|
||||||
data = data.drop_nulls()
|
data = data.drop_nulls()
|
||||||
@@ -207,6 +209,8 @@ def get_video_data(w, groups=['basic'], mode='water'):
|
|||||||
columns = list(set(columns))
|
columns = list(set(columns))
|
||||||
df = getsmallrowdata_pd(columns, ids=[w.id],
|
df = getsmallrowdata_pd(columns, ids=[w.id],
|
||||||
workstrokesonly=False, doclean=False, compute=False)
|
workstrokesonly=False, doclean=False, compute=False)
|
||||||
|
df.dropna(axis=0, how='all', inplace=True)
|
||||||
|
df.dropna(axis=1, how='all', inplace=True)
|
||||||
|
|
||||||
df['time'] = (df['time']-df['time'].min())/1000.
|
df['time'] = (df['time']-df['time'].min())/1000.
|
||||||
|
|
||||||
@@ -245,7 +249,6 @@ def get_video_data(w, groups=['basic'], mode='water'):
|
|||||||
coordinates['time'] = coordinates['time']-coordinates['time'].min()
|
coordinates['time'] = coordinates['time']-coordinates['time'].min()
|
||||||
latitude = coordinates['latitude']
|
latitude = coordinates['latitude']
|
||||||
longitude = coordinates['longitude']
|
longitude = coordinates['longitude']
|
||||||
|
|
||||||
# bundle data
|
# bundle data
|
||||||
data = {
|
data = {
|
||||||
'boatspeed': boatspeed.values.tolist(),
|
'boatspeed': boatspeed.values.tolist(),
|
||||||
@@ -263,7 +266,10 @@ def get_video_data(w, groups=['basic'], mode='water'):
|
|||||||
else:
|
else:
|
||||||
sigfigs = dict(rowingmetrics)[c]['sigfigs']
|
sigfigs = dict(rowingmetrics)[c]['sigfigs']
|
||||||
if (c != 'pace'):
|
if (c != 'pace'):
|
||||||
|
try:
|
||||||
da = ((10**sigfigs)*df2[c]).astype(int)/(10**sigfigs)
|
da = ((10**sigfigs)*df2[c]).astype(int)/(10**sigfigs)
|
||||||
|
except:
|
||||||
|
da = df2[c]
|
||||||
else:
|
else:
|
||||||
da = df2[c]
|
da = df2[c]
|
||||||
data[c] = da.values.tolist()
|
data[c] = da.values.tolist()
|
||||||
@@ -281,6 +287,14 @@ def get_video_data(w, groups=['basic'], mode='water'):
|
|||||||
|
|
||||||
maxtime = coordinates['time'].max()
|
maxtime = coordinates['time'].max()
|
||||||
|
|
||||||
|
data = pd.DataFrame(data)
|
||||||
|
data.replace([np.inf, -np.inf], np.nan, inplace=True)
|
||||||
|
data.dropna(inplace=True)
|
||||||
|
|
||||||
|
data = pl.from_pandas(data)
|
||||||
|
|
||||||
|
data = data.to_dict(as_series=False)
|
||||||
|
|
||||||
return data, metrics, maxtime
|
return data, metrics, maxtime
|
||||||
|
|
||||||
|
|
||||||
@@ -1490,7 +1504,8 @@ def getrowdata_pl(id=0, doclean=False, convertnewtons=True,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False, for_chart=False, compute=True):
|
def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False, for_chart=False, compute=True,
|
||||||
|
startenddict={}):
|
||||||
if ids:
|
if ids:
|
||||||
csvfilenames = [
|
csvfilenames = [
|
||||||
'media/strokedata_{id}.parquet.gz'.format(id=id) for id in ids]
|
'media/strokedata_{id}.parquet.gz'.format(id=id) for id in ids]
|
||||||
@@ -1504,6 +1519,17 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
|||||||
for id, f in zip(ids, csvfilenames):
|
for id, f in zip(ids, csvfilenames):
|
||||||
if os.path.isfile(f):
|
if os.path.isfile(f):
|
||||||
df = pl.scan_parquet(f)
|
df = pl.scan_parquet(f)
|
||||||
|
if startenddict:
|
||||||
|
try:
|
||||||
|
startsecond, endsecond = startenddict[id]
|
||||||
|
df = df.filter(pl.col("time") >= 1.0e3*startsecond,
|
||||||
|
pl.col("time") <= 1.0e3*endsecond)
|
||||||
|
df = df.with_columns(time = pl.col("time")-1.0e3*startsecond)
|
||||||
|
if 'cumdist' in columns:
|
||||||
|
df = df.collect()
|
||||||
|
df = df.with_columns(cumdist = pl.col("cumdist")-df[0, "cumdist"]).lazy()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
data.append(df)
|
data.append(df)
|
||||||
else:
|
else:
|
||||||
rowdata, row = getrowdata(id=id)
|
rowdata, row = getrowdata(id=id)
|
||||||
@@ -1516,6 +1542,17 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
|||||||
bands=True, otwpower=True, barchart=True,
|
bands=True, otwpower=True, barchart=True,
|
||||||
polars=True)
|
polars=True)
|
||||||
df = pl.scan_parquet(f)
|
df = pl.scan_parquet(f)
|
||||||
|
if startenddict:
|
||||||
|
try:
|
||||||
|
startsecond, endsecond = startenddict[id]
|
||||||
|
df = df.filter(pl.col("time") >= 1.0e3*startsecond,
|
||||||
|
pl.col("time") <= 1.0e3*endsecond)
|
||||||
|
df = df.with_columns(time = pl.col("time")-1.0e3*startsecond)
|
||||||
|
if 'cumdist' in columns:
|
||||||
|
df = df.collect()
|
||||||
|
df = df.with_columns(cumdist = pl.col("cumdist")-df[0, "cumdist"]).lazy()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
data.append(df)
|
data.append(df)
|
||||||
|
|
||||||
data = pl.collect_all(data)
|
data = pl.collect_all(data)
|
||||||
|
|||||||
@@ -2099,11 +2099,12 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
|||||||
promember=0, workstrokesonly=True,
|
promember=0, workstrokesonly=True,
|
||||||
labeldict=None, startenddict={}):
|
labeldict=None, startenddict={}):
|
||||||
|
|
||||||
|
print(startenddict)
|
||||||
columns = [xparam,yparam]
|
columns = [xparam,yparam]
|
||||||
columns_basic = [xparam,yparam]
|
columns_basic = [xparam,yparam]
|
||||||
add_columns = [
|
add_columns = [
|
||||||
'ftime', 'distance', 'fpace',
|
'ftime', 'distance', 'fpace',
|
||||||
'spm',
|
'spm','cumdist',
|
||||||
'time', 'pace', 'workoutstate',
|
'time', 'pace', 'workoutstate',
|
||||||
'workoutid'
|
'workoutid'
|
||||||
]
|
]
|
||||||
@@ -2117,15 +2118,17 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
|||||||
doclean = True
|
doclean = True
|
||||||
|
|
||||||
|
|
||||||
datadf = pd.DataFrame()
|
datadf = pl.DataFrame()
|
||||||
if promember:
|
if promember:
|
||||||
datadf = dataprep.read_data(columns, ids=ids, doclean=doclean,
|
datadf = dataprep.read_data(columns, ids=ids, doclean=doclean,
|
||||||
compute=compute,
|
compute=compute,
|
||||||
workstrokesonly=workstrokesonly, for_chart=True)
|
workstrokesonly=workstrokesonly, for_chart=True,
|
||||||
|
startenddict=startenddict)
|
||||||
else:
|
else:
|
||||||
datadf = dataprep.read_data(columns_basic, ids=ids, doclean=doclean,
|
datadf = dataprep.read_data(columns_basic, ids=ids, doclean=doclean,
|
||||||
compute=compute,
|
compute=compute,
|
||||||
workstrokesonly=workstrokesonly, for_chart=True)
|
workstrokesonly=workstrokesonly, for_chart=True,
|
||||||
|
startenddict=startenddict)
|
||||||
|
|
||||||
|
|
||||||
datadf = dataprep.remove_nulls_pl(datadf)
|
datadf = dataprep.remove_nulls_pl(datadf)
|
||||||
@@ -2135,6 +2138,8 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
|||||||
|
|
||||||
datadf = datadf.with_columns(pl.col("workoutid").cast(pl.UInt32).keep_name())
|
datadf = datadf.with_columns(pl.col("workoutid").cast(pl.UInt32).keep_name())
|
||||||
|
|
||||||
|
# filter for start end dict
|
||||||
|
|
||||||
|
|
||||||
nrworkouts = len(ids)
|
nrworkouts = len(ids)
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ function copyText() {
|
|||||||
</li>
|
</li>
|
||||||
{% if user.is_authenticated and user == workout.user.user and not locked %}
|
{% if user.is_authenticated and user == workout.user.user and not locked %}
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<p>Paste link to you tube video below</p>
|
<p>Paste link to Youtube video below</p>
|
||||||
<p>Use the slider to locate start point for video on workout map</p>
|
<p>Use the slider to locate start point for video on workout map</p>
|
||||||
<p>Playing the video will advance the data in synchonization. Use the regular YouTube
|
<p>Playing the video will advance the data in synchonization. Use the regular YouTube
|
||||||
controls
|
controls
|
||||||
@@ -169,9 +169,8 @@ function copyText() {
|
|||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<div id="player"></div>
|
<div id="player"></div>
|
||||||
<script>
|
|
||||||
// 1. Code for the map
|
|
||||||
{{ mapscript | safe }}
|
{{ mapscript | safe }}
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
// 2. This code loads the IFrame Player API code asynchronously.
|
// 2. This code loads the IFrame Player API code asynchronously.
|
||||||
@@ -189,6 +188,7 @@ function copyText() {
|
|||||||
|
|
||||||
var videotime = 0;
|
var videotime = 0;
|
||||||
var data = JSON.parse('{{ data|safe }}');
|
var data = JSON.parse('{{ data|safe }}');
|
||||||
|
|
||||||
{% for id, metric in metrics.items %}
|
{% for id, metric in metrics.items %}
|
||||||
var {{ id }}_values = data["{{ id }}"];
|
var {{ id }}_values = data["{{ id }}"];
|
||||||
// console.log("{{ id }}_values",{{ id }}_values);
|
// console.log("{{ id }}_values",{{ id }}_values);
|
||||||
|
|||||||
@@ -6,14 +6,9 @@
|
|||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
|
||||||
<script src="https://cdn.pydata.org/bokeh/release/bokeh-3.1.1.min.js"></script>
|
<script src="https://d3js.org/d3.v6.js"></script>
|
||||||
<script async="true" type="text/javascript">
|
|
||||||
Bokeh.set_log_level("info");
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
{{ interactiveplot |safe }}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h1>Interactive Comparison</h1>
|
<h1>Interactive Comparison</h1>
|
||||||
|
|
||||||
@@ -22,6 +17,7 @@
|
|||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
<div>
|
<div>
|
||||||
{{ the_div|safe }}
|
{{ the_div|safe }}
|
||||||
|
{{ interactiveplot |safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -387,6 +387,9 @@ def trendflexdata(workouts, options, userid=0):
|
|||||||
datadf = dataprep.filter_df(datadf, 'driveneergy', workmax,
|
datadf = dataprep.filter_df(datadf, 'driveneergy', workmax,
|
||||||
largerthan=False)
|
largerthan=False)
|
||||||
|
|
||||||
|
if yparam == 'power':
|
||||||
|
datadf = dataprep.filter_df(datadf, 'power', 1, largerthan=True)
|
||||||
|
|
||||||
datadf.dropna(axis=0, how='any', inplace=True)
|
datadf.dropna(axis=0, how='any', inplace=True)
|
||||||
|
|
||||||
datemapping = {
|
datemapping = {
|
||||||
|
|||||||
@@ -347,6 +347,7 @@ def workout_video_create_view(request, id=0):
|
|||||||
# get data
|
# get data
|
||||||
data, metrics, maxtime = dataprep.get_video_data(
|
data, metrics, maxtime = dataprep.get_video_data(
|
||||||
w, groups=metricsgroups, mode=mode)
|
w, groups=metricsgroups, mode=mode)
|
||||||
|
|
||||||
hascoordinates = pd.Series(data['latitude']).std() > 0
|
hascoordinates = pd.Series(data['latitude']).std() > 0
|
||||||
|
|
||||||
# create map
|
# create map
|
||||||
@@ -377,6 +378,7 @@ def workout_video_create_view(request, id=0):
|
|||||||
|
|
||||||
template = 'embedded_video.html'
|
template = 'embedded_video.html'
|
||||||
|
|
||||||
|
|
||||||
return render(request,
|
return render(request,
|
||||||
template,
|
template,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user