-
Notifications
You must be signed in to change notification settings - Fork 2
/
positions.py
40 lines (31 loc) · 1.17 KB
/
positions.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
import numpy as np
import matplotlib.pyplot as plt
import symlib
""" positions.py plots a host halo and its subhalos as circles.
"""
# Import a library that makes plots prettier, if it's downloaded.
try:
import palette
palette.configure(True)
except:
pass
def main():
# Read in simulation data.
sim_dir = "/oak/stanford/orgs/kipac/users/phil1/simulations/ZoomIns/SymphonyMilkyWay/Halo023"
h, hist = symlib.read_subhalos(sim_dir)
fig, ax = plt.subplots()
host = h[0,-1] # First halo, last snapshot.
symlib.plot_circle(ax, host["x"][0], host["x"][1],
host["rvir"], c="tab:red")
for i in range(1, len(h)):
sub = h[i,-1] # i-th halo, last snapshot.
if sub["ok"]:
symlib.plot_circle(ax, sub["x"][0], sub["x"][1],
sub["rvir"], c="tab:blue", lw=1.5)
# Some plotting code to make things look nice.
ax.set_xlim(-1.75*host["rvir"], 1.75*host["rvir"])
ax.set_ylim(-1.75*host["rvir"], 1.75*host["rvir"])
ax.set_xlabel(r"$X\ ({\rm kpc})$")
ax.set_ylabel(r"$Y\ ({\rm kpc})$")
fig.savefig("plots/positions.png")
if __name__ == "__main__": main()