-
Notifications
You must be signed in to change notification settings - Fork 0
/
speed_analysis.py
93 lines (70 loc) · 2.56 KB
/
speed_analysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import sys
#sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages')
sys.path.append('/home/floris/src/pymovie2')
from matplotlib import rcParams
fig_width = 3.6 # width in inches
fig_height = 3.6 # height in inches
fig_size = (fig_width, fig_height)
fontsize = 8
params = {'backend': 'Agg',
'ps.usedistiller': 'xpdf',
'ps.fonttype' : 3,
'pdf.fonttype' : 3,
'font.family' : 'sans-serif',
'font.serif' : 'Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman',
'font.sans-serif' : 'Helvetica, Avant Garde, Computer Modern Sans serif',
'font.cursive' : 'Zapf Chancery',
'font.monospace' : 'Courier, Computer Modern Typewriter',
'font.size' : fontsize,
'text.fontsize': fontsize,
'axes.labelsize': fontsize,
'axes.linewidth': 1.0,
'xtick.major.linewidth': 1,
'xtick.minor.linewidth': 1,
#'xtick.major.size': 6,
#'xtick.minor.size' : 3,
'xtick.labelsize': fontsize,
#'ytick.major.size': 6,
#'ytick.minor.size' : 3,
'ytick.labelsize': fontsize,
'figure.figsize': fig_size,
'figure.dpi' : 72,
'figure.facecolor' : 'white',
'figure.edgecolor' : 'white',
'savefig.dpi' : 300,
'savefig.facecolor' : 'white',
'savefig.edgecolor' : 'white',
'figure.subplot.left': 0.2,
'figure.subplot.right': 0.8,
'figure.subplot.bottom': 0.25,
'figure.subplot.top': 0.9,
'figure.subplot.wspace': 0.0,
'figure.subplot.hspace': 0.0,
'lines.linewidth': 1.0,
'text.usetex': True,
}
rcParams.update(params)
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib
import colorline
import flydra_analysis as fa
import sa1_analysis as sa1
import numpy as np
def speed_histogram(dataset, keys=None):
fig = plt.figure()
ax = fig.add_subplot(111)
if keys is None:
classified_keys = fa.get_classified_keys(dataset)
keys = dataset.trajecs.keys()
speeds = []
for key in keys:
trajec = dataset.trajecs[key]
if trajec.behavior == 'flyby':
frames = trajec.frames_of_flyby
else:
frames = trajec.frames
speeds.extend(trajec.speed[frames])
bins = np.linspace(0, 0.6, 50)
ax.hist(speeds, bins=bins)
fig.savefig('speeds.pdf', format='pdf')