Add Milky-Way extinction#
One usually wants to draw targets while including the Milky Way dust extinction effect.
Such effect can be accounted in Target for using the effect= option in from_draw() or using add_effect().
How it works#
skysurvey.Effect enables to change a target and the way we simulate spectra and lightcurves.
quick look at skysurvey.Effect:#
skysurvey.Effect object contains 2 parts:
a
.modelattribute that updates the Target’s model (DAG)a sncosmo effect, with its variable name and the applied frame.
.effect: sncosmo.PropagationEffect.name: str, the effect parameter name(s).frame: str, obs- or rest-frame
And that is all. When used, Effect.model will update the target model, while .effect, .name and .frame will be used to change the template.sncosmo model.
Get the Milky Way extinction Effect#
The Milky way effect has been pre-defined (skysurvey.effect.mw_extinction) and works as follows:
mwebvis derived from the Planck dust map (dustmaps.planck) given the object’s RA, Dec so:
`model = {"mwebv": {"func": skysurvey.effect.milkyway.get_mwebv, "kwargs":{"ra":"@ra", "dec":"@dec"}}}`
The sncosmo effect is
sncosmo.CCM89Dust()applied in the obsframe.
Example#
Draw SNe Ia without dust extinction (default)#
import skysurvey
snia_no_dust = skysurvey.SNeIa.from_draw(1_000)
snia_no_dust.data.head(2)
| z | x1 | c | t0 | ra | dec | magabs | magobs | x0 | template | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.18675 | -2.195 | 0.123220 | 56144.281250 | 190.206924 | 12.827494 | -18.770164 | 21.090797 | 0.000058 | salt2 |
| 1 | 0.16555 | 0.295 | 0.004345 | 56033.667969 | 206.297791 | 65.779793 | -19.359217 | 20.212688 | 0.000130 | salt2 |
The object has no mwebv entry, and it’s template has no effect, so no mwebv in the parameter name
sncosmo_model = snia_no_dust.get_template(as_model=True)
sncosmo_model.effects
[]
snia_no_dust.template_parameters
['z', 't0', 'x0', 'x1', 'c']
Draw SNe Ia accounting for Milky Way dust extinction#
from skysurvey import effects
snia = skysurvey.SNeIa.from_draw(1000, effect=effects.mw_extinction)
snia.data.head(2)
| z | x1 | c | t0 | ra | dec | magabs | mwebv | magobs | x0 | template | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.17305 | 0.175 | 0.438834 | 56049.628906 | 351.960083 | -39.255589 | -17.934202 | 0.026303 | 21.743700 | 0.000032 | salt2 |
| 1 | 0.01625 | -0.735 | 0.045270 | 56095.554688 | 264.659637 | -59.642555 | -18.933451 | 0.143170 | 15.379986 | 0.011185 | salt2 |
The object now has a mwebv entry that is connected to the RA and Dec
snia.model.visualize()
sncosmo_model = snia.get_template(as_model=True)
sncosmo_model.effects
[<sncosmo.models.CCM89Dust at 0x15eb2c880>]
snia.template_parameters
['z', 't0', 'x0', 'x1', 'c', 'mwebv', 'mwr_v']