Skip to content
Snippets Groups Projects
Commit cdff542f authored by gjaeger's avatar gjaeger
Browse files

Issue 63, changes to read only one file

parent f5236749
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -7,30 +7,33 @@ import argparse
def getParserArgs():
parser = argparse.ArgumentParser(description='Tranfer the unit from cm to m and add header for .txt file')
parser.add_argument("--filename", help='give the name of the source file')
parser.add_argument("-m", "--metric", action='store', choices=['m','cm'], default='m', help='give the original metric of trajectories (default m)')
parser.add_argument("-f", "--fps", default="16", type=float, help='give the frame rate of data')
parser.add_argument("-p", "--path", default="./", help='give the path of source file')
parser.add_argument("-d", "--description", help='give some description', default='Transfer with JPSreport')
parser.add_argument("-g", "--geometry", help="give the name of the geometry file", default='geometry.xml')
args = parser.parse_args()
return args
if __name__ == '__main__':
args = getParserArgs()
path = args.path
filename = args.filename
isTrajCm = args.metric # 1 means trajectories are in cm. Otherwise they are in m
print(path)
sys.path.append(path)
fps = args.fps
files = glob.glob("%s/*.txt"%(path))
print(files)
for file in files:
description="experiment"
geometry="geometry.xml"
print(os.path.splitext(file)[0])
fname = (os.path.splitext(file)[0])+"_traj.txt"
print(file)
print(fname)
path = args.path
description = args.description
geometry = args.geometry
sys.path.append(path)
header="# description: %s\n# framerate: %d\n# geometry: %s\n# ID: the agent ID\n# FR: the current frame\n# X,Y,Z: the agents coordinates (in metres)\n\n# ID\tFR\tX\tY\tZ"%(description,fps,geometry)
data=loadtxt(file,usecols = (0,1,2,3,4))
data=loadtxt("%s/%s.txt"%(path,filename),usecols = (0,1,2,3,4))
if isTrajCm == "m": # data are in meter
mTocm = 1
......@@ -43,4 +46,4 @@ if __name__ == '__main__':
data[:,3]/=mTocm
data[:,4]/=mTocm
savetxt(fname,data, fmt= "%d\t%d\t%.4f\t%.4f\t%.4f", delimiter ='\t', header=header, comments='', newline='\r\n')
savetxt("%straj_%s.txt"%(path,filename),data, fmt= "%d\t%d\t%.4f\t%.4f\t%.4f", delimiter ='\t', header=header, comments='', newline='\r\n')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment