trivial changes white space
This commit is contained in:
@@ -49,7 +49,7 @@ from rowingdata import (
|
||||
SpeedCoach2Parser, FITParser, fitsummarydata,
|
||||
RitmoTimeParser,KinoMapParser,
|
||||
make_cumvalues,cumcpdata,ExcelTemplate,
|
||||
summarydata, get_file_type,
|
||||
summarydata, get_file_type,
|
||||
)
|
||||
|
||||
from rowingdata.csvparsers import HumonParser
|
||||
@@ -128,12 +128,12 @@ def polarization_index(df,rower):
|
||||
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()
|
||||
@@ -143,7 +143,7 @@ def polarization_index(df,rower):
|
||||
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
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ def get_latlon(id):
|
||||
rowdata = rdata(w.csvfilename)
|
||||
|
||||
if rowdata.df.empty:
|
||||
return [pd.Series([]), pd.Series([])]
|
||||
return [pd.Series([]), pd.Series([])]
|
||||
|
||||
try:
|
||||
try:
|
||||
@@ -216,7 +216,7 @@ def workout_summary_to_df(
|
||||
trimps.append(workout_trimp(w)[0])
|
||||
rscore = workout_rscore(w)
|
||||
rscores.append(int(rscore[0]))
|
||||
|
||||
|
||||
df = pd.DataFrame({
|
||||
'name':names,
|
||||
'date':startdatetimes,
|
||||
@@ -285,7 +285,7 @@ def join_workouts(r,ids,title='Joined Workout',
|
||||
else:
|
||||
makeprivate = False
|
||||
|
||||
startdatetime = parent.startdatetime
|
||||
startdatetime = parent.startdatetime
|
||||
else:
|
||||
oarlength = 2.89
|
||||
inboard = 0.88
|
||||
@@ -311,7 +311,7 @@ def join_workouts(r,ids,title='Joined Workout',
|
||||
workouttype = parent.workouttype
|
||||
notes = parent.notes
|
||||
summary = parent.summary
|
||||
|
||||
|
||||
files = [w.csvfilename for w in ws]
|
||||
|
||||
row = rdata(files[0])
|
||||
@@ -353,7 +353,7 @@ def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
|
||||
ignoreadvanced=False):
|
||||
# clean data remove zeros and negative values
|
||||
|
||||
|
||||
|
||||
# bring metrics which have negative values to positive domain
|
||||
if len(datadf)==0:
|
||||
return datadf
|
||||
@@ -377,7 +377,7 @@ def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
|
||||
datadf['spm'] = datadf['spm'] + 1.0
|
||||
except (KeyError,TypeError) as e:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
datadf = datadf.clip(lower=0)
|
||||
except TypeError:
|
||||
@@ -421,13 +421,13 @@ def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
|
||||
datadf.mask(mask,inplace=True)
|
||||
except (KeyError,TypeError):
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
mask = datadf['efficiency'] > 200.
|
||||
datadf.mask(mask,inplace=True)
|
||||
except (KeyError,TypeError):
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
mask = datadf['spm'] < 10
|
||||
datadf.mask(mask,inplace=True)
|
||||
@@ -648,7 +648,7 @@ def fitnessmetric_to_sql(m,table='powertimefitnessmetric',debug=False):
|
||||
placeholders = ", ".join(["?"] * len(m))
|
||||
|
||||
query = "INSERT into %s ( %s ) Values (%s)" % (table, columns, placeholders)
|
||||
|
||||
|
||||
values = tuple(m[key] for key in m.keys())
|
||||
with engine.connect() as conn, conn.begin():
|
||||
result = conn.execute(query,values)
|
||||
@@ -684,8 +684,8 @@ def deletecpdata_sql(rower_id,table='cpdata'):
|
||||
conn.close()
|
||||
engine.dispose()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def updatecpdata_sql(rower_id,delta,cp,table='cpdata',distance=[]):
|
||||
deletecpdata_sql(rower_id)
|
||||
df = pd.DataFrame(
|
||||
@@ -836,7 +836,7 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
|
||||
spm = 20.
|
||||
else:
|
||||
spm = avgspm
|
||||
|
||||
|
||||
step = totalseconds/float(nr_strokes)
|
||||
|
||||
elapsed = np.arange(nr_strokes)*totalseconds/(float(nr_strokes-1))
|
||||
@@ -867,7 +867,7 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
|
||||
hr = avghr
|
||||
else:
|
||||
hr = 0
|
||||
|
||||
|
||||
df = pd.DataFrame({
|
||||
'TimeStamp (sec)': unixtime,
|
||||
' Horizontal (meters)': d,
|
||||
@@ -902,7 +902,7 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
|
||||
return (id, message)
|
||||
|
||||
from rowers.utils import totaltime_sec_to_string
|
||||
|
||||
|
||||
# Processes painsled CSV file to database
|
||||
def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
boattype='1x',
|
||||
@@ -934,7 +934,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
|
||||
if row.df.empty:
|
||||
return (0, 'Error: CSV data file was empty')
|
||||
|
||||
|
||||
dtavg = row.df['TimeStamp (sec)'].diff().mean()
|
||||
|
||||
if dtavg < 1:
|
||||
@@ -1025,7 +1025,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
if dosummary:
|
||||
summary = row.allstats()
|
||||
|
||||
|
||||
|
||||
|
||||
timezone_str = 'UTC'
|
||||
try:
|
||||
@@ -1094,7 +1094,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
)
|
||||
|
||||
ws2 = []
|
||||
|
||||
|
||||
for ww in ws:
|
||||
t = ww.duration
|
||||
delta = datetime.timedelta(hours=t.hour, minutes=t.minute, seconds=t.second)
|
||||
@@ -1146,7 +1146,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
|
||||
rscore,normp = workout_rscore(w)
|
||||
trimp,hrtss = workout_trimp(w)
|
||||
|
||||
|
||||
isbreakthrough = False
|
||||
ishard = False
|
||||
if workouttype == 'water':
|
||||
@@ -1184,7 +1184,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
btvalues=btvalues.to_json())
|
||||
|
||||
|
||||
# submit email task to send email about breakthrough workout
|
||||
if ishard:
|
||||
if r.getemailnotifications and not r.emailbounced:
|
||||
@@ -1194,7 +1194,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
btvalues=btvalues.to_json())
|
||||
|
||||
|
||||
|
||||
return (w.id, message)
|
||||
|
||||
@@ -1266,7 +1266,7 @@ def handle_nonpainsled(f2, fileformat, summary=''):
|
||||
|
||||
if not hasrecognized:
|
||||
return (0,'',0,0,'')
|
||||
|
||||
|
||||
f_to_be_deleted = f2
|
||||
# should delete file
|
||||
f2 = f2[:-4] + 'o.csv'
|
||||
@@ -1322,7 +1322,7 @@ def new_workout_from_file(r, f2,
|
||||
f3 = f3[6:]
|
||||
a = MessageAttachment(message=msg,document=f3)
|
||||
a.save()
|
||||
|
||||
|
||||
return -1, message, f2
|
||||
|
||||
# Some people try to upload Concept2 logbook summaries
|
||||
@@ -1340,7 +1340,7 @@ def new_workout_from_file(r, f2,
|
||||
os.remove(f2)
|
||||
message = "KML files are not supported"
|
||||
return (0, message, f2)
|
||||
|
||||
|
||||
# Some people upload corrupted zip files
|
||||
if fileformat == 'notgzip':
|
||||
os.remove(f2)
|
||||
@@ -1371,7 +1371,7 @@ def new_workout_from_file(r, f2,
|
||||
handle_sendemail_unrecognized,
|
||||
f4,
|
||||
r.user.email)
|
||||
|
||||
|
||||
return (0, message, f2)
|
||||
if fileformat == 'att':
|
||||
# email attachment which can safely be ignored
|
||||
@@ -1393,7 +1393,7 @@ def new_workout_from_file(r, f2,
|
||||
|
||||
if workoutsource is None:
|
||||
workoutsource = fileformat
|
||||
|
||||
|
||||
id, message = save_workout_database(
|
||||
f2, r,
|
||||
notes=notes,
|
||||
@@ -1657,7 +1657,7 @@ def getrowdata_db(id=0, doclean=False, convertnewtons=True,
|
||||
else:
|
||||
row = Workout.objects.get(id=id)
|
||||
|
||||
|
||||
|
||||
if not data.empty and data['efficiency'].mean() == 0 and data['power'].mean() != 0 and checkefficiency == True:
|
||||
data = add_efficiency(id=id)
|
||||
|
||||
@@ -1692,10 +1692,10 @@ def getsmallrowdata_db(columns, ids=[], doclean=True,workstrokesonly=True,comput
|
||||
|
||||
df = pd.concat(data,axis=0)
|
||||
# df = dd.concat(data,axis=0)
|
||||
|
||||
|
||||
else:
|
||||
try:
|
||||
df = pd.read_parquet(csvfilenames[0],columns=columns)
|
||||
df = pd.read_parquet(csvfilenames[0],columns=columns)
|
||||
except OSError:
|
||||
rowdata,row = getrowdata(id=ids[0])
|
||||
if rowdata and len(rowdata.df):
|
||||
@@ -1707,7 +1707,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True,workstrokesonly=True,comput
|
||||
|
||||
# df = df.loc[:,~df.columns.duplicated()]
|
||||
|
||||
|
||||
|
||||
|
||||
if compute:
|
||||
data = df.copy()
|
||||
@@ -1717,7 +1717,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True,workstrokesonly=True,comput
|
||||
data.dropna(axis=1,how='all',inplace=True)
|
||||
data.dropna(axis=0,how='any',inplace=True)
|
||||
return data
|
||||
|
||||
|
||||
return df
|
||||
|
||||
def getsmallrowdata_db_dask(columns, ids=[], doclean=True,workstrokesonly=True,compute=True):
|
||||
@@ -1744,10 +1744,10 @@ def getsmallrowdata_db_dask(columns, ids=[], doclean=True,workstrokesonly=True,c
|
||||
|
||||
df = dd.concat(data,axis=0)
|
||||
# df = dd.concat(data,axis=0)
|
||||
|
||||
|
||||
else:
|
||||
try:
|
||||
df = dd.read_parquet(csvfilenames[0],columns=columns)
|
||||
df = dd.read_parquet(csvfilenames[0],columns=columns)
|
||||
except OSError:
|
||||
rowdata,row = getrowdata(id=ids[0])
|
||||
if rowdata and len(rowdata.df):
|
||||
@@ -1759,7 +1759,7 @@ def getsmallrowdata_db_dask(columns, ids=[], doclean=True,workstrokesonly=True,c
|
||||
|
||||
# df = df.loc[:,~df.columns.duplicated()]
|
||||
|
||||
|
||||
|
||||
|
||||
if compute:
|
||||
data = df.compute()
|
||||
@@ -1769,7 +1769,7 @@ def getsmallrowdata_db_dask(columns, ids=[], doclean=True,workstrokesonly=True,c
|
||||
data.dropna(axis=1,how='all',inplace=True)
|
||||
data.dropna(axis=0,how='any',inplace=True)
|
||||
return data
|
||||
|
||||
|
||||
return df
|
||||
|
||||
def getsmallrowdata_db_old(columns, ids=[], doclean=True, workstrokesonly=True):
|
||||
@@ -1787,7 +1787,7 @@ def getsmallrowdata_db_old(columns, ids=[], doclean=True, workstrokesonly=True):
|
||||
f = row.df['TimeStamp (sec)'].diff().mean()
|
||||
except (AttributeError,KeyError) as e:
|
||||
f = 0
|
||||
|
||||
|
||||
if f != 0 and not np.isnan(f):
|
||||
windowsize = 2 * (int(10. / (f))) + 1
|
||||
else:
|
||||
@@ -1808,7 +1808,7 @@ def getsmallrowdata_db_old(columns, ids=[], doclean=True, workstrokesonly=True):
|
||||
except (KeyError, AttributeError):
|
||||
data[c] = 0
|
||||
|
||||
|
||||
|
||||
# convert newtons
|
||||
|
||||
if doclean:
|
||||
@@ -1907,7 +1907,7 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
|
||||
data.append(df)
|
||||
|
||||
df = pd.concat(data,axis=0)
|
||||
|
||||
|
||||
|
||||
df = df.fillna(value=0)
|
||||
|
||||
@@ -2215,9 +2215,9 @@ def add_efficiency(id=0):
|
||||
rowdata = remove_invalid_columns(rowdata)
|
||||
rowdata = rowdata.replace([-np.inf, np.inf], np.nan)
|
||||
rowdata = rowdata.fillna(method='ffill')
|
||||
|
||||
|
||||
delete_strokedata(id)
|
||||
|
||||
|
||||
if id != 0:
|
||||
rowdata['workoutid'] = id
|
||||
filename = 'media/strokedata_{id}.parquet.gz'.format(id=id)
|
||||
@@ -2250,7 +2250,7 @@ def dataprep(rowdatadf, id=0, bands=True, barchart=True, otwpower=True,
|
||||
velo = rowdatadf.loc[:,' AverageBoatSpeed (m/s)']
|
||||
except KeyError:
|
||||
velo = 500./p
|
||||
|
||||
|
||||
hr = rowdatadf.loc[:, ' HRCur (bpm)']
|
||||
spm = rowdatadf.loc[:, ' Cadence (stokes/min)']
|
||||
cumdist = rowdatadf.loc[:, 'cum_dist']
|
||||
@@ -2316,7 +2316,7 @@ def dataprep(rowdatadf, id=0, bands=True, barchart=True, otwpower=True,
|
||||
|
||||
powerhr = 60.*power/hr
|
||||
powerhr = powerhr.fillna(value=0)
|
||||
|
||||
|
||||
if driveenergy.mean() == 0 and driveenergy.std() == 0:
|
||||
driveenergy = 0*driveenergy+100
|
||||
|
||||
@@ -2521,7 +2521,7 @@ def workout_trimp(w):
|
||||
|
||||
if w.trimp > 0:
|
||||
return w.trimp,w.hrtss
|
||||
|
||||
|
||||
r = w.user
|
||||
ftp = float(r.ftp)
|
||||
if w.workouttype in otwtypes:
|
||||
@@ -2557,13 +2557,13 @@ def workout_trimp(w):
|
||||
r.hrftp,
|
||||
r.max,
|
||||
r.rest)
|
||||
|
||||
|
||||
return 0,0
|
||||
|
||||
def workout_rscore(w):
|
||||
if w.rscore > 0:
|
||||
return w.rscore,w.normp
|
||||
|
||||
|
||||
r = w.user
|
||||
ftp = float(r.ftp)
|
||||
if w.workouttype in otwtypes:
|
||||
@@ -2574,7 +2574,7 @@ def workout_rscore(w):
|
||||
r.hrftp = int(hrftp)
|
||||
r.save()
|
||||
|
||||
|
||||
|
||||
|
||||
job = myqueue(
|
||||
queuehigh,
|
||||
@@ -2586,7 +2586,7 @@ def workout_rscore(w):
|
||||
r.hrftp,
|
||||
r.max,
|
||||
r.rest)
|
||||
|
||||
|
||||
return 0,0
|
||||
|
||||
def workout_normv(w,pp=4.0):
|
||||
@@ -2603,7 +2603,7 @@ def workout_normv(w,pp=4.0):
|
||||
r.hrftp = int(hrftp)
|
||||
r.save()
|
||||
|
||||
|
||||
|
||||
|
||||
job = myqueue(
|
||||
queuehigh,
|
||||
@@ -2615,7 +2615,5 @@ def workout_normv(w,pp=4.0):
|
||||
r.hrftp,
|
||||
r.max,
|
||||
r.rest)
|
||||
|
||||
return 0,0
|
||||
|
||||
|
||||
return 0,0
|
||||
|
||||
Reference in New Issue
Block a user