-
Notifications
You must be signed in to change notification settings - Fork 60
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
mocks from galaxy power spectrum for a non-gaussian field #662
Open
Jayashree-Behera
wants to merge
10
commits into
bccp:master
Choose a base branch
from
Jayashree-Behera:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1cfe672
Add files via upload
Jayashree-Behera c101e8c
Rename galaxy2.py to galaxy.py
Jayashree-Behera e9e6d0d
Update __init__.py
Jayashree-Behera 83dddca
Update galaxy.py
Jayashree-Behera 8d55dd2
Delete galaxy.py
Jayashree-Behera 7304783
Add files via upload
Jayashree-Behera 2f01049
Rename galaxy_opt.py to galaxy.py
Jayashree-Behera 282da4d
Add files via upload
Jayashree-Behera 383dd56
Add files via upload
Jayashree-Behera a5bd6e6
Add the galaxy unit test functions
Jayashree-Behera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .galaxy_opt import FNLGalaxyPower | ||
from .linear import LinearPower, EHPower, NoWiggleEHPower | ||
from .zeldovich import ZeldovichPower | ||
from .halofit import HalofitPower | ||
from . import transfers | ||
from . import transfers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import numpy | ||
from . import transfers | ||
from ..cosmology import Cosmology | ||
from .linear import LinearPower | ||
|
||
class FNLGalaxyPower(object): | ||
""" | ||
An object to compute the galaxy/redshift power spectrum and related quantities, | ||
using a transfer function from the CLASS code or the analytic | ||
Eisenstein & Hu approximation. | ||
|
||
Parameters | ||
---------- | ||
cosmo : :class:`Cosmology`, astropy.cosmology.FLRW | ||
the cosmology instance; astropy cosmology objects are automatically | ||
converted to the proper type | ||
redshift : float | ||
the redshift of the power spectrum | ||
transfer : str, optional | ||
string specifying the transfer function to use; one of | ||
'CLASS', 'EisensteinHu', 'NoWiggleEisensteinHu' | ||
b0 : float | ||
the linear bias of the galaxy in a gaussian field | ||
fnl : float | ||
primordial non-gaussian parameter | ||
p : float | ||
correction term due to galaxy selection beyond a Poisson sampling of the halos of a given mass. | ||
p takes a between 1 and 1.6. | ||
p=1 for objects populating a fair sample of all the halos | ||
p=1.6 for objects that populate only recently merged halos | ||
Omega_m : float | ||
the matter density parameter | ||
H0 : float | ||
the Hubble constant (in units of km/s Mpc/h) | ||
c : float | ||
speed of light (in units of km/s) | ||
|
||
|
||
Attributes | ||
---------- | ||
cosmo : class:`Cosmology` | ||
the object giving the cosmological parameters | ||
sigma8 : float | ||
the z=0 amplitude of matter fluctuations | ||
redshift : float | ||
the redshift to compute the power at | ||
transfer : str | ||
the type of transfer function used | ||
""" | ||
|
||
def __init__(self, cosmo, redshift ,b0 ,fNL ,p ,c=3e5 ,transfer='CLASS'): | ||
from astropy.cosmology import FLRW | ||
|
||
# convert astropy | ||
if isinstance(cosmo, FLRW): | ||
from nbodykit.cosmology import Cosmology | ||
cosmo = Cosmology.from_astropy(cosmo) | ||
|
||
# store a copy of the cosmology | ||
self.cosmo = cosmo.clone() | ||
|
||
#get the linear bias,p,fNL,omega_m,H0,c | ||
self.b=b0 | ||
self.p=p | ||
self.fnl=fNL | ||
self.omega_m=cosmo.Omega0_m | ||
self.H0=cosmo.H0 | ||
self.c=c | ||
|
||
self.transfer = transfer | ||
|
||
# set redshift | ||
self.redshift = redshift | ||
|
||
|
||
def total_bias(self, k): | ||
""" | ||
Returns the total galaxy bias in a non-gaussian field at the redshift | ||
specified by :attr:`redshift`. | ||
|
||
Parameters | ||
--------- | ||
k : float, array_like | ||
the wavenumber in units of :math:`h Mpc^{-1}` | ||
|
||
Returns | ||
------- | ||
total_bias : float, array_like | ||
the total bias | ||
|
||
""" | ||
Plin=LinearPower(self.cosmo, self.redshift, transfer=self.transfer) | ||
Pk=Plin(k) | ||
crit_density=1.686 | ||
Dz=1/(1+self.redshift) | ||
del_b= 3*self.fnl*(self.b-self.p)* crit_density * self.omega_m/(k**2*Pk**0.5*Dz) * (self.H0/self.c)**2 | ||
|
||
total_bias=self.b + del_b | ||
|
||
return total_bias | ||
|
||
def __call__(self, k): | ||
""" | ||
Return the galaxy power spectrum in units of | ||
:math:`h^{-3} \mathrm{Mpc}^3` at the redshift specified by | ||
:attr:`redshift`. | ||
|
||
The transfer function used to evaluate the power spectrum is | ||
specified by the ``transfer`` attribute. | ||
|
||
Parameters | ||
--------- | ||
k : float, array_like | ||
the wavenumber in units of :math:`h Mpc^{-1}` | ||
|
||
Returns | ||
------- | ||
Pk : float, array_like | ||
the galaxy power spectrum evaluated at ``k`` in units of | ||
:math:`h^{-3} \mathrm{Mpc}^3` | ||
""" | ||
|
||
Plin=LinearPower(self.cosmo, self.redshift, transfer=self.transfer) | ||
Pk=Plin(k) | ||
total_bias=self.total_bias(k) | ||
|
||
Pgal = Pk * total_bias**2 | ||
|
||
return Pgal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does this parameter have a more descriptive name from the literature? It is like a bias correction parameter (removed from b)? larger p -> lower clustering?
What is a recently merged halo? A halo that recently experienced a merger event from progenitors of similar masses?