In [1]:
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

In [2]:
import absorberspec, ebossspec, sdssspec, datapath, fitsio, starburstspec
import cookb_signalsmooth as cbs
from scipy.stats import nanmean, nanmedian
import cosmology as cosmo
masterwave, allflux, allivar = ebossspec.rest_allspec_readin()
objs_ori = ebossspec.elg_readin()
nobj = objs_ori.size
galaxytype = objs_ori['CLASS']
zgood = objs_ori['zGOOD']
z = objs_ori['Z']


Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave01800_03600A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave03600_07200A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave07200_10400A.fits.

In [3]:
index_wave_all = np.searchsorted(masterwave, [1900., 10400.])
tmpflux = allflux[index_wave_all[0]:index_wave_all[1],:]
tmpivar = allivar[index_wave_all[0]:index_wave_all[1],:]
tmpwave = masterwave[index_wave_all[0]:index_wave_all[1]]
tmploglam = np.log10(tmpwave)

In [4]:
median_sn = np.zeros(objs_ori.size)
for i in np.arange(objs_ori.size):
    iuse = (np.where(tmpivar[:,i]>0))[0]
    median_sn[i] = np.median(tmpflux[iuse,i]*np.sqrt(tmpivar[iuse,i]))
tmpmedian = np.zeros(tmpwave.size)
for i in np.arange((tmpflux.shape)[0]):
    iuse = (np.where(np.logical_and(np.logical_and(np.logical_and(tmpivar[i,:]>0, zgood==1), galaxytype=='GALAXY'), median_sn>0)))[0]
    tmpmedian[i] = np.median(tmpflux[i,iuse])
tmpmedian_OIII = np.zeros(tmpwave.size)
for i in np.arange((tmpflux.shape)[0]):
    iuse = (np.where(np.logical_and(np.logical_and(np.logical_and(np.logical_and(tmpivar[i,:]>0, zgood==1), galaxytype=='GALAXY'), z>0.6), median_sn>0)))[0]
    tmpmedian_OIII[i] = np.median(tmpflux[i,iuse])
#
#outstr_dtype = [('WAVE', 'f4', tmpwave.shape),
                ('FLUXMEDIAN', 'f4', tmpmedian.shape)]
#outstr  = np.array([(tmpwave, tmpmedian)],dtype=outstr_dtype)
#fits = fitsio.FITS('ELG_composite.fits', 'rw', clobber=overwrite)
#fits.write(outstr)
#fits.close()


/Users/Benjamin/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/core/_methods.py:59: RuntimeWarning: Mean of empty slice.
  warnings.warn("Mean of empty slice.", RuntimeWarning)

In [30]:
outstr_dtype = [('WAVE', 'f4', tmpwave.shape),
                ('FLUXMEDIAN', 'f4', tmpmedian.shape)]
outstr  = np.array([(tmpwave, tmpmedian)],dtype=outstr_dtype)
fits = fitsio.FITS('ELG_composite.fits', 'rw', clobber=True)
fits.write(outstr)
fits.close()

