Private
Public Access
1
0

sort of working

This commit is contained in:
Sander Roosendaal
2018-06-25 18:42:16 +02:00
parent 1e9caf244c
commit 90dcb2f4f9
4 changed files with 84 additions and 40 deletions

View File

@@ -37,7 +37,7 @@ from django_rq import job
from django.utils import timezone
from django.utils.html import strip_tags
from utils import deserialize_list
from utils import deserialize_list,ewmovingaverage
from rowers.dataprepnodjango import (
update_strokedata, new_workout_from_file,
@@ -45,7 +45,7 @@ from rowers.dataprepnodjango import (
update_agegroup_db,fitnessmetric_to_sql,
add_c2_stroke_data_db,totaltime_sec_to_string,
create_c2_stroke_data_db,update_empower,
database_url_debug,database_url,
database_url_debug,database_url,dataprep
)
@@ -85,7 +85,7 @@ def handle_strava_import_stroke_data(stravatoken,
# ready to fetch. Hurray
fetchresolution = 'high'
series_type = 'time'
authorizationstring = str('Bearer ' + r.stravatoken)
authorizationstring = str('Bearer ' + stravatoken)
headers = {'Authorization': authorizationstring,
'user-agent': 'sanderroosendaal',
'Content-Type': 'application/json',
@@ -109,6 +109,7 @@ def handle_strava_import_stroke_data(stravatoken,
url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/latlng?resolution="+fetchresolution+"&series_type="+series_type
latlongjson = requests.get(url,headers=headers)
try:
t = np.array(timejson.json()[0]['data'])
nr_rows = len(t)
@@ -161,19 +162,37 @@ def handle_strava_import_stroke_data(stravatoken,
pace = 500./(1.0*velo2)
pace[np.isinf(pace)] = 0.0
df = pd.DataFrame({'t':10*t,
'd':10*d,
'p':10*pace,
'spm':spm,
'hr':hr,
'lat':lat,
'lon':lon,
'strokelength':strokelength,
unixtime = starttimeunix+10*t
nr_strokes = len(t)
df = pd.DataFrame({'TimeStamp (sec)':unixtime,
' ElapsedTime (sec)':10*t,
' Horizontal (meters)':10*d,
' Stroke500mPace (sec/500m)':10*pace,
' Cadence (stokes/min)':spm,
' HRCur (bpm)':hr,
' latitude':lat,
' longitude':lon,
' StrokeDistance (meters)':strokelength,
'cum_dist':10*d,
' DragFactor':np.zeros(nr_strokes),
' DriveLength (meters)':np.zeros(nr_strokes),
' StrokeDistance (meters)':np.zeros(nr_strokes),
' DriveTime (ms)':np.zeros(nr_strokes),
' StrokeRecoveryTime (ms)':np.zeros(nr_strokes),
' AverageDriveForce (lbs)':np.zeros(nr_strokes),
' PeakDriveForce (lbs)':np.zeros(nr_strokes),
' lapIdx':np.zeros(nr_strokes),
' Power (watts)':0*d,
})
res = df.to_csv(csvfilename+'.gz',index_label='index',compression='gzip')
data = dataprep(df,id=workoutid,bands=False,debug=debug)
# startdatetime = datetime.datetime.strptime(startdatetime,"%Y-%m-%d-%H:%M:%S")
return [workoutsummary,df]
return 1
@app.task