Skip to content

Commit

Permalink
update the xrb_layered analysis scripts
Browse files Browse the repository at this point in the history
these are what I am using for the 3D simulation
  • Loading branch information
zingale committed Oct 22, 2024
1 parent 71b5b56 commit 5981aca
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 56 deletions.
73 changes: 24 additions & 49 deletions Exec/science/xrb_layered/analysis/slice_vertical.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

matplotlib.use('agg')

def doit(plotfiles):
def doit(pf, size=(19.2, 10.8)):

plotfile = sys.argv[1]
ds = CastroDataset(plotfile)
ds = CastroDataset(pf)

xmin = ds.domain_left_edge[0]
xmax = ds.domain_right_edge[0]
Expand All @@ -30,34 +29,23 @@ def doit(plotfiles):

zmin = ds.domain_left_edge[2]
zmax = ds.domain_right_edge[2]
zctr = 0.5*(zmin + zmax)


zctr = 0.5*(zmin + zmax)
L_z = zmax - zmin

fig = plt.figure()

grid = ImageGrid(fig, 111, nrows_ncols=(len(plotfiles), 1),
axes_pad=0.25, label_mode="L",
cbar_mode="single", cbar_size="3%")

for i, pf in enumerate(plotfiles):

ds = CastroDataset(pf)
fields = ["magvort", "enuc"]

f = "magvort"

sp = yt.SlicePlot(ds, "y", f, origin="native", center=[xctr, yctr, zctr],
width=[L_z, L_x], fontsize="11")
sp.set_buff_size((4800,4800))
sp.swap_axes()
sp = yt.SlicePlot(ds, "y", fields,
origin="native", center=[xctr, yctr, zctr],
width=[L_z, L_x], fontsize="20")
sp.set_buff_size((4800,4800))
sp.swap_axes()

for f in fields:
if f == "Temp":
sp.set_zlim(f, 5.e5, 5.e8)
sp.set_cmap(f, "magma_r")
elif f == "enuc":
sp.set_zlim(f, 1.e14, 1.e17)
sp.set_zlim(f, 1.e16, 1.e21)
sp.set_log(f, True)
sp.set_cmap(f, "plasma_r")
elif f == "density":
Expand All @@ -73,41 +61,28 @@ def doit(plotfiles):
sp.set_zlim(f, 1.e-5, 1.0)
sp.set_log(f, True)

sp.set_axes_unit("cm")

sp.annotate_text((0.05, 0.05), "{:5.2f} ms".format(1000.0*float(ds.current_time.in_cgs())),
coord_system="figure", text_args={"color": "black", "size": 11})
sp.set_axes_unit("cm")

plot = sp.plots[f]
plot.figure = fig
plot.axes = grid[i].axes
plot.cax = grid.cbar_axes[i]
if i < len(plotfiles)-1:
grid[i].axes.xaxis.offsetText.set_visible(False)
layout = (1, len(fields))

sp._setup_plots()
fig = sp.export_to_mpl_figure((layout[0], layout[1]), axes_pad=(1.0, 0.4),
cbar_location="right", cbar_pad="2%")

fig.set_size_inches(8, 6.5)
fig.subplots_adjust(left=0.05, right=0.95, top=0.95, bottom=0.05)
fig.subplots_adjust(left=0.05, right=0.95, bottom=0.025, top=0.975)
fig.text(0.05, 0.01, f"t = {float(ds.current_time) * 1000:6.2f} ms",
fontsize="20",
transform=fig.transFigure)
fig.set_size_inches(size)
fig.tight_layout()
fig.savefig(f"xrb_{f}.png")

fig.savefig(f"slice_{pf}.png")

if __name__ == "__main__":

p = argparse.ArgumentParser()

p.add_argument("--skip", type=int, default=1,
help="interval between plotfiles")
p.add_argument("plotfiles", type=str, nargs="+",
help="list of plotfiles to plot")
p.add_argument("plotfile", type=str, nargs=1,
help="plotfiles to plot")

args = p.parse_args()

plot_prefix = args.plotfiles[0].split("plt")[0] + "plt"
plot_nums = sorted([p.split("plt")[1] for p in args.plotfiles], key=int)

plotfiles = []
for n in range(0, len(plot_nums), args.skip):
plotfiles.append("{}{}".format(plot_prefix, plot_nums[n]))

doit(plotfiles)
doit(args.plotfile[0])
14 changes: 7 additions & 7 deletions Exec/science/xrb_layered/analysis/vol-zvel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def doit(plotfile):


# transfer function
vals = [-1.e7, -5.e6, -2.5e6, 2.5e6, 5.e6, 1.e7]
vals = [-2.e7, -1.e7, -5.e6, -2.5e6, 2.5e6, 5.e6, 1.e7, 2.e7]
sigma = 5.e5

tf = yt.ColorTransferFunction((min(vals), max(vals)))
Expand All @@ -60,26 +60,26 @@ def doit(plotfile):

center = 0.5*(ds.domain_left_edge + ds.domain_right_edge)

cam.position = [2.5*ds.domain_right_edge[0],
2.5*ds.domain_right_edge[1],
center[2]+0.5*ds.domain_right_edge[2]]
cam.position = [4*ds.domain_right_edge[0],
4*ds.domain_right_edge[1],
center[2]+ds.domain_right_edge[2]]

# look toward the center -- we are dealing with an octant
normal = (center - cam.position)
normal /= np.sqrt(normal.dot(normal))

cam.switch_orientation(normal_vector=normal,
north_vector=[0., 0., 1.])
cam.set_width(ds.domain_width)
cam.zoom(1.3)
cam.set_width(2*ds.domain_width)
#cam.zoom(0.5)

sc.camera = cam

sc.save(f"{plotfile}_zvel.png", sigma_clip=4.0)

sc.annotate_axes(alpha=0.005, thickness=6)
sc.annotate_domain(ds, color=np.array([0.05, 0.05, 0.05, 0.05]))
sc.save(f"{plotfile}_zvel_axes.png", sigma_clip=3.0)
#sc.save(f"{plotfile}_zvel_axes.png", sigma_clip=3.0)

sc.save_annotated(f"{plotfile}_zvel_annotated.png",
sigma_clip=4.0, #label_fmt="%6.2g",
Expand Down

0 comments on commit 5981aca

Please sign in to comment.