able to calculate polarization index (from power only)
This commit is contained in:
@@ -117,6 +117,30 @@ from scipy.signal import savgol_filter
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
def polarization_index(df,rower):
|
||||||
|
df['dt'] = df['time'].diff()/6.e4
|
||||||
|
# remove rest (spm<15)
|
||||||
|
df.dropna(axis=0,inplace=True)
|
||||||
|
df['dt'] = df['dt'].clip(upper=4,lower=0)
|
||||||
|
|
||||||
|
|
||||||
|
masklow = (df['power']>0) & (df['power']<int(rower.pw_at))
|
||||||
|
maskmid = (df['power']>=rower.pw_at) & (df['power']<int(rower.pw_an))
|
||||||
|
maskhigh = (df['power']>rower.pw_an)
|
||||||
|
|
||||||
|
|
||||||
|
time_low_pw = df.loc[masklow,'dt'].sum()
|
||||||
|
time_mid_pw = df.loc[maskmid,'dt'].sum()
|
||||||
|
time_high_pw = df.loc[maskhigh,'dt'].sum()
|
||||||
|
|
||||||
|
frac_low = time_low_pw/(time_low_pw+time_mid_pw+time_high_pw)
|
||||||
|
frac_mid = time_mid_pw/(time_low_pw+time_mid_pw+time_high_pw)
|
||||||
|
frac_high = time_high_pw/(time_low_pw+time_mid_pw+time_high_pw)
|
||||||
|
|
||||||
|
index = math.log10(frac_high*100.*frac_low/frac_mid)
|
||||||
|
|
||||||
|
return index
|
||||||
|
|
||||||
|
|
||||||
def get_latlon(id):
|
def get_latlon(id):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import pandas as pd
|
|||||||
from scipy import optimize
|
from scipy import optimize
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from math import log10
|
||||||
|
|
||||||
nometrics = [
|
nometrics = [
|
||||||
'originalvelo',
|
'originalvelo',
|
||||||
'cumdist',
|
'cumdist',
|
||||||
@@ -359,8 +361,6 @@ This value should be fairly constant across all stroke rates.""",
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def polarization_index(df,rower):
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def calc_trimp(df,sex,hrmax,hrmin,hrftp):
|
def calc_trimp(df,sex,hrmax,hrmin,hrftp):
|
||||||
if sex == 'male':
|
if sex == 'male':
|
||||||
|
|||||||
@@ -1305,6 +1305,11 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
for w in workoutsnohr:
|
for w in workoutsnohr:
|
||||||
res = dataprep.workout_trimp(w)
|
res = dataprep.workout_trimp(w)
|
||||||
|
|
||||||
|
# ids = [w.id for w in workouts]
|
||||||
|
# df = dataprep.getsmallrowdata_db(['time','power'],ids=ids)
|
||||||
|
# polarization = dataprep.polarization_index(df,r)
|
||||||
|
|
||||||
|
|
||||||
if query:
|
if query:
|
||||||
query_list = query.split()
|
query_list = query.split()
|
||||||
workouts = workouts.filter(
|
workouts = workouts.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user