Skip to content

Instantly share code, notes, and snippets.

Created August 4, 2013 21:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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'):
#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):
diff_dg = np.array(dt[::2]) - np.array(dt[1::2])
lane = int(result.get('lane'))
for d in diff_dg:
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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment