-
Notifications
You must be signed in to change notification settings - Fork 6
/
skymap.py
65 lines (55 loc) · 1.93 KB
/
skymap.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
import matplotlib.pyplot as plt
import numpy as np
import psrcat as pc
#cat = pc.PSRCAT('data/psrcat.db')
#raj, decj = zip(*[x['JCOORD_RAD'] for x in cat.blocks])
def load_psr_pos(db_file):
cat = pc.PSRCAT(db_file)
raj, decj = zip(*[x['JCOORD_RAD'] for x in cat.blocks])
return raj, decj
def get_observation_entry(summary_file):
f = open(summary_file, 'r')
entries = []
info_list = ['date', 'time' ,'RAJ', 'DECJ', 'observer']
for line in f.readlines():
info = {}
line = line.strip()
l = line.split()
num_ele = len(l)
if num_ele < 5:
raise RuntimeError("Observation summary file should have "
"'date', 'time' ,'RAJ', 'DECJ', 'observer' in the column.")
for i in range(4):
info[info_list[i]] = l[i]
observers = ''
for i in range(4, num_ele):
observers += l[i] + ' '
info[info_list[4]] = observers
entries.append(info)
return entries
def map_projection(db_file, obs_entry):
raj, decj = load_psr_pos(db_file)
#source = ColumnDataSource(data=dict(x=raj, y=decj))
obs_RAJs = np.array([float(x['RAJ']) for x in obs_entry]) -180
obs_DECJs = np.array([float(x['DECJ']) for x in obs_entry]) -180
print obs_RAJs
print obs_DECJs
obs_RAJs = np.deg2rad(obs_RAJs)
obs_DECJs = np.deg2rad(obs_DECJs)
print obs_RAJs
print obs_DECJs
fig = plt.figure(figsize=(8, 6))
plt.title('ANTF Catalogue')
#plt.plot(raj, decj, '.')
#plt.subplot(111, projection = "mollweide")
ax = fig.add_subplot(111, projection='mollweide')
ax.plot(obs_RAJs, obs_DECJs, '.')
plt.grid(True)
plt.xlabel('Right Ascension (rad)')
plt.ylabel('Declination (rad)')
plt.show()
#plt.plot(decj)
#plt.show()
if __name__ == '__main__' :
obs_entry = get_observation_entry('p2030.cimalog_20170720_summary.txt')
sp=map_projection('data/psrcat.db', obs_entry)