In [1]:
#%matplotlib notebook
In [2]:
# imports
from importlib import reload
import numpy as np
import os
from pkg_resources import resource_filename
from matplotlib import pyplot as plt
from astropy import units
from astropy.table import Table
from astropy.cosmology import Planck15
from frb import igm
In [3]:
#stellar_mass_file = resource_filename('frb', 'data/IGM/stellarmass.dat')
stellar_mass_file = resource_filename('frb', os.path.join('data','IGM','stellarmass.dat'))
In [4]:
rho_mstar_tbl = Table.read(stellar_mass_file, format='ascii')
In [5]:
rho_mstar_tbl[0:5]
Out[5]:
In [6]:
zval = np.linspace(0., 4., 100)
rho_Mstar = igm.avg_rhoMstar(zval, remnants=False)
In [7]:
plt.clf()
ax = plt.gca()
ax.plot(zval, np.log10(rho_Mstar.value))
# Label
ax.set_xlabel('z')
ax.set_ylabel(r'$\log \, \rho_* \; [M_\odot/ \rm Mpc^3]$ ')
plt.show()
In [8]:
M_sphere = 0.0015
M_disk = 0.00055
M_WD = 0.00036
M_NS = 0.00005
M_BH = 0.00007
M_BD = 0.00014
In [9]:
f_remnants = (M_WD+M_NS+M_BH+M_BD) / (M_sphere+M_disk)
f_remnants
Out[9]:
In [10]:
rho_Mstar_full = igm.avg_rhoMstar(zval, remnants=True)
In [11]:
plt.clf()
ax = plt.gca()
ax.plot(zval, np.log10(rho_Mstar.value), label='No Remnants')
ax.plot(zval, np.log10(rho_Mstar_full.value), label='With Remnants')
# Label
ax.set_xlabel('z')
ax.set_ylabel(r'$\log \, \rho_* \; [M_\odot/ \rm Mpc^3]$ ')
# Legend
legend = plt.legend(loc='upper right', scatterpoints=1, borderpad=0.2,
handletextpad=0.1, fontsize='large')
plt.show()
In [12]:
M_HI = 0.00062
M_H2 = 0.00016
M_ISM = M_HI + M_H2
In [13]:
M_ISM/(M_sphere+M_disk)
Out[13]:
In [14]:
rhoISM = igm.avg_rhoISM(zval)
In [15]:
plt.clf()
ax = plt.gca()
ax.plot(zval, np.log10(rhoISM.value), label='ISM')
ax.plot(zval, np.log10(rho_Mstar_full.value), label='M*')
# Label
ax.set_xlabel('z')
ax.set_ylabel(r'$\log \, \rho \; [M_\odot/ \rm Mpc^3]$ ')
# Legend
legend = plt.legend(loc='upper right', scatterpoints=1, borderpad=0.2,
handletextpad=0.1, fontsize='large')
plt.show()
In [16]:
#He_file = resource_filename('frb', 'data/IGM/qheIII.txt')
He_file = resource_filename('frb', os.path.join('data','IGM','qheIII.txt'))
In [17]:
qHeIII = Table.read(He_file, format='ascii')
In [18]:
qHeIII
Out[18]:
In [19]:
plt.clf()
ax=plt.gca()
ax.plot(qHeIII['z'], qHeIII['Q_HeIII_18'])
#
ax.set_xlabel('z')
ax.set_ylabel('f(HeIII)')
#
plt.show()
In [20]:
reload(igm)
DM = igm.average_DM(1.)
DM
Out[20]:
In [21]:
DM_cumul, zeval = igm.average_DM(1., cumul=True)
In [22]:
# Inoue approximation
DM_approx = 1000. * zeval * units.pc / units.cm**3
In [23]:
plt.clf()
ax = plt.gca()
ax.plot(zeval, DM_cumul, label='JXP')
ax.plot(zeval, DM_approx, label='Approx')
# Label
ax.set_xlabel('z')
ax.set_ylabel(r'${\rm DM}_{\rm IGM} [\rm pc / cm^3]$ ')
# Legend
legend = plt.legend(loc='lower right', scatterpoints=1, borderpad=0.2,
handletextpad=0.1, fontsize='large')
plt.show()
In [24]:
plt.clf()
ax = plt.gca()
ax.plot(zeval, DM_approx/DM_cumul, label='Approx/JXP')
#ax.plot(zeval, DM_approx, label='Approx')
# Label
ax.set_xlabel('z')
ax.set_ylabel(r'Ratio of ${\rm DM}_{\rm IGM} [\rm pc / cm^3]$ ')
# Legend
legend = plt.legend(loc='upper right', scatterpoints=1, borderpad=0.2,
handletextpad=0.1, fontsize='large')
plt.show()
In [25]:
DM_cumul[0:10]
Out[25]:
In [26]:
DM_approx[0:10]
Out[26]:
In [27]:
zeval[0]
Out[27]: