Commit c5af5f3a authored by Maxime Rey's avatar Maxime Rey
Browse files

Improvement: option to make PDFs faster with phase diagrams by only plotting the last one.

parent 7c4806a1
......@@ -354,8 +354,12 @@ def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_
PD_all[istep,:,:] = PD
# Compute PDFs
if plot_PDF:
PDF_nHall[istep,:], nHbin_edges = np.histogram(np.log10(nH), bins=bins, range=np.log10(xlims), weights=weight, density=False) # True ??
PDF_Tall[istep,:] , Tbin_edges = np.histogram(np.log10(T) , bins=bins, range=np.log10(ylims), weights=weight, density=False) # True ??
if plot_PDF!='fast':
PDF_nHall[istep,:], nHbin_edges = np.histogram(np.log10(nH), bins=bins, range=np.log10(xlims), weights=weight, density=False)
PDF_Tall[istep,:] , Tbin_edges = np.histogram(np.log10(T) , bins=bins, range=np.log10(ylims), weights=weight, density=False)
elif timestep==timesteps[-1]:
PDF_nH, nHbin_edges = np.histogram(np.log10(nH), bins=bins, range=np.log10(xlims), weights=weight, density=False)
PDF_T , Tbin_edges = np.histogram(np.log10(T) , bins=bins, range=np.log10(ylims), weights=weight, density=False)
# Phase diagram with method 1 or 2.
if method1:
......@@ -368,7 +372,7 @@ def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_
if var_str=='v_rad':
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) # Enlèves le "_r"
im = plt.imshow(phase_diag.T,interpolation='nearest',origin='lower',norm=LogNorm(vmin=vmin,vmax=vmax),cmap='BuPu', extent=extent)
if contour:
if folder==folders[0]:
extent_0 = extent
......@@ -384,18 +388,20 @@ def plot_phase_diag(genpath, folders, timesteps, var_str='H', cgm_gas=False, no_
if plot_PDF:
perc_min, perc_max = 15.9, 84.1
nrm = 2e8 # Handpicked normalisation factor to get a nicer plot. Otherwise density has to be used...
# Adds T PDF on the left of the plot.
PDF_T = np.median(PDF_Tall, axis=0) / nrm
shift_T = -min(PDF_T)+np.log10(xlims[0])
xaxis_T = (Tbin_edges[:-1]+Tbin_edges[1:])*0.5
# Adds T and nH PDFs on the sides of the plot.
if plot_PDF!='fast':
PDF_T = np.median(PDF_Tall, axis=0) / nrm
PDF_nH = np.median(PDF_nHall, axis=0) / nrm
else:
PDF_T /= nrm
PDF_nH /= nrm
shift_T , xaxis_T = -min(PDF_T )+np.log10(xlims[0]), ( Tbin_edges[:-1]+ Tbin_edges[1:])*0.5
shift_nH, xaxis_nH = -min(PDF_nH)+np.log10(ylims[0]), (nHbin_edges[:-1]+nHbin_edges[1:])*0.5
ax.plot(PDF_T+shift_T, xaxis_T, '-k')
ax.fill_betweenx(xaxis_T,np.percentile(PDF_Tall,perc_min, axis=0)/nrm+shift_T, np.percentile(PDF_Tall,perc_max, axis=0)/nrm+shift_T, color='k', alpha=0.25)
# Adds nH PDF on the bottom of the plot.
PDF_nH = np.median(PDF_nHall, axis=0) / nrm
shift_nH = -min(PDF_nH)+np.log10(ylims[0])
xaxis_nH = (nHbin_edges[:-1]+nHbin_edges[1:])*0.5
ax.plot(xaxis_nH, PDF_nH+shift_nH, '-k')
ax.fill_between(xaxis_nH,np.percentile(PDF_nHall,perc_min, axis=0)/nrm+shift_nH, np.percentile(PDF_nHall,perc_max, axis=0)/nrm+shift_nH, color='k', alpha=0.25)
if plot_PDF!='fast':
ax.fill_betweenx(xaxis_T,np.percentile(PDF_Tall,perc_min, axis=0)/nrm+shift_T, np.percentile(PDF_Tall,perc_max, axis=0)/nrm+shift_T, color='k', alpha=0.25)
ax.fill_between(xaxis_nH,np.percentile(PDF_nHall,perc_min, axis=0)/nrm+shift_nH, np.percentile(PDF_nHall,perc_max, axis=0)/nrm+shift_nH, color='k', alpha=0.25)
# if (var_str=='HI') or (var_str=='MgII') or (var_str=='CIV') or (var_str=='OVI'):
# Adds two temperature split chosen for ouflows.
......
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