Export to MapMyFitness now works
This commit is contained in:
@@ -9,6 +9,7 @@ import requests.auth
|
||||
import json
|
||||
from django.utils import timezone
|
||||
from datetime import datetime,timedelta
|
||||
import arrow
|
||||
import numpy as np
|
||||
from dateutil import parser
|
||||
import time
|
||||
@@ -239,7 +240,11 @@ def createunderarmourworkoutdata(w):
|
||||
except:
|
||||
return 0
|
||||
|
||||
st = w.startdatetime.astimezone(pytz.timezone(w.timezone))
|
||||
start_time = st.isoformat()
|
||||
|
||||
averagehr = int(row.df[' HRCur (bpm)'].mean())
|
||||
averagespm = int(row.df[' Cadence (stokes/min)'].mean()/2.)
|
||||
maxhr = int(row.df[' HRCur (bpm)'].max())
|
||||
duration = w.duration.hour*3600
|
||||
duration += w.duration.minute*60
|
||||
@@ -253,31 +258,42 @@ def createunderarmourworkoutdata(w):
|
||||
|
||||
# adding diff, trying to see if this is valid
|
||||
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
|
||||
t = row.df.ix[:,'TimeStamp (sec)'].values-row.df.ix[0,'TimeStamp (sec)']
|
||||
t[0] = t[1]
|
||||
t = row.df.ix[:,'TimeStamp (sec)'].values #-row.df.ix[0,'TimeStamp (sec)']
|
||||
|
||||
# t += arrow.get(st).timestamp
|
||||
|
||||
# t[0] = t[1]
|
||||
|
||||
d = row.df.ix[:,'cum_dist'].values
|
||||
d[0] = d[1]
|
||||
t = t.astype(int)
|
||||
t = t.astype(float)
|
||||
|
||||
|
||||
|
||||
|
||||
d = d.astype(int)
|
||||
spm = row.df[' Cadence (stokes/min)'].astype(int)
|
||||
spm[0] = spm[1]
|
||||
hr = row.df[' HRCur (bpm)'].astype(int)
|
||||
|
||||
speed = row.df[' AverageBoatSpeed (m/s)']
|
||||
speed = speed.replace(np.inf,0)
|
||||
|
||||
haslatlon=1
|
||||
|
||||
try:
|
||||
lat = row.df[' latitude'].values
|
||||
lon = row.df[' longitude'].values
|
||||
lat = row.df[' latitude']
|
||||
lon = row.df[' longitude']
|
||||
if not lat.std() and not lon.std():
|
||||
haslatlon = 0
|
||||
except KeyError:
|
||||
haslatlon = 0
|
||||
|
||||
|
||||
|
||||
# path data
|
||||
if haslatlon:
|
||||
locdata = []
|
||||
for e in zip(t,lat,lon):
|
||||
for e in zip(t,lat.values,lon.values):
|
||||
point = {
|
||||
'lat':e[1],
|
||||
'lng':e[2],
|
||||
@@ -303,8 +319,6 @@ def createunderarmourworkoutdata(w):
|
||||
for e in zip(t,spm):
|
||||
spmdata.append([e[0],e[1]])
|
||||
|
||||
st = w.startdatetime.astimezone(pytz.timezone(w.timezone))
|
||||
start_time = st.isoformat()
|
||||
|
||||
timeseries = {
|
||||
"distance": distancedata,
|
||||
@@ -312,22 +326,32 @@ def createunderarmourworkoutdata(w):
|
||||
"cadence": spmdata,
|
||||
}
|
||||
|
||||
aggregrates = {
|
||||
|
||||
aggregates = {
|
||||
"elapsed_time_total": int(duration),
|
||||
"active_time_total": int(duration),
|
||||
"distance_total": int(max(d)),
|
||||
"heartrate_avg": averagehr,
|
||||
"heart_rate_min": int(min(hr)),
|
||||
"heart_rate_max": int(max(hr)),
|
||||
"speed_min": speed.min().astype(float),
|
||||
"speed_max": speed.max().astype(float),
|
||||
"speed_avg": speed.mean(),
|
||||
"cadence_min": int(min(spm)/2.),
|
||||
"cadence_max": int(max(spm)/2.),
|
||||
"cadence_avg": averagespm,
|
||||
}
|
||||
|
||||
|
||||
# if haslatlon:
|
||||
# timeseries["position"] = locdata
|
||||
if haslatlon:
|
||||
timeseries["position"] = locdata
|
||||
|
||||
data = {
|
||||
"name": name,
|
||||
"start_datetime": start_time,
|
||||
"name": name,
|
||||
"has_time_series": True,
|
||||
"time_series": timeseries,
|
||||
"aggregates": aggregates,
|
||||
"start_locale_timezone": "Etc/UTC",
|
||||
"activity_type": "/v7.1/activity_type/128/",
|
||||
"notes": notes,
|
||||
|
||||
Reference in New Issue
Block a user