Commit 1e63832d authored by Maxime Rey's avatar Maxime Rey
Browse files

Improvement: contour plots for phase diagrams now available.

parent d2c5630c
......@@ -111,7 +111,8 @@ from ratatouille.ks import *
###################################################################################################################################
def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_sat=False, bins=300, xlims=None, ylims=None, vmin=None, vmax=None, factor=1, saveinfile=True, savefig=False):
def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_sat=False, bins=300, contour=False, levels=None, sigma=3, \
xlims=None, ylims=None, vmin=None, vmax=None, factor=1, saveinfile=True, savefig=False):
"""
Plots phase diagram from different output files (for the same timestep) one after another.
......@@ -123,6 +124,7 @@ def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_
plot_phase_diag(genpath, folders, timestep)
"""
from mpl_toolkits.axes_grid1 import make_axes_locatable
from scipy.ndimage import gaussian_filter
from ratatouille import readNsave as ras
from matplotlib.colors import LogNorm
import matplotlib.pyplot as plt
......@@ -141,8 +143,8 @@ def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_
raise ValueError(f"The variable folder ({folders}) should be a list. If you just want one simulation, use a list with a single element.")
g2Msun = 1./1.9891e33
for index, fold in enumerate(folders):
RamsesDir = genpath + fold
for index, folder in enumerate(folders):
RamsesDir = genpath + folder
for timestep in timesteps:
_, cells, cell_pos, _ = ras.extract_cells(RamsesDir,timestep,factor=factor,saveinfile=True)
cell_dx, rho, nH, _, vx, vy, vz, xHII, _, _, _, T, _, _ = cells
......@@ -214,7 +216,16 @@ def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_
im = plt.imshow(phase_diag.T,interpolation='nearest',origin='lower',vmin=vmin,vmax=vmax,cmap='seismic', extent=extent)
else:
im = plt.imshow(phase_diag.T,interpolation='nearest',origin='lower',norm=LogNorm(vmin=vmin,vmax=vmax),cmap='BuPu_r', extent=extent)
if folder==folders[0]:
phase_diag_gauss_0 = gaussian_filter(phase_diag, sigma)
phase_diag_gauss_0 = np.ma.masked_where(phase_diag_gauss_0 <= 0, phase_diag_gauss_0)
plt.contour(phase_diag_gauss_0.T,levels=levels,origin='lower',norm=LogNorm(vmin=vmin,vmax=vmax),colors='b', extent=extent)
else:
plt.contour(phase_diag_gauss_0.T,levels=levels,origin='lower',norm=LogNorm(vmin=vmin,vmax=vmax),colors='b', extent=extent, linestyles='dashed')
phase_diag_gauss = gaussian_filter(phase_diag, sigma)
phase_diag_gauss = np.ma.masked_where(phase_diag_gauss <= 0, phase_diag_gauss)
plt.contour(phase_diag_gauss.T,levels=levels,origin='lower',norm=LogNorm(vmin=vmin,vmax=vmax),colors='k', extent=extent)
if (var_str=='HI') or (var_str=='MgII') or (var_str=='CIV') or (var_str=='OVI'):
# Adds two temperature split chosen for ouflows.
ax.axhline(4.25, color='b', alpha=0.5)
......@@ -242,7 +253,7 @@ def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_
plt.colorbar(im, cax=cax).set_label(label=fr'$M_{{{var_str}}} [M_\odot]$',size=16)
if savefig:
fig.savefig(f'PhaseDiag_{fold[:-1]}_{timestep}.svg',bbox_inches='tight',pad_inches=0)
fig.savefig(f'PhaseDiag_{folder[:-1]}_{timestep}.svg',bbox_inches='tight',pad_inches=0)
def plot_evol_phase_diag(RamsesDir, max_timestep, bins=300, xlims=None, ylims=None, vmin=None, vmax=None, factor=1, savefig=False, saveinfile=True):
......
Supports Markdown
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