fastar.IntegratedSSPSynthesizer#

class fastar.IntegratedSSPSynthesizer(model_label=None, imf_function=None)[source]#

Bases: BaseSSPSynthesizer

Class for generating synthetic integrated SSP spectroscopic and photometric predictions with a PCA-based stellar spectral model.

__init__(model_label=None, imf_function=None)#

Methods

__init__([model_label, imf_function])

load_precomputed_models([age_range, ...])

Compute or load a grid of precomputed SSP spectra and save them to disk.

mass_to_light_ratio(age, met[, imf_params, ...])

Compute the mass-to-light ratio of an SSP in a any photometric filter.

predict_spectrum(logg, teff, fmet)

Predict stellar spectra given logg, Teff, and [Fe/H] using the PCA regressor.

stellar_mass(age, met[, imf_params])

Compute the stellar mass still contributing to the flux in the SSP.

synthesize(age, met[, imf_params])

Generate an SSP spectrum for a given age and metallicity.

synthesize_nsim(age, met[, imf_params, ...])

Estimate SSP spectral uncertainties via Monte Carlo perturbation of the stellar parameters.

synthesize_nsim_systematic(age, met[, ...])

Estimate SSP spectral uncertainties via Monte Carlo perturbation of the stellar parameters.

load_precomputed_models(age_range=None, met_range=None, imf_range=None, cache_dir='ssp_cache', user_label=None)[source]#

Compute or load a grid of precomputed SSP spectra and save them to disk.

This function evaluates the SSP model on a grid of age, metallicity, and IMF parameters. If a cached file with matching parameters exists, it loads the data from disk. Otherwise, it computes the SSP grid, saves it to an HDF5 file, and returns the resulting data arrays.

Parameters:
  • age_range (array-like or None, optional) – Array of SSP ages in Gyr. If None, uses the default isochrone age grid.

  • met_range (array-like or None, optional) – Array of SSP metallicities [M/H]. If None, uses the default isochrone metallicity grid.

  • imf_range (list of dicts or None, optional) – List of parameter dictionaries for the IMF function. Each dictionary defines one IMF configuration. If None, defaults to a single empty dictionary (default IMF).

  • cache_dir (str, optional) – Directory where the SSP grids are stored or will be saved. Default is “ssp_cache”.

  • user_label (str, optional) – Optional string output filename for custom identification.

Returns:

  • wave (ndarray) – Wavelength grid of the synthesized SSP spectra.

  • spec_grid (ndarray) – SSP spectra on the specified grid, with shape (n_ages, n_mets, n_imfs, n_wave).

  • age_range (ndarray) – Array of ages used in the grid.

  • met_range (ndarray) – Array of metallicities used in the grid.

  • imf_range (list of dict) – List of IMF parameter dictionaries used in the grid.

mass_to_light_ratio(age, met, imf_params=None, filter_response=None, solar_mag=None)[source]#

Compute the mass-to-light ratio of an SSP in a any photometric filter.

This function synthesizes an SSP spectrum for the given age and met, integrates the total stellar mass from the IMF, and computes the AB magnitude of the integrated spectrum using the specified filter response.

If no solar magnitude is provided (solar_mag=None), the magnitude of the Sun in the same filter is computed from the stored reference solar spectrum. This allows the M/L ratio to be returned in solar units.

Parameters:
  • age (float) – Age of the stellar population in Gyr.

  • met (float) – Metallicity [M/H] of the population.

  • imf_params (dict, optional) – Dictionary of parameters for the initial mass function. Default is empty dict.

  • filter_response (array-like or None, optional) – Response curve sampled over the wavelength grid. If None, the default V-band filter response is used.

  • solar_mag (float or None, optional) – AB magnitude of the Sun in the same filter. If None, computed from solar spectrum.

Returns:

Dictionary containing:
  • ”stars” : float Stellar mass-to-light ratio (M*/L) in solar units.

  • ”total” : float Total mass-to-light ratio (M_total/L), assuming total mass = 1 solar mass.

Return type:

dict

stellar_mass(age, met, imf_params=None)[source]#

Compute the stellar mass still contributing to the flux in the SSP.

Returns:

Total stellar mass (M_sun).

Return type:

float

synthesize(age, met, imf_params=None)[source]#

Generate an SSP spectrum for a given age and metallicity.

Parameters:
  • age (float) – Age of the population (in Gyr).

  • met (float) – Metallicity [M/H].

  • imf_params (dict, optional) – Parameters for the IMF. Default is empty dict.

Returns:

Synthesized spectrum.

Return type:

array

synthesize_nsim(age, met, imf_params=None, dmet=0.1, dteff=0.005, dlogg=0.2, nsim=50, key=Array([0, 0], dtype=uint32))[source]#

Estimate SSP spectral uncertainties via Monte Carlo perturbation of the stellar parameters. Returns (wave, std_spectrum).

synthesize_nsim_systematic(age, met, imf_params=None, dmet=0.1, dteff=0.005, dlogg=0.2, nsim=50, key=Array([0, 0], dtype=uint32))[source]#

Estimate SSP spectral uncertainties via Monte Carlo perturbation of the stellar parameters. In contrast to synthesize_nsim, this systematically shifts parameters of all stars in the SSP by the same amount. Returns std_spectrum.