In [5]:
nemlines = 25
emission = np.zeros(nemlines, dtype=[('NAME','S10'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
emission[0] = ('FeII*', 2365.-10., 0.49, 2365.)
emission[1] = ('FeII*', 2600.-25., 0.49, 2600.)
#emission[2] = ('[OII]', 3727.+20., 1.80, 3727.)
emission[2] = ('[OII]', 3727.-125., 1.85, 3727.)
emission[3] = ('[NeIII]', 3868.-80., 0.61, 3868.)
emission[4] = ('[OIII]', 4364.44-5., 0.555, 4364.44)
emission[5] = ('[OIII]', 4959.-90.5, 0.96, 4959.)
emission[6] = ('[OIII]', 5008.-70., 1.72, 5008.)
emission[7] = ('[OI]', 6302.-55., 0.51, 6302.)
emission[8] = ('[NII]', 6548.-120., 0.57, 6548.)
emission[9] = ('[NII]', 6583.-5., 0.89, 6583.)
emission[10] = ('[SII]', 6716.-40., 1.03, 6716.)
emission[11] = ('[SII]', 6730.+13, 0.73, 6730.)
emission[12] = ('[ArIII]', 7137.-50., 0.47, 7137.)
#emission[13] = ('CII]+CII]*', 2327.64-160., 0.63, 2327.64)
emission[13] = ('CII]', 2327.64-74., 0.62, 2327.64)
emission[14] = ('[NI]', 5200.00-45., 0.43, 5200.00)
emission[15] = ('[OI]', 6365.53-45., 0.42, 6365.53)
emission[16] = ('[SII]', 4069.75-95., 0.545, 4069.75)
emission[17] = ('[OII]', 7321.94-60., 0.41, 7321.94)
emission[18] = ('HeI', 3188.67-45., 0.40, 3188.67)
emission[19] = ('HeI', 4472.73-45., 0.45, 4472.73)
#emission[20] = ('HeI', 5017.08-45., 0.45, 5017.08)
emission[21] = ('HeI', 5877.24-50.0, 0.56, 5877.24)
emission[22] = ('HeI', 6680.0-70., 0.46, 6680.0)
emission[23] = ('HeI', 7067.2-85., 0.445, 7067.2)
emission[24] = ('[OII]', 2471+28., 0.62, 2471.0)


nabslines = 10
absorption = np.zeros(nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
absorption[0] = ('FeII', 2250.-60., 0.275, 2250.)
absorption[1] = ('FeII', 2300.+14., 0.14, 2300.)
absorption[2] = ('FeII', 2600.-60., 0.10, 2600.)
absorption[3] = ('MgII', 2800.-60., 0.145, 2800.)
absorption[4] = ('MgI', 2853.-30., 0.225, 2853.)
#absorption[4] = ('CaII', 3934.78-180., 0.05, 3934.78)
#absorption[5] = ('K', 3934.78-25., 0.05, 3934.78)
#absorption[6] = ('H', 3969.59-10., 0.05, 3969.59)
#absorption[7] = ('MgI b', 5183.62-150., 0.15, 5183.62)
#absorption[8] = (r'NaI D$_{2,1}$', 5900.-165., 0.15, 5900.)
#absorption[9] = (r'G band', 4307.-15., 0.09, 4307.)

nstellarabs = 7
stellarabs = np.zeros(nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
stellarabs[0] = ('CaII', 3934.78-145., 0.05, 3934.78)
stellarabs[1] = ('K', 3934.78-24., 0.05, 3934.78)
stellarabs[2] = ('H', 3969.59-12., 0.05, 3969.59)
stellarabs[3] = ('MgI b', 5183.62-130., 0.15, 5183.62)
stellarabs[4] = (r'NaI D$_{2,1}$', 5900.-135., 0.15, 5900.)
stellarabs[5] = (r'G band', 4307.-19., 0.09, 4307.)
stellarabs[6] = (r'CIII', 2297.58-50., 0.045, 2297.58)


nbalmer = 7
balmer = np.zeros(nbalmer, dtype=[('NAME','S10'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
balmer[0] = (r'H$\alpha$', 6563.-60, 0.235, 6563.)
balmer[1] = (r'$\beta$', 4861.-30., 0.25, 4861.)
balmer[2] = (r'$\gamma$', 4341.-28., 0.265, 4341.)
balmer[3] = (r'$\delta$', 4102.-27., 0.24, 4102.)
balmer[4] = (r'$\epsilon$', 3970.-22., 0.23, 3907.)
balmer[5] = (r'$\zeta$', 3889.-20., 0.235, 3889.)
balmer[6] = (r'$\eta$', 3835.-25., 0.22, 3835.)

In [6]:
fig = plt.figure(figsize=(25,10))
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(100)
ax.xaxis.set_minor_locator(minorLocator)
ax.plot(tmpwave, tmpmedian, lw=1)
ax.set_xlim(2000, 7500)
ax.set_ylim(-0.20, 2.2)
ax.set_title('Composite Spectrum of Emission-line Galaxies (ELGs) from eBOSS Pilot Observations', fontsize=24)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<F(\lambda)\right>$ [arbitrary unit]', fontsize=28)
#ax.set_xscale('log')
#ax.set_yscale('log')
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
#emission_name = array(['FeII*', 'FeII*', '[OII]', '[NeIII]','[OIII]', '[OIII]', 'HeI', '[OI]',
#                       'NII', 'NII', 'SII', 'SII', '[ArIII]'])
#emission_xpos = array([2300.,   2550.,   3727.,   3868.,     4363.,   4959.,    5876., 6300.,
#                       6548., 6583., 6716., 6730., 7137.])
tmpcor = 0.02
for i in np.arange(nemlines):
    etmp = emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS']-tmpcor, etmp['NAME'], fontsize=15, color='g')
for i in np.arange(nabslines):
    atmp = absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS']-tmpcor, atmp['NAME'], fontsize=15)
for i in np.arange(nbalmer):
    btmp = balmer[i]
    ax.text(btmp['XPOS'], btmp['YPOS']-tmpcor, btmp['NAME'], color='maroon', fontsize=20)
for i in np.arange(nstellarabs):
    stmp = stellarabs[i]
    ax.text(stmp['XPOS'], stmp['YPOS']-tmpcor, stmp['NAME'], color='maroon', fontsize=15)
ax.plot([3934.78, 3934.78], [0.115-tmpcor, 0.18-tmpcor], 'maroon', lw=1) # Ca II
ax.plot([3969.59, 3969.59], [0.115-tmpcor, 0.18-tmpcor], 'maroon', lw=1) # Ca II
ax.plot([5891.58, 5891.58], [0.225-tmpcor, 0.30-tmpcor], 'maroon', lw=1) # Na I
ax.plot([5897.56, 5897.56], [0.225-tmpcor, 0.30-tmpcor], 'maroon', lw=1) # Na I
ax.plot([4307.90, 4307.90], [0.155-tmpcor, 0.22-tmpcor], 'maroon', lw=1) # G (Ca, CH+, Fe)
ax.plot([5183.62, 5183.62], [0.225-tmpcor, 0.30-tmpcor], 'maroon', lw=1) # Mg I
ax.plot([5172.70, 5172.70], [0.225-tmpcor, 0.30-tmpcor], 'maroon', lw=1) # Mg I 
ax.plot([5167.33, 5167.33], [0.225-tmpcor, 0.30-tmpcor], 'maroon', lw=1)  # Mg I
ax.plot([2297.58, 2297.58], [0.13-tmpcor, 0.32-tmpcor], 'maroon', lw=1)  # Mg I
ax.plot([4364.44+1., 4364.44+55], [0.435-tmpcor, 0.54-tmpcor], 'green', lw=1)  # [OIII]
ax.plot([4069.75+0., 4069.75-35], [0.46-tmpcor, 0.52-tmpcor], 'green', lw=1)  # [SII]
ax.plot([2326+0., 2326-20.], [0.51-tmpcor, 0.59-tmpcor], 'green', lw=1)
ax.plot([2471+0., 2471+75.], [0.44-tmpcor, 0.59-tmpcor], 'green', lw=1)
ax.plot([6680+0., 6680-20.], [0.40-tmpcor, 0.44-tmpcor], 'green', lw=1)
ax.plot([7067+0., 7067-30.], [0.385-tmpcor, 0.43-tmpcor], 'green', lw=1)
#ax.plot([5748.89+0., 5748.89-0.], [0.0, 1.35], 'black', lw=1)
#ax.plot([4662.86+0., 4662.86-0.], [0.0, 1.35], 'black', lw=1)
#ax.plot([2255-5., 2255-80.], [0.40, 0.35], 'black', lw=1)
#ax.plot([5756.8+0., 5756.8-0.], [0.37, 2.43], 'green', lw=1)
#ax.plot([9548.8+0., 9548.8-0.], [0.37, 2.43], 'green', lw=1)
#ax.plot([9069+0., 9069-0.], [0.37, 2.43], 'green', lw=1)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_full_NIRadded.eps')



In [7]:
(outwave, fluxmedian, fluxmean, oiifluxmedian, oiifluxmean, oiiifluxmedian, oiiifluxmean) = ebossspec.new_feiimgii_composite()
absorberstack = (fitsio.read('/Users/Benjamin/AstroData/Absorbers/Absorbers_Composite_Allabs_2.0AA_z0.6_1.2.fits'))[0]


Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave01800_03600A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave03600_07200A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave07200_10400A.fits.
(8620,)
/Users/Benjamin/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/polynomial.py:588: RankWarning: Polyfit may be poorly conditioned
  warnings.warn(msg, RankWarning)
/Users/Benjamin/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/polynomial.py:588: RankWarning: Polyfit may be poorly conditioned
  warnings.warn(msg, RankWarning)


In [8]:
fig = plt.figure(figsize=(25,10))
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(100)
ax.xaxis.set_minor_locator(minorLocator)
ax.plot(tmpwave, tmpmedian, lw=1)
ax.set_xlim(1900, 2200)
ax.set_ylim(0.0, 1.)
ax.set_title('Composite Spectrum of Emission-line Galaxies (ELGs) from eBOSS Pilot Observations', fontsize=24)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<F(\lambda)\right>$ [arbitrary unit]', fontsize=28)
#ax.set_xscale('log')
#ax.set_yscale('log')
xtmp = np.linspace(2000., 3000., 1000)
ytmp = np.power(xtmp/1000., -2.)
yspan = np.log10(3000.)-np.log10(2000.)
xspan = np.log10(0.47)-np.log10(0.31)
print(yspan, xspan, yspan/xspan)
print(np.median(ytmp))
ax.plot(xtmp, ytmp*1.8, lw=2, color='red')
logx = np.log10(tmpwave[(tmpwave>2000.) & (tmpwave<2200.)])
logy = np.log10(tmpmedian[(tmpwave>2000.) & (tmpwave<2200.)])
logz = np.polyfit(logx, logy, 1)
logp = np.poly1d(logz)
ax.plot(np.power(10, logx), np.power(10., logp(logx)), color='magenta', lw=4)


(0.17609125905568135, 0.18073616410144477, 0.97430007951725528)
0.160000019238
Out[8]:
[<matplotlib.lines.Line2D at 0x1126c4750>]

In [9]:
logp


Out[9]:
poly1d([-2.1231672 ,  6.68767355])

In [13]:
fig = plt.figure(figsize=(24,8))
#fig.subplots_adjust(top=0.99, bottom=0.01)
this_ylim = [0.10, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(20)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*1.
ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=2)
ax.set_ylim(this_ylim)
ax.set_xlim(2200, 2900)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'Normalized flux $\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
#ax.text(2205, 1.91, 'Blue: Emission Line Galaxies at 0.6<z<1.2 (Zhu & eBOSS 2015)', color='b', fontsize=22, fontname='serif')
#ax.text(2205, 1.83, r'Red:  Quasar Absorption-line Systems at 0.4<z<2.2 (Zhu & M${\rm {\'e}}$nard  2013)', color='r', fontsize=22, fontname='serif')
ax.text(2205, 1.91, 'Blue: Emission-line Galaxies (ELGs) at 0.6<z<1.2', color='b', fontsize=22, fontname='serif')
ax.text(2205, 1.83, r'Red:  Quasar Absorption-line Systems (QSOABSs) at 0.6<z<1.2', color='r', fontsize=22, fontname='serif')

this_nabslines = 13
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('FeII 2249.88', 2249.88-8.5, 0.25, 2249.88)
this_absorption[1] = ('FeII 2260.78', 2260.78+2.5, 0.25, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+2.5, 0.25, 2344.21)
this_absorption[3] = ('FeII 2374.46', 2374.46-8.5, 0.25, 2374.46)
this_absorption[4] = ('FeII 2382.76', 2382.76+2.5, 0.25, 2382.76)
#this_absorption[5] = ('MnII 2576.88', 2576.88-3, 0.2, 2576.88)
this_absorption[6] = ('FeII 2586.65', 2586.65-8.5, 0.23, 2586.65)
#this_absorption[7] = ('MnII 2594.50', 2594.50-3, 0.2, 2594.50)
this_absorption[8] = ('FeII 2600.17', 2600.17+2.5, 0.23, 2600.17)
#this_absorption[9] = ('MnII 2606.46', 2606.46+1.5, 0.2, 2606.46)
this_absorption[10] = ('MgII 2796.35', 2796.35-10.5, 0.25, 2796.35)
this_absorption[11] = ('MgII 2803.53', 2803.53+3.5, 0.25, 2803.53)
this_absorption[12] = ('MgI 2852.96', 2852.96+3.5, 0.25, 2852.96)

this_nemlines = 11
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S25'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('CII] doublet', 2324.21-9.0, 1.37, 2324.21)
this_emission[1] = ('CII] triplet', 2328.83+2.5, 1.37, 2328.83)
#this_emission[2] = ('', 2328.83+2.5, 1.11, 2328.83)
this_emission[3] = ('FeII* 2365.55', 2365.55-8.5, 1.35, 2365.55)
this_emission[4] = ('FeII* 2396.36', 2396.36+2.5, 1.35, 2396.36)
this_emission[5] = ('FeII* 2626.45', 2626.45+2.5, 1.35, 2626.45)
this_emission[6] = ('FeII* 2612.65', 2612.65-8.5, 1.35, 2612.65)
#this_emission[7] = ('[NeIV] doublet', 2422.56-9.5, 1.35, 2422.56)
#this_emission[8] = ('2422.56 2425.14', 2425.14+2.5, 1.33, 2425.14)
this_emission[9] = ('[OII] doublet', 2470.97-9.5, 1.35, 2470.97)
this_emission[10] = ('2470.97 2471.09', 2471.09+2.5, 1.335, 2471.09)


#this_emission[5] = ('FeII* 2632.11', 2632.11+2.5, 1.3, 2632.11)
#this_emission[5] = ('FeII* 2467.98', 2467.98+2.5, 1.3, 2467.98)

this_nstellarabs = 2
this_stellarabs = np.zeros(this_nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_stellarabs[0] = ('CIII 2297.58', 2297.58+2.5, 0.46, 2297.58)
#this_stellarabs[1] = ('CoI 2295.87', 2295.87+2.5, 0.48, 2295.87)


for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1.0, this_ylim[0]], '--k', linewidth=2)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1.0, this_ylim[1]], '--g', linewidth=2)
for i in np.arange(this_nstellarabs):
    atmp = this_stellarabs[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom', color='maroon')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [0.43, 0.80], '-', color='maroon')
    
# MnII
ax.plot([2576.88-0., 2576.88-0], [1, 0.53], '--k', lw=2)
ax.text(2576.88-9.5, 0.545, 'MnII 2576.88', fontsize=16, rotation='vertical',va='bottom')
ax.plot([2594.50-0., 2594.50-0.], [this_ylim[0], 1.48], '--k', lw=2)
ax.text(2594.50-9.5, 1.1, 'MnII 2594.50', fontsize=16, rotation='vertical',va='bottom')
ax.plot([2606.46-0., 2606.46-0.], [1, 0.53], '--k', lw=2)
ax.text(2606.46+2.5, 0.545, 'MnII 2606.46', fontsize=16, rotation='vertical',va='bottom')
#ax.text(2328.83+2.0, 1.17, '2326.11 2327.64 2328.83', color='g', rotation='vertical',va='bottom', fontsize=12)

# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1.5)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*1.
ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=1.5)

fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers.eps')



In [14]:
(sboutwave, sbfluxmean, sbfluxmedian, sbfluxused) = starburstspec.mgii_composite()


Reading /Users/Benjamin/AstroData/AllInOne/AIO_SBSF_HSTFOS_NEDzRestFrame_Wave00900_01800A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_SBSF_HSTFOS_NEDzRestFrame_Wave01800_03600A.fits.

In [26]:
fig = plt.figure(figsize=(24,8))
#fig.subplots_adjust(top=0.99, bottom=0.01)
this_ylim = [0.10, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(20)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
#ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.plot(sboutwave+dwave/2.-0.7, sbfluxmedian, 'b', drawstyle='steps', linewidth=1.5)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*1.
ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=2)
ax.set_ylim(this_ylim)
ax.set_xlim(2200, 2900)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'Normalized flux $\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
#ax.text(2205, 1.91, 'Blue: Emission Line Galaxies at 0.6<z<1.2 (Zhu & eBOSS 2015)', color='b', fontsize=22, fontname='serif')
#ax.text(2205, 1.83, r'Red:  Quasar Absorption-line Systems at 0.4<z<2.2 (Zhu & M${\rm {\'e}}$nard  2013)', color='r', fontsize=22, fontname='serif')
ax.text(2205, 1.91, 'Blue: Local Star-forming Regions at z~0', color='b', fontsize=22, fontname='serif')
ax.text(2205, 1.83, r'Red:  Quasar Absorption-line Systems (QSOABSs) at 0.6<z<1.2', color='r', fontsize=22, fontname='serif')

this_nabslines = 13
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('FeII 2249.88', 2249.88-8.5, 0.25, 2249.88)
this_absorption[1] = ('FeII 2260.78', 2260.78+2.5, 0.25, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+2.5, 0.25, 2344.21)
this_absorption[3] = ('FeII 2374.46', 2374.46-8.5, 0.25, 2374.46)
this_absorption[4] = ('FeII 2382.76', 2382.76+2.5, 0.25, 2382.76)
#this_absorption[5] = ('MnII 2576.88', 2576.88-3, 0.2, 2576.88)
this_absorption[6] = ('FeII 2586.65', 2586.65-8.5, 0.23, 2586.65)
#this_absorption[7] = ('MnII 2594.50', 2594.50-3, 0.2, 2594.50)
this_absorption[8] = ('FeII 2600.17', 2600.17+2.5, 0.23, 2600.17)
#this_absorption[9] = ('MnII 2606.46', 2606.46+1.5, 0.2, 2606.46)
this_absorption[10] = ('MgII 2796.35', 2796.35-10.5, 0.25, 2796.35)
this_absorption[11] = ('MgII 2803.53', 2803.53+3.5, 0.25, 2803.53)
this_absorption[12] = ('MgI 2852.96', 2852.96+3.5, 0.25, 2852.96)

this_nemlines = 11
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S25'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('CII] doublet', 2324.21-9.0, 1.37, 2324.21)
this_emission[1] = ('CII] triplet', 2328.83+2.5, 1.37, 2328.83)
#this_emission[2] = ('', 2328.83+2.5, 1.11, 2328.83)
this_emission[3] = ('FeII* 2365.55', 2365.55-8.5, 1.35, 2365.55)
this_emission[4] = ('FeII* 2396.36', 2396.36+2.5, 1.35, 2396.36)
this_emission[5] = ('FeII* 2626.45', 2626.45+2.5, 1.35, 2626.45)
this_emission[6] = ('FeII* 2612.65', 2612.65-8.5, 1.35, 2612.65)
#this_emission[7] = ('[NeIV] doublet', 2422.56-9.5, 1.35, 2422.56)
#this_emission[8] = ('2422.56 2425.14', 2425.14+2.5, 1.33, 2425.14)
this_emission[9] = ('[OII] doublet', 2470.97-9.5, 1.35, 2470.97)
this_emission[10] = ('2470.97 2471.09', 2471.09+2.5, 1.335, 2471.09)


#this_emission[5] = ('FeII* 2632.11', 2632.11+2.5, 1.3, 2632.11)
#this_emission[5] = ('FeII* 2467.98', 2467.98+2.5, 1.3, 2467.98)

this_nstellarabs = 2
this_stellarabs = np.zeros(this_nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_stellarabs[0] = ('CIII 2297.58', 2297.58+2.5, 0.46, 2297.58)
#this_stellarabs[1] = ('CoI 2295.87', 2295.87+2.5, 0.48, 2295.87)


for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1.0, this_ylim[0]], '--k', linewidth=2)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1.0, this_ylim[1]], '--g', linewidth=2)
for i in np.arange(this_nstellarabs):
    atmp = this_stellarabs[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom', color='maroon')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [0.43, 0.80], '-', color='maroon')
    
# MnII
ax.plot([2576.88-0., 2576.88-0], [1, 0.53], '--k', lw=2)
ax.text(2576.88-9.5, 0.545, 'MnII 2576.88', fontsize=16, rotation='vertical',va='bottom')
ax.plot([2594.50-0., 2594.50-0.], [this_ylim[0], 1.48], '--k', lw=2)
ax.text(2594.50-9.5, 1.1, 'MnII 2594.50', fontsize=16, rotation='vertical',va='bottom')
ax.plot([2606.46-0., 2606.46-0.], [1, 0.53], '--k', lw=2)
ax.text(2606.46+2.5, 0.545, 'MnII 2606.46', fontsize=16, rotation='vertical',va='bottom')
#ax.text(2328.83+2.0, 1.17, '2326.11 2327.64 2328.83', color='g', rotation='vertical',va='bottom', fontsize=12)

# Replot
#ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1.5)
ax.plot(sboutwave+dwave/2.-0.7, sbfluxmedian, 'b', drawstyle='steps', linewidth=1.5)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*1.
ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=1.5)

fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_localwithqsoabsorbers.eps')



In [16]:
fig = plt.figure(figsize=(24,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(5)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.set_ylim(this_ylim)
ax.set_xlim(2230, 2415)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.5)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
this_nabslines = 6
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('FeII 2249.88', 2249.88-3, 0.2, 2249.88)
this_absorption[1] = ('FeII 2260.78', 2260.78+1.5, 0.2, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+1.5, 0.2, 2344.21)
this_absorption[3] = ('FeII 2374.46', 2374.46+1.5, 0.2, 2374.46)
this_absorption[4] = ('FeII 2382.76', 2382.76+1.5, 0.2, 2382.76)
#this_absorption[5] = ('CIII 2297.58', 2297.58+1.5, 0.2, 2297.58)


this_nemlines = 7
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S25'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('CII] doublet', 2324.21-3.0, 1.37, 2324.21)
this_emission[1] = ('', 2325.40-9.0, 1.3, 2325.40)
this_emission[2] = ('CII] triplet', 2326.11+4.0, 1.37, 2326.11)
this_emission[3] = ('', 2327.64-9.0, 1.3, 2327.64)
this_emission[4] = ('', 2328.83+2.5, 1.3, 2328.83)
#this_emission[2] = ('2326.11 2327.64 2328.83', 2328.83+2.5, 1.03, 2328.83)
this_emission[5] = ('FeII* 2396.36', 2396.36+1., 1.3, 2396.36)
this_emission[6] = ('FeII* 2365.55', 2365.55+1., 1.3, 2365.55)


this_nstellarabs = 1
this_stellarabs = np.zeros(this_nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_stellarabs[0] = ('CIII 2297.58', 2297.58+1.5, 0.46, 2297.58)

#this_emission[2] = ('FeII* 2632.11', 2632.11+10., 1.2, 2632.11)

for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1, this_ylim[0]], '--k', lw=2)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1, this_ylim[1]], '--g', linewidth=2)
for i in np.arange(this_nstellarabs):
    atmp = this_stellarabs[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom', color='maroon')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [0.43, 0.80], '-', color='maroon', lw=1)
    
# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=2.5)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*1.
ax.plot(absorberstack['WAVE']+dwave/2., yabs, 'r', linewidth=2., drawstyle='steps')
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers_2350.eps')



In [31]:
fig = plt.figure(figsize=(24,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(2)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.set_ylim(this_ylim)
ax.set_xlim(2560, 2640)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.5)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
this_nabslines = 5
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('MnII 2576.88', 2576.88-1.5, 0.2, 2576.88)
this_absorption[1] = ('FeII 2586.65', 2586.65-2.5, 0.2, 2586.65)
this_absorption[2] = ('MnII 2594.50', 2594.50-1.5, 0.2, 2594.50)
this_absorption[3] = ('FeII 2600.17', 2600.17+1.5, 0.2, 2600.17)
this_absorption[4] = ('MnII 2606.46', 2606.46+1., 0.2, 2606.46)

this_nemlines = 3
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('FeII* 2626.45', 2626.45+1.3, 1.4, 2626.45)
this_emission[1] = ('FeII* 2612.65', 2612.65+1., 1.4, 2612.65)
#this_emission[2] = ('FeII* 2632.11', 2632.11+10., 1.2, 2632.11)

for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1, this_ylim[0]], '--k', lw=2)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1,this_ylim[1]], '--g', linewidth=2)
    
# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=3.0)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*1.
ax.plot(absorberstack['WAVE']+dwave/2., yabs, 'r', linewidth=2.5, drawstyle='steps')
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers_2600.eps')



In [59]:
fig = plt.figure(figsize=(24,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(2)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.set_ylim(this_ylim)
ax.set_xlim(2560, 2640)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.5)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
this_nabslines = 5
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('MnII 2576.88', 2576.88-1.5, 0.2, 2576.88)
this_absorption[1] = ('FeII 2586.65', 2586.65-2.5, 0.2, 2586.65)
this_absorption[2] = ('MnII 2594.50', 2594.50-1.5, 0.2, 2594.50)
this_absorption[3] = ('FeII 2600.17', 2600.17+1.5, 0.2, 2600.17)
this_absorption[4] = ('MnII 2606.46', 2606.46+1., 0.2, 2606.46)

this_nemlines = 3
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('FeII* 2626.45', 2626.45+1.3, 1.4, 2626.45)
this_emission[1] = ('FeII* 2612.65', 2612.65+1., 1.4, 2612.65)
#this_emission[2] = ('FeII* 2632.11', 2632.11+10., 1.2, 2632.11)

for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1, this_ylim[0]], '--k', lw=2)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1,this_ylim[1]], '--g', linewidth=2)
    
ax.plot([2560., 2640.], [1, 1], '--k', linewidth=2)
# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=3.0)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers_2600_1.eps')

imask = np.where(np.logical_and(outwave<2600., outwave>2595.5))
plotutils.fill_between_steps(ax, outwave[imask]+dwave/2., fluxmedian[imask], 1, color='DeepSkyBlue')
imask = np.where(np.logical_and(outwave>=2600.-0.2, outwave<2604.))
plotutils.fill_between_steps(ax, outwave[imask]+dwave/2., fluxmedian[imask], 1, color='Coral')

imask = np.where(np.logical_and(outwave<2586.6, outwave>2581))
plotutils.fill_between_steps(ax, outwave[imask]+dwave/2., fluxmedian[imask], 1, color='DeepSkyBlue')
imask = np.where(np.logical_and(outwave>=2586.6-0.7, outwave<2589.5))
plotutils.fill_between_steps(ax, outwave[imask]+dwave/2., fluxmedian[imask], 1, color='Coral')

fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers_2600_2.eps')
imask = np.where(np.logical_and(outwave<2612.+0.5, outwave>2612-3.))
plotutils.fill_between_steps(ax, outwave[imask]+dwave/2., fluxmedian[imask], 1, color='DeepSkyBlue')
imask = np.where(np.logical_and(outwave>=2612.-0.0, outwave<2612.+4))
plotutils.fill_between_steps(ax, outwave[imask]+dwave/2., fluxmedian[imask], 1, color='Coral')

imask = np.where(np.logical_and(outwave<2626.+0.5, outwave>2626.-3.5))
plotutils.fill_between_steps(ax, outwave[imask]+dwave/2., fluxmedian[imask], 1, color='DeepSkyBlue')
imask = np.where(np.logical_and(outwave>=2626.-0.2, outwave<2626.+4))
plotutils.fill_between_steps(ax, outwave[imask]+dwave/2., fluxmedian[imask], 1, color='Coral')
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers_2600_4.eps')

yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*1.
ax.plot(absorberstack['WAVE']+dwave/2., yabs, 'r', linewidth=2.5, drawstyle='steps')
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers_2600_3.eps')



In [18]:
fig = plt.figure(figsize=(24,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(2)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.set_ylim(this_ylim)
ax.set_xlim(2760, 2870)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.5)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
this_nabslines = 3
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('MgII 2796.35', 2796.35-3.5, 0.2, 2796.35)
this_absorption[1] = ('MgII 2803.53', 2803.53+1.8, 0.2, 2803.53)
this_absorption[2] = ('MgI 2852.96', 2852.96+1.5, 0.21, 2852.96)

for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [this_ylim[0],1.], '--k', lw=2)
    #ax.plot([atmp['WAVE'], atmp['WAVE']], [this_ylim[0],this_ylim[1]], '--k', lw=2)
#plot([2344.21, 2344.21], [0.25, 1.25], 'g')
#plot([2374.46, 2374.46], [0.25, 1.25], 'g')
#plot([2382.77, 2382.77], [0.25, 1.25], 'g')
#plot([2365.55, 2365.55], [0.25, 1.25], 'r')
#plot([2396.35, 2396.35], [0.25, 1.25], 'r')

# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=3.0)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])
ax.plot(absorberstack['WAVE']+dwave/2., yabs, 'r', linewidth=2.5, drawstyle='steps')
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers_2800.eps')



In [22]:
fig = plt.figure(figsize=(24,8))
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(20)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., oiifluxmedian, 'b', drawstyle='steps', linewidth=1)
this_ylim = [0.15, 2.29]
ax.set_ylim(this_ylim)
ax.set_xlim(3000, 4000)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.5)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
this_nabslines = 8
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('TiII 3067.24', 3067.24-18., 0.22, 3067.24)
this_absorption[1] = ('TiII 3073.86', 3073.86+10., 0.22, 3073.86)
#this_absorption[2] = ('AlI 3083.05', 3083.05+1.5, 0.23, 3083.05)
this_absorption[3] = ('TiII 3230.12', 3230.12-18., 0.23, 3230.12)
this_absorption[4] = ('TiII 3242.92', 3242.92+10., 0.23, 3242.92)
this_absorption[5] = ('TiII 3384.73', 3384.73+10., 0.23, 3384.73)
#this_absorption[6] = ('CaII 3934.78', 3934.78-30., 0.23, 3934.78)
#this_absorption[7] = ('CaII 3969.59', 3969.59+10., 0.23, 3969.59)

this_nemlines = 5
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('[OII] 3727.10', 3727.1-23., 1.42+0.3, 3727.1)
this_emission[1] = ('[OII] 3729.86', 3729.8+10., 1.42+0.3, 3729.9)
this_emission[2] = ('[NeIII] 3869.77', 3869.77+6., 1.4+0.35, 3869.77)
this_emission[3] = ('HeI 3189.67', 3189.67+10., 1.4+0.3, 3189.67)
#this_emission[4] = ('HeI 3820.69', 3820.69+10., 1.4+0.3, 3810.69)


this_nbalmer = 11
this_balmer = np.zeros(this_nbalmer, dtype=[('NAME','S10'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
#this_balmer[0] = (r'$\alpha$', 6563.-35., 0.25, 6563.)
#this_balmer[1] = (r'$\beta$', 4861.-35., 0.25, 4861.)
#this_balmer[2] = (r'$\gamma$', 4341.-35., 0.265, 4341.)
#this_balmer[3] = (r'$\delta$', 4102.-35., 0.24, 4102.)
this_balmer[4] = (r'$\epsilon$', 3970.+12., 0.9+0.08, 3907.)
this_balmer[5] = (r'$\zeta$', 3889.-8., 0.85+0.08, 3889.)
this_balmer[6] = (r'$\eta$', 3835.38-8., 0.75+0.08, 3835.38)
this_balmer[7] = (r'$\theta$', 3797.90-8., 0.8+0.08, 3797.90)
this_balmer[8] = (r'$\iota$', 3770.63-6., 0.82+0.08, 3770.63)
this_balmer[9] = (r'$\kappa$', 3750.15-8., 0.77+0.08, 3750.15)
#this_balmer[10] = (r'break', 3647.15-10., 0.77, 3647.15)


this_nstellarabs = 3
this_stellarabs = np.zeros(this_nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_stellarabs[0] = ('CaII K 3934.78', 3934.78-16., 0.23, 3934.78)
this_stellarabs[1] = ('CaII H 3969.59', 3969.59+8., 0.23, 3969.59)
#this_stellarabs[2] = (r'Balmer break', 3647.15-10., 0.23, 3647.00)


for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1.1, this_ylim[0]], '--k', lw=2)
for i in np.arange(this_nbalmer):
    btmp = this_balmer[i]
    ax.text(btmp['XPOS'], btmp['YPOS'], btmp['NAME'], color='maroon', fontsize=24)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1, this_ylim[1]], '--g', linewidth=1)
for i in np.arange(this_nstellarabs):
    atmp = this_stellarabs[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom', color='maroon')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [0.9, this_ylim[0]], '-', color='maroon', lw=1)
   
# Replot    
ax.plot(outwave+dwave/2., oiifluxmedian, 'b', drawstyle='steps', linewidth=1.5)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*1.+0.2
ax.plot(absorberstack['WAVE']+dwave/2., yabs, 'r', linewidth=1.2, drawstyle='steps')
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withqsoabsorbers2.eps')



In [369]:
plt.plot(outwave+dwave/2., oiifluxmedian, 'b', drawstyle='steps')
plt.xlim(3650, 3800)


Out[369]:
(3650, 3800)

In [201]:



Reading /Users/Benjamin/AstroData/AllInOne/AIO_SBSF_HSTFOS_NEDzRestFrame_Wave00900_01800A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_SBSF_HSTFOS_NEDzRestFrame_Wave01800_03600A.fits.

In [24]:
fig = plt.figure(figsize=(24,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(20)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.set_ylim(this_ylim)
ax.set_xlim(2200, 2900)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'Normalized flux $\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
#ax.text(2205, 1.91, 'Blue: Emission Line Galaxies at 0.6<z<1.2 (Zhu & eBOSS 2015, r~15 kpc)', color='b', fontsize=22, fontname='serif')
#ax.text(2205, 1.83, 'Red:  Local Star-forming Regions at z~0 (Leitherer 2011, r<40 pc)', color='r', fontsize=22, fontname='serif')
ax.text(2205, 1.91, 'Blue: Emission-line Galaxies (ELGs) at 0.6<z<1.2 (Aperture ~ 15 kpc)', color='b', fontsize=22, fontname='serif')
ax.text(2205, 1.83, 'Red:  Local Star-forming Regions at z~0 (Aperture < 40 pc)', color='r', fontsize=22, fontname='serif')
#plot([2299., 2299.], this_ylim, 'k')
#plot([2297., 2297.], [0.6,0.85], 'k')


this_nabslines = 13
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('FeII 2249.88', 2249.88-8.5, 0.2, 2249.88)
this_absorption[1] = ('FeII 2260.78', 2260.78+2.5, 0.2, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+2.5, 0.2, 2344.21)
this_absorption[3] = ('FeII 2374.46', 2374.46-8.5, 0.2, 2374.46)
this_absorption[4] = ('FeII 2382.76', 2382.76+2.5, 0.2, 2382.76)
#this_absorption[5] = ('MnII 2576.88', 2576.88-3, 0.2, 2576.88)
this_absorption[6] = ('FeII 2586.65', 2586.65-8.5, 0.18, 2586.65)
#this_absorption[7] = ('MnII 2594.50', 2594.50-3, 0.2, 2594.50)
this_absorption[8] = ('FeII 2600.17', 2600.17+2.5, 0.18, 2600.17)
#this_absorption[9] = ('MnII 2606.46', 2606.46+1.5, 0.2, 2606.46)
this_absorption[10] = ('MgII 2796.35', 2796.35-10.5, 0.2, 2796.35)
this_absorption[11] = ('MgII 2803.53', 2803.53+3.5, 0.2, 2803.53)
this_absorption[12] = ('MgI 2852.96', 2852.96+3.5, 0.21, 2852.96)

this_nemlines = 11
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S25'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('CII] doublet', 2324.21-9.0, 1.37, 2324.21)
this_emission[1] = ('CII] triplet', 2328.83+2.5, 1.37, 2328.83)
#this_emission[2] = ('', 2328.83+2.5, 1.11, 2328.83)
this_emission[3] = ('FeII* 2365.55', 2365.55-8.5, 1.35, 2365.55)
this_emission[4] = ('FeII* 2396.36', 2396.36+2.5, 1.35, 2396.36)
this_emission[5] = ('FeII* 2626.45', 2626.45+2.5, 1.35, 2626.45)
this_emission[6] = ('FeII* 2612.65', 2612.65-8.5, 1.35, 2612.65)
#this_emission[7] = ('[NeIV] doublet', 2422.56-9.5, 1.35, 2422.56)
#this_emission[8] = ('2422.56 2425.14', 2425.14+2.5, 1.33, 2425.14)
this_emission[9] = ('[OII] doublet', 2470.97-9.5, 1.35, 2470.97)
this_emission[10] = ('2470.97 2471.09', 2471.09+2.5, 1.335, 2471.09)


this_nstellarabs = 1
this_stellarabs = np.zeros(this_nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_stellarabs[0] = ('CIII 2297.58', 2297.58+2.5, 0.46, 2297.58)

for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [this_ylim[0], 1.0], '--k', linewidth=2)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1.0, this_ylim[1]], '--g', linewidth=2)
for i in np.arange(this_nstellarabs):
    atmp = this_stellarabs[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom', color='maroon')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [0.43, 0.80], '-', color='maroon')

# MnII
ax.plot([2576.88-0., 2576.88-0], [1, 0.53], '--k', lw=2)
ax.text(2576.88-9.5, 0.545, 'MnII 2576.88', fontsize=16, rotation='vertical',va='bottom')
ax.plot([2594.50-0., 2594.50-0.], [this_ylim[0], 1.48], '--k', lw=2)
ax.text(2594.50-9.5, 1.1, 'MnII 2594.50', fontsize=16, rotation='vertical',va='bottom')
ax.plot([2606.46-0., 2606.46-0.], [1, 0.53], '--k', lw=2)
ax.text(2606.46+2.5, 0.545, 'MnII 2606.46', fontsize=16, rotation='vertical',va='bottom')

# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.plot(sboutwave+dwave/2.-0.7, sbfluxmedian, 'r', drawstyle='steps', linewidth=1.5)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withlocalsfsb.eps')



In [25]:
fig = plt.figure(figsize=(24,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(5)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.set_ylim(this_ylim)
ax.set_xlim(2230, 2415)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.5)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
this_nabslines = 6
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('FeII 2249.88', 2249.88-5, 0.2, 2249.88)
this_absorption[1] = ('FeII 2260.78', 2260.78+1.5, 0.2, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+1.5, 0.2, 2344.21)
this_absorption[3] = ('FeII 2374.46', 2374.46+1.5, 0.2, 2374.46)
this_absorption[4] = ('FeII 2382.76', 2382.76+1.5, 0.2, 2382.76)
#this_absorption[5] = ('CIII 2297.58', 2297.58+1.5, 0.2, 2297.58)


this_nemlines = 7
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S25'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('CII] doublet', 2324.21-3.0, 1.37, 2324.21)
this_emission[1] = ('', 2325.40-9.0, 1.3, 2325.40)
this_emission[2] = ('CII] triplet', 2326.11+4.0, 1.37, 2326.11)
this_emission[3] = ('', 2327.64-9.0, 1.3, 2327.64)
this_emission[4] = ('', 2328.83+2.5, 1.3, 2328.83)
#this_emission[2] = ('2326.11 2327.64 2328.83', 2328.83+2.5, 1.03, 2328.83)
this_emission[5] = ('FeII* 2396.36', 2396.36+1., 1.3, 2396.36)
this_emission[6] = ('FeII* 2365.55', 2365.55+1., 1.3, 2365.55)


this_nstellarabs = 1
this_stellarabs = np.zeros(this_nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_stellarabs[0] = ('CIII 2297.58', 2297.58+2.5, 0.46, 2297.58)

#this_emission[2] = ('FeII* 2632.11', 2632.11+10., 1.2, 2632.11)

for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1, this_ylim[0]], '--k', lw=2)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1, this_ylim[1]], '--g', linewidth=2)
for i in np.arange(this_nstellarabs):
    atmp = this_stellarabs[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom', color='maroon')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [0.43, 0.80], '-', color='maroon', lw=1)
    
# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=2.5)
ax.plot(sboutwave+dwave/2.-0.7, sbfluxmedian, 'r', drawstyle='steps', linewidth=2.)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 2/eBOSS_composite_withlocalsfsb_2350.eps')



In [22]:
index_wave = searchsorted(masterwave, [2300., 4001.])
index_oii = searchsorted(masterwave, 3727.)
# Selection needs to be revisited
ii = (where(logical_and(logical_and(logical_and(allivar[index_wave[0], :]>0, 
                                                allivar[index_wave[1], :]>0), zgood==1), galaxytype=='GALAXY')))[0]
oiisum = sum(allflux[index_oii-10:index_oii+10, ii], axis=0)
oiilum = oiisum*power(cosmo.luminosity_distance(objs_ori[ii]['Z']), 2)
oii_left = sum(allflux[index_oii-25:index_oii-15, ii], axis=0)
oii_right = sum(allflux[index_oii+15:index_oii+25, ii], axis=0)
oii_ew = oiisum/(oii_left+oii_right)*2.
xx = allflux[index_wave[0]:index_wave[1], ii]

In [35]:
sort_index = argsort(oii_ew)
#xmean1 = nanmean(xx[:,sort_index[100:2000]], 1)
xmean1 = nanmean(xx[:,sort_index[0:500]], 1)
xmean2 = nanmean(xx[:,sort_index[2000:3000]], 1)
xmean3 = nanmean(xx[:,sort_index[2000:4000]], 1)
xmean4 = nanmean(xx[:,sort_index[3000:4000]], 1)
xmean5 = nanmean(xx[:,sort_index[4000:5000]], 1)
xmean6 = nanmean(xx[:,sort_index[7000:8000]], 1)
xmean = nanmean(xx[:,sort_index[2000:-100]], 1)
xmeanall = nanmean(xx,1)

In [40]:
fig = figure(figsize=(10,7))
this_ylim = [0.15, 0.6]
ax = fig.add_subplot(111)
dwave = median(masterwave[index_wave[0]+1:index_wave[1]]-masterwave[index_wave[0]:index_wave[1]-1])
#plot(masterwave[index_wave[0]:index_wave[1]]+0.6, xmean4*1.1, 'g', drawstyle='steps')
ax.plot(masterwave[index_wave[0]:index_wave[1]]+dwave/2, xmean1*1.15, 'b', lw=2, drawstyle='steps')
ax.plot(masterwave[index_wave[0]:index_wave[1]]+dwave/2., xmean4*1.15, 'r', lw=2, drawstyle='steps')
ax.plot(masterwave[index_wave[0]:index_wave[1]]+dwave/2., xmean6*1.15, 'g', lw=2, drawstyle='steps')

ax.set_ylim(this_ylim)
ax.set_xlim(2760, 2880)
plot([2796.75,  2796.75], [0.0, 3.5], 'k')
plot([2803.27,  2803.27], [0.0, 3.5], 'k')


Out[40]:
[<matplotlib.lines.Line2D at 0x239e97cd0>]

In [206]:
tmploglam = log10(tmpwave)
# Get the Mask array
# Region Mg II
# Range
waveleft = 2760.
waveright = 2840.
# Lines intersted
this_nabslines = 3
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4'),
                                               ('WAVELEFT', 'f4'), ('WAVERIGHT', 'f4')])
this_absorption[0] = ('MgII 2796.35', 2796.35-4., 0.2, 2796.35, 2780., 2810.)
this_absorption[1] = ('MgII 2803.53', 2803.53+1.5, 0.2, 2803.53, 2780., 2810. )
this_absorption[2] = ('MgI 2852.96', 2852.96+1.5, 0.21, 2852.96, 2840., 2860.)
# Mask out range and lines
mask = ones(tmpwave.size)
mask[(tmpwave<waveleft) | (tmpwave>waveright)] = 0
for i in arange(this_nabslines):
    mask[(tmpwave>this_absorption[i]['WAVELEFT']) & (tmpwave<this_absorption[i]['WAVERIGHT'])] = 0

index1 = ii[sort_index[500:1200]]
index2 = ii[sort_index[1200:2000]]
index3 = ii[sort_index[2200:3000]]
index4 = ii[sort_index[3200:4000]]
index5 = ii[sort_index[4200:-100]]
(median_norm_median1, mean_norm_median1) = ebossspec.composite_engine(tmploglam, tmpflux[:,index1], 
                                                                      tmpivar[:,index1], mask, polyorder=3)
(median_norm_median2, mean_norm_median2) = ebossspec.composite_engine(tmploglam, tmpflux[:,index2], 
                                                                      tmpivar[:,index2], mask, polyorder=3)
(median_norm_median3, mean_norm_median4) = ebossspec.composite_engine(tmploglam, tmpflux[:,index3], 
                                                                      tmpivar[:,index3], mask, polyorder=3)
(median_norm_median4, mean_norm_median4) = ebossspec.composite_engine(tmploglam, tmpflux[:,index4], 
                                                                      tmpivar[:,index4], mask, polyorder=3)
(median_norm_median5, mean_norm_median5) = ebossspec.composite_engine(tmploglam, tmpflux[:,index5], 
                                                                      tmpivar[:,index5], mask, polyorder=3)

In [65]:


In [255]:
fig = figure(figsize=(20,8))
this_ylim = [0.35, 1.45]
ax = fig.add_subplot(111)
dwave = median(tmpwave[1:]-tmpwave[:-1])
ax.plot(tmpwave+dwave/2., median_norm_median1, 'r', drawstyle='steps', linewidth=3)
ax.set_ylim(this_ylim)
ax.set_xlim(2770, 2830)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'Normalized $f(\lambda)$', fontsize=20)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='both', length=7, width=2, labelsize=15)

this_nabslines = 3
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('MgII 2796.35', 2796.35+0.5, 0.4, 2796.35)
this_absorption[1] = ('MgII 2803.53', 2803.53+0.5, 0.4, 2803.53)
#this_absorption[2] = ('MgI 2852.96', 2852.96+1.5, 0.21, 2852.96)

for i in arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=14, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], this_ylim, '--k')

# Replot
ax.plot(tmpwave+dwave/2., median_norm_median5, 'blue', drawstyle='steps', linewidth=3)
#ax.plot(tmpwave+dwave/2., median_norm_median4, 'brown', drawstyle='steps', linewidth=2)
#ax.plot(tmpwave+dwave/2., median_norm_median3, 'green', drawstyle='steps', linewidth=2)
ax.plot(tmpwave+dwave/2., median_norm_median2, 'green', drawstyle='steps', linewidth=3)
#ax.plot(tmpwave+dwave/2., median_norm_median1, 'blue', drawstyle='steps', linewidth=2)
ax.text(2771, 1.350, 'Blue: High [OII] EW', color='blue', fontsize=17, fontname='serif')
ax.text(2771, 1.300, 'Green: Medium [OII] EW', color='green', fontsize=17, fontname='serif')
ax.text(2771, 1.250, 'Red: Low [OII] EW', color='red', fontsize=17, fontname='serif')

nlines = 2
lines = zeros(nlines, dtype=[('SIGN', 'i'),('ELEMENT','S20'),('WAVE','f4'),('EW','f4'), ('WAVELEFT', 'f4')])
lines[0] = (-1, 'MgII', 2796.35, 2., 2789.)
lines[1] = (-1, 'MgII', 2803.53, 2., 2798.)
ew_profile1 = ebossspec.line_property(tmploglam, median_norm_median1-1., lines, npixels=20)
ew_profile2 = ebossspec.line_property(tmploglam, median_norm_median2-1., lines, npixels=20)
ew_profile3 = ebossspec.line_property(tmploglam, median_norm_median3-1., lines, npixels=20)
ew_profile4 = ebossspec.line_property(tmploglam, median_norm_median4-1., lines, npixels=20)
ew_profile5 = ebossspec.line_property(tmploglam, median_norm_median5-1., lines, npixels=20)
ew1 = ravel(ew_profile1[0]['EW'])
ew2 = -ravel(ew_profile2[0]['EW'])
ew3 = -ravel(ew_profile3[0]['EW'])
ew4 = -ravel(ew_profile4[0]['EW'])
ew5 = -ravel(ew_profile5[0]['EW'])
#frac1 = ew1/max(ew1)
frac2 = ew2/max(ew2)
frac3 = ew3/max(ew3)
frac4 = ew4/max(ew4)
frac5 = ew5/max(ew5)
#vel1 = ravel(ew_profile1[0]['VEL'])
vel2 = ravel(ew_profile2[0]['VEL'])
vel3 = ravel(ew_profile3[0]['VEL'])
vel4 = ravel(ew_profile4[0]['VEL'])
vel5 = ravel(ew_profile5[0]['VEL'])
#i1 = (where(logical_and(frac1>0.3, frac1<0.7)))[0]
#f = interp1d(frac1[i1], vel1[i1])
#vel501 = f(0.5)
i2 = (where(logical_and(frac2>0.3, frac2<0.7)))[0]
f = interp1d(frac2[i2], vel2[i2])
vel502 = f(0.5)
i3 = (where(logical_and(frac3>0.3, frac3<0.7)))[0]
f = interp1d(frac3[i3], vel3[i3])
vel503 = f(0.5)
i4 = (where(logical_and(frac4>0.3, frac4<0.7)))[0]
f = interp1d(frac4[i4], vel4[i4])
vel504 = f(0.5)
i5 = (where(logical_and(frac5>0.3, frac5<0.7)))[0]
f = interp1d(frac5[i5], vel5[i5])
vel505 = f(0.5)


MgIIEW_list = array([max(ew1), max(ew2), max(ew3), max(ew4), max(ew5)])
MgIIVEL50_list = array([vel501, vel502, vel503, vel504, vel505])



In [256]:
tmploglam = log10(tmpwave)
# Get the Mask array
# Region Mg II
# Range
waveleft = 2550.
waveright = 2650.
# Lines intersted
this_nabslines = 5
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4'),
                                               ('WAVELEFT', 'f4'), ('WAVERIGHT', 'f4')])
this_absorption[0] = ('MnII 2576.88', 2576.88-3, 0.2, 2576.88, 2570., 2580.)
this_absorption[1] = ('FeII 2586.65', 2586.65-3, 0.2, 2586.65, 2583., 2589.)
this_absorption[2] = ('MnII 2594.50', 2594.50-3, 0.2, 2594.50, 2590., 2615.)
this_absorption[3] = ('FeII 2600.17', 2600.17+1.5, 0.2, 2600.17, 2590., 2615.)
this_absorption[4] = ('MnII 2606.46', 2606.46+1.5, 0.2, 2606.46, 2590., 2615.)

this_nemlines = 3
this_emission = zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4'),
                                            ('WAVELEFT', 'f4'), ('WAVERIGHT', 'f4')])
this_emission[0] = ('FeII* 2626.45', 2626.45+1.5, 1.3, 2626.45, 2590., 2615.)
this_emission[1] = ('FeII* 2612.65', 2612.65+1.5, 1.3, 2612.65, 2621., 2631.)

# Mask out range and lines
mask = ones(tmpwave.size)
mask[(tmpwave<waveleft) | (tmpwave>waveright)] = 0
for i in arange(this_nabslines):
    mask[(tmpwave>this_absorption[i]['WAVELEFT']) & (tmpwave<this_absorption[i]['WAVERIGHT'])] = 0
for i in arange(this_nemlines):
    mask[(tmpwave>this_emission[i]['WAVELEFT']) & (tmpwave<this_emission[i]['WAVERIGHT'])] = 0

index1 = ii[sort_index[200:1000]]
index2 = ii[sort_index[1200:2000]]
index3 = ii[sort_index[2200:3000]]
index4 = ii[sort_index[3200:4000]]
index5 = ii[sort_index[4200:-100]]
(median_norm_median1, mean_norm_median1) = ebossspec.composite_engine(tmploglam, tmpflux[:,index1], 
                                                                      tmpivar[:,index1], mask, polyorder=3)
(median_norm_median2, mean_norm_median2) = ebossspec.composite_engine(tmploglam, tmpflux[:,index2], 
                                                                      tmpivar[:,index2], mask, polyorder=3)
(median_norm_median3, mean_norm_median4) = ebossspec.composite_engine(tmploglam, tmpflux[:,index3], 
                                                                      tmpivar[:,index3], mask, polyorder=3)
(median_norm_median4, mean_norm_median4) = ebossspec.composite_engine(tmploglam, tmpflux[:,index4], 
                                                                      tmpivar[:,index4], mask, polyorder=3)
(median_norm_median5, mean_norm_median5) = ebossspec.composite_engine(tmploglam, tmpflux[:,index5], 
                                                                      tmpivar[:,index5], mask, polyorder=3)

In [257]:
fig = figure(figsize=(20,8))
this_ylim = [0.35, 1.45]
ax = fig.add_subplot(111)
dwave = median(tmpwave[1:]-tmpwave[:-1])
ax.plot(tmpwave+dwave/2., median_norm_median1, 'r', drawstyle='steps', linewidth=3)
ax.set_ylim(this_ylim)
ax.set_xlim(2570, 2631)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'Normalized $f(\lambda)$', fontsize=20)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='both', length=7, width=2, labelsize=15)

this_nabslines = 5
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('MnII 2576.88', 2576.88-1.2, 0.4, 2576.88)
this_absorption[1] = ('FeII 2586.65', 2586.65+0.75, 0.4, 2586.65)
this_absorption[2] = ('MnII 2594.50', 2594.50+0.75, 0.4, 2594.50)
this_absorption[3] = ('FeII 2600.17', 2600.17+0.75, 0.4, 2600.17)
this_absorption[4] = ('MnII 2606.46', 2606.46+0.75, 0.4, 2606.46)

this_nemlines = 3
this_emission = zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('FeII* 2626.45', 2626.45+1.0, 1.2, 2626.45)
this_emission[1] = ('FeII* 2612.65', 2612.65+0.5, 1.2, 2612.65)
#this_emission[2] = ('FeII* 2632.11', 2632.11+10., 1.2, 2632.11)

for i in arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=14, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], this_ylim, '--k')
for i in arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=14)
    ax.plot([etmp['WAVE'], etmp['WAVE']], this_ylim, ':g', linewidth=1)
    
# Replot
ax.plot(tmpwave+dwave/2., median_norm_median5, 'blue', drawstyle='steps', linewidth=3)
#ax.plot(tmpwave+dwave/2., median_norm_median4, 'brown', drawstyle='steps', linewidth=2)
#ax.plot(tmpwave+dwave/2., median_norm_median3, 'green', drawstyle='steps', linewidth=2)
ax.plot(tmpwave+dwave/2., median_norm_median2, 'green', drawstyle='steps', linewidth=3)
#ax.plot(tmpwave+dwave/2., median_norm_median1, 'blue', drawstyle='steps', linewidth=2)
ax.text(2571, 1.350, 'Blue: High [OII] EW', color='blue', fontsize=17, fontname='serif')
ax.text(2571, 1.300, 'Green: Medium [OII] EW', color='green', fontsize=17, fontname='serif')
ax.text(2571, 1.250, 'Red: Low [OII] EW', color='red', fontsize=17, fontname='serif')

#nlines = 2
#lines = zeros(nlines, dtype=[('SIGN', 'i'),('ELEMENT','S20'),('WAVE','f4'),('EW','f4'), ('WAVELEFT', 'f4')])
#lines[0] = (-1, 'MgII', 2796.35, 2., 2789.)
#lines[1] = (-1, 'MgII', 2803.53, 2., 2798.)
#ew_profile1 = ebossspec.line_property(tmploglam, median_norm_median1-1., lines, npixels=20)
#ew_profile2 = ebossspec.line_property(tmploglam, median_norm_median2-1., lines, npixels=20)
#ew_profile3 = ebossspec.line_property(tmploglam, median_norm_median3-1., lines, npixels=20)
#ew_profile4 = ebossspec.line_property(tmploglam, median_norm_median4-1., lines, npixels=20)
#ew_profile5 = ebossspec.line_property(tmploglam, median_norm_median5-1., lines, npixels=20)
#print(max(-ravel(ew_profile1[0]['EW'])))
#print(max(-ravel(ew_profile2[0]['EW'])))
#print(max(-ravel(ew_profile3[0]['EW'])))
#print(max(-ravel(ew_profile4[0]['EW'])))
#print(max(-ravel(ew_profile5[0]['EW'])))
#MgIIEW_list = array([max(-ravel(ew_profile1[0]['EW'])), max(-ravel(ew_profile2[0]['EW'])),
#                     max(-ravel(ew_profile3[0]['EW'])), max(-ravel(ew_profile4[0]['EW'])),
#                     max(-ravel(ew_profile5[0]['EW']))])


Out[257]:
<matplotlib.text.Text at 0x230b9c490>

In [258]:
tmploglam = log10(tmpwave)
# Get the Mask array
# Region Mg II
# Range
waveleft = 3500.
waveright = 3775.
# Lines intersted
#this_nabslines = 5
#this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4'),
#                                               ('WAVELEFT', 'f4'), ('WAVERIGHT', 'f4')])
#this_absorption[0] = ('MnII 2576.88', 2576.88-3, 0.2, 2576.88, 2570., 2580.)
#this_absorption[1] = ('FeII 2586.65', 2586.65-3, 0.2, 2586.65, 2583., 2589.)
#this_absorption[2] = ('MnII 2594.50', 2594.50-3, 0.2, 2594.50, 2590., 2615.)
#this_absorption[3] = ('FeII 2600.17', 2600.17+1.5, 0.2, 2600.17, 2590., 2615.)
#this_absorption[4] = ('MnII 2606.46', 2606.46+1.5, 0.2, 2606.46, 2590., 2615.)

this_nemlines = 3
this_emission = zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4'),
                                            ('WAVELEFT', 'f4'), ('WAVERIGHT', 'f4')])
this_emission[0] = ('[OII]', 3727.+20., 1.75, 3727., 3723., 3732.)


# Mask out range and lines
mask = ones(tmpwave.size)
mask[(tmpwave<waveleft) | (tmpwave>waveright)] = 0
#for i in arange(this_nabslines):
#    mask[(tmpwave>this_absorption[i]['WAVELEFT']) & (tmpwave<this_absorption[i]['WAVERIGHT'])] = 0
for i in arange(this_nemlines):
    mask[(tmpwave>this_emission[i]['WAVELEFT']) & (tmpwave<this_emission[i]['WAVERIGHT'])] = 0

index1 = ii[sort_index[500:1200]]
index2 = ii[sort_index[1200:2000]]
index3 = ii[sort_index[2200:3000]]
index4 = ii[sort_index[3200:4000]]
index5 = ii[sort_index[4200:-100]]
(median_norm_median1, mean_norm_median1) = ebossspec.composite_engine(tmploglam, tmpflux[:,index1], 
                                                                      tmpivar[:,index1], mask, polyorder=3)
(median_norm_median2, mean_norm_median2) = ebossspec.composite_engine(tmploglam, tmpflux[:,index2], 
                                                                      tmpivar[:,index2], mask, polyorder=3)
(median_norm_median3, mean_norm_median4) = ebossspec.composite_engine(tmploglam, tmpflux[:,index3], 
                                                                      tmpivar[:,index3], mask, polyorder=3)
(median_norm_median4, mean_norm_median4) = ebossspec.composite_engine(tmploglam, tmpflux[:,index4], 
                                                                      tmpivar[:,index4], mask, polyorder=3)
(median_norm_median5, mean_norm_median5) = ebossspec.composite_engine(tmploglam, tmpflux[:,index5], 
                                                                      tmpivar[:,index5], mask, polyorder=3)

In [259]:
fig = figure(figsize=(12,7))
ax = fig.add_subplot(111)
dwave = median(tmpwave[1:]-tmpwave[:-1])
ax.plot(tmpwave+dwave/2., median_norm_median1, 'r', drawstyle='steps', linewidth=2)
this_ylim = [0.15, 11.]
ax.set_ylim(this_ylim)
ax.set_xlim(3680, 3780)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'Normalized $f(\lambda)$', fontsize=20)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='both', length=7, width=2, labelsize=15)

this_nabslines = 8
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('TiII 3067.24', 3067.24-30., 0.22, 3067.24)
this_absorption[1] = ('TiII 3073.86', 3073.86+10., 0.22, 3073.86)
#this_absorption[2] = ('AlI 3083.05', 3083.05+1.5, 0.23, 3083.05)
this_absorption[3] = ('TiII 3230.12', 3230.12-30., 0.23, 3230.12)
this_absorption[4] = ('TiII 3242.92', 3242.92+10., 0.23, 3242.92)
this_absorption[5] = ('TiII 3384.73', 3384.73+10., 0.23, 3384.73)
this_absorption[6] = ('CaII 3934.78', 3934.78-30., 0.23, 3934.78)
this_absorption[7] = ('CaII 3969.59', 3969.59+10., 0.23, 3969.59)

this_nemlines = 3
this_emission = zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('[OII] 3727.1', 3727.1-3., 8, 3727.1)
this_emission[1] = ('[OII] 3729.8', 3729.8+2., 8, 3729.9)
#this_emission[2] = ('[NeIII] 3869.77', 3869.77+10., 1.4, 3869.77)

