Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Guang
x-cigale
Commits
54834293
Commit
54834293
authored
Jul 08, 2019
by
Guang
Committed by
Guang
Oct 23, 2019
Browse files
optimize redshifting for speed
parent
6b81bd30
Changes
1
Hide whitespace changes
Inline
Side-by-side
pcigale/sed_modules/redshifting.py
View file @
54834293
...
@@ -76,10 +76,10 @@ def igm_transmission(wavelength, redshift):
...
@@ -76,10 +76,10 @@ def igm_transmission(wavelength, redshift):
# n = 3 - 9 -> 1
# n = 3 - 9 -> 1
for
n
in
range
(
3
,
n_transitions_max
):
for
n
in
range
(
3
,
n_transitions_max
):
if
n
<=
5
:
if
n
<=
5
:
w
=
np
.
where
(
z_n
[
n
,
:]
<
3
)
w
=
z_n
[
n
,
:]
<
3
tau_n
[
n
,
w
]
=
(
tau_a
*
fact
[
n
]
*
tau_n
[
n
,
w
]
=
(
tau_a
*
fact
[
n
]
*
np
.
power
(
0.25
*
(
1.
+
z_n
[
n
,
w
]),
(
1.
/
3.
)))
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
]
*
tau_n
[
n
,
w
]
=
(
tau_a
*
fact
[
n
]
*
np
.
power
(
0.25
*
(
1.
+
z_n
[
n
,
w
]),
(
1.
/
6.
)))
np
.
power
(
0.25
*
(
1.
+
z_n
[
n
,
w
]),
(
1.
/
6.
)))
elif
5
<
n
<=
9
:
elif
5
<
n
<=
9
:
...
@@ -91,11 +91,11 @@ def igm_transmission(wavelength, redshift):
...
@@ -91,11 +91,11 @@ def igm_transmission(wavelength, redshift):
for
n
in
range
(
2
,
n_transitions_max
):
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
# 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.
tau_n
[
n
,
w
]
=
0.
z_l
=
wavelength
/
lambda_limit
-
1.
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
=
np
.
zeros_like
(
wavelength
)
tau_l_igm
[
w
]
=
(
0.805
*
np
.
power
(
1.
+
z_l
[
w
],
3
)
*
tau_l_igm
[
w
]
=
(
0.805
*
np
.
power
(
1.
+
z_l
[
w
],
3
)
*
...
@@ -120,7 +120,7 @@ def igm_transmission(wavelength, redshift):
...
@@ -120,7 +120,7 @@ def igm_transmission(wavelength, redshift):
tau_l_lls
[
w
]
=
n0
*
((
term1
-
term2
)
*
term3
-
term4
)
tau_l_lls
[
w
]
=
n0
*
((
term1
-
term2
)
*
term3
-
term4
)
# Reset for short wavelength (z_l<0)
# 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
# Get the normalization factor at z_l=0
tau_norm_l_igm
=
np
.
interp
(
0
,
z_l
,
tau_l_igm
)
tau_norm_l_igm
=
np
.
interp
(
0
,
z_l
,
tau_l_igm
)
tau_norm_l_lls
=
np
.
interp
(
0
,
z_l
,
tau_l_lls
)
tau_norm_l_lls
=
np
.
interp
(
0
,
z_l
,
tau_l_lls
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment