In [ ]:
import yt
import logging
import numpy as np
import matplotlib
matplotlib.rcParams['font.family'] = 'stixgeneral'
matplotlib.rcParams['figure.dpi'] = 150
import matplotlib.pyplot as plt
from yt_cluster_ratio_fields import *
logging.getLogger('yt').setLevel(logging.ERROR)
from mpl_toolkits.axes_grid1 import AxesGrid
In [ ]:
ds = yt.load('/home/ychen/temp/1212_L45_M10_b1_h0_10Myr/data/MHD_Jet_10Myr_hdf5_plt_cnt_0630')
print(ds)
sl = yt.SlicePlot(ds, 'y', 'entropy_ratio').zoom(4)
sl.set_zlim('entropy_ratio', 0.5, 2)
sl.set_cmap('entropy_ratio', 'seismic')
sl.annotate_timestamp(corner='upper_left', time_format='{time:6.0f} {units}',
time_unit='Myr', text_args={'color': 'k'})
sl.annotate_contour(field='entropy_ratio', ncont=1, clim=(0.8, 0.8),
plot_args={'colors': 'k', 'lw': 1, 'linestyles': ':'})
sl.annotate_contour(field='entropy_ratio', ncont=1, clim=(0.6, 0.6),
plot_args={'colors': 'grey', 'lw': 1, 'linestyles': '--'})
sl._setup_plots()
pl = sl.plots['entropy_ratio']
pl.cb.set_ticks([0.5,1,2])
pl.cb.set_ticklabels([0.5,1,2])
sl.show()
In [ ]:
ds = yt.load('/home/ychen/temp/1212_L45_M10_b1_h0_10Myr/data/MHD_Jet_10Myr_hdf5_plt_cnt_1047')
print(ds)
sl = yt.SlicePlot(ds, 'y', 'entropy_ratio').zoom(4)
sl.set_zlim('entropy_ratio', 0.5, 2)
sl.set_cmap('entropy_ratio', 'seismic')
sl.annotate_timestamp(corner='upper_left', time_format='{time:6.0f} {units}',
time_unit='Myr', text_args={'color': 'k'})
sl.annotate_contour(field='entropy_ratio', ncont=1, clim=(0.8, 0.8),
plot_args={'colors': 'k', 'lw': 1, 'linestyles': ':'})
sl.annotate_contour(field='entropy_ratio', ncont=1, clim=(0.6, 0.6),
plot_args={'colors': 'grey', 'lw': 1, 'linestyles': '--'})
sl._setup_plots()
pl = sl.plots['entropy_ratio']
pl.cb.set_ticks([0.5,1,2])
pl.cb.set_ticklabels([0.5,1,2])
sl.show()
In [ ]:
ds = yt.load('/home/ychen/temp/1212_L45_M10_b1_h0_10Myr/data/MHD_Jet_10Myr_hdf5_plt_cnt_1364')
print(ds)
sl = yt.SlicePlot(ds, 'y', 'entropy_ratio', width=[(300, 'kpc'), (150, 'kpc')])
sl.set_zlim('entropy_ratio', 0.5, 2)
sl.set_cmap('entropy_ratio', 'seismic')
sl.annotate_timestamp(corner='upper_left', time_format='{time:6.0f} {units}',
time_unit='Myr', text_args={'color': 'k'})
sl.annotate_contour(field='entropy_ratio', ncont=1, clim=(0.8, 0.8),
plot_args={'colors': 'k', 'lw': 1, 'linestyles': ':'})
sl.annotate_contour(field='entropy_ratio', ncont=1, clim=(0.6, 0.6),
plot_args={'colors': 'grey', 'lw': 1, 'linestyles': '--'})
sl._setup_plots()
pl = sl.plots['entropy_ratio']
pl.cb.set_ticks([0.5,1,2])
pl.cb.set_ticklabels([0.5,1,2])
sl.show()
In [ ]:
files = ['/d/d12/ychen/2016_production_runs/1212_L45_M10_b1_h0_10Myr/data/MHD_Jet_10Myr_hdf5_plt_cnt_%04i' % ind
for ind in [630, 1047, 1364]]
# for ind in [1364, 1364, 1364]]
files
In [ ]:
center=(0.0,0.0,0.0)
fig = plt.figure()
grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
nrows_ncols = (3, 1),
axes_pad = 0.05,
label_mode = "L",
share_all = True,
cbar_location="right",
cbar_mode="single",
cbar_size="1.5%",
cbar_pad="0%")
cbs = []
for i, f in enumerate(files):
# Load the data and create a single plot
ds = yt.load(f)# load data
print(ds)
sl = yt.SlicePlot(ds, 'y', 'entropy_ratio', width=[(260, 'kpc'), (120, 'kpc')])
sl.set_zlim('entropy_ratio', 0.5, 2)
sl.set_cmap('entropy_ratio', 'seismic')
sl.set_buff_size((800,400))
sl.annotate_timestamp(0.03, 0.85, time_format='{time:6.0f} {units}',
time_unit='Myr', text_args={'color': 'k'})
sl.annotate_contour('jet ', ncont=1, clim=(1E-3, 1E-3),
plot_args={'colors': 'yellow', 'linewidths': 1, 'alpha': 0.8, 'linestyles': '-'})
sl.set_font_size(9)
pl = sl.plots['entropy_ratio']
#sl.annotate_text((0.05, 0.95), labels[i], coord_system='axis', text_args={'color':'k'})
# This forces the ProjectionPlot to redraw itself on the AxesGrid axes.
pl.figure = fig
pl.axes = grid[i].axes
#pl.cax = grid.cbar_axes[i]
cbs.append(pl.cb)
# Finally, this actually redraws the plot.
sl._setup_plots()
for i, ax in enumerate(grid.axes_all):
ax.tick_params(axis='x', color='grey')
ax.tick_params(axis='y', color='grey')
ax.set_ylim(-55, 55)
ax.set_yticks([-50,0,50])
ax.set_yticklabels([-50,0,50])
ax.set_xlim(-130, 130)
ax.set_xticks([-100, -50, 0, 50, 100])
ax.set_xticklabels([-100, -50, 0, 50, 100])
#ax.minorticks_off()
ax.tick_params(axis='x', color='grey')
ax.tick_params(axis='y', color='grey')
ax.grid(ls='--', alpha=0.5)
if i == 2:
ax.set_xlabel('z [kpc]')
ax.set_ylabel('x [kpc]')
else:
ax.set_xlabel('')
ax.set_ylabel('x [kpc]')
cb = plt.colorbar(ax.images[-1], cax=grid.cbar_axes[0], ticks=[0.5,1,2])
cb.ax.set_ylabel('entropy ratio')
cb.set_ticklabels([0.5,1,2])
fig.set_figwidth(4)
fig.set_figheight(7)
fig.savefig('entropy_ratio_slices_poloidal.pdf', bbox_inches='tight')
In [ ]:
center=(0.0,0.0,0.0)
fig = plt.figure()
grid = AxesGrid(fig, (0.075,0.075,0.85,0.85),
nrows_ncols = (3, 1),
axes_pad = 0.05,
label_mode = "L",
share_all = True,
cbar_location="right",
cbar_mode="single",
cbar_size="1.5%",
cbar_pad="0%")
cbs = []
for i, f in enumerate(files):
# Load the data and create a single plot
ds = yt.load(f)# load data
print(ds)
sl = yt.SlicePlot(ds, 'y', 'density', width=[(260, 'kpc'), (120, 'kpc')])
sl.set_zlim('density', 5E-27, 1E-25)
#sl.set_cmap('entropy_ratio', 'seismic')
sl.set_buff_size((800,400))
sl.annotate_timestamp(0.03, 0.85, time_format='{time:6.0f} {units}',
time_unit='Myr', text_args={'color': 'k'})
sl.annotate_contour('jet ', ncont=1, clim=(1E-3, 1E-3),
plot_args={'colors': 'grey', 'linewidths': 1, 'alpha': 0.8, 'linestyles': '-'})
sl.set_font_size(9)
pl = sl.plots['density']
#sl.annotate_text((0.05, 0.95), labels[i], coord_system='axis', text_args={'color':'k'})
# This forces the ProjectionPlot to redraw itself on the AxesGrid axes.
pl.figure = fig
pl.axes = grid[i].axes
#pl.cax = grid.cbar_axes[i]
cbs.append(pl.cb)
# Finally, this actually redraws the plot.
sl._setup_plots()
for i, ax in enumerate(grid.axes_all):
ax.tick_params(axis='x', color='grey')
ax.tick_params(axis='y', color='grey')
ax.set_ylim(-55, 55)
ax.set_yticks([-50,0,50])
ax.set_yticklabels([-50,0,50])
ax.set_xlim(-130, 130)
ax.set_xticks([-100, -50, 0, 50, 100])
ax.set_xticklabels([-100, -50, 0, 50, 100])
#ax.minorticks_off()
ax.tick_params(axis='x', color='grey')
ax.tick_params(axis='y', color='grey')
ax.grid(ls='--', alpha=0.5)
if i == 2:
ax.set_xlabel('z [kpc]')
ax.set_ylabel('x [kpc]')
else:
ax.set_xlabel('')
ax.set_ylabel('x [kpc]')
cb = plt.colorbar(ax.images[-1], cax=grid.cbar_axes[0])
cb.ax.set_ylabel(r'density [g/cm$^3$]')
fig.set_figwidth(4)
fig.set_figheight(7)
fig.savefig('density_slices_poloidal.pdf', bbox_inches='tight')
In [ ]:
center = [0.0,0.0,0.0]
radius = (200, 'kpc')
sp = ds.sphere(center, radius)
low_entropy = sp.cut_region(["obj['entropy_ratio'] < 0.8"])
In [ ]:
sl = yt.SlicePlot(ds, 'y', 'entropy_ratio', data_source=low_entropy).zoom(4)
sl.set_zlim('entropy_ratio', 0.5, 2)
sl.set_cmap('entropy_ratio', 'seismic')
sl.annotate_sphere(center, radius)
sl.show()
In [ ]:
sl = yt.SlicePlot(ds, 'y', 'temperature_ratio', data_source=low_entropy).zoom(4)
sl.set_zlim('temperature_ratio', 0.5, 2)
sl.set_cmap('temperature_ratio', 'seismic')
sl.annotate_sphere(center, radius)
sl.show()
In [ ]:
ls = {9: 'solid', 8: 'dashed', 7: 'dotted', 6: 'dashdot', 5: 'solid', 4: 'dotted', 3: 'dotted'}
colors = {9: '#c7e9b4', 8: '#7fcdbb', 7: '#41b6c4', 6: '#1d91c0', 5: '#225ea8', 4: '#0c2c84'}
plt.figure(figsize=(4.5,2.4))
table = np.genfromtxt('/home/ychen/Mount/gdrive/2016_production_runs/1212_L45_M10_b1_h0_10Myr/gridanalysis_entropy_ratio_mass.txt')
table.shape
tt = table[:,1]
for i in np.arange(table.shape[1]-1, 3, -1):
if max(table[:,i]) > 0:
plt.fill_between(tt, table[:,i], 0, label='x=%.1f' % (i/10),
linestyle=ls[i], lw=1, facecolor=colors[i], edgecolor='grey')
plt.axvspan(0, 10, color='C1', alpha=0.3)
plt.annotate('jet active', xy=(4, 5E9), xytext=(30, 5E9),
arrowprops=dict(arrowstyle="fancy",
fc="0.3", ec="none",))
plt.xlabel('time (Myr)')
plt.ylabel(r'mass of low-entropy gas ( M$_{\odot}$)')
#plt.semilogy()
#plt.ylim(1E7, 1E11)
plt.ylim(0, 3.5E10)
plt.xlim(0, 300)
plt.legend(loc=2)
In [ ]:
ls = {9: 'solid', 8: 'dashed', 7: 'dotted', 6: 'dashdot', 5: 'solid', 4: 'dotted', 3: 'dotted'}
colors = {9: '#c7e9b4', 8: '#7fcdbb', 7: '#41b6c4', 6: '#1d91c0', 5: '#225ea8', 4: '#0c2c84'}
plt.figure(figsize=(4.5,2.4))
E_jet = 1E45*10*yt.units.Myr.in_units('s').v
print(E_jet)
table = np.genfromtxt('/home/ychen/Mount/gdrive/2016_production_runs/1212_L45_M10_b1_h0_10Myr/gridanalysis_entropy_ratio_energy.txt')
tt = table[:,1]
print(table.shape)
for i in np.arange(table.shape[1]-1, 3, -1):
if max(table[:,i]) > 0:
plt.fill_between(tt, table[:,i], 1E-3*E_jet, label='x=%.1f' % (i/10),
linestyle=ls[i], lw=1, facecolor=colors[i], edgecolor='grey')
plt.xlabel('time (Myr)')
plt.ylabel('energy budget of low-entropy gas (erg)')
#plt.semilogy()
plt.ylim(1E-3*E_jet, 0.7E0*E_jet)
plt.legend(loc=2)
#plt.errorbar(5, 2E58, xerr=4.5, capsize=3, elinewidth=5, alpha=0.5, color='C1')
plt.axvspan(0, 10, color='C1', alpha=0.3)
plt.annotate('jet active', xy=(4, 2.5E58), xytext=(30, 2.5E58),
arrowprops=dict(arrowstyle="fancy",
fc="0.3", ec="none",))
#connectionstyle="angle3,angleA=0,angleB=-90"))
plt.twinx()
#plt.semilogy()
plt.ylim(1E-3, 0.7E0)
plt.ylabel(r'(E$_{\mathrm{jet}}$)')
plt.xlim(0,300)
plt.savefig('energy_budget_poloidal.pdf', bbox_inches='tight')
In [ ]:
ls = {9: 'solid', 8: 'dashed', 7: 'dotted', 6: 'dashdot', 5: 'solid', 4: 'dotted', 3: 'dotted'}
colors = {9: '#c7e9b4', 8: '#7fcdbb', 7: '#41b6c4', 6: '#1d91c0', 5: '#225ea8', 4: '#0c2c84'}
fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(4.5, 5), sharex=True, gridspec_kw={'hspace': 0})
table_m = np.genfromtxt('/home/ychen/Mount/gdrive/2016_production_runs/1212_L45_M10_b1_h0_10Myr/gridanalysis_entropy_ratio_mass.txt')
tt = table_m[:,1]
axes[0].grid(ls='--', alpha=0.5)
# Mass
for i in np.arange(table_m.shape[1]-1, 3, -1):
axes[0].fill_between(tt, table_m[:,i]/1E10, 0, label='x=%.1f' % (i/10),
linestyle=ls[i], lw=1, facecolor=colors[i], edgecolor='grey')
axes[0].axvspan(0, 10, color='C1', alpha=0.3)
axes[0].legend(loc=2, bbox_to_anchor=(0.03, 0.99), frameon=False)
axes[0].set_ylabel('mass of the \nlow-entropy gas [10$^{10}$ M$_{\odot}$]')
axes[0].set_ylim(0, 3.5)
# Energy
table_e = np.genfromtxt('/home/ychen/Mount/gdrive/2016_production_runs/1212_L45_M10_b1_h0_10Myr/gridanalysis_entropy_ratio_energy.txt')
tt = table_e[:,1]
E_jet = 1E45*10*yt.units.Myr.in_units('s').v
axes[1].grid(ls='--', alpha=0.5)
for i in np.arange(table_e.shape[1]-1, 3, -1):
axes[1].fill_between(tt, table_e[:,i]/1E59, 0, label='x=%.1f' % (i/10),
linestyle=ls[i], lw=1, facecolor=colors[i], edgecolor='grey')
axes[1].axvspan(0, 10, color='C1', alpha=0.3)
axes[1].annotate('jet active', xy=(4, 1.7), xytext=(30, 1.7),
arrowprops=dict(arrowstyle="fancy",
fc="0.3", ec="none",))
axes[1].set_xlabel('time [Myr]')
axes[1].set_ylabel('energy budget of the \nlow-entropy gas [10$^{59}$ erg]')
#plt.semilogy()
axes[1].set_ylim(0, 2.4)
ax2 = axes[1].twinx()
#plt.semilogy()
ax2.set_ylim(0, 2.5E59/E_jet)
ax2.set_ylabel(r'[E$_{\mathrm{jet}}$]')
ax2.set_xlim(0,300)
plt.savefig('mass_energy_budget_poloidal.pdf', bbox_inches='tight')
In [ ]:
ls = {9: 'solid', 8: 'dashed', 7: 'dotted', 6: 'dashdot', 5: 'solid', 4: 'dotted', 3: 'dotted'}
colors = {9: '#c7e9b4', 8: '#7fcdbb', 7: '#41b6c4', 6: '#1d91c0', 5: '#225ea8', 4: '#0c2c84'}
fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(4.5, 5), sharex=True, gridspec_kw={'hspace': 0})
table_m = np.genfromtxt('/home/ychen/Mount/gdrive/2016_production_runs/1212_L45_M10_b1_h0_10Myr/gridanalysis_entropy_ratio_mass_exclude_jet.txt')
tt = table_m[:,1]
axes[0].grid(ls='--', alpha=0.5)
# Mass
for i in np.arange(table_m.shape[1]-1, 3, -1):
axes[0].fill_between(tt, table_m[:,i]/1E10, 0, label='x=%.1f' % (i/10),
linestyle=ls[i], lw=1, facecolor=colors[i], edgecolor='grey')
axes[0].axvspan(0, 10, color='C1', alpha=0.3)
axes[0].legend(loc=2, bbox_to_anchor=(0.03, 0.99), frameon=False)
axes[0].set_ylabel('mass of the \nlow-entropy gas [10$^{10}$ M$_{\odot}$]')
axes[0].set_ylim(0, 3.5)
# Energy
table_e = np.genfromtxt('/home/ychen/Mount/gdrive/2016_production_runs/1212_L45_M10_b1_h0_10Myr/gridanalysis_entropy_ratio_energy_exclude_jet.txt')
tt = table_e[:,1]
E_jet = 1E45*10*yt.units.Myr.in_units('s').v
axes[1].grid(ls='--', alpha=0.5)
for i in np.arange(table_e.shape[1]-1, 3, -1):
axes[1].fill_between(tt, table_e[:,i]/1E59, 0, label='x=%.1f' % (i/10),
linestyle=ls[i], lw=1, facecolor=colors[i], edgecolor='grey')
axes[1].axvspan(0, 10, color='C1', alpha=0.3)
axes[1].annotate('jet active', xy=(4, 1.7), xytext=(30, 1.7),
arrowprops=dict(arrowstyle="fancy",
fc="0.3", ec="none",))
axes[1].set_xlabel('time [Myr]')
axes[1].set_ylabel('energy budget of the \nlow-entropy gas [10$^{59}$ erg]')
#plt.semilogy()
axes[1].set_ylim(0, 2.4)
ax2 = axes[1].twinx()
#plt.semilogy()
ax2.set_ylim(0, 2.5E59/E_jet)
ax2.set_ylabel(r'[E$_{\mathrm{jet}}$]')
ax2.set_xlim(0,300)
plt.savefig('mass_energy_budget_poloidal_exclude_jet.pdf', bbox_inches='tight')