View on GitHub

Pycosmicstar

Python Cosmic Star Formation Rate

download .ZIPdownload .TGZ

Instalation.



$sudo apt-get install python-pytools 
$sudo python setup.py install
To verify if the package was correctely installed run:

python test_all.py

Usage.


The cosmological background

from pycosmicstar.lcdmcosmology import lcdmcosmology

#Instancing a LCDM Object.
lcdmUniverser = lcdmcosmology(omegam=0.24,
omegab=0.04,
omegal=0.73,
h=0.7)
The attributes are the cosmological parameters.

Plotting the time variation with redshift, the age of the Universe as a function of the redshift and the Hubble parameter.
z = arange(0, 10.5, 0.1)

#The time variation with redshift
plt.plot(z, log([lcdmUniverser.dt_dz(zi) for zi in z]))
plt.xlabel(r"$z$ - Redshift")
plt.ylabel(r"$\log(\frac{\frac{dt}{dz}}{yr})$")
plt.show()

# The age of the Universe as a function of the redshift
plt.plot(z, [lcdmUniverser.age(zi) for zi in z])
plt.xlabel(r"$z$ - Redshift")
plt.ylabel(r"$t$ (yr)")
plt.show()

#The Hubble parameter
plt.plot(z, [lcdmUniverser.H(zi) for zi in z])
plt.xlabel(r"$z$ - Redshift")
plt.ylabel(r"$H(z)$ ")
plt.show()



Download the example 1.



Figure 1. $\frac{dt}{dz}$ x $z$



Figure 2. Age of the Universe.


Figure 3. Hubble Parameter.

The attributes and public methods of lcdmcosmology class:

      1. dt_dz(z) - time, $t$,  and redshift, $z$, relation;
      2. H(z) - Hubble parameter as a function of $z$;
      3. dr_dz(z) - Comove distance variation for flat Universe;
      4. dV_dz(z) - Comove volume variation;
      5. growthFunction(z) - Growth Function of cosmological density perturbations;
      6. dgrowth_dt(z) - derivative of the growth function with respect to  time;
      7. dsigma2_dk(k) - derivative of the variance of linear density field, $\sigma$ ;
      8. sigma(kmass) - variance of linear density field (\textbf{kmass} is the mass scale);
      9. rodm(z) - dark matter density;
      10. robr(z) - baryonic matterdensity.

The Hierarchical Scenario of Structure Formation

Creating a new structure object, given a dark halo mass function:


from pycosmicstar.structures import structures
from pycosmicstar.lcdmcosmology import lcdmcosmology

import matplotlib.pyplot as plt
from numpy import arange, log

#Creating a object considering the
#Sheth & Tormen (1999) mass function.
stUniverser = structures(cosmology=lcdmcosmology, omegam=0.24,
omegab=0.04, omegal=0.73, h=0.7, massFunctionType="ST")

#Creating a object considering the
#Tinker et al. (2010) mass function.
tkUniverser = structures(cosmology=lcdmcosmology, omegam=0.24,
omegab=0.04, omegal=0.73, h=0.7, massFunctionType="TK", delta_halo=200)

z = arange(0, 10.5, 0.1)

#Plotting the fraction of baryons into structures
plt.plot(z, [stUniverser.fbstruc(zi) for zi in z], label="ST")
plt.plot(z, [tkUniverser.fbstruc(zi) for zi in z], label="TK")
plt.xlabel(r"$z$ - Redshift")
plt.ylabel(r"$f_{b}$")
plt.legend()
plt.show()

#plotting the accretion rate of baryons into structure
plt.plot(z, [stUniverser.abt(1.0 / (1.0 + zi)) for zi in z],
label="ST")
plt.plot(z, [tkUniverser.abt(1.0 / (1.0 + zi)) for zi in z],
label="TK")
plt.xlabel(r"$z$ - Redshift")
plt.ylabel(r"$a_{b}$")
plt.legend()
plt.show()

#Plotting the numerical density of dark haloes.
plt.plot(z, [stUniverser.numerical_density_halos(zi) for zi in z],
label="ST")
plt.plot(z, [tkUniverser.numerical_density_halos(zi) for zi in z],
label="TK")
plt.xlabel(r"$z$ - Redshift")
plt.ylabel(r"numerical density of halos")
plt.legend()
plt.show()

Download the source code of example 2.


Figure 4: The fraction of baryons into structures according to
dark haloes mass function.


Figure 5: The accretion rate of baryons into structures according to
dark haloes mass function.



