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
|
||||
|
||||
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):
|
||||
try:
|
||||
|
||||
@@ -11,6 +11,8 @@ import pandas as pd
|
||||
from scipy import optimize
|
||||
from django.utils import timezone
|
||||
|
||||
from math import log10
|
||||
|
||||
nometrics = [
|
||||
'originalvelo',
|
||||
'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):
|
||||
if sex == 'male':
|
||||
|
||||
@@ -1304,6 +1304,11 @@ def workouts_view(request,message='',successmessage='',
|
||||
workoutsnohr = workouts.exclude(averagehr__isnull=False)
|
||||
for w in workoutsnohr:
|
||||
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:
|
||||
query_list = query.split()
|
||||
|
||||
Reference in New Issue
Block a user