Prospector: Stellar Population Inference

repository·main·Indexed 41 days ago

https://github.com/bd-j/prospector

A framework for principled inference of stellar population properties from photometric and spectroscopic data. It supports high-dimensional property inference using parametric or flexible star formation histories (SFHs) via nested or ensemble Monte Carlo sampling (emcee, dynesty). Version 2.0 introduces a structured array output and a list-based Observation instance format for handling multiple datasets with distinct noise models.

Tokens
23.4K
Snippets
58
Records
112
Agent score
52%

What's inside Prospector

  1. Overview of Prospector

    main

    Prospector is a tool for principled inference of stellar population properties from photometric and/or spectroscopic data. It supports:

    • High-dimensional stellar population property inference using parametric or flexible SFHs via nested or ensemble Monte Carlo sampling.
    • Rigorous combination of multiple photometric, spectroscopic, and line flux datasets (from UV to Far-IR) using flexible spectroscopic calibration models and forward modeling.
  2. What is Prospector?

    main

    Prospector is a Python package designed for principled inference of stellar population properties. It uses flexible models to analyze photometric and/or spectroscopic data.

    Key capabilities include:

    • High-dimensional inference: Infer stellar population properties (including nebular emission) from rest UV through Far-IR data using nested or ensemble MCMC sampling.
    • Data combination: Rigorously combine photometric and spectroscopic data using flexible spectroscopic calibration models and forward modeling.
    • Flexible SFH: Use spectra and/or photometry to constrain highly flexible star formation history (SFH) treatments.
  3. Fit nebular emission lines

    main

    While Prospector/FSPS includes self-consistent nebular emission, it may not be flexible enough for high S/N or high-resolution data where line ratios deviate from Cloudy predictions or gas kinematics differ from stellar kinematics.

    For these cases, you should use Prospector's nebular line amplitude optimization or marginalization capabilities to fit the nebular lines explicitly.

  4. Decide between restframe and observed frame spectra fitting

    main

    The choice of frame depends on your data composition:

    • Spectra only: You can fit in either the restframe or the observed frame. If fitting in the restframe, you must specify the distance explicitly via a lumdist model parameter; otherwise, the model will incorrectly infer distance from the redshift (which is 0 in the restframe).
    • Simultaneous photometry and spectroscopy: You should fit the spectra in the observed frame.
  5. Fit and marginalize over emission line fluxes

    main

    If the FSPS nebular grids are too inflexible to match observed line ratios (e.g., due to AGN or shocks), you can fit for the true emission line fluxes and marginalize over them.

    To enable this, set the model parameter marginalize_elines to True. This introduces explicit parameters to account for line properties:

    • eline_sigma: The emission line widths (defaults to 100 km/s). Can be a scalar (same for all lines) or a vector (separate for each line).
    • eline_delta_zred: The redshift offset from the stellar model (defaults to the systemic redshift). Can be a scalar or a vector.

    This method uses linear least-squares to determine maximum likelihood fluxes and uncertainties, and can incorporate priors based on cloudy-FSPS predictions. Note that this decouples line ratios from the physical model.

  6. Use CSPSpecBasis and FastStepBasis as Sources

    main

    A 'Source' is an object that generates the galaxy spectrum using stellar population synthesis (SPS).

    • CSPSpecBasis: A wrapper for FSPS. Use this for standard parameterized SFHs. It allows access to various spectral and isochrone libraries.
    • FastStepBasis: Use this instead of CSPSpecBasis if you are using piecewise constant or other flexible SFHs.
    from prospect.sources import CSPSpecBasis
    
    sps = CSPSpecBasis(zcontinuous=1)
    # Access libraries via sps.ssp.libraries
  7. Marginalize spectral lines using SpecModel

    main

    To accurately predict nebular line fluxes and handle uncertainty in line amplitudes, use the prospect.models.sedmodel.SpecModel class. This allows you to:

    • Determine maximum-likelihood line amplitudes for each prediction.
    • Compute a likelihood penalty for marginalizing over all possible line amplitudes.
    • Incorporate priors based on the FSPS nebular line model.

    Note: Line velocity offsets and widths are not handled by this marginalization; they must still be explicitly fit or specified as model parameters.

  8. Understand Prospector units and defaults

    main

    Prospector uses the following default units:

    • Flux Density (Spectra and Photometry): maggies (defined as Janskys/3631). It is recommended to supply data in these units.
    • Wavelengths: vacuum Angstroms.
    • Masses: Solar masses of stars formed (the integral of the SFH), which differs from surviving solar masses due to stellar mass loss.
  9. Use Prospector-Beta Priors for galaxy photometry fitting

    main

    Prospector-Beta priors are designed for fitting galaxy photometry when redshift is unknown. They break the age-mass-redshift degeneracy by downweighting physically unlikely solutions (e.g., massive, quiescent galaxies in the very early universe).

    These priors encode empirical constraints on redshifts, masses, and star formation histories. The current implementation is fully dynamic, calculating galaxy number density and differential comoving volume on-the-fly to ensure consistency with the chosen cosmology and to allow for redshift-dependent mass limits.

  10. Understand the structure of a Prospect parameter file

    main

    A Prospect parameter file (e.g., demo_params.py) is a Python script that defines the ingredients for a fit. It typically consists of:

    1. Imports: Necessary modules for modeling and data handling.
    2. Ingredient Building Methods: Functions like build_model, build_obs, build_sps, and build_noise that return the required objects for the fit.
    3. Executable Portion: Code inside an if __name__ == "__main__": block that defines command-line arguments using a parser, creates a configuration dictionary, calls the building methods, executes the fit via prospect.fitting.fit_model, and writes the results to an output file.

    Custom command-line arguments added to the parser are included in the configuration dictionary and can be passed to the building methods to control model types, data loading, or parameter initialization.

  11. Handle spectral resolution and smoothing

    main

    Prospector uses FSPS stellar spectral libraries. The MILES library has a resolution of ~2.5Å FWHM from 3750Å to 7200Å (restframe). Data outside this range or higher resolution data (beyond library resolution) requires smoothing to match the data's resolution (the combination of physical velocity dispersion and instrumental resolution).

    Prospector provides FFT-based smoothing methods assuming a Gaussian Line Spread Function (LSF) in either wavelength or velocity space. You can also apply wavelength-dependent Gaussian dispersion where $\sigma_{\lambda} = f(\lambda)$.

    Smoothing is controlled by the following parameters:

    • sigma_smooth
    • smooth_type
    • fftsmooth

    For undersampled spectra, use the UnderSampledSpectrum class, which integrates the model (already smoothed by velocity dispersion and instrumental resolution) over the provided pixels.

  12. Understand Prospector v2.0 output structure

    main

    The output from fitting (chains or samples) is now stored as a structured array.

    • Each row corresponds to a single sample.
    • Each column corresponds to a parameter (including multidimensional parameters).
    • Additional metadata (such as sample weights, likelihoods, and posterior probabilities) are stored as separate datasets in the output.
    • For backward compatibility, the unstructured_chain dataset contains an old-style numpy.ndarray with shape (nsample, ndim).