Generating random SEDs

This examples generate some random SEDs. After initialising the built-in SED model, we use Analyzer to sample some input parameters. The simplex_transform flag ensures that the star formation history parameters are normalised to one.

[1]:
import torch
import matplotlib.pyplot as plt
import starduster

torch.set_num_threads(1)
torch.manual_seed(seed=111);
[2]:
sed_model = starduster.MultiwavelengthSED.from_builtin()
sed_model.configure(
    pn_sfh_disk=starduster.VanillaGrid(simplex_transform=True),
    pn_sfh_bulge=starduster.VanillaGrid(simplex_transform=True),
    flat_input=True
)

params = starduster.sample_effective_region(sed_model, n_samp=3)
with torch.no_grad():
    samples = sed_model(params, return_lum=False)
[3]:
fig, ax = plt.subplots(figsize=(10, 5))

for sed in samples:
    ax.plot(sed_model.lam, sed)

ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel(r'$\lambda \, [\rm \mu m]$')
ax.set_ylabel(r'$f_\nu \, [\rm Jy]$')

pass
../_images/tutorials_sampling_seds_3_0.png