Mercurial Hosting > traffic-intelligence
comparison scripts/process.py @ 1063:3c37d8d20e97
minor addition to process.py
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 13 Jul 2018 09:59:01 -0400 |
parents | a2e20aba0740 |
children | cbc026dacf0b |
comparison
equal
deleted
inserted
replaced
1062:a2e20aba0740 | 1063:3c37d8d20e97 |
---|---|
21 | 21 |
22 # main function | 22 # main function |
23 parser.add_argument('--delete', dest = 'delete', help = 'data to delete', choices = ['feature', 'object', 'classification', 'interaction']) | 23 parser.add_argument('--delete', dest = 'delete', help = 'data to delete', choices = ['feature', 'object', 'classification', 'interaction']) |
24 parser.add_argument('--process', dest = 'process', help = 'data to process', choices = ['feature', 'object', 'classification', 'prototype', 'interaction']) | 24 parser.add_argument('--process', dest = 'process', help = 'data to process', choices = ['feature', 'object', 'classification', 'prototype', 'interaction']) |
25 parser.add_argument('--display', dest = 'display', help = 'data to display (replay over video)', choices = ['feature', 'object', 'classification', 'interaction']) | 25 parser.add_argument('--display', dest = 'display', help = 'data to display (replay over video)', choices = ['feature', 'object', 'classification', 'interaction']) |
26 parser.add_argument('--progress', dest = 'progress', help = 'information about the progress of processing', action = 'store_true') | |
26 parser.add_argument('--analyze', dest = 'analyze', help = 'data to analyze (results)', choices = ['feature', 'object', 'classification', 'interaction', 'event']) | 27 parser.add_argument('--analyze', dest = 'analyze', help = 'data to analyze (results)', choices = ['feature', 'object', 'classification', 'interaction', 'event']) |
27 | 28 |
28 # common options | 29 # common options |
29 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file') | 30 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file') |
30 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects/interactions to process', type = int) | 31 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects/interactions to process', type = int) |
95 else: | 96 else: |
96 print('No video/site to process') | 97 print('No video/site to process') |
97 | 98 |
98 if args.nProcesses > 1: | 99 if args.nProcesses > 1: |
99 pool = Pool(args.nProcesses) | 100 pool = Pool(args.nProcesses) |
101 | |
102 ################################# | |
103 # Delete | |
104 ################################# | |
105 if args.progress: | |
106 print('Providing information on data progress') | |
107 print('TODO') | |
100 | 108 |
101 ################################# | 109 ################################# |
102 # Delete | 110 # Delete |
103 ################################# | 111 ################################# |
104 if args.delete is not None: | 112 if args.delete is not None: |
241 plt.boxplot([data.loc[data['sites']==siteId, name] for siteId in siteIds], labels = [session.query(Site).get(siteId).name for siteId in siteIds]) | 249 plt.boxplot([data.loc[data['sites']==siteId, name] for siteId in siteIds], labels = [session.query(Site).get(siteId).name for siteId in siteIds]) |
242 plt.ylabel(name+' Speeds (km/h)') | 250 plt.ylabel(name+' Speeds (km/h)') |
243 plt.savefig(name.lower()+'-speeds.png', dpi=dpi) | 251 plt.savefig(name.lower()+'-speeds.png', dpi=dpi) |
244 plt.close() | 252 plt.close() |
245 elif args.output == 'event': | 253 elif args.output == 'event': |
246 data.to_csv('speeds.csv', index = False) | 254 data.to_csv(args.eventFilename, index = False) |
247 | 255 |
248 if args.analyze == 'interaction': # redo as for object, export in dataframe all interaction data | 256 if args.analyze == 'interaction': # redo as for object, export in dataframe all interaction data |
249 indicatorIds = [2,5,7,10] | 257 indicatorIds = [2,5,7,10] |
250 conversionFactors = {2: 1., 5: 30.*3.6, 7:1./30, 10:1./30} | 258 conversionFactors = {2: 1., 5: 30.*3.6, 7:1./30, 10:1./30} |
251 maxIndicatorValue = {2: float('inf'), 5: float('inf'), 7:10., 10:10.} | 259 maxIndicatorValue = {2: float('inf'), 5: float('inf'), 7:10., 10:10.} |
300 if method == 'centile': | 308 if method == 'centile': |
301 row.extend(aggregated) | 309 row.extend(aggregated) |
302 else: | 310 else: |
303 row.append(aggregated) | 311 row.append(aggregated) |
304 outputData.append(row) | 312 outputData.append(row) |
305 pd.DataFrame(outputData, columns = headers).to_csv('aggregated-speeds.csv', index = False) | 313 pd.DataFrame(outputData, columns = headers).to_csv(utils.removeExtension(args.eventFilename)+'-aggregated.csv', index = False) |