comparison scripts/process.py @ 1068:e6b791ad7f85

minor
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 16 Jul 2018 22:53:11 -0400
parents 092bd9c7deaf
children 9ee5c7636640
comparison
equal deleted inserted replaced
1067:092bd9c7deaf 1068:e6b791ad7f85
246 # Analyze 246 # Analyze
247 ################################# 247 #################################
248 if args.analyze == 'object': 248 if args.analyze == 'object':
249 # user speeds, accelerations 249 # user speeds, accelerations
250 # aggregation per site 250 # aggregation per site
251 if args.eventFilename is None:
252 print('Missing output filename (event-filename). Exiting')
253 sys.exit(0)
251 data = [] # list of observation per site-user with time 254 data = [] # list of observation per site-user with time
252 headers = ['site', 'date', 'time', 'user_type'] 255 headers = ['site', 'date', 'time', 'user_type']
253 aggFunctions, tmpheaders = utils.aggregationMethods(args.aggMethods, args.aggCentiles) 256 aggFunctions, tmpheaders = utils.aggregationMethods(args.aggMethods, args.aggCentiles)
254 headers.extend(tmpheaders) 257 headers.extend(tmpheaders)
255 if args.nProcesses == 1: 258 if args.nProcesses == 1:
258 else: 261 else:
259 jobs = [pool.apply_async(processing.extractVideoSequenceSpeeds, args = (str(parentPath/vs.getDatabaseFilename()), vs.cameraView.site.name, args.nObjects, vs.startTime, vs.cameraView.cameraType.frameRate, args.minUserDuration, args.aggMethods, args.aggCentiles)) for vs in videoSequences] 262 jobs = [pool.apply_async(processing.extractVideoSequenceSpeeds, args = (str(parentPath/vs.getDatabaseFilename()), vs.cameraView.site.name, args.nObjects, vs.startTime, vs.cameraView.cameraType.frameRate, args.minUserDuration, args.aggMethods, args.aggCentiles)) for vs in videoSequences]
260 for job in jobs: 263 for job in jobs:
261 data.extend(job.get()) 264 data.extend(job.get())
262 pool.close() 265 pool.close()
263
264 data = pd.DataFrame(data, columns = headers) 266 data = pd.DataFrame(data, columns = headers)
265 if args.output == 'figure': 267 if args.output == 'figure':
266 for name in headers[4:]: 268 for name in headers[4:]:
267 plt.ioff() 269 plt.ioff()
268 plt.figure() # siteids does not exist 270 plt.figure()
269 plt.boxplot([data.loc[data['site']==site.name, name] for site in sites], labels = [site.name for site in sites]) 271 plt.boxplot([data.loc[data['site']==site.name, name] for site in sites], labels = [site.name for site in sites])
270 plt.ylabel(name+' Speeds (km/h)') 272 plt.ylabel(name+' Speeds (km/h)')
271 plt.savefig(name.lower()+'-speeds.png', dpi=dpi) 273 plt.savefig(name.lower()+'-speeds.png', dpi=dpi)
272 plt.close() 274 plt.close()
273 elif args.output == 'event': 275 elif args.output == 'event':