some bug fixing for invalid TCX files
This commit is contained in:
@@ -581,8 +581,12 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
|||||||
try:
|
try:
|
||||||
latavg = row.df[' latitude'].mean()
|
latavg = row.df[' latitude'].mean()
|
||||||
lonavg = row.df[' longitude'].mean()
|
lonavg = row.df[' longitude'].mean()
|
||||||
|
|
||||||
tf = TimezoneFinder()
|
tf = TimezoneFinder()
|
||||||
timezone_str = tf.timezone_at(lng=lonavg,lat=latavg)
|
try:
|
||||||
|
timezone_str = tf.timezone_at(lng=lonavg,lat=latavg)
|
||||||
|
except ValueError:
|
||||||
|
timezone_str = 'UTC'
|
||||||
if timezone_str == None:
|
if timezone_str == None:
|
||||||
timezone_str = tf.closest_timezone_at(lng=lonavg,
|
timezone_str = tf.closest_timezone_at(lng=lonavg,
|
||||||
lat=latavg)
|
lat=latavg)
|
||||||
@@ -613,6 +617,12 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
|||||||
else:
|
else:
|
||||||
privacy = 'visible'
|
privacy = 'visible'
|
||||||
|
|
||||||
|
# checking for inf values
|
||||||
|
|
||||||
|
totaldist = np.nan_to_num(totaldist)
|
||||||
|
maxhr = np.nan_to_num(maxhr)
|
||||||
|
averagehr = np.nan_to_num(averagehr)
|
||||||
|
|
||||||
# check for duplicate start times and duration
|
# check for duplicate start times and duration
|
||||||
ws = Workout.objects.filter(startdatetime=workoutstartdatetime,
|
ws = Workout.objects.filter(startdatetime=workoutstartdatetime,
|
||||||
distance=totaldist,
|
distance=totaldist,
|
||||||
@@ -621,12 +631,8 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
|||||||
message = "Warning: This workout probably already exists in the database"
|
message = "Warning: This workout probably already exists in the database"
|
||||||
privacy = 'hidden'
|
privacy = 'hidden'
|
||||||
|
|
||||||
# checking for inf values
|
|
||||||
totaldist = np.nan_to_num(totaldist)
|
|
||||||
maxhr = np.nan_to_num(maxhr)
|
|
||||||
averagehr = np.nan_to_num(averagehr)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
w = Workout(user=r,name=title,date=workoutdate,
|
w = Workout(user=r,name=title,date=workoutdate,
|
||||||
workouttype=workouttype,
|
workouttype=workouttype,
|
||||||
@@ -650,11 +656,14 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
|
|||||||
# delta,cpvalues,avgpower = datautils.getsinglecp(row.df)
|
# delta,cpvalues,avgpower = datautils.getsinglecp(row.df)
|
||||||
thesecs = totaltime
|
thesecs = totaltime
|
||||||
maxt = 1.05*thesecs
|
maxt = 1.05*thesecs
|
||||||
logarr = datautils.getlogarr(maxt)
|
if maxt > 0:
|
||||||
dfgrouped = df.groupby(['workoutid'])
|
logarr = datautils.getlogarr(maxt)
|
||||||
delta,cpvalues,avgpower = datautils.getcp(dfgrouped,logarr)
|
dfgrouped = df.groupby(['workoutid'])
|
||||||
|
delta,cpvalues,avgpower = datautils.getcp(dfgrouped,logarr)
|
||||||
|
|
||||||
res,btvalues = utils.isbreakthrough(delta,cpvalues,r.p0,r.p1,r.p2,r.p3,r.cpratio)
|
res,btvalues = utils.isbreakthrough(delta,cpvalues,r.p0,r.p1,r.p2,r.p3,r.cpratio)
|
||||||
|
else:
|
||||||
|
res = 0
|
||||||
if res:
|
if res:
|
||||||
isbreakthrough = True
|
isbreakthrough = True
|
||||||
res = datautils.updatecp(delta,cpvalues,r)
|
res = datautils.updatecp(delta,cpvalues,r)
|
||||||
|
|||||||
Reference in New Issue
Block a user