-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added P&R2017 neutral hydrogen mass model #347
base: module/neutral_hydrogen
Are you sure you want to change the base?
Changes from all commits
541c4ea
8197798
7192a7b
b3467ac
5d63d1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
'''This module contains methods that model the properties of neutral hydrogen. | ||
''' | ||
""" | ||
This module contains methods that model the properties of neutral hydrogen | ||
emission in the Universe. | ||
|
||
Merger Rates | ||
================ | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
:toctree: ../api/ | ||
|
||
pr_halo_model | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is the best name for the model, mostly because it makes me think that this is a halo model. Suggestions would be |
||
|
||
""" | ||
|
||
from .mass import * # noqa F401,F403 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ambiguous how the module is to be structured. In this way, you could access the function under both |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import numpy as np | ||
from astropy import units | ||
|
||
|
||
r"""HI mass module. | ||
This module provides functions to calculate neutral Hydrogen masses for haloes. | ||
|
||
""" | ||
|
||
__all__ = [ | ||
'pr_halo_model', | ||
] | ||
|
||
|
||
def pr_halo_model(halo_mass, circular_velocity, cosmology, | ||
alpha=0.17, | ||
beta=-0.55, | ||
v_c0=np.exp(1.57) * (units.km / units.s), | ||
v_c1=np.exp(4.39) * (units.km / units.s), | ||
Y_p=0.24): | ||
r"""Model of Padmanabhan & Refregier (2017), equation 1. | ||
|
||
Halo neutral Hydrogen (HI 21-cm) masses as a function of halo mass, | ||
halo circular velocity, and cosmology. | ||
|
||
Parameters | ||
---------- | ||
halo_mass : (nhalos,) `~astropy.Quantity` | ||
The masses of the underlying halos in units of solar mass. | ||
circular_velocity : (nhalos,) `~astropy.Quantity` | ||
The circular velocity for the halos in units of [km s-1]. | ||
cosmology : `~astropy.cosmology.Cosmology` | ||
Cosmology object providing values of omega_baryon and omega_matter. | ||
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be better moved to the end of the parameter list because it will be filled by the pipeline runner automatically. |
||
alpha : float | ||
Linear model constant, fit from data. | ||
beta : float | ||
Model exponent, fit from data. | ||
v_c0 : `~astropy.Quantity` | ||
Velocity for the lower exponential cutoff of the model | ||
in units of [km s-1]. | ||
v_c1 : `~astropy.Quantity` | ||
Velocity for the upper exponential cutoff of the model | ||
in units of [km s-1]. | ||
Y_p : float | ||
Cosmic Helium fraction. | ||
|
||
Returns | ||
------- | ||
m_hone : (nhalos,) `~astropy.Quantity` | ||
Neutral hydrogen mass contained in the halo, in units of solar mass. | ||
|
||
References | ||
---------- | ||
.. Padmanabhan & Refregier 2017, MNRAS, Volume 464, Issue 4, p. 4008 | ||
https://arxiv.org/abs/1607.01021 | ||
|
||
Examples | ||
-------- | ||
>>> import numpy as np | ||
>>> from astropy import units | ||
>>> from astropy.cosmology import Planck15 | ||
>>> from skypy.neutral_hydrogen import mass | ||
|
||
Sample halo masses on a grid and use a simple model for the circular velocity. | ||
|
||
>>> m_halo = np.logspace(8,15,128) * units.Msun | ||
>>> v_halo = (96.6 * (units.km / units.s)) * m_halo / (1.e11 * units.Msun) | ||
|
||
Calculate the neutral Hydrogen mass within each halo. | ||
|
||
>>> m_hone = pr_halo_model(m_halo, v_halo, Planck15) | ||
|
||
""" | ||
|
||
f_Hc = 1. - Y_p * (cosmology.Ob0 / cosmology.Om0) | ||
|
||
lower_cutoff = np.exp(-(v_c0 / circular_velocity)**3.) | ||
upper_cutoff = np.exp(-(circular_velocity / v_c1)**3.) | ||
|
||
m_pivot = (1.e11 / cosmology.h) * units.Msun | ||
|
||
m_hone = (alpha * f_Hc * halo_mass * np.power(halo_mass / m_pivot, beta) * | ||
lower_cutoff * upper_cutoff) | ||
|
||
return m_hone |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from astropy.cosmology import FlatLambdaCDM | ||
from astropy import units | ||
|
||
pr_data = np.asarray([0.00000000e+00, 8.08547768e-45, 6.40736312e+09, 3.66714636e+09, | ||
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]) * units.Msun | ||
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it useful to have half of the tests return zero masses? |
||
|
||
|
||
def test_pr_halo_model(): | ||
|
||
from skypy.neutral_hydrogen.mass import pr_halo_model | ||
|
||
cosmology = FlatLambdaCDM(Om0=1.0, H0=70.0, Ob0=0.045) | ||
|
||
m_halo = np.logspace(8, 15, 8) * units.Msun | ||
v_halo = (96.6 * (units.km / units.s)) * m_halo / (1.e11 * units.Msun) | ||
|
||
m_hone = pr_halo_model(m_halo, v_halo, cosmology) | ||
|
||
# test scalar output | ||
assert np.isscalar(pr_halo_model(m_halo[0], v_halo[0], cosmology).value) | ||
|
||
# test array output | ||
assert pr_halo_model(m_halo, v_halo, cosmology).value.shape == (8,) | ||
|
||
# test pre-computed example | ||
assert units.allclose(pr_halo_model(m_halo, v_halo, cosmology), pr_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still the heading from GW, plus too many underlines