In [1]:
import ebossspec, fitsio, ebossanalysis
from scipy import stats

In [322]:
reload(ebossspec)
reload(ebossanalysis)


Out[322]:
<module 'ebossanalysis' from 'ebossanalysis.py'>

In [84]:
x = ebossspec.save_feiimgii_composite_binoii(overwrite=True)


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,)
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/OII_feiimgii_composite.fits.

In [112]:
x = ebossspec.save_feiimgii_composite_binoii(overwrite=True, bootstrap=True)


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,)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
100% |########################################################################|
outshape: (2651, 100, 14)
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/OII_feiimgii_composite_bootstrap.fits.

In [115]:
oii_composite_bstrap = ebossspec.feiimgii_composite_readin(binoii=True, bootstrap=True)
oii_composite = ebossspec.feiimgii_composite_readin(binoii=True)

In [117]:
oii_composite_bstrap.dtype


Out[117]:
dtype([('WAVE', '>f4', (2651,)), ('EWFLUXMEDIAN', '>f4', (2651, 100, 14)), ('EWOII_FLUXMEDIAN', '>f4', (2651, 100, 14)), ('LUMFLUXMEDIAN', '>f4', (2651, 100, 14)), ('LUMOII_FLUXMEDIAN', '>f4', (2651, 100, 14)), ('OIIEWMIN', '>f4', (14,)), ('OIIEWMAX', '>f4', (14,)), ('OIIEWBIN', '>f4', (14,)), ('OIILUMMIN', '>f4', (14,)), ('OIILUMMAX', '>f4', (14,)), ('OIILUMBIN', '>f4', (14,))])

In [108]:
figsize(20,8)
for i in arange(4)+5:
    plot(ddd['WAVE'], ddd['LUMFLUXMEDIAN'][:,i])
xlim(2310, 2410)
ylim(0,1.5)


Out[108]:
(0, 1.5)

In [120]:
x = ebossspec.save_feiimgii_composite(overwrite=True)
y = ebossspec.save_feiimgii_composite(bootstrap=True, nbootstrap=500, overwrite=True)


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,)
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/feiimgii_composite.fits.
Removing existing file
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,)
100% |########################################################################|
100% |########################################################################|
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/feiimgii_composite_bootstrap.fits.
Removing existing file

In [24]:
data = ebossspec.feiimgii_composite_readin(bootstrap=True)

In [32]:
flux[:,10].shape


Out[32]:
(2651,)

In [15]:
data.dtype.fields


Out[15]:
<dictproxy {'FLUXMEAN': (dtype(('>f4', (2651,))), 21208),
 'FLUXMEDIAN': (dtype(('>f4', (2651,))), 10604),
 'OII_FLUXMEAN': (dtype(('>f4', (2651,))), 42416),
 'OII_FLUXMEDIAN': (dtype(('>f4', (2651,))), 31812),
 'WAVE': (dtype(('>f4', (2651,))), 0)}>

In [28]:
wave = data['WAVE']
flux = data['FLUXMEDIAN']

In [30]:
figsize(24, 8)
for i in arange(500):
    plot(wave, flux[:,i])
xlim(2550, 2650)
ylim(0.15, 1.8)


Out[30]:
(0.15, 1.8)

In [201]:
wave_nofluorescent = array([2382.76, 2796.35, 2803.53])
wave_nonresonant = array([2365.55, 2396.36, 2612.65, 2626.45])
#wave_nonresonant = array([2365.55, 2396.36, 2626.45])
wave_yesfluorescent = array([2344.21, 2374.46, 2586.65, 2600.17])

# Symmetric Gaussian profile
xtmp = linspace(-800., 500, num=100)
#ytmp = 1.-stats.norm.pdf((xtmp+50)/150.)*1.3
ytmp = 1.+stats.norm.pdf((xtmp+0)/100.)*0.8

#tmp_wave = wave_yesfluorescent
#tmp_wave = wave_nofluorescent
tmp_wave = wave_nonresonant

fig = figure(figsize=(10,8))
this_ylim = [0.85, 1.6]
ax = fig.add_subplot(111)
xlimits = [-800, 500]

ax.set_ylim(this_ylim)
ax.set_xlim(xlimits)
ax.set_xlabel('Velocity [km/s]', 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)

colors = ['blue', 'green', 'red', 'magenta']
offset = [1.8, 1.4, 1.8, 1.0]
for i in arange(tmp_wave.size):
    tmpvel = zeros(wave.size)
    tmpvel[1:] = (wave[1:]-tmp_wave[i])/wave[1:]*3E5
    tmpvel[0] = tmpvel[1]
    tmpflux = 1.-(1.-flux)*offset[i]
    #ax.plot(tmpvel+69./2., tmpflux, color=colors[i], drawstyle='steps', lw=2)
    ax.plot(tmpvel, tmpflux, color=colors[i], lw=3)
    ax.plot(xlimits, [1,1], ':k', lw=1)
    
ax.plot(xtmp, ytmp, 'k--')
ax.plot([0,0], this_ylim, 'k--')


Out[201]:
[<matplotlib.lines.Line2D at 0x12aca21d0>]

In [215]:
wave_nofluorescent = array([2382.76, 2796.35, 2803.53])
#wave_nonresonant = array([2365.55, 2396.36, 2612.65, 2626.45])
wave_nonresonant = array([2365.55, 2396.36, 2626.45])
wave_yesfluorescent = array([2344.21, 2374.46, 2586.65, 2600.17, 2382.76])

# Symmetric Gaussian profile
xtmp = linspace(-800., 500, num=100)
ytmp = 1.-stats.norm.pdf((xtmp+40)/135.)*1.4
#ytmp = 1.+stats.norm.pdf((xtmp+0)/100.)*0.85
ytmp_emission = stats.norm.pdf((xtmp+0)/100.)*0.85

tmp_wave = wave_yesfluorescent
#tmp_wave = wave_nofluorescent
#tmp_wave = wave_nonresonant

fig = figure(figsize=(10,8))
this_ylim = [0.15, 1.1]
ax = fig.add_subplot(111)
xlimits = [-1000, 500]

ax.set_ylim(this_ylim)
ax.set_xlim(xlimits)
ax.set_xlabel('Velocity [km/s]', 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)

colors = ['blue', 'green', 'red', 'magenta', 'yellow']
#wave_yesfluorescent = array([2344.21, 2374.46, 2586.65, 2600.17])
offset = [1.0, 1.35, 0.9, 0.7, 0.8]
fillin = [0.1, 0., 0.2, 0.4, 0.6]
for i in arange(tmp_wave.size):
    tmpvel = zeros(wave.size)
    tmpvel[1:] = (wave[1:]-tmp_wave[i])/wave[1:]*3E5
    tmpvel[0] = tmpvel[1]
    tmpemission = stats.norm.pdf((tmpvel+0)/100.)*fillin[i]
    tmpflux = 1.-(1.-flux)*offset[i]
    #ax.plot(tmpvel+69./2., tmpflux, color=colors[i], drawstyle='steps', lw=2)
    #ax.plot(tmpvel, tmpflux, color=colors[i], lw=3)
    #if i==2 or i==4: ax.plot(tmpvel, tmpflux, color=colors[i], lw=3)
    ax.plot(tmpvel, tmpflux-tmpemission, color=colors[i], lw=3)

ax.plot(xlimits, [1,1], ':k', lw=1)    
ax.plot(xtmp, ytmp, 'k--')
#ax.plot([-50,-50], this_ylim, 'k--')


Out[215]:
[<matplotlib.lines.Line2D at 0x12beb8bd0>]

In [213]:
wave_nofluorescent = array([2382.76, 2796.35, 2803.53])
#wave_nonresonant = array([2365.55, 2396.36, 2612.65, 2626.45])
wave_nonresonant = array([2365.55, 2396.36, 2626.45])
wave_yesfluorescent = array([2344.21, 2374.46, 2586.65, 2600.17, 2382.76])

# Symmetric Gaussian profile
xtmp = linspace(-800., 500, num=100)
ytmp = 1.-stats.norm.pdf((xtmp+50)/150.)*1.3
#ytmp = 1.+stats.norm.pdf((xtmp+0)/100.)*0.8

tmp_wave = wave_yesfluorescent
#tmp_wave = wave_nofluorescent
#tmp_wave = wave_nonresonant

fig = figure(figsize=(10,8))
this_ylim = [0.4, 1.1]
ax = fig.add_subplot(111)
xlimits = [-800, 500]

ax.set_ylim(this_ylim)
ax.set_xlim(xlimits)
ax.set_xlabel('Velocity [km/s]', 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)

colors = ['blue', 'green', 'red', 'magenta', 'yellow']
#wave_yesfluorescent = array([2344.21, 2374.46, 2586.65, 2600.17])
offset = [1.0, 1.35, 0.9, 0.7, 0.8]
fillin = [0.1, 0., 0.2, 0.4, 0.6]
for i in arange(tmp_wave.size):
    tmpvel = zeros(wave.size)
    tmpvel[1:] = (wave[1:]-tmp_wave[i])/wave[1:]*3E5
    tmpvel[0] = tmpvel[1]
    tmpemission = stats.norm.pdf((tmpvel+0)/100.)*fillin[i]
    tmpflux = 1.-(1.-flux)*offset[i]
    #ax.plot(tmpvel+69./2., tmpflux, color=colors[i], drawstyle='steps', lw=2)
    ax.plot(tmpvel, tmpflux, color=colors[i], lw=3)
    #if i==2 or i==4: ax.plot(tmpvel, tmpflux, color=colors[i], lw=3)
    #ax.plot(tmpvel, tmpflux-tmpemission, color=colors[i], lw=3)

ax.plot(xlimits, [1,1], ':k', lw=1)    
#ax.plot(xtmp, ytmp, 'k--')
#ax.plot([-50,-50], this_ylim, 'k--')


Out[213]:
[<matplotlib.lines.Line2D at 0x12be43450>]

In [199]:
#wave_nofluorescent = array([2382.76, 2796.35, 2803.53])
wave_nofluorescent = array([2382.76, 2796.35, 2803.53])
#wave_nonresonant = array([2365.55, 2396.36, 2612.65, 2626.45])
wave_nonresonant = array([2365.55, 2396.36, 2626.45])
wave_yesfluorescent = array([2344.21, 2374.46, 2586.65, 2600.17])

# Symmetric Gaussian profile
xtmp = linspace(-800., 500, num=100)
ytmp = 1.-stats.norm.pdf((xtmp+50)/150.)*1.3
#ytmp = 1.+stats.norm.pdf((xtmp+0)/100.)*0.8

#tmp_wave = wave_yesfluorescent
tmp_wave = wave_nofluorescent
#tmp_wave = wave_nonresonant

fig = figure(figsize=(10,8))
this_ylim = [0.15, 1.1]
ax = fig.add_subplot(111)
xlimits = [-800, 500]

ax.set_ylim(this_ylim)
ax.set_xlim(xlimits)
ax.set_xlabel('Velocity [km/s]', 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)

colors = ['yellow', 'green', 'red', 'magenta']
#wave_nofluorescent = array([2382.76, 2796.35, 2803.53])
offset = [0.8, 0.6, 0.55, 0.9]
fillin = [0.6, 0.95, 0.85]
for i in arange(tmp_wave.size):
    tmpvel = zeros(wave.size)
    tmpvel[1:] = (wave[1:]-tmp_wave[i])/wave[1:]*3E5
    tmpvel[0] = tmpvel[1]
    tmpemission = stats.norm.pdf((tmpvel+0)/100.)*fillin[i]
    tmpflux = 1.-(1.-flux)*offset[i]
    #ax.plot(tmpvel+69./2., tmpflux, color=colors[i], drawstyle='steps', lw=2)
    ax.plot(tmpvel, tmpflux, color=colors[i], lw=3)
    ax.plot(tmpvel, tmpflux-tmpemission, '--', color=colors[i], lw=3)
    ax.plot(xlimits, [1,1], ':k', lw=1)
    
#ax.plot(xtmp, ytmp, 'k--')



In [51]:
ebossanalysis.do_velspace_flux(overwrite=True, bootstrap=True)


Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/lines/Bootstrap_velspace_flux.fits
Out[51]:
True

In [208]:
ebossanalysis.do_velspace_flux(overwrite=True, binoii=True, bootstrap=False)


Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/lines/OII_Velspace_flux.fits
Removing existing file
Out[208]:
True

In [209]:
(ewvelflux, lumvelflux) = ebossanalysis.velspace_flux_readin(binoii=True)
(ewvelflux_bstrap, lumvelflux_bstrap) = ebossanalysis.velspace_flux_readin(binoii=True, bootstrap=True)

In [213]:
print ewvelflux.size
print ewvelflux_bstrap['FLUX'].shape
print ewvelflux[0]['LINES']


14
(14, 12, 200, 100)
[ 2382.764  2796.352  2803.531  2852.964  2344.213  2374.46   2586.649
  2600.172  2365.55   2396.355  2612.653  2626.45 ]

