From 402cf97d40dbe4a399ee49105b5fc2501afb4815 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Sun, 20 Oct 2024 08:49:40 -0700 Subject: [PATCH 1/2] update the massive star plotting scripts these reflect what was used in the paper --- .../analysis/massive_star_multi.py | 32 ++++++++++++------- .../analysis/massive_star_sequence.py | 17 +++++----- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Exec/science/massive_star/analysis/massive_star_multi.py b/Exec/science/massive_star/analysis/massive_star_multi.py index 4722093e33..0bf35f1684 100755 --- a/Exec/science/massive_star/analysis/massive_star_multi.py +++ b/Exec/science/massive_star/analysis/massive_star_multi.py @@ -13,7 +13,8 @@ matplotlib.use('agg') - +ANNOTATE_O16 = False +ANNOTATE_NSE = True def make_plot(plotfile, prefix="plot", width_frac=0.1, @@ -25,8 +26,8 @@ def make_plot(plotfile, prefix="plot", width_frac=0.1, t_drive = 0.0 if "[*] castro.drive_initial_convection_tmax" in ds.parameters: t_drive = ds.parameters["[*] castro.drive_initial_convection_tmax"] - elif "castro.drive_initial_convection_tmax" in ds.parameters: - t_drive = ds.parameters["castro.drive_initial_convection_tmax"] + elif "[*] castro.drive_initial_convection_tmax" in ds.parameters: + t_drive = ds.parameters["[*] castro.drive_initial_convection_tmax"] print(t_drive) xmin = ds.domain_left_edge[0] @@ -75,19 +76,26 @@ def make_plot(plotfile, prefix="plot", width_frac=0.1, sp.set_cmap(f, "magma") sp.set_zlim(f, 1.e-2, 5) - if f == "enuc": - # now do a contour of NSE - if ("boxlib", "in_nse") in ds.derived_field_list: - sp.annotate_contour("in_nse", ncont=1, clim=(0.5, 0.5), take_log=False, - plot_args={"colors": "k", "linewidths": 2}) + + # now do a contour of O + if ANNOTATE_O16: + sp.annotate_contour(("boxlib", "X(O16)"), ncont=1, clim=(0.5, 0.5), factor=32, take_log=False, + plot_args={"colors": "0.5", "linewidths": 2}) + + # now do a contour of NSE + if ANNOTATE_NSE: + if ("boxlib", "in_nse") in ds.derived_field_list: + sp.annotate_contour("in_nse", levels=1, clim=(0.5, 0.5), take_log=False, + plot_args={"colors": "k", "linewidths": 2}) + sp.set_axes_unit("cm") fig = sp.export_to_mpl_figure((layout[0], layout[1]), axes_pad=(1.0, 0.4), cbar_location=cbar_location, cbar_pad="2%") - fig.subplots_adjust(left=0.05, right=0.95, bottom=0.025, top=0.975) - fig.text(0.02, 0.02, f"$t - \\tau_\\mathrm{{drive}}$ = {float(ds.current_time) - t_drive:6.1f} s", + fig.subplots_adjust(left=0.05, right=0.95, bottom=0.035, top=0.975) + fig.text(0.02, 0.01, f"$t - \\tau_\\mathrm{{drive}}$ = {float(ds.current_time) - t_drive:6.1f} s", transform=fig.transFigure) fig.set_size_inches(size) fig.tight_layout() @@ -95,7 +103,7 @@ def make_plot(plotfile, prefix="plot", width_frac=0.1, if layout[0] >= layout[1]: extra = "_vertical" - fig.savefig(f"{prefix}_{os.path.basename(plotfile)}_w{width_frac:04.2f}{extra}.pdf", pad_inches=0.1, bbox_inches="tight") + fig.savefig(f"{prefix}_{os.path.basename(plotfile)}_w{width_frac:04.2f}{extra}.pdf", pad_inches=0.1) #, bbox_inches="tight") if __name__ == "__main__": @@ -112,7 +120,7 @@ def make_plot(plotfile, prefix="plot", width_frac=0.1, plotfile = args.plotfile[0] if args.vertical: - size = (7.5, 11.0) + size = (7.0, 10.0) layout = (2, 2) else: size = (19.2, 8.5) diff --git a/Exec/science/massive_star/analysis/massive_star_sequence.py b/Exec/science/massive_star/analysis/massive_star_sequence.py index 96b4218085..3d708158ec 100755 --- a/Exec/science/massive_star/analysis/massive_star_sequence.py +++ b/Exec/science/massive_star/analysis/massive_star_sequence.py @@ -15,7 +15,7 @@ matplotlib.use('agg') -times = [50, 100, 150, 200, 250] +times = [50, 100, 150, 200, 250, 300] def find_files(plist): @@ -60,8 +60,8 @@ def make_plot(field, pfiles, *, t_drive = 0.0 if "[*] castro.drive_initial_convection_tmax" in ds.parameters: t_drive = ds.parameters["[*] castro.drive_initial_convection_tmax"] - elif "castro.drive_initial_convection_tmax" in ds.parameters: - t_drive = ds.parameters["castro.drive_initial_convection_tmax"] + elif "[*] castro.drive_initial_convection_tmax" in ds.parameters: + t_drive = ds.parameters["[*] castro.drive_initial_convection_tmax"] print(t_drive) xmin = ds.domain_left_edge[0] @@ -127,11 +127,10 @@ def make_plot(field, pfiles, *, sp.set_cmap(f, "magma") sp.set_zlim(f, 1.e-2, 5) - if f == "enuc": - # now do a contour of NSE - if ("boxlib", "in_nse") in ds.derived_field_list: - sp.annotate_contour("in_nse", levels=1, clim=(0.5, 0.5), take_log=False, - plot_args={"colors": "k", "linewidths": 2}) + # now do a contour of NSE + if ("boxlib", "in_nse") in ds.derived_field_list: + sp.annotate_contour("in_nse", levels=1, clim=(0.5, 0.5), take_log=False, + plot_args={"colors": "k", "linewidths": 2}) sp.set_axes_unit("cm") @@ -168,7 +167,7 @@ def make_plot(field, pfiles, *, args = p.parse_args() if args.vertical: - size = (7.5, 8.5) + size = (7.0, 8.0) else: size = (19.2, 8.5) From dcd22de70a69fb14b72469f911e11061220b16c7 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Sun, 20 Oct 2024 08:50:32 -0700 Subject: [PATCH 2/2] remove unused script --- .../analysis/massive_star_slice.py | 105 ------------------ 1 file changed, 105 deletions(-) delete mode 100755 Exec/science/massive_star/analysis/massive_star_slice.py diff --git a/Exec/science/massive_star/analysis/massive_star_slice.py b/Exec/science/massive_star/analysis/massive_star_slice.py deleted file mode 100755 index 5980d8d04a..0000000000 --- a/Exec/science/massive_star/analysis/massive_star_slice.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env python3 - -import matplotlib -matplotlib.use('agg') - -import os -import sys -import yt -import matplotlib.pyplot as plt -import numpy as np -from functools import reduce - -from mpl_toolkits.axes_grid1 import ImageGrid - -# assume that our data is in CGS -from yt.units import cm, amu -from yt.frontends.boxlib.api import CastroDataset - -def make_plot(plotfile, fields, prefix="plot"): - - ds = CastroDataset(plotfile) - - xmin = ds.domain_left_edge[0] - xmax = ds.domain_right_edge[0] - - ymin = ds.domain_left_edge[1] - ymax = ds.domain_right_edge[1] - - xctr = 0.0 * xmin - L_x = xmax - xmin - - yctr = 0.5 * (ymin + ymax) - L_y = ymax - ymin - - - fig = plt.figure() - fig.set_size_inches(12.0, 9.0) - - width_frac = 0.1 - - grid = ImageGrid(fig, 111, nrows_ncols=(1, len(fields)), - axes_pad=1.0, label_mode="L", cbar_mode="each", cbar_pad=0) - - - for i, f in enumerate(fields): - - sp = yt.SlicePlot(ds, "theta", f, - center=[xmin + 0.5*width_frac*L_x, yctr, 0.0*cm], - width=[width_frac*L_x, width_frac*L_y, 0.0*cm], fontsize="12") - sp.set_buff_size((2400,2400)) - - if f == "Ye": - sp.set_zlim(f, 0.46, 0.5) - sp.set_log(f, False) - sp.set_cmap(f, "magma_r") - elif f == "abar": - sp.set_log(f, False) - sp.set_cmap(f, "viridis") - elif f == "enuc": - sp.set_log(f, True, linthresh=1.e12) - sp.set_zlim(f, -1.e20, 1.e20) - sp.set_cmap(f, "bwr") - elif f == "MachNumber": - sp.set_zlim(f, 1.e-4, 0.3) - sp.set_cmap(f, "plasma") - elif f == "magvel": - sp.set_zlim(f, 100.0, 2.e7) - sp.set_cmap(f, "viridis") - elif f == "magvort": - sp.set_cmap(f, "magma") - sp.set_zlim(f, 1.e-2, 5) - - if f == "enuc": - # now do a contour of density - sp.annotate_contour("in_nse", ncont=1, clim=(0.5, 0.5), take_log=False, - plot_args={"colors": "k", "linewidths": 2}) - - sp.set_axes_unit("cm") - - plot = sp.plots[f] - plot.figure = fig - plot.axes = grid[i].axes - plot.cax = grid.cbar_axes[i] - - sp._setup_plots() - - sp.plots[f].axes.xaxis.set_major_locator(plt.MaxNLocator(4)) - sp.plots[f].axes.ticklabel_format(axis="both", style="scientific", scilimits=(0,0)) - - fig.text(0.02, 0.02, "time = {:8.5f} s".format(float(ds.current_time)), transform=fig.transFigure) - - fig.set_size_inches(19.2, 10.8) - fig.tight_layout() - fig.savefig(f"{prefix}_{os.path.basename(plotfile)}_slice.png") - - -if __name__ == "__main__": - - plotfile = sys.argv[1] - - fields = ["Ye", "abar", "enuc"] - make_plot(plotfile, fields, prefix="comp") - - fields = ["MachNumber", "magvel", "magvort"] - make_plot(plotfile, fields, prefix="vel")