ruptures 2
This commit is contained in:
@@ -59,6 +59,17 @@
|
||||
<td>
|
||||
</tr>
|
||||
</table>
|
||||
<h1>Feeling lucky?</h1>
|
||||
<p>
|
||||
<form enctype="multipart/form-data" method="post">
|
||||
<input type="hidden" name="ruptures" value="ruptures">
|
||||
<table width=100%>
|
||||
{{ ruptureform.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<input class="button" type="submit" value="I'm feeling lucky">
|
||||
</form>
|
||||
</p>
|
||||
<h1>Interval Shorthand</h1>
|
||||
<p>
|
||||
See the how-to <a href="#howto">at the bottom of this page</a> for details on how to use this form.
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Normal file
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Normal file
Binary file not shown.
@@ -18,6 +18,8 @@ from rowers.utils import intervals_to_string
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
from json.decoder import JSONDecodeError
|
||||
|
||||
import ruptures as rpt
|
||||
|
||||
def default(o): # pragma: no cover
|
||||
if isinstance(o, numpy.int64): return int(o)
|
||||
if isinstance(o, numpy.int32): return int(o)
|
||||
@@ -6140,6 +6142,42 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
||||
|
||||
powerupdateform = PowerIntervalUpdateForm(initial=data)
|
||||
|
||||
# feeling lucky / ruptures
|
||||
if request.method == 'POST' and "ruptures" in request.POST:
|
||||
df = pd.DataFrame({
|
||||
'spm':rowdata.df[' Cadence (stokes/min)'],
|
||||
'power':rowdata.df[' Power (watts)'],
|
||||
'v':rowdata.df[' AverageBoatSpeed (m/s)']
|
||||
})
|
||||
algo = rpt.Pelt(model="rbf").fit(df.values)
|
||||
result = algo.predict(pen=10)
|
||||
|
||||
|
||||
df['time'] = rowdata.df['TimeStamp (sec)'].values
|
||||
timeprev = int(df['time'].values[0])
|
||||
timenext = int(df['time'].values[result[0]])
|
||||
s = '{delta}sec'.format(delta=timenext-timeprev)
|
||||
|
||||
|
||||
for i in range(len(result)-1):
|
||||
timeprev = int(df['time'].values[result[i]-1])
|
||||
timenext = int(df['time'].values[result[i+1]-1])
|
||||
interval = '+{delta}sec'.format(delta=timenext-timeprev)
|
||||
s += interval
|
||||
|
||||
try:
|
||||
rowdata.updateinterval_string(s)
|
||||
except:
|
||||
messages.error(request,"Nope, you were not lucky")
|
||||
|
||||
intervalstats = rowdata.allstats()
|
||||
itime, idist, itype = rowdata.intervalstats_values()
|
||||
nrintervals = len(idist)
|
||||
savebutton = 'savestringform'
|
||||
intervalString = s
|
||||
form = SummaryStringForm(initial={'intervalstring':intervalString})
|
||||
|
||||
|
||||
# We have submitted the mini language interpreter
|
||||
if request.method == 'POST' and "intervalstring" in request.POST:
|
||||
form = SummaryStringForm(request.POST)
|
||||
|
||||
Reference in New Issue
Block a user