Note
Go to the end to download the full example code.
Metallicity shapes panchromatic SED with dust emission¶
Stellar metallicity affects the stellar continuum shape and overall energy balance. Dust emission responds to absorbed stellar photons: metal-poor hot stars emit bluer light with less IR-absorbed energy, while metal-rich cooler stars are less bright in the UV but more absorbed in the optical/NIR. We sweep stellar metallicity on a young star-forming galaxy at z = 0.2 with dust attenuation and thermal emission from warm dust.
Reference: Conroy 2013 (stellar), Silva et al. 1998 (dust emission).

/tengri/src/tengri/forward/sed_model.py:12928: YoungTopMetallicityWarning: met_logzsol reaches Z = 0.0896 (its upper bound, Z = 0.0449, plus 3 x the metallicity-scatter upper bound of 0.1 dex that the scatter kernel spans), above Z = 0.0497, where the metallicity weights start to use the Z = 0.0600 node of this SSP grid (its highest complete node is Z = 0.0400). The Z = 0.0600 node has no stars above ~12 Msun for log10(age/yr) <= 7.15: FSPS ISOCHRONES/PARSEC/isoc_z0.0600.dat: Mini capped at 12.01 Msun for every log age 5.50-7.15 (343 rows at 5.50; isoc_z0.0200.dat reaches 300 Msun); the PARSEC massive-star tracks stop at Z = 0.04 (Chen et al. 2015, MNRAS 452, 1068). The metallicity is therefore held at Z = 0.0400 for log10(age/yr) <= 7.15, and the top node's weight rises linearly with log age to 1 at 7.20; older populations use the top node unchanged. To use a MIST [Z/H] = +0.5 node (FSPS zlegend Z = 0.0449) at young ages instead, load the grid with top_z='mist': tengri.load_ssp(<name>, top_z='mist') or load_ssp_data(<path>, top_z='mist'). That node has MIST isochrones, so between Z = 0.0400 and 0.0449 the young population switches isochrone physics, not only metallicity.
return cls(
/tengri/src/tengri/forward/orchestrator.py:1087: SFHBeforeBigBangWarning: Star formation history forms 43% of its stellar mass before the Big Bang at z=0.20 (cosmic age 11.27 Gyr). That mass is truncated, so the prediction does not reflect the requested SFH: bound the SFH age parameter or the redshift to keep star formation within cosmic time.
state = component.apply(
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" # suppress XLA/PjRt C++ INFO+WARNING logs
import warnings
import jax
import jax.numpy as jnp
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import tengri
from tengri.plot import setup_style
setup_style()
warnings.filterwarnings("ignore", message=".*BakedInBackend.*")
ssp = tengri.load_ssp()
model = tengri.SEDModel.build(
ssp,
sfh={
"type": "dpl",
"all_params": tengri.Fixed(tengri.DEFAULT),
"alpha": 2.0,
"beta": 2.5,
"tau_gyr": 1.0,
"log_total_mass": 10.0,
},
dust_attenuation={
"law": "power_law",
"type": "two_component",
"all_params": tengri.Fixed(tengri.DEFAULT),
"tau_bc": 1.0,
"tau_diff": 0.5,
},
dust_emission={
"type": "modified_blackbody",
"all_params": tengri.Fixed(tengri.DEFAULT),
"T": 30.0,
"beta_ir": 1.8,
},
# ``met_logzsol`` is swept below (#2296: a params-dict key the spec
# declared Fixed is refused), so it must be free; no ``met=`` group was
# declared before, defaulting the whole group to ``Fixed(DEFAULT)``.
# Bounds cover the -1.5..0.5 sweep.
met={"logzsol": tengri.Uniform(-2.0, 0.5)},
redshift=tengri.Fixed(0.2),
)
baseline = dict(model.spec.sample(jax.random.PRNGKey(0)))
met_logzsol_values = np.array([-1.5, -0.7, 0.0, 0.5])
norm = mpl.colors.Normalize(vmin=met_logzsol_values.min(), vmax=met_logzsol_values.max())
cmap = plt.get_cmap("viridis")
fig, ax = plt.subplots(figsize=(6.5, 4.2))
for met_logzsol in met_logzsol_values:
params = {**baseline, "met_logzsol": jnp.float64(met_logzsol)}
out = model.predict(params)
wave = np.asarray(model.wavelengths)
nu = 2.998e18 / wave # Å/s -> Hz
nu_l_nu = nu * np.asarray(out.rest_sed())
ax.loglog(wave, nu_l_nu, color=cmap(norm(met_logzsol)), lw=1.4)
ax.set_xlim(900, 3e5)
ax.set_ylim(1e40, 1e44)
ax.set_xlabel(r"Rest-frame wavelength $\lambda$ [$\mathrm{\AA}$]")
ax.set_ylabel(r"$\nu L_\nu$ [erg s$^{-1}$]")
for wl in [912, 6563, 1e4, 1e5]:
ax.axvline(wl, color="gray", ls=":", lw=0.6, alpha=0.3)
cbar = fig.colorbar(plt.cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax, pad=0.01)
cbar.set_label(r"Stellar metallicity $\log Z_\star/Z_\odot$")
fig.tight_layout()
plt.savefig("plot_logzsol_panchromatic.png", dpi=150, bbox_inches="tight")
Total running time of the script: (0 minutes 3.533 seconds)