-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualizer.py
executable file
·172 lines (98 loc) · 4.11 KB
/
visualizer.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import numpy as np
import matplotlib.pyplot as plt
from io import StringIO
def velocitymaps(data, sys):
gas = data[data['PTG'] == 1]
stars = data[data['PTG'] == 2]
plt.figure(figsize = (10,4))
plt.subplot(121)
plt.scatter(gas['X'], gas['Y'], c=gas['V']-sys, cmap = 'bwr')
plt.title('Gas')
plt.colorbar()
plt.subplot(122)
plt.scatter(stars['X'], stars['Y'], c=stars['V']-sys, cmap = 'bwr')
plt.title('Stars')
plt.colorbar()
plt.tight_layout()
plt.show()
def rotationcurve(data, ulim = 300, color = 'b', label = ''):
plt.plot(data['R'], (data['V']-sys)/np.cos(data['PHI']*np.pi/180), color+',')
uniquer = np.unique(data['R'],return_index = True)[1]
uniquei = np.zeros(len(data), dtype = bool)
uniquei[uniquer] = 1
plt.plot(data['R'][uniquei], (data['VMOD'][uniquei]-sys)/np.cos(data['PHI'][uniquei]*np.pi/180),
color+'.', label = label)
plt.ylim(0,ulim)
def readheader(file):
header = open(file).readlines()[11:24]
readrange = (header[0].find('PARAMETER') + 9, header[0].find(' F'))
header = [i[readrange[0]:readrange[1]].split(' ') for i in header]
return np.asarray([[i for i in header[j] if i] for j in range(len(header))][1:], dtype = float)
def visualize(file):
names = ('PTG', 'FIB', 'X', 'Y', 'R', 'PHI', 'V', 'Ve', 'Ve_ADJ', 'VMOD', 'CHI', 'WGT', 'FLG', 'O')
data = np.genfromtxt(file, comments = '#', names = names)
gas = data[data['PTG'] == 1]
stars = data[data['PTG'] == 2]
header = readheader('test.out')
inc = header[0,0]
sys = header[2,0]
velocitymaps(data, sys)
rotationcurve(stars, label = 'Stars')
rotationcurve(gas, color = 'r', label = 'Gas')
plt.legend()
if __name__=='__main__':
visualize('/home/brian/Desktop/Code/AD/test.out')
visualize('/home/brian/Downloads/kbw_release/test_c.out')
visualize('/home/brian/Downloads/kbw_release/testic.out')
'''
# In[28]:
#18: untie systemic velocities, n, 1,2
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[29]:
#6: delete based on error limit, 300
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[30]:
#7: delete based on chisq limit, 1000
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[31]:
#14: tie pointings, 1,2 (why tie back together?)
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[32]:
#8: undelete based on chisq limit, 100 (what does this mean? why?)
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[33]:
#8: undelete based on chisq limit, 100 (why again?)
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[34]:
#8: undelete based on chisq limit, 100 (why?)
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[35]:
#7: delete based on chisq limit, 25 (isn't this just undoing previous steps?)
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[36]:
#26,n,1,2: untie stochastic errors
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[37]:
#10: adjust chisq based off error dist, 1
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[38]:
#10: adjust chisq based off error dist, 1 (why again?)
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[39]:
#8: undelete on chisq, 36
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[40]:
#10: adjust chisq based on error dist, 1
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[41]:
#3: delete points based on gaussian growth curve, 1 (what does this mean? Why does it take so long?)
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[42]:
#3,1 again
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[43]:
#3,1 again
visualize('/home/brian/Downloads/kbw_release/example/test.out')
# In[45]:
visualize('/home/brian/Downloads/kbw_release/example/test.out')
'''