|
166 | 166 | "sfr = np.diff(mfh) / np.diff(cosmic_time)\n", |
167 | 167 | "t_sfr = (cosmic_time[1:] + cosmic_time[:-1]) / 2\n", |
168 | 168 | "\n", |
| 169 | + "# Estimate the times at which the model formed a given fraction of the present\n", |
| 170 | + "# mass\n", |
| 171 | + "mass_fractions = [0.1, 0.5, 0.9, 0.99]\n", |
| 172 | + "times_frac = model.time_at_stellar_mass_frac(mass_fractions)\n", |
| 173 | + "\n", |
169 | 174 | "fig, axes = plt.subplots(nrows=3, sharex=True)\n", |
170 | 175 | "fig.suptitle(\"Log-normal SFH with a quenching event\")\n", |
171 | 176 | "fig.supxlabel(f\"cosmic time ({cosmic_time.unit})\")\n", |
|
175 | 180 | "ax.set_yscale('log')\n", |
176 | 181 | "ax.plot(cosmic_time, mfh.to_value(u.Msun), '.-')\n", |
177 | 182 | "\n", |
| 183 | + "for t, m in zip(times_frac, mass_fractions):\n", |
| 184 | + " ax.annotate(f\"{m * 100:.1f}%\", xy=(t.value, 1e9), va=\"top\", ha=\"center\",\n", |
| 185 | + " arrowprops=dict(facecolor='black', shrink=0.05))\n", |
| 186 | + " # ax.arrow(t.value, 1e9, dx=0, dy=3e9, width=0.03,\n", |
| 187 | + " # head_width=0.1, head_length=0.1)\n", |
| 188 | + "\n", |
178 | 189 | "ax = axes[1]\n", |
179 | 190 | "ax.set_ylabel(r\"SFR (M$_\\odot$/yr)\")\n", |
180 | 191 | "ax.set_yscale('log')\n", |
|
183 | 194 | "ax = axes[2]\n", |
184 | 195 | "ax.set_ylabel(r\"Z\")\n", |
185 | 196 | "ax.set_yscale('log')\n", |
186 | | - "ax.plot(cosmic_time, model.ism_metallicity(cosmic_time), '.-')\n", |
| 197 | + "ax.plot(cosmic_time, model.ism_metallicity(cosmic_time), '.-') \n", |
187 | 198 | "\n", |
188 | 199 | "for ax in axes:\n", |
189 | 200 | " ax.axvline(quenching_time.to_value(cosmic_time.unit), color='r', label=\"Quenching event\")\n", |
|
243 | 254 | "ax.set_yscale('log')\n", |
244 | 255 | "ax.set_ylim(5e-5, 0.05)\n", |
245 | 256 | "\n", |
246 | | - "mappable = ax.pcolormesh(ssp.ages.to_value(\"Gyr\"), ssp.metallicities, ssp_weights.to_value(u.Msun), norm=LogNorm())\n", |
| 257 | + "mappable = ax.pcolormesh(ssp.ages.to_value(\"Gyr\"), ssp.metallicities.value, ssp_weights.to_value(u.Msun), norm=LogNorm())\n", |
247 | 258 | "\n", |
248 | 259 | "plt.colorbar(mappable, ax=ax, label=r\"SSP mass (M$_\\odot$)\")\n", |
249 | 260 | "\n", |
|
0 commit comments