aggregate_plots.py
Go to the documentation of this file.
00001 
00002 import commands
00003 import os
00004 
00005 
00006 def aggregate_plots(dir, name_list, extension_list):
00007     n = len(name_list)
00008     for i in range(n):
00009     #for nm in name_list:
00010         nm = name_list[i]
00011         ex = extension_list[i]
00012         pngs_list = commands.getoutput('find %s/0* -name "*%s.%s"'%(dir, nm, ex))
00013         pngs_list = pngs_list.splitlines()
00014 
00015         st = '%s/%s'%(dir, nm)
00016         os.system('rm -rf %s'%st) # remove previously existing directory.
00017         os.system('mkdir %s'%st)
00018         for p in pngs_list:
00019             sp = p.split('/')
00020             fname = str.join('_',sp[1:])
00021             print 'saving ', fname
00022             os.system('cp %s %s'%(p, st+'/'+fname))
00023 
00024 
00025 if __name__ == '__main__':
00026     import optparse
00027     p = optparse.OptionParser()
00028 
00029     p.add_option('-d', '--dir', action='store', default='',
00030                  type='string', dest='dir', help='directory with logged data')
00031     p.add_option('-a', '--agg', action='store_true', dest='agg',
00032                  help='aggregate plots from different trials into one folder for comparison')
00033 
00034     opt, args = p.parse_args()
00035 
00036     if opt.dir == '':
00037         raise RuntimeError('Need a directory to work with (-d or --dir)')
00038 
00039     if opt.agg:
00040         name_list = ['mechanism_trajectories_handhook']
00041         extension_list = ['pkl']
00042 #        name_list = ['trajectory_check', 'force_components',
00043 #                     'mechanism_trajectories_handhook', 'poses_dict']
00044 #        extension_list = ['png', 'png', 'pkl', 'pkl']
00045         aggregate_plots(opt.dir, name_list, extension_list)
00046 
00047 


2010_biorob_everyday_mechanics
Author(s): Advait Jain, Hai Nguyen, Charles C. Kemp (Healthcare Robotics Lab, Georgia Tech)
autogenerated on Wed Nov 27 2013 11:58:43