# HG changeset patch # User Nicolas Saunier # Date 1316540941 14400 # Node ID 41a5853ec495e69eb818d132b9eeaf362e7528ff # Parent b0719b3ad3db5ab5221317b0724d5e0c3a849dd7 added utility to offset the time intervales of complete trajectory files diff -r b0719b3ad3db -r 41a5853ec495 python/offset-trajectories.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/offset-trajectories.py Tue Sep 20 13:49:01 2011 -0400 @@ -0,0 +1,23 @@ +#! /usr/bin/env python +import sys + +import ubc_utils +import utils + +if len(sys.argv) < 3: + print("Usage: %s filename offsetframes") + sys.exit() + +nFrames = int(sys.argv[2]) + +def modifyLines(objectNum, lines): + result = lines + tmp = lines[0].split(" ") + firstInstant = int(tmp[1])+nFrames + lastInstant = int(tmp[2])+nFrames + tmp[1] = str(firstInstant) + tmp[2] = str(lastInstant) + result[0] = " ".join(tmp) + return result + +ubc_utils.modifyTrajectoryFile(modifyLines, sys.argv[1], sys.argv[1]+".new") diff -r b0719b3ad3db -r 41a5853ec495 python/ubc_utils.py --- a/python/ubc_utils.py Mon Sep 19 16:43:28 2011 -0400 +++ b/python/ubc_utils.py Tue Sep 20 13:49:01 2011 -0400 @@ -80,8 +80,7 @@ print('read {0} objects'.format(objNum)) def modifyTrajectoryFile(modifyLines, filenameIn, filenameOut): - '''Reads filenameIn, replaces the first line with the result of modifyLines and writes the result in filenameOut''' - #sortByNum(objects) + '''Reads filenameIn, replaces the lines with the result of modifyLines and writes the result in filenameOut''' fileIn = utils.openCheck(filenameIn, 'r', True) fileOut = utils.openCheck(filenameOut, "w", True)