8000 Assert type of cosmo object under transform. by rainwoodman · Pull Request #614 · bccp/nbodykit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Assert type of cosmo object under transform. #614

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions nbodykit/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from six import string_types
from nbodykit.utils import deprecate
from nbodykit import _global_options
from nbodykit.cosmology import Cosmology

def StackColumns(*cols):
"""
Stack the input dask arrays vertically, column by column.
Expand Down Expand Up @@ -233,6 +235,11 @@ def CartesianToSky(pos, cosmo, velocity=None, observer=[0,0,0], zmax=100., frame
TypeError
If the input columns are not dask arrays
"""
if not isinstance(cosmo, Cosmology):
raise TypeError("Please convert the cosmo object to "
"nbodykit.cosmology.Cosmology. See, e.g. "
"Cosmology.from_astropy.")

from astropy.constants import c
from scipy.interpolate import interp1d

Expand Down Expand Up @@ -364,6 +371,11 @@ def SkyToCartesian(ra, dec, redshift, cosmo, observer=[0, 0, 0], degrees=True, f
TypeError
If the input columns are not dask arrays
"""
if not isinstance(cosmo, Cosmology):
raise TypeError("Please convert the cosmo object to "
"nbodykit.cosmology.Cosmology. See, e.g. "
"Cosmology.from_astropy.")

ra, dec, redshift = da.broadcast_arrays(ra, dec, redshift)

# pos on the unit sphere
Expand Down Expand Up @@ -408,6 +420,11 @@ def HaloConcentration(mass, cosmo, redshift, mdef='vir'):
of structural parameters for Einasto and NFW profiles", 2014, arxiv:1402.7073

"""
if not isinstance(cosmo, Cosmology):
raise TypeError("Please convert the cosmo object to "
"nbodykit.cosmology.Cosmology. See, e.g. "
"Cosmology.from_astropy.")

from halotools.empirical_models import NFWProfile

mass, redshift = da.broadcast_arrays(mass, redshift)
Expand All @@ -430,6 +447,10 @@ def HaloVelocityDispersion(mass, cosmo, redshift, mdef='vir'):

See http://adsabs.harvard.edu/abs/2008ApJ...672..122E
"""
if not isinstance(cosmo, Cosmology):
raise TypeError("Please convert the cosmo object to "
"nbodykit.cosmology.Cosmology. See, e.g. "
"Cosmology.from_astropy.")

mass, redshift = da.broadcast_arrays(mass, redshift)
def compute_vdisp(mass, redshift):
Expand Down Expand Up @@ -475,6 +496,11 @@ def HaloRadius(mass, cosmo, redshift, mdef='vir'):
This is proper Mpc/h, to convert to comoving, divide this by scaling factor.

"""
if not isinstance(cosmo, Cosmology):
raise TypeError("Please convert the cosmo object to "
"nbodykit.cosmology.Cosmology. See, e.g. "
"Cosmology.from_astropy.")

from halotools.empirical_models import halo_mass_to_halo_radius

mass, redshift = da.broadcast_arrays(mass, redshift)
Expand Down
0