diff 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
line wrap: on
line diff
--- a/python/utils.py	Wed Jul 18 02:54:02 2012 -0400
+++ b/python/utils.py	Wed Jul 18 02:54:22 2012 -0400
@@ -164,6 +164,16 @@
 # maths section
 #########################
 
+def framesToTime(nFrames, frameRate, initialTime = (0.,0.,0.)):
+    'returns hour, minutes and seconds'
+    from math import floor
+    seconds = floor(float(nFrames)/float(frameRate))
+    h = floor(seconds/3600.)
+    seconds = seconds - h*3600
+    m = floor(seconds/60)
+    seconds = seconds - m*60
+    return (h+initialTime[0], m+initialTime[1], seconds+initialTime[2])
+
 def sortXY(X,Y):
     'returns the sorted (x, Y(x)) sorted on X'
     D = {}