getting part
This commit is contained in:
@@ -192,11 +192,11 @@ def tailwind(bearing, vwind, winddir):
|
||||
|
||||
|
||||
def interactive_hr_piechart(df, rower, title, totalseconds=0):
|
||||
if df.empty:
|
||||
if df.is_empty():
|
||||
return "", "Not enough data to make a chart"
|
||||
|
||||
df.sort_values(by='hr', inplace=True)
|
||||
df['timehr'] = df['deltat']*df['hr']
|
||||
df = df.sort("hr")
|
||||
df = df.with_columns((pl.col("deltat")*pl.col("hr")).alias("deltat"))
|
||||
|
||||
sumtimehr = df['deltat'].sum()
|
||||
|
||||
@@ -205,24 +205,23 @@ def interactive_hr_piechart(df, rower, title, totalseconds=0):
|
||||
|
||||
hrzones = rower.hrzones
|
||||
|
||||
qry = 'hr < {ut2}'.format(ut2=rower.ut2)
|
||||
qrydata = df.query(qry)
|
||||
qrydata = df.filter(pl.col("hr") < rower.ut2)
|
||||
frac_lut2 = totalseconds*qrydata['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = '{ut2} <= hr < {ut1}'.format(ut1=rower.ut1, ut2=rower.ut2)
|
||||
frac_ut2 = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
qrydata = df.lazy().filter(pl.col("hr") >= rower.ut2).filter(pl.col("hr") < rower.ut1)
|
||||
frac_ut2 = totalseconds*qrydata.collect()['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = '{ut1} <= hr < {at}'.format(ut1=rower.ut1, at=rower.at)
|
||||
frac_ut1 = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
qrydata = df.lazy().filter(pl.col("hr") >= rower.ut1).filter(pl.col("hr") < rower.at)
|
||||
frac_ut1 = totalseconds*qrydata.collect()['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = '{at} <= hr < {tr}'.format(at=rower.at, tr=rower.tr)
|
||||
frac_at = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
qrydata = df.lazy().filter(pl.col("hr") >= rower.at).filter(pl.col("hr") < rower.tr)
|
||||
frac_at = totalseconds*qrydata.collect()['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = '{tr} <= hr < {an}'.format(tr=rower.tr, an=rower.an)
|
||||
frac_tr = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
qrydata = df.lazy().filter(pl.col("hr") >= rower.tr).filter(pl.col("hr") < rower.an)
|
||||
frac_tr = totalseconds*qrydata.collect()['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = 'hr >= {an}'.format(an=rower.an)
|
||||
frac_an = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
qrydata = df.filter(pl.col("hr") >= rower.an)
|
||||
frac_an = totalseconds*qrydata['deltat'].sum()/sumtimehr
|
||||
|
||||
datadict = {
|
||||
'<{ut2}'.format(ut2=hrzones[1]): frac_lut2,
|
||||
@@ -1931,7 +1930,6 @@ def interactive_streamchart(id=0, promember=0):
|
||||
return [script, div]
|
||||
|
||||
def forcecurve_multi_interactive_chart(selected): # pragma: no cover
|
||||
df_plot = pd.DataFrame()
|
||||
ids = [analysis.id for analysis in selected]
|
||||
workoutids = [analysis.workout.id for analysis in selected]
|
||||
|
||||
@@ -1940,18 +1938,17 @@ def forcecurve_multi_interactive_chart(selected): # pragma: no cover
|
||||
columns = ['catch', 'slip', 'wash', 'finish', 'averageforce',
|
||||
'peakforceangle', 'peakforce', 'spm', 'distance',
|
||||
'workoutstate', 'workoutid', 'driveenergy', 'cumdist']
|
||||
columns = columns + [name for name, d in metrics.rowingmetrics]
|
||||
|
||||
rowdata = dataprep.getsmallrowdata_db(columns, ids=workoutids,
|
||||
rowdata = dataprep.getsmallrowdata_pl(columns, ids=workoutids,
|
||||
workstrokesonly=False)
|
||||
|
||||
rowdata = rowdata.fill_nan(None).drop_nulls()
|
||||
|
||||
rowdata.dropna(axis=1, how='all', inplace=True)
|
||||
rowdata.dropna(axis=0, how='any', inplace=True)
|
||||
|
||||
if rowdata.empty:
|
||||
if rowdata.is_empty():
|
||||
return "", "No Valid Data Available", "", ""
|
||||
|
||||
data_dict = rowdata.to_dict("records")
|
||||
data_dict = rowdata.to_dicts()
|
||||
|
||||
thresholdforces = []
|
||||
for analysis in selected:
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -2381,14 +2381,16 @@ def history_view_data(request, userid=0):
|
||||
|
||||
ids = [w.id for w in g_workouts]
|
||||
|
||||
columns = ['hr', 'power', 'time']
|
||||
|
||||
df = getsmallrowdata_db(columns, ids=ids)
|
||||
# columns = ['hr', 'power', 'time']
|
||||
columns = [name for name, d in metrics.rowingmetrics]+['workoutstate', 'workoutid']
|
||||
|
||||
df = getsmallrowdata_pl(columns, ids=ids)
|
||||
try:
|
||||
df['deltat'] = df['time'].diff().clip(lower=0)
|
||||
df = df.with_columns(pl.col('time').diff().clip(lower_bound=0).alias("deltat"))
|
||||
except KeyError: # pragma: no cover
|
||||
pass
|
||||
df = dataprep.clean_df_stats(df, workstrokesonly=True,
|
||||
|
||||
df = dataprep.clean_df_stats_pl(df, workstrokesonly=True,
|
||||
ignoreadvanced=True, ignorehr=False)
|
||||
|
||||
totalmeters, totalhours, totalminutes, totalseconds = get_totals(
|
||||
@@ -2418,13 +2420,13 @@ def history_view_data(request, userid=0):
|
||||
whours=whours,
|
||||
wminutes=wminutes, wseconds=wseconds,
|
||||
)
|
||||
ddf = getsmallrowdata_db(columns, ids=[w.id for w in a_workouts])
|
||||
ddf = getsmallrowdata_pl(columns, ids=[w.id for w in a_workouts])
|
||||
try:
|
||||
ddf['deltat'] = ddf['time'].diff().clip(lower=0)
|
||||
ddf = ddf.with_columns(pl.col("time").diff().clip(lower_bound=0).alias("deltat"))
|
||||
except KeyError: # pragma: no cover
|
||||
pass
|
||||
|
||||
ddf = dataprep.clean_df_stats(ddf, workstrokesonly=False,
|
||||
ddf = dataprep.clean_df_stats_pl(ddf, workstrokesonly=False,
|
||||
ignoreadvanced=True)
|
||||
|
||||
try:
|
||||
@@ -2432,13 +2434,13 @@ def history_view_data(request, userid=0):
|
||||
except (KeyError, ValueError, AttributeError): # pragma: no cover
|
||||
ddict['hrmean'] = 0
|
||||
try:
|
||||
ddict['hrmax'] = ddf['hr'].max().astype(int)
|
||||
ddict['hrmax'] = int(ddf['hr'].max())
|
||||
except (KeyError, ValueError, AttributeError): # pragma: no cover
|
||||
ddict['hrmax'] = 0
|
||||
|
||||
ddict['powermean'] = int(wavg(ddf, 'power', 'deltat'))
|
||||
try:
|
||||
ddict['powermax'] = ddf['power'].max().astype(int)
|
||||
ddict['powermax'] = int(ddf['power'].max())
|
||||
except KeyError: # pragma: no cover
|
||||
ddict['powermax'] = 0
|
||||
ddict['nrworkouts'] = a_workouts.count()
|
||||
@@ -2453,13 +2455,13 @@ def history_view_data(request, userid=0):
|
||||
totalsdict['distance'] = totalmeters
|
||||
try:
|
||||
totalsdict['powermean'] = int(wavg(df, 'power', 'deltat'))
|
||||
totalsdict['powermax'] = df['power'].max().astype(int)
|
||||
totalsdict['powermax'] = int(df['power'].max())
|
||||
except KeyError: # pragma: no cover
|
||||
totalsdict['powermean'] = 0
|
||||
totalsdict['powermax'] = 0
|
||||
try:
|
||||
totalsdict['hrmean'] = int(wavg(df, 'hr', 'deltat'))
|
||||
totalsdict['hrmax'] = df['hr'].max().astype(int)
|
||||
totalsdict['hrmax'] = int(df['hr'].max())
|
||||
except KeyError: # pragma: no cover
|
||||
totalsdict['hrmean'] = 0
|
||||
totalsdict['hrmax'] = 0
|
||||
@@ -2479,14 +2481,14 @@ def history_view_data(request, userid=0):
|
||||
a_workouts = g_workouts.filter(workouttype=typeselect)
|
||||
meters, hours, minutes, seconds = get_totals(a_workouts)
|
||||
totalseconds = 3600 * hours + 60 * minutes + seconds
|
||||
ddf = getsmallrowdata_db(columns, ids=[w.id for w in a_workouts])
|
||||
ddf = getsmallrowdata_pl(columns, ids=[w.id for w in a_workouts])
|
||||
|
||||
try:
|
||||
ddf['deltat'] = ddf['time'].diff().clip(lower=0)
|
||||
ddf = ddf.with_columns(pl.col("time").diff().clip(lower_bound=0).alias("deltat"))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
ddf = dataprep.clean_df_stats(ddf, workstrokesonly=True,
|
||||
ddf = dataprep.clean_df_stats_pl(ddf, workstrokesonly=True,
|
||||
ignoreadvanced=True)
|
||||
|
||||
totalscript, totaldiv = interactive_hr_piechart(
|
||||
|
||||
@@ -16,7 +16,7 @@ from rowers.utils import (
|
||||
from rowers.celery import result as celery_result
|
||||
from rowers.interactiveplots import *
|
||||
from scipy.interpolate import griddata
|
||||
from rowers.dataprep import getsmallrowdata_db
|
||||
from rowers.dataprep import getsmallrowdata_db, getsmallrowdata_pl
|
||||
from rowers.dataprep import timedeltaconv
|
||||
from scipy.special import lambertw
|
||||
from io import BytesIO
|
||||
|
||||
Reference in New Issue
Block a user