Skip to content

Commit

Permalink
tau doctsring
Browse files Browse the repository at this point in the history
  • Loading branch information
sambit-giri committed Aug 28, 2024
1 parent 3cb4964 commit 5e5bfd4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/tools21cm/tau.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ def tau(ionfractions, redshifts, num_points = 50):
* The Universe is assumed to be fully ionized at the lowest redshift supplied.
* To get the total optical depth, look at the last value in tau_0
Example:
To calculate the optical depth for a scenario where the Universe is instantaneously
reionized:
>>> z_reion = 11.
>>> redshifts = np.linspace(z_reion, 1100., 50)
>>> ionfracs = np.zeros(len(redshifts))
>>> tau0, tau_z = tau(ionfracs, redshifts)
>>> print 'Total tau: ', tau0[-1]
0.0884755058758
'''

if len(ionfractions) != len(redshifts):
Expand Down
20 changes: 20 additions & 0 deletions tests/test_optical_depth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import numpy as np
import tools21cm as t2c

def test_Thomson_optical_depth():
"""
To calculate the optical depth for a scenario where the Universe is instantaneously
reionized:
>>> z_reion = 11.
>>> redshifts = np.linspace(z_reion, 1100., 50)
>>> ionfracs = np.zeros(len(redshifts))
>>> tau0, tau_z = tau(ionfracs, redshifts)
>>> print 'Total tau: ', tau0[-1]
0.0884755058758
"""
z_reion = 11.
redshifts = np.linspace(z_reion, 1100., 50)
ionfracs = np.zeros(len(redshifts))
tau0, tau_z = t2c.tau(ionfracs, redshifts)
assert np.abs(tau0[-1]-0.0884755058758)<0.01

0 comments on commit 5e5bfd4

Please sign in to comment.