Private
Public Access
1
0

added add_effiency and eff calc added to otw_physics

This commit is contained in:
Sander Roosendaal
2017-08-07 09:08:56 +02:00
parent c55be018d7
commit 2e4e6c47e0
2 changed files with 65 additions and 9 deletions

View File

@@ -460,7 +460,8 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
if consistencychecks:
a_messages.error(r.user,'Failed consistency check: '+key+', autocorrected')
else:
a_messages.error(r.user,'Failed consistency check: '+key+', not corrected')
pass
# a_messages.error(r.user,'Failed consistency check: '+key+', not corrected')
except ZeroDivisionError:
pass
@@ -1259,6 +1260,27 @@ def datafusion(id1,id2,columns,offset):
return df
def add_efficiency(id=0):
rowdata,row = getrowdata_db(id=id,doclean=False)
power = rowdata['power']
pace = rowdata['pace']/1.0e3
velo = 500./pace
ergpw = 2.8*velo**3
efficiency = 100.*ergpw/power
efficiency = efficiency.replace([-np.inf,np.inf],np.nan)
efficiency.fillna(method='ffill')
rowdata['efficiency'] = efficiency
delete_strokedata(id)
if id != 0:
rowdata['workoutid'] = id
engine = create_engine(database_url, echo=False)
with engine.connect() as conn, conn.begin():
rowdata.to_sql('strokedata',engine,if_exists='append',index=False)
conn.close()
engine.dispose()
return rowdata
# This is the main routine.
# it reindexes, sorts, filters, and smooths the data, then
# saves it to the stroke_data table in the database