comparison python/utils.py @ 248:571ba5ed22e2

added utils for bus processing
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 18 Jul 2012 02:54:22 -0400
parents ee1caff48b03
children 4aa792cb0fa9
comparison
equal deleted inserted replaced
247:8f0ed138d373 248:571ba5ed22e2
161 161
162 162
163 ######################### 163 #########################
164 # maths section 164 # maths section
165 ######################### 165 #########################
166
167 def framesToTime(nFrames, frameRate, initialTime = (0.,0.,0.)):
168 'returns hour, minutes and seconds'
169 from math import floor
170 seconds = floor(float(nFrames)/float(frameRate))
171 h = floor(seconds/3600.)
172 seconds = seconds - h*3600
173 m = floor(seconds/60)
174 seconds = seconds - m*60
175 return (h+initialTime[0], m+initialTime[1], seconds+initialTime[2])
166 176
167 def sortXY(X,Y): 177 def sortXY(X,Y):
168 'returns the sorted (x, Y(x)) sorted on X' 178 'returns the sorted (x, Y(x)) sorted on X'
169 D = {} 179 D = {}
170 for x, y in zip(X,Y): 180 for x, y in zip(X,Y):