bd-j / prospector

Python code for Stellar Population Inference from Spectra and SEDs
http://prospect.readthedocs.io
MIT License
157 stars 73 forks source link
fitting stellar-population-properties

Version 2.0! (in progress)

This is a major refactor to allow for multiple datasets (i.e. multiple spectra) with different noise models and instrument parameters to constrain a single galaxy model. Other updates may include cleaner stored outputs, interfaces with additional nested samplers, and improved tretments of smoothing.

Work to do includes:

Migration from < v2.0

For many users the primary difference from v1.X will be that the data to predict and fit a model to is now specified as a list of prospect.observation.Observation() instances, instead of a single 'obs' dictionary. There is a new convenience method to convert from the old 'obs' dictionary format to the new specification. This can be used with existing scripts as follows:

# old build_obs function giving a dictionary
obs_dict = build_obs(**run_params)
# get convenience method
from prospect.observation import from_oldstyle
# make a new list of Observation instances from the dictionary
observations = from_oldstyle(obs_dict)
# verify and prepare for fitting; similar to 'obsutils.fix_obs()'
[obs.rectify() for obs in observations]
print(observations)

It is recommended to do the conversion within the build_obs() method, if possible. This list of observations is then supplied to fit_model. Because noise models are now attached explicitly to each observation, they do not need to be generated separately or supplied to fit_model(), which no longer accepts a noise= argument. For outlier models, the the noise model should be instantiated with names for the outlier model that correspond to fixed or free parameters of the model.

from prospect.fitting import fit_model
output = fit_model(observations, model, sps, **config)

Another change is that spectral response functions (i.e. calibration vectors) are now handled by specialized sub-classes of these Observation classes. See the spectroscopy docs for details.

The interface to write_model has been changed and simplified. See usage for details.

Finally, the output chain or samples is now stored as a structured array, where each row corresponds to a sample, and each column is a parameter (possibly multidimensional). Additional information (such as sample weights, likelihoods, and poster probabilities) are stored as additional datasets in the output. The unstructured_chain dataset of the output contains an old-style simple numpy.ndarray of shape (nsample, ndim)

Purpose

Docs Tests arXiv LICENSE

Conduct principled inference of stellar population properties from photometric and/or spectroscopic data. Prospector allows you to:

Read the documentation and the code paper.

Installation

See installation for requirements and dependencies. The documentation includes a tutorial and demos.

To install to a conda environment with dependencies, see conda_install.sh. To install just Prospector (stable release):

python -m pip install astro-prospector

To install the latest development version:

cd <install_dir>
git clone https://github.com/bd-j/prospector
cd prospector
python -m pip install .

Then, in Python

import prospect

Citation

If you use this code, please reference this paper:

@ARTICLE{2021ApJS..254...22J,
       author = {{Johnson}, Benjamin D. and {Leja}, Joel and {Conroy}, Charlie and {Speagle}, Joshua S.},
        title = "{Stellar Population Inference with Prospector}",
      journal = {\apjs},
     keywords = {Galaxy evolution, Spectral energy distribution, Astronomy data modeling, 594, 2129, 1859, Astrophysics - Astrophysics of Galaxies, Astrophysics - Instrumentation and Methods for Astrophysics},
         year = 2021,
        month = jun,
       volume = {254},
       number = {2},
          eid = {22},
        pages = {22},
          doi = {10.3847/1538-4365/abef67},
archivePrefix = {arXiv},
       eprint = {2012.01426},
 primaryClass = {astro-ph.GA},
       adsurl = {https://ui.adsabs.harvard.edu/abs/2021ApJS..254...22J},
      adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

and make sure to cite the dependencies as listed in installation

Example

Inference with mock broadband data, showing the change in posteriors as the number of photometric bands is increased. Demonstration of posterior inference with increasing number of photometric bands