This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
from datetime import time | |
import numpy as np | |
import matplotlib.pyplot as plt | |
tree = ET.parse('Results_in_XML_format.lef') | |
root = tree.getroot() | |
good_events = [] | |
for event in root.iter('EVENT'): | |
for style in event.findall('SWIMSTYLE'): | |
if style.get('relaycount') == "1" and style.get('stroke') != "MEDLEY" and int(style.get('distance')) > 50 and (event.get('round')=='FIN'): | |
good_events.append(event.get('eventid')) | |
#print len(good_events) | |
differences = [[], [], [], [], [], [], [], []] | |
for result in root.iter('RESULT'): | |
if result.get('eventid') in good_events: | |
splits = result.find('SPLITS') | |
if splits is not None: | |
split = splits.findall('SPLIT') | |
t = [] | |
for s in split: | |
tmp = s.get('swimtime').split(':') | |
h = int(tmp[0]) | |
m = int(tmp[1]) | |
s = float(tmp[2]) | |
t.append(h*3600 + m*60 + s) | |
dt = [t[0]] | |
for ii in xrange(len(t)-1): | |
dt.append(t[ii+1]-t[ii]) | |
diff_dg = np.array(dt[::2]) - np.array(dt[1::2]) | |
lane = int(result.get('lane')) | |
for d in diff_dg: | |
differences[lane-1].append(d) | |
print [len(ii) for ii in differences] | |
plt.plot(range(1,9), np.median(differences,1), 'o-') | |
plt.xlabel("Ligne d'eau") | |
plt.ylabel('Difference Aller vs Retour (s)') | |
plt.title('BCN 2013: %d finales individuelles, 1 nage'% len(good_events)) | |
plt.grid() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment