In [1]:
%pylab inline
from astropy.io import fits
from astropy.table import Table
from simqso.sqrun import buildWaveGrid,load_sim_output
from simqso import hiforest
from simqso.sqmodels import WP11_model
import bossqsos


Populating the interactive namespace from numpy and matplotlib

Input luminosity function


In [2]:
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")


Out[2]:
Text(0,0.5,'log Phi')

Run the simulation, save the spectra


In [3]:
_ = bossqsos.qsoSimulation(bossqsos.simParams,saveSpectra=True)


boss_dr9qlf_sim output not found
generating QSO grid
integration returned  390  objects
... building continuum grid
WARNING: GaussianPLawDistribution continuum is deprecated
simulating  390  quasar spectra
units are  flux
max number iterations:  5
mapping photometry
               stage     time  elapsed     frac
     Initialize Grid    2.744    2.744    0.032
   Generate Features    0.728    3.472    0.009
Build Quasar Spectra   82.069   85.541    0.959
            PhotoMap    0.016   85.557    0.000
              Finish    0.000   85.557    0.000

Simulation outputs


In [4]:
wave,qsos = load_sim_output('boss_dr9qlf_sim','.')


WARNING: failed to restore BrokenPowerLawContinuumVar
WARNING: failed to restore BossDr9EmissionLineTemplateVar
WARNING: failed to restore HIAbsorptionVar

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.


In [5]:
qsos[::40]


Out[5]:
<Table length=10>
absMagappMagzslopes [5]emLines [62,3]igmlossynMag [9]synFlux [9]obsFlux [9]obsFluxErr [9]obsMag [9]obsMagErr [9]spec [2304]
float32float32float32float32float32int32float32float32float32float32float32float32float32
-24.685620.8463.38965-1.79535 .. -1.139961033.72 .. 257.28517424.3515 .. 20.66710.181726 .. 5.40965-0.177366 .. 6.428410.268415 .. 2.008725.2823 .. 20.47970.879222 .. 0.3392510.0 .. 0.0112628
-24.50520.59762.9546-1.19237 .. -1.150791033.99 .. 290.43410022.2512 .. 19.99461.25757 .. 10.04961.26722 .. 10.5810.261168 .. 1.8591422.2291 .. 19.93870.218488 .. 0.1907647.91128e-06 .. 0.0263321
-24.633820.94843.48486-1.53193 .. -1.101541034.37 .. 339.70412024.9756 .. 20.18220.102274 .. 8.454760.080238 .. 9.612930.192477 .. 1.6956624.3268 .. 20.04290.717452 .. 0.191511.2102e-09 .. 0.0153086
-24.3421.16273.37231-1.62156 .. -1.132461033.33 .. 328.8087523.2182 .. 20.87990.516105 .. 4.446660.542061 .. 4.162020.174958 .. 1.443623.098 .. 20.95170.311342 .. 0.3765760.0 .. 0.00729482
-23.618421.16312.37851-1.20363 .. -0.7035641034.41 .. 316.13415621.6813 .. 20.52452.12552 .. 6.168882.09932 .. 9.948880.201327 .. 1.9942621.6893 .. 20.00560.103206 .. 0.2176291.50076 .. 0.00636894
-24.362320.90773.04106-2.03431 .. -0.8879331033.79 .. 226.29418022.7992 .. 21.12830.759106 .. 3.537520.414685 .. 3.224330.224871 .. 1.3402423.3482 .. 21.22890.487931 .. 0.4512871.56249e-20 .. 0.00911326
-25.060919.98812.85412-1.6036 .. -0.9152331033.64 .. 300.5171221.8547 .. 19.54811.81183 .. 15.16232.08349 .. 14.18570.260983 .. 1.7552921.6974 .. 19.62040.134786 .. 0.1343410.0 .. 0.0197842
-24.35820.75622.89916-1.56836 .. -0.9877231033.43 .. 260.45713122.0414 .. 21.03691.52555 .. 3.848131.5072 .. 6.415710.296009 .. 1.6787322.0446 .. 20.48190.209642 .. 0.2840841.25003 .. 0.00670096
-22.824121.7212.05311-1.53718 .. -0.7852951034.31 .. 287.76518721.3757 .. 21.46442.81654 .. 2.595513.11615 .. 3.196970.247343 .. 1.3811221.2631 .. 21.23820.0858312 .. 0.4690311.46555 .. 0.00445822
-23.532621.38292.57529-1.26999 .. -0.8430571033.74 .. 326.03411322.0617 .. 21.07161.49737 .. 3.727031.92474 .. 2.700670.271367 .. 1.4262321.7826 .. 21.42130.151477 .. 0.5733610.87479 .. 0.00466612