In [290]:
figsize(24, 8)
#for i in arange(3)+2:
#    for j in arange(20):
#        plot(ewvelflux['VEL'], ewvelflux_bstrap['FLUX'][i][0,:,j])
#for i in [9,10,11,12,13]:

CM = get_cmap('jet')
for i, ioii in enumerate([2,3,4]):
#for i, ioii in enumerate([5,6,7,8]):
#for i, ioii in enumerate([9,10,11,12,13]):
    color = CM(i/4.+0.0)
    plot(ewvelflux[ioii]['VEL'], lumvelflux[ioii]['FLUX'][0,:], color=color, lw=3)
xlim(-1400, 1000)
ylim(0.15, 1.8)
plot([-4000,4000],[1,1])


Out[290]:
[<matplotlib.lines.Line2D at 0x12ec97ed0>]

In [323]:
ebossanalysis.unify_absorptionline_profile(bootstrap=True, overwrite=True)


Removing existing file
Correting the original spectra...
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/lines/Corrected_Bootstrap_velspace_flux.fits
Removing existing file
Out[323]:
True

In [190]:
ebossanalysis.unify_emissionline_profile(bootstrap=True, overwrite=True)


Removing existing file
Out[190]:
True

In [307]:
reload(ebossanalysis)


Out[307]:
<module 'ebossanalysis' from 'ebossanalysis.py'>

In [302]:
ebossanalysis.unify_emissionline_profile_binoii(overwrite=True)


Removing existing file
Out[302]:
True

In [325]:
ebossanalysis.unify_absorptionline_profile_binoii(bootstrap=True, overwrite=True)


Removing existing file
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/lines/OII_Corrected_Bootstrap_velspace_flux.fits
Out[325]:
True

In [308]:
ew_emission, lum_emission = ebossanalysis.unify_emissionline_profile_readin(bootstrap=False, binoii=True)
ew_absorption, lum_absorption = ebossanalysis.unify_absorptionline_profile_readin(bootstrap=False, binoii=True)

In [314]:
lum_absorption.dtype


Out[314]:
dtype([('LINES', '>f8', (8,)), ('VEL', '>f8', (200,)), ('FLUX', '>f8', (8, 200)), ('FABS', '>f8', (8, 200)), ('NORMFABS', '>f8', (8, 200)), ('FNORM', '>f8', (8,)), ('INDEX', '>i4', (8,)), ('UNIFIEDABSORPTION', '>f8', (200,)), ('UNIFIEDABSORPTION_DISP', '>f8', (200,)), ('UNIFIEDEMISSION', '>f8', (200,)), ('UNIFIEDEMISSION_DISP', '>f8', (200,)), ('COEFF', '>f8', (8, 2)), ('FABS_2374', '>f8', (200,))])

In [313]:
figsize(24, 8)
CM = get_cmap('jet')
for i, ioii in enumerate([2,3,4]):
#for i, ioii in enumerate([6,8]):
#for i, ioii in enumerate([10,11,12,13]):
    color = CM(i/4.+0.0)
    #plot(ew_emission[ioii]['VEL'], ew_emission[ioii]['UNIFIEDFLUX'][:], color=color, lw=3)
    plot(ew_absorption[ioii]['VEL'], ew_absorption[ioii]['UNIFIEDABSORPTION'][:], color=color, lw=3)

xlim(-1000, 1000)
ylim(0.85, 1.3)
ylim(0.65, 1.1)
plot([-1000,1000], [1,1], lw=6)
#fill_between(vel, 1.+emission['UNIFIEDDISP'], 1.-emission['UNIFIEDDISP'])


Out[313]:
[<matplotlib.lines.Line2D at 0x12f45f550>]

In [86]:
xx = np.std(emission['UNIFIEDFLUX'], axis=1)

In [87]:
xx.shape


Out[87]:
(200,)

In [194]:
print median(emission['UNIFIEDDISP'])
print median(absorption_bstrap['UNIFIEDABSORPTION_DISP'])


0.0411438587493
0.0170728693019

In [188]:
plot(vel, absorption_bstrap['UNIFIEDABSORPTION_DISP'])


Out[188]:
[<matplotlib.lines.Line2D at 0x1246bf890>]

In [176]:



---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-176-3f2d6ce28b85> in <module>()
----> 1 ebossanalysis.unify_absorptionline_profile(overwrite=True)

/Users/Benjamin/Code/BGT-Cosmology/Spectroscopy/ebossanalysis.py in unify_absorptionline_profile(overwrite, bootstrap)
    478 
    479     # Dispersion
--> 480     tmp_flux = np.zeros((nspec*use_indices[3:].size, vel.size))
    481     for i in np.arange(nspec):
    482         for j in np.arange(use_indices[3:].size):

UnboundLocalError: local variable 'nspec' referenced before assignment

In [198]:
absorption = ebossanalysis.unify_absorptionline_profile_readin()

In [199]:
absorption.dtype


Out[199]:
dtype([('LINES', '>f8', (8,)), ('VEL', '>f8', (200,)), ('FLUX', '>f8', (8, 200)), ('FABS', '>f8', (8, 200)), ('NORMFABS', '>f8', (8, 200)), ('FNORM', '>f8', (8,)), ('INDEX', '>i4', (8,)), ('UNIFIEDABSORPTION', '>f8', (200,)), ('UNIFIEDEMISSION', '>f8', (200,)), ('COEFF', '>f8', (8, 2)), ('FABS_2374', '>f8', (200,))])

In [127]:
ebossanalysis.unify_absorptionline_profile(overwrite=True, bootstrap=True)


Looping over all spectra...
Removing existing file
Correting the original spectra...
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Looping over all the spectra
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/lines/Corrected_Bootstrap_velspace_flux.fits
Removing existing file
Out[127]:
True

In [184]:
absorption_bstrap = ebossanalysis.unify_absorptionline_profile_readin(bootstrap=True)

In [185]:
absorption_bstrap.dtype


Out[185]:
dtype([('LINES', '>f8', (8,)), ('VEL', '>f8', (200,)), ('FLUX', '>f8', (8, 200, 500)), ('FABS', '>f8', (8, 200, 500)), ('NORMFABS', '>f8', (8, 200, 500)), ('FNORM', '>f8', (8,)), ('INDEX', '>i4', (8,)), ('UNIFIEDABSORPTION', '>f8', (200, 500)), ('UNIFIEDABSORPTION_DISP', '>f8', (200,)), ('UNIFIEDEMISSION', '>f8', (200, 500)), ('UNIFIEDEMISSION_DISP', '>f8', (200,)), ('COEFF', '>f8', (8, 2, 500)), ('FABS_2374', '>f8', (200, 500))])

In [187]:
figsize(24, 8)
for i in arange(100):
    plot(vel, absorption_bstrap['UNIFIEDABSORPTION'][:,i])
    #plot(vel, emission['FLUX'][3,:,i])
xlim(-1000, 600)
ylim(0.75, 1.1)
plot([-1000,1000], [1,1], lw=6)
fill_between(vel, 1.+absorption_bstrap['UNIFIEDABSORPTION_DISP'], 1.-absorption_bstrap['UNIFIEDABSORPTION_DISP'])


Out[187]:
<matplotlib.collections.PolyCollection at 0x11ab363d0>

In [209]:
corrected_bstrap = ebossanalysis.corrected_velspace_flux_readin(bootstrap=True)

In [210]:
corrected_bstrap.dtype


Out[210]:
dtype([('LINES', '>f8', (12,)), ('VEL', '>f8', (200,)), ('FLUX', '>f8', (12, 200, 500))])

In [29]:
ebossspec.value_add_elg(overwrite=True)


Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave01800_03600A.fits.
Reading /Users/Benjamin/AstroData/AllInOne/AIO_ELG_eBOSS_SDSSRestFrame_Wave03600_07200A.fits.
dwave: 0.858506734961
allfinite: 21528
Write into file: /Users/Benjamin/AstroData/SDSS/eBOSS/VAGC_spAll-ELG-v5.4-zQ.fits.
Removing existing file

In [30]:
objs_ori = ebossspec.elg_readin()
oii = (ebossspec.elg_readin(vac=True))[0]
galaxytype = objs_ori['CLASS']
zgood = objs_ori['zGOOD']
oiilum = oii['OIILUM']
oii_ew = oii['OIIEW']
z = objs_ori['Z']
inuv = (where(logical_and(logical_and(logical_and(zgood, 
        oii['Z']>0.6), oii['Z']<1.2), galaxytype=='GALAXY')))[0]

In [31]:
nonzero(isfinite(log10(oiilum[inuv])))


Out[31]:
(array([   0,    1,    2, ..., 8617, 8618, 8619]),)

In [329]:
fig = figure(figsize=(9,7))
ax = fig.add_subplot(111)
n, bins, patches = ax.hist(oii_ew[inuv], 
                           bins=arange(0, 200, 5), edgecolor='black')
this_ylim = [0, 800]
ax.set_ylim(this_ylim)
#ax.set_xscale('log')
#ax.set_xlim(3680, 3780)
ax.set_title(r'[OII] EW Distribution', fontsize=20)
ax.set_xlabel(r'$W_{\rm O\,II}^{\lambda3727}$ [$\AA$]', fontsize=20)
ax.set_ylabel(r'$\Delta$ N ($\Delta W_{\rm O\,II}^{\lambda3727}$ = 5 $\AA$)', fontsize=20)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 1/EW_distribution.eps')

# Luminosity
fig = figure(figsize=(9,7))
ax = fig.add_subplot(111)
n, bins, patches = ax.hist(log10(oiilum[inuv]), 
                           bins=arange(40., 43.5, 0.1), edgecolor='black')
this_ylim = [0, 1100]
ax.set_ylim(this_ylim)
#ax.set_xscale('log')
#ax.set_xlim(3680, 3780)
ax.set_title(r'[OII] Luminosity Distribution', fontsize=20)
ax.set_xlabel(r'$\log_{10}\,L_{\rm O\,II}^{\lambda3727}$ [${\rm erg\,s}^{-1}$]', fontsize=20)
ax.set_ylabel(r'$\Delta$ N ($\Delta \log_{10}\,L_{\rm O\,II}^{\lambda3727}$ = 0.1 dex)', fontsize=20)
fig.savefig('/Users/Benjamin/Dropbox/Zhu_Projects/Fine Structure Emission/Version 1/Lum_distribution.eps')



In [50]:
median(log10(oiilum[inuv]))


Out[50]:
41.618402036969989

In [53]:
median(log10(oiilum[inuv[log10(oiilum[inuv])>42.]]))


Out[53]:
42.156532932050531

In [60]:
oiiewmin, oiiewmax, oiiewbin, oiilummin, oiilummax, oiilumbin = ebossspec.oiiewbins()

In [326]:
median(oii_ew[inuv])


Out[326]:
51.373382157209548

In [66]:
oiiewmin.shape


Out[66]:
(14,)

In [73]:
newshape = oiiewmin.shape+(14,)+(3,)

In [74]:
newshape


Out[74]:
(14, 14, 3)

In [75]:
xxxx = zeros(newshape)

In [76]:
xxxx[:,0] = 3.4

In [260]:
infile = '/Users/Benjamin/AstroData/Absorbers/Absorbers_Composite_Allabs_0.8AA.fits'
outfile = infile.replace('.fits', '_REW.fits')

In [261]:
print infile, outfile


/Users/Benjamin/AstroData/Absorbers/Absorbers_Composite_Allabs_0.8AA.fits /Users/Benjamin/AstroData/Absorbers/Absorbers_Composite_Allabs_0.8AA_REW.fits

In [295]:
reload(ebossanalysis)


Out[295]:
<module 'ebossanalysis' from 'ebossanalysis.py'>

In [281]:
ebossanalysis.absorber_measure()

In [282]:
xxx = ebossanalysis.stack_absorber_readin(rew=True)

In [283]:
xxx['TFLUX']


Out[283]:
array([ 2.15998797,  3.54151604,  3.19343143,  0.82486567,  1.59861495,
        0.91176477,  1.50274707,  2.26242024])

In [273]:
xxx['LINES']


Out[273]:
array([ 2382.764,  2796.352,  2803.531,  2852.964,  2344.213,  2374.46 ,
        2586.649,  2600.172])

In [294]:
ebossanalysis.unify_absorptionline_profile_binoii(overwrite=True)


0 2
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-294-22cb5a1248a7> in <module>()
----> 1 ebossanalysis.unify_absorptionline_profile_binoii(overwrite=True)

/Users/Benjamin/Code/BGT-Cosmology/Spectroscopy/ebossanalysis.py in unify_absorptionline_profile_binoii(overwrite, bootstrap)
   1044                                     normalized_flux_absorption, fabs_norm, use_indices, unified_absorption, unified_disp, \
   1045                                     unified_emission, unified_emission_disp, coeff_abs, absorption_norm_2374)], 
-> 1046                                     dtype=out_dtype)
   1047             if (iewlum == 0):
   1048                 ew_outstr[i] = tmp_outstr

UnboundLocalError: local variable 'out_dtype' referenced before assignment

In [ ]: