Commit 5030369d authored by Maxime Rey's avatar Maxime Rey
Browse files

Improvement: 'stars_density' now only has median or average, not both...

parent db0cb20a
......@@ -1679,8 +1679,7 @@ def plot_sfr(genpath, folders, timestep, labels, rmsat=True, hist_lims=None, bin
cu2cm = info['unit_l'] * info['boxlen']
center_cm, r200_cm = [cen*cu2cm for cen in center], r200*cu2cm
_,star_x,star_y,star_z,_,star_age,_,_,_,_,star_minit \
= ras.extract_stars(RamsesDir,timestep, factor=1, rmsat=rmsat, saveinfile=saveinfile)
_,star_x,star_y,star_z,_,star_age,_,_,_,_,star_minit = ras.extract_stars(RamsesDir,timestep, factor=1, rmsat=rmsat, saveinfile=saveinfile)
rad_stars = np.sqrt((star_x-center_cm[0])**2+(star_y-center_cm[1])**2+(star_z-center_cm[2])**2)
sel = tuple([rad_stars<0.1*r200_cm])
times, sfr = compute_sfr(star_age[sel], star_minit[sel], info, hist_lims=hist_lims, bins=bins)
......@@ -1899,10 +1898,11 @@ def stars_density(genpath, folders, labels, timesteps, nbins=50, factor=1, shade
PDF, bin_edges = np.histogram(age_stars,bins=thebins,density=False,weights=nh_stars)
nb, _ = np.histogram(age_stars,bins=thebins,density=False)
x_axis, avg = (bin_edges[:-1]+bin_edges[1:])*0.5, PDF/nb
ax.plot(x_axis,avg, label=labels[index], c=colors[index])
# Compute errors.
x_axis = (bin_edges[:-1]+bin_edges[1:])*0.5
# Compute errors adn plot.
if shade=='std':
avg = PDF/nb
ax.plot(x_axis,avg, label=labels[index], c=colors[index])
nH2 = np.concatenate([nh_stars\
[(bin_edges[:-1][bini] < age_stars) & (age_stars <= bin_edges[1:][bini])] \
- PDF[bini]/nb[bini] for bini in range(nbins-1)]) # liste des xi - <x>
......@@ -1919,11 +1919,9 @@ def stars_density(genpath, folders, labels, timesteps, nbins=50, factor=1, shade
err_top.append(np.percentile(nH2,75))
median.append(np.percentile(nH2,50))
ax.fill_between(x_axis,err_bot, err_top, alpha=0.25, color=colors[index])
ax.plot(x_axis,median, ls='--', c=colors[index])
ax.plot(x_axis,median, label=labels[index], c=colors[index])
err_lab = '25-75 percentiles.'
if shade=='perc':
ax.plot([],[], label='median', color='k', ls='--')
ax.fill_between([],[], [], alpha=0.25, label=err_lab, color='k')
plt.legend()
ax.set_yscale('log')
......
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