In [1]:
import os
import numpy as np
import matplotlib.pyplot as plt
In [2]:
from desisim.io import read_basis_templates
from desisim.templates import QSO, SIMQSO
from desisim.bal import BAL
In [3]:
%matplotlib inline
In [4]:
seed = 555
rand = np.random.RandomState(seed)
In [5]:
nplot = 5
In [6]:
balflux, balwave, balmeta = read_basis_templates('BAL')
In [7]:
these = rand.choice(len(balmeta), nplot)
for ii in these:
plt.plot(balwave, balflux[ii, :], label='Index {}'.format(ii))
plt.legend(loc='lower right')
plt.show()
In [8]:
nmodel = 10
zrange = (1.8, 3.0)
In [9]:
qso = QSO()
flux, wave, meta = qso.make_templates(nmodel, seed=seed, zrange=zrange,
lyaforest=False, nocolorcuts=True)
meta
Out[9]:
In [10]:
qso_bal = QSO(balqso=True)
flux_bal, _, meta_bal = qso_bal.make_templates(nmodel, seed=seed, balprob=1, zrange=zrange,
lyaforest=False, nocolorcuts=True)
meta_bal
Out[10]:
In [11]:
for ii in range(nmodel):
plt.plot(wave, flux[ii, :], label='QSO')
plt.plot(wave, flux_bal[ii, :], label='BAL QSO')
plt.xlim(balwave.min()*(1+zrange[0]), balwave.max()*(1+zrange[1]))
plt.legend(loc='upper right')
plt.show()
In [12]:
nsimmodel = 20
simqq = SIMQSO()
simflux, simwave, simmeta = simqq.make_templates(nsimmodel, zrange=(1.8, 3), seed=seed,
nocolorcuts=True, lyaforest=False)
simmeta
Out[12]:
In [13]:
bal = BAL()
simflux_bal, balmeta = bal.insert_bals(simwave, simflux, simmeta['REDSHIFT'], balprob=0.5, seed=seed)
balmeta
Out[13]:
In [14]:
for ii in range(nmodel):
plt.plot(simwave, simflux[ii, :], label='QSO')
plt.plot(simwave, simflux_bal[ii, :], label='BAL QSO (ID={})'.format(balmeta['TEMPLATEID'][ii]))
plt.xlim(3400, 5500)
plt.legend(loc='upper right')
plt.show()