forked from rflrob/YildizLabCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlottingBetter.py
More file actions
executable file
·111 lines (89 loc) · 3.53 KB
/
PlottingBetter.py
File metadata and controls
executable file
·111 lines (89 loc) · 3.53 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from glob import glob
from os import path
from matplotlib.pyplot import figure, subplot, hist, title, show
from numpy import arange, pi
import platform
from functools import reduce
mol_rad = "0.001"
plot_as_polar = True
show_individuals = True
min_sep = 5
max_sep = 35
if 'Win' in platform.system():
basedir = 'F:/Peter/'
elif 'Darwin' in platform.system():
basedir = '/Volumes/NewVolume/Peter'
else:
basedir = ''
dirs = {122: ['2010-09-12'],
124:['2010-09-12'],
125: ['2010-09-13'],
592:['2010-09-27']}
rotations = {122: '-3', 124: '-4', 125: '-7', 592: 'WT'}
plottypes = [592, 125, 122]
#######################################################################
def get_data(data_dirs, types_in_dirs):
adx = []
ady = []
ae = []
aaa = []
for datadir in data_dirs:
for dyntype in types_in_dirs:
for mtfile in glob(path.join(basedir,datadir, 'Dyn%s*-MTs.txt'%dyntype)):
mtfile = mtfile.replace('\\', '/')
matfile = glob(mtfile.split('-MTs')[0]+'*.mat')[0]
matfile = matfile.replace('\\', '/')
if not path.isfile(matfile):
print "*"*70
print "Can't find '", matfile, "' in ", dir
print "*"
continue
_ip.magic("run AlignToAxos -r " + mol_rad+ " " + matfile + " " +
mtfile)
print "run AlignToAxos -r " + mol_rad+ " " + matfile + " " + mtfile
adx.extend(dxs); ady.extend(dys); ae.extend(es); aaa.extend(all_axo_angles)
return adx, ady, ae, aaa
oldsep = path.sep
path.sep = '/'
numrows = 2 + show_individuals
#for enumed, dyntype in enumerate(plottypes):
# adx = []; ady = []; ae = []; aaa = [];
# for datadir in dirs[dyntype]:
# for mtfile in glob(path.join(basedir,datadir, 'Dyn%s*-MTs.txt'%dyntype)):
# mtfile = mtfile.replace('\\', '/')
#
# matfile = glob(mtfile.split('-MTs')[0]+'*.mat')[0]
# matfile = matfile.replace('\\', '/')
#
# if not path.isfile(matfile):
# print "*"*70
# print "Can't find '", matfile, "' in ", dir
# print "*"
# continue
#
# _ip.magic("run AlignToAxos -r " + mol_rad+ " " + matfile + " " +
# mtfile)
# print "run AlignToAxos -r " + mol_rad+ " " + matfile + " " + mtfile
# adx.extend(dxs); ady.extend(dys); ae.extend(es); aaa.extend(all_axo_angles)
rotvals = sorted(set([rotations[type] for type in plottypes]))
for enumed, rot in enumerate(rotvals):
types = [key for key in rotations if rotations[key] == rot and key in
plottypes]
curr_dirs = reduce(append, [dirs[type] for type in dirs if type in types],[])
adx, ady, ae, aaa = get_data(curr_dirs, types)
figure(2)
c,r,t = as_polar_with_errors(adx, ady, ae, aaa, 'g')
s = (min_sep < r) & (r < max_sep)
figure(1)
# Plot the Distance histograms
subplot(numrows,len(rotvals), enumed+1)
title('%s' % rot)
hist(r, arange(0, 45, 2))
# Plot the angle histograms
subplot(numrows,len(rotvals),len(rotvals) + enumed + 1, polar=plot_as_polar)
hist((t + 10*pi)%(2*pi), arange(0,361, 15)*pi/180)
if show_individuals:
subplot(3, len(rotvals), len(rotvals) * 2 + enumed + 1, polar=True)
polar(t[s], r[s], 'x')
path.sep = oldsep
show()