Mercurial Hosting > traffic-intelligence
diff scripts/process.py @ 1064:cbc026dacf0b
changed interval string representation
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 15 Jul 2018 22:52:26 -0400 |
parents | 3c37d8d20e97 |
children | d4d052a05337 |
line wrap: on
line diff
--- a/scripts/process.py Fri Jul 13 09:59:01 2018 -0400 +++ b/scripts/process.py Sun Jul 15 22:52:26 2018 -0400 @@ -16,7 +16,7 @@ parser = argparse.ArgumentParser(description='This program manages the processing of several files based on a description of the sites and video data in an SQLite database following the metadata module.') # input parser.add_argument('--db', dest = 'metadataFilename', help = 'name of the metadata file', required = True) -parser.add_argument('--videos', dest = 'videoIds', help = 'indices of the video sequences', nargs = '*', type = int) +parser.add_argument('--videos', dest = 'videoIds', help = 'indices of the video sequences', nargs = '*') parser.add_argument('--sites', dest = 'siteIds', help = 'indices of the video sequences', nargs = '*') # main function @@ -84,27 +84,31 @@ videoSequences = [] sites = [] if args.videoIds is not None: - videoSequences = [session.query(VideoSequence).get(videoId) for videoId in args.videoIds] - siteIds = set([vs.cameraView.siteIdx for vs in videoSequences]) + for videoId in args.videoIds: + if '-' in videoId: + videoSequences.extend([session.query(VideoSequence).get(i) for i in moving.TimeInterval.parse(videoId)]) + else: + videoSequences.append(session.query(VideoSequence).get(int(videoId))) + sites = set([vs.cameraView.site for vs in videoSequences]) elif args.siteIds is not None: - siteIds = set(args.siteIds) - for siteId in siteIds: - tmpsites = getSite(session, siteId) - sites.extend(tmpsites) - for site in tmpsites: - videoSequences.extend(getSiteVideoSequences(site)) + for siteId in args.siteIds: + if '-' in siteId: + sites.extend([session.query(Site).get(i) for i in moving.TimeInterval.parse(siteId)]) + else: + sites.append(session.query(Site).get(int(siteId))) + for site in sites: + videoSequences.extend(getSiteVideoSequences(site)) else: print('No video/site to process') - +sys.exit() if args.nProcesses > 1: pool = Pool(args.nProcesses) ################################# -# Delete +# Report progress in the processing ################################# if args.progress: print('Providing information on data progress') - print('TODO') ################################# # Delete @@ -245,8 +249,8 @@ if args.output == 'figure': for name in headers[4:]: plt.ioff() - plt.figure() - plt.boxplot([data.loc[data['sites']==siteId, name] for siteId in siteIds], labels = [session.query(Site).get(siteId).name for siteId in siteIds]) + plt.figure() # siteids does not exist + plt.boxplot([data.loc[data['site']==site.name, name] for site in sites], labels = [site.name for site in sites]) plt.ylabel(name+' Speeds (km/h)') plt.savefig(name.lower()+'-speeds.png', dpi=dpi) plt.close()