Make Template + Supernova

Test insertion of SNe in desisim.templates.GALAXY.

For now it will fail because metadata needed by the GALAXY is missing.


In [1]:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

from desisim.templates import BGS

mpl.rc('font', size=14)

Generate BGS Galaxy

Just generate a vanilla galaxy from the BGS templates.


In [2]:
bgs_obj = BGS()
flux, wave, meta, objmeta = bgs_obj.make_templates(nmodel=1, zrange=(0.1,0.1), seed=1)


INFO:io.py:955:read_basis_templates: Reading /Users/sybenzvi/Documents/DESI/spectro/templates/basis_templates/v3.0/bgs_templates_v2.2.fits
/Users/sybenzvi/anaconda/envs/desi/lib/python3.6/site-packages/speclite/filters.py:1466: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  values_no_units = values_no_units[values_slice]

In [3]:
fig, ax = plt.subplots(1,1, figsize=(7,4))
ax.plot(wave, flux[0])
ax.set(xlabel='wavelength [$\AA$]',
       ylabel='flux')
fig.tight_layout();


Insert BGS + SN Ia

Attempt to insert a Type Ia supernova into a BGS spectrum. This will fail for now.


In [5]:
bgs_obj = BGS(add_SNeIa=True)
flux, wave, meta, objmeta, snmeta = bgs_obj.make_templates(nmodel=1, zrange=(0.1,0.1), 
                                                   sne_fluxratiorange=(1,1), sne_filter='decam2014r', seed=1)
plt.plot(wave, flux[0])


INFO:io.py:955:read_basis_templates: Reading /Users/sybenzvi/Documents/DESI/spectro/templates/basis_templates/v3.0/bgs_templates_v2.2.fits
INFO:io.py:955:read_basis_templates: Reading /Users/sybenzvi/Documents/DESI/spectro/templates/basis_templates/v3.0/sne_templates_v1.1.fits
/Users/sybenzvi/anaconda/envs/desi/lib/python3.6/site-packages/speclite/filters.py:1466: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  values_no_units = values_no_units[values_slice]
Out[5]:
[<matplotlib.lines.Line2D at 0x12ab5d358>]

In [ ]: