Commit 54834293 authored by Guang's avatar Guang Committed by Guang
Browse files

optimize redshifting for speed

parent 6b81bd30
......@@ -76,10 +76,10 @@ def igm_transmission(wavelength, redshift):
# n = 3 - 9 -> 1
for n in range(3, n_transitions_max):
if n <= 5:
w = np.where(z_n[n, :] < 3)
w = z_n[n, :] < 3
tau_n[n, w] = (tau_a * fact[n] *
np.power(0.25 * (1. + z_n[n, w]), (1. / 3.)))
w = np.where(z_n[n, :] >= 3)
w = z_n[n, :] >= 3
tau_n[n, w] = (tau_a * fact[n] *
np.power(0.25 * (1. + z_n[n, w]), (1. / 6.)))
elif 5 < n <= 9:
......@@ -91,11 +91,11 @@ def igm_transmission(wavelength, redshift):
for n in range(2, n_transitions_max):
# If z_n>=redshift or z_n<0, the photon cannot be absorbed by Lyman n->1
w = np.where( (z_n[n, :] >= redshift) | (z_n[n, :] < 0) )
w = (z_n[n, :] >= redshift) | (z_n[n, :] < 0)
tau_n[n, w] = 0.
z_l = wavelength / lambda_limit - 1.
w = np.where( z_l < redshift )
w = z_l < redshift
tau_l_igm = np.zeros_like(wavelength)
tau_l_igm[w] = (0.805 * np.power(1. + z_l[w], 3) *
......@@ -120,7 +120,7 @@ def igm_transmission(wavelength, redshift):
tau_l_lls[w] = n0 * ((term1 - term2) * term3 - term4)
# Reset for short wavelength (z_l<0)
w = np.where( z_l<0 )
w = z_l<0
# Get the normalization factor at z_l=0
tau_norm_l_igm = np.interp(0, z_l, tau_l_igm)
tau_norm_l_lls = np.interp(0, z_l, tau_l_lls)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment