Package cosmolopy

Source Code for Package cosmolopy

 1  """CosmoloPy is a package of cosmology routines built on NumPy/SciPy. 
 2   
 3  Capabilities include 
 4  -------------------- 
 5   
 6  `cosmolopy.density` 
 7    Various cosmological densities. 
 8   
 9  `cosmolopy.distance` 
10    Various cosmological distance measures. 
11   
12  `cosmolopy.luminosityfunction` 
13    Galaxy luminosity functions (Schecter functions). 
14   
15  `cosmolopy.magnitudes` 
16    Conversion in and out of the AB magnitude system. 
17   
18  `cosmolopy.parameters` 
19    Pre-defined sets of cosmological parameters (e.g. from WMAP). 
20   
21  `cosmolopy.perturbation` 
22    Perturbation theory and the power spectrum. 
23   
24  `cosmolopy.reionization` 
25    The reionization of the IGM. 
26   
27  Functions take cosmological parameters (which can be numpy arrays) 
28  as keywords, and ignore any extra keywords. This means you can make a 
29  dictionary of all of your cosmological parameters and pass it to any 
30  function.   
31   
32  The `parameters` module supplies some convenient pre-defined parameter sets. 
33   
34  Usage 
35  ----- 
36   
37  The easiest way to use CosmoloPy is to create a dictionary of the 
38  cosmology parameters and pass it to each function using the ** syntax. 
39   
40  >>> import cosmolopy.distance as cd 
41  >>> cosmo = {'omega_M_0':0.3, 'omega_lambda_0':0.7, 'omega_k_0':0.0, 'h':0.72} 
42  >>> d_co = cd.comoving_distance(6., **cosmo) 
43  >>> print "Comoving distance to z=6 is %.1f Mpc" % (d_co) 
44  Comoving distance to z=6 is 8017.8 Mpc 
45   
46  The cosmolopy package also defines some convenient shortcuts, 
47  including a fiducial cosmology (currently the WMAP7+BAO+H0 mean), so 
48  you can just do this: 
49   
50  >>> from cosmolopy import * 
51  >>> d_a = cd.angular_diameter_distance(6, **fidcosmo) 
52  >>> print "Angluar-diameter distance to z=6 is %.1f Mpc" % (d_a) 
53  Angluar-diameter distance to z=6 is 1209.9 Mpc 
54  >>> d_light = cd.light_travel_distance(6, **fidcosmo) 
55  >>> print "Light-travel distance to z=6 is %.1f Mpc" % (d_light) 
56  Light-travel distance to z=6 is 3922.9 Mpc 
57   
58  Calculate the mass of a halo with Virial temperature of 10^4 kelvin, 
59  then verify the Virial temperature for a halo of that mass: 
60   
61  >>> import cosmolopy.perturbation as cp 
62  >>> cosmo = {'omega_M_0' : 0.27,  
63  ... 'omega_lambda_0' : 1-0.27,  
64  ... 'omega_b_0' : 0.045,  
65  ... 'omega_n_0' : 0.0, 
66  ... 'N_nu' : 0, 
67  ... 'h' : 0.72, 
68  ... 'n' : 1.0, 
69  ... 'sigma_8' : 0.9 
70  ... }  
71  >>> mass = cp.virial_mass(1e4, 6.0, **cosmo) 
72  >>> temp = cp.virial_temp(mass, 6.0, **cosmo) 
73  >>> print "Mass = %.3g M_sun" % mass 
74  Mass = 1.68e+08 M_sun 
75  >>> print round(temp, 4) 
76  10000.0 
77   
78  Calculate the critical and matter densities: 
79   
80  >>> from cosmolopy import * 
81  >>> 'rho_crit=%.3g Msun/Mpc^3, rho_0=%.3g Msun/Mpc^3' % cden.cosmo_densities(**fidcosmo) 
82  'rho_crit=1.38e+11 Msun/Mpc^3, rho_0=3.75e+10 Msun/Mpc^3' 
83   
84  Look in the tests/ and examples/ directories for more examples.  
85   
86  """ 
87   
88  import constants as cc 
89  import density as cden 
90  import distance as cd 
91  import perturbation as cp 
92  import reionization as cr 
93  import parameters as cparam 
94  import magnitudes as cmag 
95  import luminosityfunction as cl 
96   
97  fidcosmo = cparam.WMAP7_BAO_H0_mean(flat=True, extras=True) 
98