-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bonne_Projection.py
39 lines (34 loc) · 1.04 KB
/
Bonne_Projection.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
from __future__ import division, print_function
import numpy as np
import matplotlib.pyplot as plt
import pyfits
from matplotlib import colors
from mpltools import style
style.use('dark_background')
datafile = 'gti_photon_events.fits'
outfile = ''
data = pyfits.open(datafile)[1].data
print(len(data))
pos = []
for event in data:
pos.append([event[3]-180, event[4]])
print("Done loading")
print(len(pos))
def bonne_project(pos, parallel=90, meridian=0):
pos = np.array(pos)
p1 = np.deg2rad(parallel)
mer = np.deg2rad(meridian)
rho = 1.0/np.tan(p1) + p1 - np.deg2rad(pos[1])
E = (np.deg2rad(pos[0])-mer)*np.cos(np.deg2rad(pos[1]))/rho
x = rho*np.sin(E)
y = 1.0/np.tan(p1) - rho*np.cos(E)
return np.array([x,y])
print("Projecting")
img = np.array([bonne_project(x) for x in pos]).T
print("Plotting")
fig = plt.figure(frameon=False)
ax = plt.Axes(fig, [0.,0.,1.,1.])
ax.set_axis_off()
fig.add_axes(ax)
ax.hist2d(img[0], img[1], bins=500, cmap='cubehelix', norm=colors.LogNorm(), normed=True)
plt.savefig(outfile, dpi=750)