From e08ebd1d645b4ec1a9ab54a008fde45f8fe8029c Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 9 Nov 2020 19:16:21 +0100 Subject: [PATCH 1/3] getfastest (distance) --- rowers/datautils.py | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/rowers/datautils.py b/rowers/datautils.py index a9610e99..dda402c0 100644 --- a/rowers/datautils.py +++ b/rowers/datautils.py @@ -364,3 +364,54 @@ def getmaxwattinterval(tt,ww,i): deltat = 0 return deltat,wmax + +def getfastest(df,thedistance): + tt = df['time'].copy() + dd = df['cumdist'].copy() + + tmax = tt.max() + + if tmax > 500000: + newlen=int(tmax/2000.) + newt = np.arange(newlen)*tmax/float(newlen) + deltat = newt[1]-newt[0] + else: + newt = np.arange(0,tmax,10.) + deltat = 10. + + dd = griddata(tt.values, + dd.values,newt,method='linear',rescale=True) + + tt = pd.Series(newt) + dd = pd.Series(dd) + + G = pd.concat([pd.Series([0]),dd]) + h = np.mgrid[0:len(tt)+1:1,0:len(tt)+1:1] + distances = pd.DataFrame(h[1]-h[0]) + ones = 1+np.zeros(len(G)) + Ghor = np.outer(ones,G) + Gver = np.outer(G,ones) + Gdif = Ghor-Gver + Gdif = np.tril(Gdif.T).T + Gdif = pd.DataFrame(Gdif) + F = Gdif + + F.fillna(inplace=True,method='ffill',axis=1) + F.fillna(inplace=True,value=0) + + restime = [] + distance = [] + + for i in np.arange(0,len(tt)+1,1): + restime.append(deltat*i) + cp = np.diag(F,i).max() + distance.append(cp) + + distance[0] = distance[1] + + restime = np.array(restime) + distance = np.array(distance) + + d2 = griddata(distance,restime,[thedistance],method='linear',rescale=True) + + return d2[0]/1000. From 79b4c1032fdb6e4e35fed3892a5a26aeca51d970 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 9 Nov 2020 20:36:24 +0100 Subject: [PATCH 2/3] some error checking in getfastest --- rowers/datautils.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rowers/datautils.py b/rowers/datautils.py index dda402c0..68efe7a5 100644 --- a/rowers/datautils.py +++ b/rowers/datautils.py @@ -365,11 +365,17 @@ def getmaxwattinterval(tt,ww,i): return deltat,wmax -def getfastest(df,thedistance): +def getfastest(df,thevalue,mode='distance'): tt = df['time'].copy() dd = df['cumdist'].copy() tmax = tt.max() + if mode == 'distance': + if dd.max() > thevalue: + return 0 + else: + if tt.max() > thevalue: + return 0 if tmax > 500000: newlen=int(tmax/2000.) @@ -412,6 +418,10 @@ def getfastest(df,thedistance): restime = np.array(restime) distance = np.array(distance) - d2 = griddata(distance,restime,[thedistance],method='linear',rescale=True) + d2 = 0 + if mode == 'distance': + d2 = griddata(distance,restime,[thevalue],method='linear',rescale=True) + else: + d2 = griddata(restime,distance,[thevalue],method='linear',rescale=True) return d2[0]/1000. From 2a65454ba5983e7bee4f18673386324e63cedb86 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 9 Nov 2020 21:31:06 +0100 Subject: [PATCH 3/3] flex chart bug fix --- rowers/interactiveplots.py | 10 ++++++---- rowers/views/analysisviews.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 004c25db..ed1d54eb 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -2983,7 +2983,7 @@ def interactive_otwcpchart(powerdf,promember=0,rowername="",r=None,cpfit='data', watermarkh = 35 watermarkanchor = 'bottom_right' plot.extra_y_ranges = {"watermark": watermarkrange} - plot.sizing_mode = 'stretch_both' + plot.sizing_mode = 'scale_both' @@ -3292,7 +3292,8 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower, watermarkh = 35 watermarkanchor = 'bottom_right' plot.extra_y_ranges = {"watermark": watermarkrange} - plot.sizing_mode = 'stretch_both' + plot.sizing_mode = 'scale_both' + plot.image_url([watermarkurl],1.8*max(thesecs),watermarky, watermarkw,watermarkh, @@ -3479,7 +3480,7 @@ def interactive_windchart(id=0,promember=0): plot.xaxis.axis_label = "Distance (m)" plot.yaxis.axis_label = "Wind Speed (m/s)" plot.y_range = Range1d(-7,7) - plot.sizing_mode = 'stretch_both' + plot.sizing_mode = 'scale_both' plot.extra_y_ranges = {"winddirection": Range1d(start=0,end=360)} @@ -6391,7 +6392,8 @@ def interactive_otw_advanced_pace_chart(id=0,promember=0): watermarkanchor = 'bottom_right' plot.extra_y_ranges = {"watermark": watermarkrange} plot.extra_x_ranges = {"watermark": watermarkrange} - plot.sizing_mode = 'stretch_both' + plot.sizing_mode = 'scale_both' + plot.image_url([watermarkurl],watermarkx,watermarky, watermarkw,watermarkh, diff --git a/rowers/views/analysisviews.py b/rowers/views/analysisviews.py index 361d57f3..ff4a64d4 100644 --- a/rowers/views/analysisviews.py +++ b/rowers/views/analysisviews.py @@ -558,6 +558,7 @@ def cpdata(workouts, options): res = interactive_otwcpchart(powerdf,promember=True,rowername=rowername,r=r, cpfit=cpfit,title=title,type=wtype) + print('noot') script = res[0] div = res[1] p1 = res[2]