the distribution in g-band magnitude:


In [6]:
_ = hist(qsos['obsMag'][:,1],linspace(17,22,20),log=True)


color-color diagram from observed magnitudes, including errors:


In [7]:
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)


Out[7]:
(-0.5, 1.5)

the list of emission lines in the model:


In [8]:
qsodatahdr = fits.getheader('boss_dr9qlf_sim.fits',1)
for i,n in enumerate(qsodatahdr['LINENAME'].split(',')):
    print('%d:%s, '% (i,n,),end=" ")
print()


0:LyB,  1:ArI,  2:FeIII:UV1,  3:CIII*,  4:LyAn,  5:LyAb,  6:NV,  7:SiII,  8:OI,  9:CII,  10:SiIV+OIV],  11:L1480,  12:CIVn,  13:CIVb,  14:HeII,  15:OIII],  16:L1690,  17:NIII],  18:SiII_1818,  19:AlIII,  20:SiIII],  21:CIII]b,  22:CIII]n,  23:fe2120,  24:fe2220,  25:MgIIb,  26:MgIIn,  27:OIII_3133,  28:[NeV]3346,  29:[NeV]3426,  30:[OII]3728,  31:[NeIII]3869,  32:HeI3889,  33:[NeIII]3968,  34:Hd,  35:Hg,  36:[OIII]4364,  37:Hbeta,  38:[OIII]4960,  39:[OIII]5008,  40:HeI_5877,  41:[OI]6302,  42:[OI]6365,  43:[NII]6549,  44:[NII]6585,  45:HAb,  46:HAn,  47:[SII]6718,  48:[SII]6732,  49:HeI7067,  50:[OII]7321,  51:OI8446,  52:[SIII]9069,  53:FeII9202,  54:Pae,  55:Pad,  56:HeI10830,  57:Pag,  58:OI11287,  59:Pabeta,  60:Paalpha,  61:HeI20580,  

broad CIV equivalent width, displaying the Baldwin Effect:


In [9]:
scatter(qsos['absMag'],qsos['emLines'][:,13,1],c=qsos['z'],cmap=cm.autumn_r)
colorbar()
xlabel("$M_{1450}$")
ylabel("CIV equivalent width $\AA$")


Out[9]:
Text(0,0.5,'CIV equivalent width $\\AA$')

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.


In [10]:
figure(figsize=(14,4))
plot(wave/1e4,qsos['spec'][0])
yscale('log')
xlabel('wave [micron]')


Out[10]:
Text(0.5,0,'wave [micron]')

zoom in on the lyman alpha - CIV region:


In [11]:
figure(figsize=(14,4))
plot(wave,qsos['spec'][20])
xlim(3500,7500)
title('$z=%.3f$'%qsos['z'][20])


Out[11]:
Text(0.5,1,'$z=2.590$')

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):


In [2]:
# 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)

In [3]:
figure(figsize=(14,4))
plot(wave,T)


Out[3]:
[<matplotlib.lines.Line2D at 0x1c1de0c278>]

In [4]:
figure(figsize=(14,4))
plot(wave,T)
xlim(4300,4800)


Out[4]:
(4300, 4800)

In [ ]: