<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Input luminosity function
Step1:  Run the simulation, save the spectra
Step2:  Simulation outputs
Step3:  the table of simulated quasars, including redshift, luminosity, synthetic flux/mags in nine bands, and "observed" photometry with errors included.
also includes details of the model inputs for each quasar
Step4:  the distribution in g-band magnitude
Step5:  color-color diagram from observed magnitudes, including errors
Step6:  the list of emission lines in the model
Step7:  broad CIV equivalent width, displaying the Baldwin Effect
Step8:  Example spectra
for this example the wavelength cutoff is 30 micron, but the model doesn't include warm dust and thus is invalid beyond a few micron.
Step9:  zoom in on the lyman alpha - CIV region
Step10:  IGM absorption model (simqso.hiforest)
an example of the forest transmission spectra at R=30,000 (the native resolution for the monte carlo forest spectra)
<ASSISTANT_TASK:>
Python Code:
M1450 = linspace(-30,-22,20)
zz = arange(0.7,3.5,0.5)
ple = bossqsos.BOSS_DR9_PLE()
lede = bossqsos.BOSS_DR9_LEDE()
for z in zz:
    if z<2.2:
        qlf = ple if z<2.2 else lede
    plot(M1450,qlf(M1450,z),label='z=%.1f'%z)
legend(loc='lower left')
xlim(-21.8,-30.2)
xlabel("$M_{1450}$")
ylabel("log Phi")
Explanation: Input luminosity function
End of explanation
_ = bossqsos.qsoSimulation(bossqsos.simParams,saveSpectra=True)
Explanation: Run the simulation, save the spectra
End of explanation
wave,qsos = load_sim_output('boss_dr9qlf_sim','.')
Explanation: Simulation outputs
End of explanation
qsos[::40]
Explanation: the table of simulated quasars, including redshift, luminosity, synthetic flux/mags in nine bands, and "observed" photometry with errors included.
also includes details of the model inputs for each quasar: slopes is the set of broken power law slopes defining the continuum, emLines is the set of Gaussian parameters for each emission line (wave, EW, sigma) measured in the rest frame.
End of explanation
_ = hist(qsos['obsMag'][:,1],linspace(17,22,20),log=True)
Explanation: the distribution in g-band magnitude:
End of explanation
scatter(qsos['obsMag'][:,0]-qsos['obsMag'][:,1],qsos['obsMag'][:,1]-qsos['obsMag'][:,2],
        c=qsos['z'],cmap=cm.autumn_r,alpha=0.7)
colorbar()
xlabel('u-g')
ylabel('g-r')
xlim(-0.75,3)
ylim(-0.5,1.5)
Explanation: color-color diagram from observed magnitudes, including errors:
End of explanation
qsodatahdr = fits.getheader('boss_dr9qlf_sim.fits',1)
for i,n in enumerate(qsodatahdr['LINENAME'].split(',')):
    print('%d:%s, '% (i,n,),end=" ")
print()
Explanation: the list of emission lines in the model:
End of explanation
scatter(qsos['absMag'],qsos['emLines'][:,13,1],c=qsos['z'],cmap=cm.autumn_r)
colorbar()
xlabel("$M_{1450}$")
ylabel("CIV equivalent width $\AA$")
Explanation: broad CIV equivalent width, displaying the Baldwin Effect:
End of explanation
figure(figsize=(14,4))
plot(wave/1e4,qsos['spec'][0])
yscale('log')
xlabel('wave [micron]')
Explanation: Example spectra
for this example the wavelength cutoff is 30 micron, but the model doesn't include warm dust and thus is invalid beyond a few micron.
End of explanation
figure(figsize=(14,4))
plot(wave,qsos['spec'][20])
xlim(3500,7500)
title('$z=%.3f$'%qsos['z'][20])
Explanation: zoom in on the lyman alpha - CIV region:
End of explanation
# XXX WARNING -- an ugly hack is needed here. Internally, a table of Voigt profiles is generated 
# at startup in order to speed the forest spectra generation. This table is defined in terms of
# the wave dispersion the first time a simulation is run. Here we are changing the wavelength
# model, and thus before executing the next cells you must restart the kernel and execute only
# the first cell.
np.random.seed(12345)
wave = buildWaveGrid(dict(waveRange=(3500,4800),SpecDispersion=30000))
forest = hiforest.IGMTransmissionGrid(wave,WP11_model,1)
T = forest.next_spec(0,2.9)
figure(figsize=(14,4))
plot(wave,T)
figure(figsize=(14,4))
plot(wave,T)
xlim(4300,4800)
Explanation: IGM absorption model (simqso.hiforest)
an example of the forest transmission spectra at R=30,000 (the native resolution for the monte carlo forest spectra):
End of explanation
<END_TASK>