this_nbalmer = 10
this_balmer = zeros(this_nbalmer, dtype=[('NAME','S10'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
#this_balmer[0] = (r'$\alpha$', 6563.-35., 0.25, 6563.)
#this_balmer[1] = (r'$\beta$', 4861.-35., 0.25, 4861.)
#this_balmer[2] = (r'$\gamma$', 4341.-35., 0.265, 4341.)
#this_balmer[3] = (r'$\delta$', 4102.-35., 0.24, 4102.)
this_balmer[4] = (r'$\epsilon$', 3970.+10., 0.9, 3907.)
this_balmer[5] = (r'$\zeta$', 3889.-10., 0.85, 3889.)
this_balmer[6] = (r'$\eta$', 3835.38-10., 0.75, 3835.38)
this_balmer[7] = (r'$\theta$', 3797.90-10., 0.8, 3797.90)
this_balmer[8] = (r'$\iota$', 3770.63-7., 0.82, 3770.63)
this_balmer[9] = (r'$\kappa$', 3750.15-10., 0.77, 3750.15)

#for i in arange(this_nabslines):
#    atmp = this_absorption[i]
#    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=14, rotation='vertical',va='bottom')
#    ax.plot([atmp['WAVE'], atmp['WAVE']], this_ylim, '--k')
#for i in arange(this_nbalmer):
#    btmp = this_balmer[i]
#    ax.text(btmp['XPOS'], btmp['YPOS'], btmp['NAME'], color='brown', fontsize=20)
for i in arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=15)
    ax.plot([etmp['WAVE'], etmp['WAVE']], this_ylim, ':g', linewidth=3)
   
# Replot
ax.plot(tmpwave+dwave/2., median_norm_median5, 'blue', drawstyle='steps', linewidth=3)
#ax.plot(tmpwave+dwave/2., median_norm_median4, 'brown', drawstyle='steps', linewidth=2)
#ax.plot(tmpwave+dwave/2., median_norm_median3, 'green', drawstyle='steps', linewidth=2)
ax.plot(tmpwave+dwave/2., median_norm_median2, 'green', drawstyle='steps', linewidth=3)
#ax.plot(tmpwave+dwave/2., median_norm_median1, 'blue', drawstyle='steps', linewidth=2)
ax.text(3682, 10.40, 'Blue: High [OII] EW', color='blue', fontsize=17, fontname='serif')
ax.text(3682, 9.85, 'Green: Medium [OII] EW', color='green', fontsize=17, fontname='serif')
ax.text(3682, 9.30, 'Red: Low [OII] EW', color='red', fontsize=17, fontname='serif')

nlines = 1
lines = zeros(nlines, dtype=[('SIGN', 'i'),('ELEMENT','S20'),('WAVE','f4'),('EW','f4'), ('WAVELEFT', 'f4')])
lines[0] = (1, 'OII', 3728.45, 2., 3720.)
ew_profile1 = ebossspec.line_property(tmploglam, median_norm_median1-1., lines, npixels=20)
ew_profile2 = ebossspec.line_property(tmploglam, median_norm_median2-1., lines, npixels=20)
ew_profile3 = ebossspec.line_property(tmploglam, median_norm_median3-1., lines, npixels=20)
ew_profile4 = ebossspec.line_property(tmploglam, median_norm_median4-1., lines, npixels=20)
ew_profile5 = ebossspec.line_property(tmploglam, median_norm_median5-1., lines, npixels=20)
print(max(ravel(ew_profile1[0]['EW'])))
print(max(ravel(ew_profile2[0]['EW'])))
print(max(ravel(ew_profile3[0]['EW'])))
print(max(ravel(ew_profile4[0]['EW'])))
print(max(ravel(ew_profile5[0]['EW'])))
OIIEW_list = array([max(ravel(ew_profile1[0]['EW'])), max(ravel(ew_profile2[0]['EW'])),
                    max(ravel(ew_profile3[0]['EW'])), max(ravel(ew_profile4[0]['EW'])),
                    max(ravel(ew_profile5[0]['EW']))])


6.4722
12.6608
20.0938
27.4593
56.0733

In [190]:
tmploglam = log10(tmpwave)
# Get the Mask array
# Region Mg II
# Range
waveleft = 2305.
waveright = 2410.
# Lines intersted
this_nabslines = 6
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4'),
                                               ('WAVELEFT', 'f4'), ('WAVERIGHT', 'f4')])
#this_absorption[0] = ('FeII 2249.88', 2249.88-5, 0.2, 2249.88, )
#this_absorption[1] = ('FeII 2260.78', 2260.78+1.5, 0.2, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+1.5, 0.2, 2344.21, 2341., 2350.)
this_absorption[3] = ('FeII 2374.46', 2374.46+1.5, 0.2, 2374.46, 2372., 2376.5)
this_absorption[4] = ('FeII 2382.76', 2382.76+1.5, 0.2, 2382.76, 2379., 2400.)
#this_absorption[5] = ('CIII 2297.58', 2297.58+1.5, 0.2, 2297.58)


this_nemlines = 3
this_emission = zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4'),
                                            ('WAVELEFT', 'f4'), ('WAVERIGHT', 'f4')])
this_emission[0] = ('CII] 2327.64', 2327.64+1., 1.3, 2327.64, 2320., 2331.)
this_emission[1] = ('FeII* 2396.36', 2396.36+1., 1.3, 2396.36, 2379., 2400.)
this_emission[2] = ('FeII* 2365.55', 2365.55+1., 1.3, 2365.55, 2361., 2370.)

# Mask out range and lines
mask = ones(tmpwave.size)
mask[(tmpwave<waveleft) | (tmpwave>waveright)] = 0
for i in arange(this_nabslines):
    mask[(tmpwave>this_absorption[i]['WAVELEFT']) & (tmpwave<this_absorption[i]['WAVERIGHT'])] = 0
for i in arange(this_nemlines):
    mask[(tmpwave>this_emission[i]['WAVELEFT']) & (tmpwave<this_emission[i]['WAVERIGHT'])] = 0

index1 = ii[sort_index[200:1000]]
index2 = ii[sort_index[1200:2000]]
index3 = ii[sort_index[2200:3000]]
index4 = ii[sort_index[3200:4000]]
index5 = ii[sort_index[4200:-100]]
(median_norm_median1, mean_norm_median1) = ebossspec.composite_engine(tmploglam, tmpflux[:,index1], 
                                                                      tmpivar[:,index1], mask, polyorder=3)
(median_norm_median2, mean_norm_median2) = ebossspec.composite_engine(tmploglam, tmpflux[:,index2], 
                                                                      tmpivar[:,index2], mask, polyorder=3)
(median_norm_median3, mean_norm_median4) = ebossspec.composite_engine(tmploglam, tmpflux[:,index3], 
                                                                      tmpivar[:,index3], mask, polyorder=3)
(median_norm_median4, mean_norm_median4) = ebossspec.composite_engine(tmploglam, tmpflux[:,index4], 
                                                                      tmpivar[:,index4], mask, polyorder=3)
(median_norm_median5, mean_norm_median5) = ebossspec.composite_engine(tmploglam, tmpflux[:,index5], 
                                                                      tmpivar[:,index5], mask, polyorder=3)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-190-645b74093bb2> in <module>()
     32     mask[(tmpwave>this_emission[i]['WAVELEFT']) & (tmpwave<this_emission[i]['WAVERIGHT'])] = 0
     33 
---> 34 index1 = ii[sort_index[200:1000]]
     35 index2 = ii[sort_index[1200:2000]]
     36 index3 = ii[sort_index[2200:3000]]

NameError: name 'ii' is not defined

In [191]:
fig = figure(figsize=(20,8))
this_ylim = [0.35, 1.45]
ax = fig.add_subplot(111)
dwave = median(tmpwave[1:]-tmpwave[:-1])
ax.plot(tmpwave+dwave/2., median_norm_median1, 'g', drawstyle='steps', linewidth=2)
ax.set_ylim(this_ylim)
ax.set_xlim(waveleft, waveright)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'Normalized $f(\lambda)$', fontsize=20)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='both', length=7, width=2, labelsize=15)

this_nabslines = 6
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
#this_absorption[0] = ('FeII 2249.88', 2249.88-5, 0.2, 2249.88)
#this_absorption[1] = ('FeII 2260.78', 2260.78+1.5, 0.2, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+1.5, 0.4, 2344.21)
this_absorption[3] = ('FeII 2374.46', 2374.46+1.5, 0.4, 2374.46)
this_absorption[4] = ('FeII 2382.76', 2382.76+1.5, 0.4, 2382.76)
this_absorption[5] = ('CIII 2297.58', 2297.58+1.5, 0.4, 2297.58)


this_nemlines = 3
this_emission = zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('CII] 2327.64', 2327.64+1., 1.2, 2327.64)
this_emission[1] = ('FeII* 2396.36', 2396.36+1., 1.2, 2396.36)
this_emission[2] = ('FeII* 2365.55', 2365.55+1., 1.2, 2365.55)

#this_emission[2] = ('FeII* 2632.11', 2632.11+10., 1.2, 2632.11)

for i in arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=14, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], this_ylim, '--k')
for i in arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=14)
    ax.plot([etmp['WAVE'], etmp['WAVE']], this_ylim, ':g', linewidth=1)
    
# Replot
ax.plot(tmpwave+dwave/2., median_norm_median5, 'blue', drawstyle='steps', linewidth=2)
#ax.plot(tmpwave+dwave/2., median_norm_median4, 'brown', drawstyle='steps', linewidth=2)
#ax.plot(tmpwave+dwave/2., median_norm_median3, 'green', drawstyle='steps', linewidth=2)
ax.plot(tmpwave+dwave/2., median_norm_median2, 'red', drawstyle='steps', linewidth=2)
#ax.plot(tmpwave+dwave/2., median_norm_median1, 'blue', drawstyle='steps', linewidth=2)
ax.text(waveleft+1., 1.350, 'Blue: High [OII] EW', color='blue', fontsize=17, fontname='serif')
ax.text(waveleft+1., 1.300, 'Red: Medium [OII] EW', color='red', fontsize=17, fontname='serif')
ax.text(waveleft+1., 1.250, 'Green: Low [OII] EW', color='green', fontsize=17, fontname='serif')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-191-7dafec07cedc> in <module>()
      3 ax = fig.add_subplot(111)
      4 dwave = median(tmpwave[1:]-tmpwave[:-1])
----> 5 ax.plot(tmpwave+dwave/2., median_norm_median1, 'g', drawstyle='steps', linewidth=2)
      6 ax.set_ylim(this_ylim)
      7 ax.set_xlim(waveleft, waveright)

NameError: name 'median_norm_median1' is not defined

In [157]:
print min(tmpwave), max(tmpwave)


1900.3255784 7199.9256879

In [227]:
fig = figure(figsize=(8,8))
ax = fig.add_subplot(111)
ax.plot(OIIEW_list[:], MgIIEW_list[:], 'o', ms=30)
#this_ylim = [0.15, 11.]
#ax.set_ylim(this_ylim)
#ax.set_xlim(3680, 3780)
ax.set_title(r'Correlations between UV lines and [OII] $\lambda$3727', fontsize=15)
ax.set_xlabel(r'$W_{\rm O\,II}^{\lambda3727}$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'$W_{\rm UV\,Lines}$ [$\AA$]', fontsize=20)
for axis in ['top','bottom','left','right']:
    ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='both', length=7, width=2, labelsize=15)



In [179]:
rest_loc = searchsorted(tmpwave, [2770, 2830])
temp = vstack((tmpwave[rest_loc[0]:rest_loc[1]], median_norm_median5[rest_loc[0]:rest_loc[1]])).T
savetxt('temp.txt', temp)

In [254]:
fig = figure(figsize=(8,8))
ax = fig.add_subplot(111)
ax.plot(OIIEW_list[1:], MgIIVEL50_list[1:], 'o', ms=30)
this_ylim = [-90, -200.]
ax.set_ylim(this_ylim)
#ax.set_xlim(3680, 3780)
ax.set_title(r'Correlations between UV lines and [OII] $\lambda$3727', fontsize=15)
ax.set_xlabel(r'$W_{\rm O\,II}^{\lambda3727}$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'$V_{50}$ [km/s]', fontsize=20)
for axis in ['top','bottom','left','right']:
    ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='both', length=7, width=2, labelsize=15)
ax.set_xscale('log')



In [180]:
plot(tmpwave, median_norm_median5)
xlim(2770,2830)


Out[180]:
(2770, 2830)

In [233]:
fig = figure(figsize=(10,8))
ax = fig.add_subplot(111)
ax.plot(tmpwave, tmpmedian, lw=1)
ax.set_xlim(7100, 7200)
ax.set_ylim(0.30, 0.550)
ax.plot([2422.56, 2422.56], [0.3, 0.50])
ax.plot([4070, 4070], [0.4, 0.50])
ax.plot([4077, 4077], [0.4, 0.50])


Out[233]:
[<matplotlib.lines.Line2D at 0x273800e90>]

In [195]:
fig = plt.figure(figsize=(9,7))
ax = fig.add_subplot(111)
ax.tick_params(axis='both', which='minor', length=4, width=2, labelsize=20, pad=8)
ax.tick_params(axis='both', which='major', length=8, width=2, labelsize=20, pad=8)
n, bins, patches = ax.hist(objs_ori[(objs_ori['zGOOD']==1) & (galaxytype=='GALAXY')]['Z'], 
                           bins=np.arange(0, 2.0, 0.05), edgecolor='blue', fill=False)
this_ylim = [0, 1500]
ax.set_ylim(this_ylim)
ax.set_xlim(0, 1.5)
ax.set_title('Redshift Distribution', fontsize=20)
ax.set_xlabel(r'$z$', fontsize=26)
ax.set_ylabel(r'$\Delta N$ ($\Delta z=0.05$)', fontsize=20)
n, bins, patches = ax.hist(objs_ori[((objs_ori['zGOOD']==1) & (objs_ori['Z']>0.6)) & (objs_ori['Z']<1.2)]['Z'], 
                           bins=np.arange(0, 2.0, 0.05), color='blue')
ax.text(0.133, 1300, ' Solid ($0.6<z<1.2$)', color='blue', fontsize=18)
#ax.text(1.33, 1230, ' used in this work', color='blue', fontsize=18)
#ax.text(1.33, 1160, ' N = 8620', color='blue', fontsize=18)
ax.text(0.133, 1230, ' $N=8620$', color='blue', fontsize=18)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 1/eBOSS_redshift_distribution.eps')



In [272]:
imgii = (where(logical_and(logical_and(objs_ori['zGOOD']==1, objs_ori['Z']>0.35), objs_ori['Z']<1.2)))[0]
ifeii2600 = (where(logical_and(logical_and(objs_ori['zGOOD']==1, objs_ori['Z']>0.43), objs_ori['Z']<1.2)))[0]
ifeii2350 = (where(logical_and(logical_and(objs_ori['zGOOD']==1, objs_ori['Z']>0.66), objs_ori['Z']<1.2)))[0]
iused = (where(logical_and(logical_and(objs_ori['zGOOD']==1, objs_ori['Z']>(3600./2200.-1.)), 
                           objs_ori['Z']<10400./4050.-1.)))[0]
print imgii.size, ifeii2600.size, ifeii2550.size, iused.size


11659 10968 8534 9023

In [21]:
galaxytype = objs_ori['CLASS']
zgood = objs_ori['zGOOD']
z = objs_ori['Z']

In [27]:
from cookb_signalsmooth import smooth

In [41]:
filename = '/Users/Benjamin/AstroData/HST/IUE/HD63922/lp19251'
Odat = genfromtxt(filename, skip_header=19)
Owave = arange(12250)*0.1+1900.
Oflux = Odat[:,0]
iOwave = (where(logical_and(logical_and(Oflux>1E-11, Owave>2200.), Owave<2900.)))[0]
x = Owave[iOwave]
y = Oflux[iOwave]
z = np.polyfit(x, y, 3)
p = np.poly1d(z)
ycont = p(x)
yy = y/ycont

In [74]:
fig = figure(figsize=(20,8))
this_ylim = [0.85, 1.18]
ax = fig.add_subplot(111)
dwave = median(outwave[1:]-outwave[:-1])
#ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*2.
#ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=2)
ax.set_ylim(this_ylim)
ax.set_xlim(2800, 3600)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'Normalized $f(\lambda)$', fontsize=20)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='both', length=7, width=2, labelsize=15)
#ax.text(2205, 1.90, 'Blue: Emission Line Galaxies at 0.6<z<1.0 (eBOSS 2015)', color='b', fontsize=16, fontname='serif')
#ax.text(2205, 1.83, r'Red:  Quasar Absorption-line Systems at 0.4<z<2.2 (Zhu & Menard  2013)', color='r', fontsize=16, fontname='serif')

this_nabslines = 13
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('FeII 2249.88', 2249.88-8.5, 0.2, 2249.88)
this_absorption[1] = ('FeII 2260.78', 2260.78+2.5, 0.2, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+2.5, 0.2, 2344.21)
this_absorption[3] = ('FeII 2374.46', 2374.46-8.5, 0.2, 2374.46)
this_absorption[4] = ('FeII 2382.76', 2382.76+2.5, 0.2, 2382.76)
#this_absorption[5] = ('MnII 2576.88', 2576.88-3, 0.2, 2576.88)
this_absorption[6] = ('FeII 2586.65', 2586.65-8.5, 0.18, 2586.65)
#this_absorption[7] = ('MnII 2594.50', 2594.50-3, 0.2, 2594.50)
this_absorption[8] = ('FeII 2600.17', 2600.17+2.5, 0.18, 2600.17)
#this_absorption[9] = ('MnII 2606.46', 2606.46+1.5, 0.2, 2606.46)
this_absorption[10] = ('MgII 2796.35', 2796.35-10.5, 0.2, 2796.35)
this_absorption[11] = ('MgII 2803.53', 2803.53+3.5, 0.2, 2803.53)
this_absorption[12] = ('MgI 2852.96', 2852.96+3.5, 0.21, 2852.96)

this_nemlines = 11
this_emission = zeros(this_nemlines, dtype=[('NAME','S25'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('CII] doublet', 2324.21-9.0, 1.35, 2324.21)
this_emission[1] = ('CII]* triplet', 2328.83+2.5, 1.35, 2328.83)
#this_emission[2] = ('', 2328.83+2.5, 1.11, 2328.83)
this_emission[3] = ('FeII* 2365.55', 2365.55-8.5, 1.3, 2365.55)
this_emission[4] = ('FeII* 2396.36', 2396.36+2.5, 1.3, 2396.36)
this_emission[5] = ('FeII* 2626.45', 2626.45+2.5, 1.3, 2626.45)
this_emission[6] = ('FeII* 2612.65', 2612.65-8.5, 1.3, 2612.65)
#this_emission[7] = ('[NeIV] doublet+FeIII', 2422.56-9.5, 1.2, 2422.56)
this_emission[7] = ('[NeIV] doublet', 2422.56-9.5, 1.3, 2422.56)
this_emission[8] = ('2422.56 2425.14', 2425.14+2.5, 1.28, 2425.14)
this_emission[9] = ('[OII] doublet', 2470.97-9.5, 1.3, 2470.97)
this_emission[10] = ('2470.97 2471.09', 2471.09+2.5, 1.285, 2471.09)


#this_emission[5] = ('FeII* 2632.11', 2632.11+2.5, 1.3, 2632.11)
#this_emission[5] = ('FeII* 2467.98', 2467.98+2.5, 1.3, 2467.98)

this_nstellarabs = 2
this_stellarabs = zeros(this_nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_stellarabs[0] = ('CIII 2297.58', 2297.58+2.5, 0.48, 2297.58)
this_stellarabs[1] = ('CoI 2295.87', 2295.87+2.5, 0.48, 2295.87)


for i in arange(this_nabslines):
    atmp = this_absorption[i]
#    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=14, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1.0, this_ylim[0]], '--k', linewidth=2)
for i in arange(this_nemlines):
    etmp = this_emission[i]
#    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=14)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1.0, this_ylim[1]], '--g', linewidth=2)
for i in arange(this_nstellarabs):
    atmp = this_stellarabs[i]
#    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=14, rotation='vertical',va='bottom', color='brown')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [0.43, 0.85], '-', color='brown')
    
# MnII
ax.plot([2576.88-0., 2576.88-0], [1, 0.53], '--k', lw=2)
#ax.text(2576.88-9.5, 0.545, 'MnII 2576.88', fontsize=14, rotation='vertical',va='bottom')
ax.plot([2594.50-0., 2594.50-0.], [this_ylim[0], 1.48], '--k', lw=2)
#ax.text(2594.50-9.5, 1.1, 'MnII 2594.50', fontsize=14, rotation='vertical',va='bottom')
ax.plot([2606.46-0., 2606.46-0.], [1, 0.53], '--k', lw=2)
#ax.text(2606.46+2.5, 0.545, 'MnII 2606.46', fontsize=14, rotation='vertical',va='bottom')
#ax.text(2328.83+2.0, 1.17, '2326.11 2327.64 2328.83', color='g', rotation='vertical',va='bottom', fontsize=12)

# Replot
#ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1.5)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*2.
ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=2)
#ax.plot(x-2., smooth(((yy-0.03)-1.)*1.2+1., 30), 'r', linewidth=2)


Out[74]:
[<matplotlib.lines.Line2D at 0x22f2f3d90>]

In [63]:
reload(ebossspec)


Out[63]:
<module 'ebossspec' from 'ebossspec.py'>

In [76]:
(newoutwave, newfluxmedian, newfluxmean) = ebossspec.new_feiimgii_composite()


Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave01800_03600A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave03600_07200A.fits.
(8620,)

In [38]:
fig = figure(figsize=(20,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
dwave = median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., norm_fluxmedian, 'b', drawstyle='steps', linewidth=1)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*2.
#ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=2)
ax.set_ylim(this_ylim)
ax.set_xlim(2200, 2900)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'Normalized $f(\lambda)$', fontsize=20)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.0)
ax.tick_params(axis='both', which='both', length=7, width=2, labelsize=15)
ax.text(2205, 1.90, 'Blue: Emission Line Galaxies at 0.6<z<1.0 (eBOSS 2015)', color='b', fontsize=16, fontname='serif')
ax.text(2205, 1.83, r'Red:  Quasar Absorption-line Systems at 0.4<z<2.2 (Zhu & M${\rm {\'e}}$nard  2013)', color='r', fontsize=16, fontname='serif')

this_nabslines = 13
this_absorption = zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('FeII 2249.88', 2249.88-8.5, 0.2, 2249.88)
this_absorption[1] = ('FeII 2260.78', 2260.78+2.5, 0.2, 2260.78)
this_absorption[2] = ('FeII 2344.21', 2344.21+2.5, 0.2, 2344.21)
this_absorption[3] = ('FeII 2374.46', 2374.46-8.5, 0.2, 2374.46)
this_absorption[4] = ('FeII 2382.76', 2382.76+2.5, 0.2, 2382.76)
#this_absorption[5] = ('MnII 2576.88', 2576.88-3, 0.2, 2576.88)
this_absorption[6] = ('FeII 2586.65', 2586.65-8.5, 0.18, 2586.65)
#this_absorption[7] = ('MnII 2594.50', 2594.50-3, 0.2, 2594.50)
this_absorption[8] = ('FeII 2600.17', 2600.17+2.5, 0.18, 2600.17)
#this_absorption[9] = ('MnII 2606.46', 2606.46+1.5, 0.2, 2606.46)
this_absorption[10] = ('MgII 2796.35', 2796.35-10.5, 0.2, 2796.35)
this_absorption[11] = ('MgII 2803.53', 2803.53+3.5, 0.2, 2803.53)
this_absorption[12] = ('MgI 2852.96', 2852.96+3.5, 0.21, 2852.96)

this_nemlines = 11
this_emission = zeros(this_nemlines, dtype=[('NAME','S25'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('CII] doublet', 2324.21-9.0, 1.35, 2324.21)
this_emission[1] = ('CII]* triplet', 2328.83+2.5, 1.35, 2328.83)
#this_emission[2] = ('', 2328.83+2.5, 1.11, 2328.83)
this_emission[3] = ('FeII* 2365.55', 2365.55-8.5, 1.3, 2365.55)
this_emission[4] = ('FeII* 2396.36', 2396.36+2.5, 1.3, 2396.36)
this_emission[5] = ('FeII* 2626.45', 2626.45+2.5, 1.3, 2626.45)
this_emission[6] = ('FeII* 2612.65', 2612.65-8.5, 1.3, 2612.65)
#this_emission[7] = ('[NeIV] doublet+FeIII', 2422.56-9.5, 1.2, 2422.56)
this_emission[7] = ('[NeIV] doublet', 2422.56-9.5, 1.3, 2422.56)
this_emission[8] = ('2422.56 2425.14', 2425.14+2.5, 1.28, 2425.14)
this_emission[9] = ('[OII] doublet', 2470.97-9.5, 1.3, 2470.97)
this_emission[10] = ('2470.97 2471.09', 2471.09+2.5, 1.285, 2471.09)


#this_emission[5] = ('FeII* 2632.11', 2632.11+2.5, 1.3, 2632.11)
#this_emission[5] = ('FeII* 2467.98', 2467.98+2.5, 1.3, 2467.98)

this_nstellarabs = 2
this_stellarabs = zeros(this_nstellarabs, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_stellarabs[0] = ('CIII 2297.58', 2297.58+2.5, 0.48, 2297.58)
this_stellarabs[1] = ('CoI 2295.87', 2295.87+2.5, 0.48, 2295.87)


for i in arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=14, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1.0, this_ylim[0]], '--k', linewidth=2)
for i in arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=14)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1.0, this_ylim[1]], '--g', linewidth=2)
for i in arange(this_nstellarabs):
    atmp = this_stellarabs[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=14, rotation='vertical',va='bottom', color='brown')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [0.43, 0.85], '-', color='brown')
    
# MnII
ax.plot([2576.88-0., 2576.88-0], [1, 0.53], '--k', lw=2)
ax.text(2576.88-9.5, 0.545, 'MnII 2576.88', fontsize=14, rotation='vertical',va='bottom')
ax.plot([2594.50-0., 2594.50-0.], [this_ylim[0], 1.48], '--k', lw=2)
ax.text(2594.50-9.5, 1.1, 'MnII 2594.50', fontsize=14, rotation='vertical',va='bottom')
ax.plot([2606.46-0., 2606.46-0.], [1, 0.53], '--k', lw=2)
ax.text(2606.46+2.5, 0.545, 'MnII 2606.46', fontsize=14, rotation='vertical',va='bottom')
#ax.text(2328.83+2.0, 1.17, '2326.11 2327.64 2328.83', color='g', rotation='vertical',va='bottom', fontsize=12)

# Replot
ax.plot(outwave+dwave/2., norm_fluxmean, 'b', drawstyle='steps', linewidth=1.5)
yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*2.
#ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=2)
ax.plot(newoutwave+dwave/2., newfluxmedian, 'r', linewidth=2)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-38-eec3f57ad10b> in <module>()
      3 ax = fig.add_subplot(111)
      4 dwave = median(outwave[1:]-outwave[:-1])
----> 5 ax.plot(outwave+dwave/2., norm_fluxmedian, 'b', drawstyle='steps', linewidth=1)
      6 yabs = 1.-(1.-absorberstack['FLUXMEDIAN'])*2.
      7 #ax.plot(absorberstack['WAVE'], yabs, 'r', linewidth=2)

NameError: name 'norm_fluxmedian' is not defined

In [ ]:


In [14]:
fig, axes = subplots(figsize=(20,18), ncols=2, nrows=6)
axesall = axes.ravel()
fig.subplots_adjust(hspace=0, wspace=0)
minorLocator   = MultipleLocator(100)
for i, ax in zip(arange(12), axesall[0:10]):
    if i<=1:
        ax.xaxis.tick_top()
    else:
        setp(ax.get_xticklabels(), visible=False)
for ax in axesall[1:13:2]:
    ax.yaxis.tick_right()
    #setp(ax.get_yticklabels(), visible=False)
xlimits = [-2490, 1990]

wave0 = array([2852.96, 3728.48, 2803.53, 2626.45, 2600.17, 2471.03, 2382.76, 2396.36, 2344.21, 2365.55, 2260.78, 2326.17])
text0 = array(['MgI 2852.96', '[OII] 3728.48', 
               'MgII 2803.53', 'FeII* 2626.45',
               'FeII 2600.17', '[OII] 2471.03',
               'FeII 2382.76', 'FeII* 2396.36',
               'FeII 2344.21', 'FeII* 2365.55',
               'FeII 2260.78', 'CII]+CII]*'])

[3727.10, 3729.86]
[2612.65, 2626.45]
[2586]
ylimits = array([[0.71, 1.19], [0.10, 11.19], 
                 [0.41, 1.19], [0.81, 1.49],
                 [0.36, 1.26], [0.81, 1.21],
                 [0.51, 1.26], [0.71, 1.29],
                 [0.41, 1.19], [0.81, 1.29],
                 [0.81, 1.09], [0.81, 1.39],])
xpos0 = 700
ypos0 = array([0.76, 9,
               0.5, 1.35,
               0.45, 1.13,
               0.6, 1.15,
               0.5, 1.15,
               0.86, 1.25])

tmpvel = zeros(outwave.size)
linecolor = ['black', 'green']
for i, ax in zip(arange(12), axesall):
    tmpvel = zeros(outwave.size)
    tmpvel[1:] = (outwave[1:]-wave0[i])/outwave[1:]*3E5
    tmpvel[0] = tmpvel[1]
    ax.plot(tmpvel+69./2., fluxmedian, 'b', drawstyle='steps', lw=2)
    icolor = mod(i,2)
    ax.plot(xlimits, [1,1], ':k', lw=1)
    ax.plot([0,0], ylimits[i,:], '--', color=linecolor[icolor], lw=1)
    ax.set_ylim(ylimits[i,:])
    ax.text(xpos0, ypos0[i], text0[i], color=linecolor[icolor], fontsize=18)
    if i>=10:
        ax.set_xlabel('Velocity [km/s]', fontsize=22)
# [OII]
plotoii = True
if plotoii:
    i = 1
    ax = axesall[1]
    tmpvel = zeros(outwave.size)
    tmpvel[1:] = (outwave[1:]-wave0[i])/outwave[1:]*3E5
    tmpvel[0] = tmpvel[1]
    ax.plot(tmpvel+69./2., oiifluxmedian, 'b', drawstyle='steps', lw=2)
    icolor = mod(i,2)
    ax.plot(xlimits, [1,1], ':k', lw=1)
    #linewave = array([3727.10, 3729.86])
    #linevel = (linewave-wave0[i])/linewave*3E5
    #for j in arange(linewave.size):
    #    ax.plot([linevel[j], linevel[j]], ylimits[i,:], '--', color=linecolor[icolor], lw=1)
    ax.set_ylim(ylimits[i,:])
    #ax.text(600, 9, '[OII] 3727.10, 3729.86', color=linecolor[icolor], fontsize=15)

for ax in axesall:
    ax.tick_params(axis='x', which='major', length=10, width=2, labelsize=20)
    ax.tick_params(axis='x', which='minor', length=5, width=2, labelsize=20)
    ax.tick_params(axis='y', which='major', length=6, width=2, labelsize=18)
    ax.tick_params(axis='y', which='minor', length=3, width=2, labelsize=18)
    ax.set_xlim(xlimits)
    ax.xaxis.set_minor_locator(minorLocator)

fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 1/eBOSS_composite_velocity.eps')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-14-b4447f8cc50a> in <module>()
     38                0.86, 1.25])
     39 
---> 40 tmpvel = zeros(outwave.size)
     41 linecolor = ['black', 'green']
     42 for i, ax in zip(arange(12), axesall):

NameError: name 'outwave' is not defined

In [65]:
count_nonzero(newfluxmean)


Out[65]:
2651

In [7]:
out_dtype = np.dtype({'names': ['wave', 'flux'], 'formats': ['(5786,)float', '(5786,)float']})

In [8]:
out_dtype


Out[8]:
dtype([('wave', '<f8', (5786,)), ('flux', '<f8', (5786,))])

In [9]:
outstr = np.zeros(1, dtype=out_dtype)
outstr['wave'] = tmpwave
outstr['flux'] = tmpmedian

In [12]:
fits = fitsio.FITS('/Users/Benjamin/AstroData/SDSS/eBOSS/stacks/eBOSS_composite_full.fits', 'rw', clobber=True)

In [13]:
fits.write(outstr)
fits.close()

In [193]:
fig = plt.figure(figsize=(24,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(2)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.set_ylim(this_ylim)
ax.set_xlim(2560, 2640)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.5)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
this_nabslines = 5
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('MnII 2576.88', 2576.88-3, 0.2, 2576.88)
this_absorption[1] = ('FeII 2586.65', 2586.65-3, 0.2, 2586.65)
this_absorption[2] = ('MnII 2594.50', 2594.50-3, 0.2, 2594.50)
this_absorption[3] = ('FeII 2600.17', 2600.17+1.5, 0.2, 2600.17)
this_absorption[4] = ('MnII 2606.46', 2606.46+1.5, 0.2, 2606.46)

this_nemlines = 3
this_emission = np.zeros(this_nemlines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'), ('WAVE','f4')])
this_emission[0] = ('FeII* 2626.45', 2626.45+1.5, 1.3, 2626.45)
this_emission[1] = ('FeII* 2612.65', 2612.65+1.5, 1.3, 2612.65)
#this_emission[2] = ('FeII* 2632.11', 2632.11+10., 1.2, 2632.11)

for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [1, this_ylim[0]], '--k', lw=2)
for i in np.arange(this_nemlines):
    etmp = this_emission[i]
    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], color='g', rotation='vertical',va='bottom', fontsize=16)
    ax.plot([etmp['WAVE'], etmp['WAVE']], [1,this_ylim[1]], '--g', linewidth=2)
    
# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=3.0)
ax.plot(sboutwave+dwave/2.-0.7, sbfluxmedian, 'r', drawstyle='steps', linewidth=2.5)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 1/eBOSS_composite_withlocalsfsb_2600.eps')



In [194]:
fig = plt.figure(figsize=(24,8))
this_ylim = [0.15, 1.8]
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(2)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(outwave[1:]-outwave[:-1])
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=1)
ax.set_ylim(this_ylim)
ax.set_xlim(2760, 2870)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=15)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$\left<R(\lambda)\right>$', fontsize=28)
for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(2.5)
ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24, pad=8)
ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24, pad=8)
this_nabslines = 3
this_absorption = np.zeros(this_nabslines, dtype=[('NAME','S20'),('XPOS','f4'),('YPOS','f4'),('WAVE', 'f4')])
this_absorption[0] = ('MgII 2796.35', 2796.35-4., 0.2, 2796.35)
this_absorption[1] = ('MgII 2803.53', 2803.53+1.5, 0.2, 2803.53)
this_absorption[2] = ('MgI 2852.96', 2852.96+1.5, 0.21, 2852.96)

for i in np.arange(this_nabslines):
    atmp = this_absorption[i]
    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=16, rotation='vertical',va='bottom')
    ax.plot([atmp['WAVE'], atmp['WAVE']], [this_ylim[0],this_ylim[1]], '--k', lw=2)
#plot([2344.21, 2344.21], [0.25, 1.25], 'g')
#plot([2374.46, 2374.46], [0.25, 1.25], 'g')
#plot([2382.77, 2382.77], [0.25, 1.25], 'g')
#plot([2365.55, 2365.55], [0.25, 1.25], 'r')
#plot([2396.35, 2396.35], [0.25, 1.25], 'r')

# Replot
ax.plot(outwave+dwave/2., fluxmedian, 'b', drawstyle='steps', linewidth=3.0)
ax.plot(sboutwave+dwave/2.-0.7, sbfluxmedian, 'r', drawstyle='steps', linewidth=2.5)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 1/eBOSS_composite_withlocalsfsb_2800.eps')



In [26]:
dwave


Out[26]:
0.68729582619675966

In [363]:
xtmp = np.linspace(-800., 600, num=100)
ytmp = 1.+stats.norm.pdf((xtmp+0)/np.sqrt(69**2+95.**2))*9.5

center = 5008.239
fig = plt.figure(figsize=(14,6))
ax = fig.add_subplot(111)
minorLocator   = plt.MultipleLocator(100)
ax.xaxis.set_minor_locator(minorLocator)
dwave = np.median(tmpwave[4181:4201]-tmpwave[4180:4200])
tmpcontinuum = np.median(tmpmedian_OIII[4180:4200])*0.95
tmpvel = (tmpwave-center)/center*3E5
dvel = dwave/center*3E5
#tmpvel = (tmpwave-4960.295)/4960.295*3E5
#dvel = dwave/4960.295*3E5
#ax.plot(tmpwave+dwave/2., tmpmedian_OIII/tmpcontinuum, lw=3, drawstyle='steps')
ax.plot(tmpvel+0., tmpmedian_OIII/tmpcontinuum, lw=3)
#ax.set_xlim(4990, 5020)
ax.set_xlim(-800,600)
ax.set_ylim(0.0, 7.0)
#ax.set_title('Composite Spectrum of Emission Line Galaxies (ELGs) from eBOSS', fontsize=24)
ax.set_xlabel(r'$\lambda$ [$\AA$]', fontsize=28)
ax.set_ylabel(r'$f(\lambda)$ [arbitrary unit]', fontsize=28)
#ax.set_xscale('log')
#ax.set_yscale('log')
#for axis in ['top','bottom','left','right']:
#  ax.spines[axis].set_linewidth(2.0)
#ax.tick_params(axis='both', which='minor', length=5, width=2, labelsize=24)
#ax.tick_params(axis='both', which='major', length=10, width=2, labelsize=24)
ax.plot(xtmp, ytmp, '--', lw=6, color='green')
#emission_name = array(['FeII*', 'FeII*', '[OII]', '[NeIII]','[OIII]', '[OIII]', 'HeI', '[OI]',
#                       'NII', 'NII', 'SII', 'SII', '[ArIII]'])
#emission_xpos = array([2300.,   2550.,   3727.,   3868.,     4363.,   4959.,    5876., 6300.,
#  6548., 6583., 6716., 6730., 7137.])

#for i in np.arange(nemlines):
#    etmp = emission[i]
#    ax.text(etmp['XPOS'], etmp['YPOS'], etmp['NAME'], fontsize=15, color='g')
#for i in np.arange(nabslines):
#    atmp = absorption[i]
#    ax.text(atmp['XPOS'], atmp['YPOS'], atmp['NAME'], fontsize=15)
#for i in np.arange(nbalmer):
#    btmp = balmer[i]
#    ax.text(btmp['XPOS'], btmp['YPOS'], btmp['NAME'], color='brown', fontsize=20)
#for i in np.arange(nstellarabs):
#    stmp = stellarabs[i]
#    ax.text(stmp['XPOS'], stmp['YPOS'], stmp['NAME'], color='brown', fontsize=15)

#ax.plot([3934.78, 3934.78], [0.115, 0.18], 'brown', lw=1) # Ca II
#ax.plot([3969.59, 3969.59], [0.115, 0.18], 'brown', lw=1) # Ca II
#ax.plot([5891.58, 5891.58], [0.225, 0.30], 'brown', lw=1) # Na I
#ax.plot([5897.56, 5897.56], [0.225, 0.30], 'brown', lw=1) # Na I
#ax.plot([4307.90, 4307.90], [0.155, 0.22], 'brown', lw=1) # G (Ca, CH+, Fe)
#ax.plot([5183.62, 5183.62], [0.225, 0.30], 'brown', lw=1) # Mg I
#ax.plot([5172.70, 5172.70], [0.225, 0.30], 'brown', lw=1) # Mg I 
#ax.plot([5167.33, 5167.33], [0.225, 0.30], 'brown', lw=1)  # Mg I
#ax.plot([2297.58, 2297.58], [0.16, 0.38], 'brown', lw=1)  # Mg I
#ax.plot([4364.44+1., 4364.44+55], [0.435, 0.54], 'green', lw=1)  # [OIII]
#ax.plot([4069.75+0., 4069.75-35], [0.46, 0.52], 'green', lw=1)  # [SII]
#ax.plot([2326+0., 2326-20.], [0.55, 0.63], 'green', lw=1)
#ax.plot([2471+0., 2471+55.], [0.47, 0.60], 'green', lw=1)
#ax.plot([6680+0., 6680-20.], [0.39, 0.44], 'green', lw=1)
#ax.plot([7067+0., 7067-30.], [0.37, 0.43], 'green', lw=1)
#ax.plot([2255-5., 2255-80.], [0.40, 0.35], 'black', lw=1)
#ax.plot([5756.8+0., 5756.8-0.], [0.37, 2.43], 'green', lw=1)
#ax.plot([9548.8+0., 9548.8-0.], [0.37, 2.43], 'green', lw=1)
#ax.plot([4960.295+0., 4960.295-0.], [0.85, 5], 'green', lw=1)
#ax.plot([5008.240+0., 5008.240-0.], [0.85, 5], 'green', lw=1)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 1/eBOSS_composite_full_OIII.eps')



In [389]:
objs_ori[(objs_ori['zGOOD']==1) & (galaxytype=='GALAXY') & (z>0.6) & (z<1.2)].shape


Out[389]:
(8620,)

In [27]:
test = ebossspec.feiimgii_composite_readin()

In [28]:
test.dtype


Out[28]:
dtype([('WAVE', '>f4', (3736,)), ('FLUXMEDIAN', '>f4', (3736,)), ('FLUXMEAN', '>f4', (3736,)), ('OII_FLUXMEDIAN', '>f4', (3736,)), ('OII_FLUXMEAN', '>f4', (3736,)), ('OIII_FLUXMEDIAN', '>f4', (3736,)), ('OIII_FLUXMEAN', '>f4', (3736,))])

In [34]:
import plotutils

In [ ]: