Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 3194
1
import matplotlib.pyplot as plt
2
from matplotlib.patches import Ellipse
3
import numpy as np
4
5
def draw_sky(galaxies):
6
"""adapted from Vishal Goklani"""
7
size_multiplier = 45
8
fig = plt.figure(figsize=(10,10))
9
ax = fig.add_subplot(111, aspect='equal')
10
n = galaxies.shape[0]
11
for i in range(n):
12
_g = galaxies[i,:]
13
x,y = _g[0], _g[1]
14
d = np.sqrt( _g[2]**2 + _g[3]**2 )
15
a = 1.0/ ( 1 - d )
16
b = 1.0/( 1 + d)
17
theta = np.degrees( np.arctan2( _g[3], _g[2])*0.5 )
18
19
ax.add_patch( Ellipse(xy=(x, y), width=size_multiplier*a, height=size_multiplier*b, angle=theta) )
20
ax.autoscale_view(tight=True)
21
22
return fig
23