Commit d5f2dbb1 authored by Loic Hausammann's avatar Loic Hausammann

GEAR: update plot script

parent ed6c0ba5
#!/usr/bin/env
from h5py import File
from sys import argv
f = File(argv[-1], "r")
a = 0
# a = f["Cosmology"].attrs["Scale-factor"]
data = f["PartType0/Metals"][:]
print(a, data.min(), data.max())
......@@ -24,9 +24,9 @@ gear = "gear/snapshot_%04i.hdf5" % snap
width = 50 * kpc
do_dmo = False
do_hydro = False
do_stars = False
do_dmo = True
do_hydro = True
do_stars = True
do_feedback = True
do_plot = {
# DMO
......@@ -289,5 +289,6 @@ def doPlot(filename, i, name, center):
center = None
# center = np.array([1724.33547783, 1802.56263082, 1785.09893269])
center = doPlot(gear, 1, "GEAR", center=center)
center = None
doPlot(swift, 0, "SWIFT", center=center)
savePlot()
#!/usr/bin/env python3
import yt
import matplotlib.pyplot as plt
def save1DPlot(profiles):
plt.figure(figsize=(8, 8))
plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=0.5)
markers = ["s", "o"]
for i, p in enumerate(profiles[0]):
z = p.x.in_units("")
m = p["Masses"].in_units("Msun").d
plt.plot(z, m, linestyle="-", marker=markers[i],
markeredgecolor='none', linewidth=1.2, alpha=0.8)
plt.semilogx()
plt.semilogy()
plt.xlabel(r"Metal fraction", fontsize='large')
plt.ylabel("$\mathrm{Mass\ (Msun)}$", fontsize='large')
plt.legend(profiles[1], loc=4, frameon=True, ncol=2, fancybox=True)
leg = plt.gca().get_legend()
ltext = leg.get_texts()
plt.setp(ltext, fontsize='small')
plt.grid(True)
plt.savefig("metals.png", bbox_inches='tight', pad_inches=0.03, dpi=300)
def do1DPlot(f, name, i):
sp = f.sphere(f.center, f.width)
# Because ParticleProfilePlot doesn't exist, I will do the following trick.
p = yt.create_profile(sp, ("PartType0", "Metallicity"),
("PartType0", "Masses"),
weight_field=None, n_bins=50,
accumulation=False)
return p
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment