diff --git a/rowers/datautils.py b/rowers/datautils.py index a9610e99..68efe7a5 100644 --- a/rowers/datautils.py +++ b/rowers/datautils.py @@ -364,3 +364,64 @@ def getmaxwattinterval(tt,ww,i): deltat = 0 return deltat,wmax + +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.) + 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 = 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. 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]