ArtificialStellarPopulations / ArtPop

✨ ArtPop – Building artificial galaxies one star at a time.
https://artpop.readthedocs.io/en/latest/
MIT License
61 stars 10 forks source link

Add extinction option round 2 #10

Closed johnnygreco closed 2 years ago

johnnygreco commented 2 years ago

giphy

Overview

I realized today that my previous attempt at this (PR #9) had a bug – if you didn't give extinction for all filters (when using a dict), it would break when calculating the magnitudes for the missing filters, since it always tries to add extinction.

This PR fixes this by creating a dictionary regardless of whether you give a single float or a dict for a subset of the filters.

Example Behavior

For example, if you are using the LSST photometric system:

# input at SSP instantiation -> saved a_lam attribute
a_lam = 5.0 -> a_lam = {'LSST_g': 5.0, 'LSST_r': 5.0, 'LSST_i': 5.0, 'LSST_z': 5.0, 'LSST_y': 5.0}

# input at SSP instantiation -> saved a_lam attribute
a_lam = {'LSST_i': 1.0}-> a_lam = {'LSST_g': 0.0, 'LSST_r': 0.0, 'LSST_i': 1.0, 'LSST_z': 0.0, 'LSST_y': 0.0}

New Warnings

Given the way the code is currently written, the extinction bookkeeping gets messy if you want to add SSPs together to form a composite population object. Sorting that out is beyond the scope of this PR, so for now, a warning is given if the user tries to combine two SSPs with extinction.

Finally, I noticed that we do not support smooth models when combining source objects into composite sources. Again, since this isn't a primary use case, I added a warning if the use tries to combine sources with smooth components.