Model grid#
A key feature of FASTAR is that models can be continuously evaluated for any age, metallicity and IMF. However, certain applications might require using a constant grid of SSP models (in the same way standard SSP models are distributed). FASTAR can also be used in this way.
[1]:
from matplotlib import pyplot as plt
from fastar import IntegratedSSPSynthesizer
from fastar.imf import kroupa
# Initialize the synthesizer
ssp = IntegratedSSPSynthesizer(imf_function=kroupa)
# Define ages and metallicities
age_arr = [1, 2, 3]
met_arr = [-0.1, 0, 0.1]
wave, spec_grid = ssp.load_precomputed_models(age_range=age_arr, met_range=met_arr)
Calculating SSP predictions
To avoid re-computing the same model grid, once calculated, grids are cached locally at ssp_cache/ but this can be set to any local directory.
Important
To check whether a model grid exists,
FASTARrelies on the expected filename. This filename is generated internally based on the age, metallicity, and IMF ranges, but it can also be defined by the user.
Optimized ages and metallicities#
The differentiable nature of FASTAR can be used to define an optimal age and metallicity sampling, meaning that the relative spectral variation between two consecutive bins remains constant (e.g. finer sampling for young ages and coarser for older populations). These are the default ages and metallicities used to generate model grids.
[2]:
# If load_precomputed_models is called with no age and metallicity arrays, it will use by default the optimal sampling
wave, spec_grid = ssp.load_precomputed_models()
Calculating SSP predictions
Instead the user may want to use the age and metallicity binning of the underlying isochrones. These are readily accessible as well
[3]:
age_basti = ssp.ages / 1000.0 # Myr -> Gyr
met_basti = ssp.mets
wave, spec_grid = ssp.load_precomputed_models(age_range=age_basti, met_range=met_basti)
Loading SSP grid from ssp_cache/sspgrid_age0.02-14.00_met-2.50-0.30_imfkroupa_specNone.hdf5
Errors in integrated SSP models#
Estimating the expected error of SSP models has been a long overdue task. With FASTAR one can take a first step by propagating the uncertainty in the stellar atmospheric parameters.
[4]:
age = 10 # Gyr
met = 0.0 # Solar metallicity
std = ssp.synthesize_nsim(age=10, met=met)
fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(ssp.wave, std, color='xkcd:azure')
ax.set_xlabel('Wavelength [Å]')
ax.set_ylabel(r'SSP 1$\sigma$ uncertainty [erg s$^{-1}$ cm$^{-2}$ $\AA^{-1}$]')
ax.set_title(f'Age: {age} Gyr, [M/H]: {met}')
fig.tight_layout()
plt.show()