Figure 6: Numerical density of dark haloes.



The attributes and public methods:
      1. cosmology : A class  that implements the methods of the abstract class cosmology;
      2. lmin (default - 6.0): $\log_{10}$ of the minimal mass of dark haloes where it is possible to start the star formation.
      3. zmax (default - 20.0): the redshift where the star formation starts.
      4. omegam: ($\Omega_{m}$, default 0.24) - The dark matter parameter;
      5. omegab : ($\Omega_{b}$, default 0.04) - The baryonic parameter; 
      6. omegal: ($\Omega_{\Lambda}$, default 0.73) - The dark energy parameter; 
      7. h: (default, 0.7) - The h of the Hubble constant ($H_{0} = 100h$ ).
      8. cacheDir (default None):  The directory where the cache file will be storaged;
      9. cacheFile (default None): Name of the database for caching;
      10. massFunctionType (default "ST"): the dark haloes mass function type
      11. delta_halo (default 200): The $\Delta_{h}$ of Tinker et al. mass function;
      12. qBurr (default 1): The Coeficienty of Burr Distribution;
      1. massFunction(lm, z) -  Return the dark haloes mass function, lm is the $\log_{10}$ of the mass of the dark halo;
      2. fbstruc(z) - Return the faction of barions into structures;
      3. halos_n(z) - return the integral of the mass function of dark halos multiplied by mass in the range of $\log(M_{min})$ a $\log(M_{max})$;
      4. numerical_density_halos(z) - Return the numerial density of dark halos within the comove volume;
      5. abt(z) - return the accretion rate which accounts for the increase in the fraction of baryons in structures.

The Cosmic Star Formation Rate


Instancing cosmic star formation rate using differents dark haloes mass function:


from pycosmicstar.cosmicstarformation import cosmicstarformation
from pycosmicstar.lcdmcosmology import lcdmcosmology
from pycosmicstar.observationalCSFR import ObservationalCSFR

import matplotlib.pyplot as plt
from numpy import arange, array

z = arange(0, 20, 0.1)

#Cosmic Star Formation Rate using Tinker et al. dark haloes mass function
myCSFR_TK = cosmicstarformation(cosmology=lcdmcosmology,
massFunctionType="TK",
delta_halo=200)

#Cosmic Star Formation Rate using Press and Schechter dark haloes mass function
myCSFR_PS = cosmicstarformation(cosmology=lcdmcosmology,
massFunctionType="PS")

#Cosmic Star Formation Rate using Seth et al. dark haloes mass function
myCSFR_ST = cosmicstarformation(cosmology=lcdmcosmology)


csfrTK = array([myCSFR_TK.cosmicStarFormationRate(zi) for zi in z])

csfrPS = array([myCSFR_PS.cosmicStarFormationRate(zi) for zi in z])
csfrST = array([myCSFR_ST.cosmicStarFormationRate(zi) for zi in z])

obsCSFR = ObservationalCSFR()
x, y = obsCSFR.csfredshift()
xerr, yerr = obsCSFR.errorData()
plt.errorbar(x, y, yerr=yerr, xerr=xerr, fmt='.')
plt.plot(z, csfrTK, label="TK")
plt.plot(z, csfrST, label="ST")
plt.plot(z, csfrPS, label="PS")
plt.legend(loc=4)
plt.yscale('log')
plt.ylabel(r'$\dot{\rho}_{*}$( M$_{\odot}$Mpc$^{-3}$yr$^{-1}$)')
plt.xlabel(r'$z$')
plt.show()
Download the example 3.



Figure 7: The Cosmic Star Formation Rate.

The attributes and Public methods:
      1. The attributes of structure;
      2. tau  (default 2.5 ): time scale, in Gyr, of the CSFR.
      3. eimf (default 1.35): exponent of the Initial Mass Function.
      4. nsch (default 1): the normalization factor in the CSFR model.
      5. lmin (default 6.0): log10 of the minal mass of the dark halo where it is possible to have star formation.
      6. zmax (default 20.0):  redshift that start the star formation.
      1. cosmicStarFormationRate(z) - returns the cosmic star formation rate, $\dot{\rho}_{*}(z)$, in M$_{\odot}$yr$^{-1}$Mpc$^{-3}$;
      2. gasDensityInStructures(z) - returns the density of gas in structures, $\rho_{g}(z)$, in M$_{\odot}$Mpc$^{-3}$;
      3. phi(m) - returns the Initial Mass Function (IMF), $\Phi(m)$, which gives the distribution of the stellar mass.