本文整理汇总了Python中astropy.cosmology.FlatLambdaCDM方法的典型用法代码示例。如果您正苦于以下问题:Python cosmology.FlatLambdaCDM方法的具体用法?Python cosmology.FlatLambdaCDM怎么用?Python cosmology.FlatLambdaCDM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.cosmology
的用法示例。
在下文中一共展示了cosmology.FlatLambdaCDM方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _subclass_init
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def _subclass_init(self, catalog_root_dir,
catalog_path_template,
use_cache=True,
**kwargs): #pylint: disable=W0221
if not os.path.isdir(catalog_root_dir):
raise RuntimeError("Catalog directory %s does not exist." % (catalog_root_dir))
self._catalog_path_template = {k: os.path.join(catalog_root_dir, v) for k, v in catalog_path_template.items()}
cosmology = kwargs.get('cosmology', {})
cosmo_astropy_allowed = FlatLambdaCDM.__init__.__code__.co_varnames[1:]
cosmo_astropy = {k: v for k, v in cosmology.items() if k in cosmo_astropy_allowed}
self.cosmology = FlatLambdaCDM(**cosmo_astropy)
for k, v in cosmology.items():
if k not in cosmo_astropy_allowed:
setattr(self.cosmology, k, v)
self.lightcone = kwargs.get('lightcone')
self.sky_area = kwargs.get('sky_area')
self.cache = dict() if use_cache else None
self._members_only = kwargs.get('members_only')
self._quantity_modifiers = self._generate_quantity_modifiers()
示例2: __init__
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def __init__(self, **cosmology_kwargs):
# Default cosmology to use. This is the one assumed for the PLAsTiCC
# dataset.
cosmology_parameters = {"H0": 70, "Om0": 0.3, "Tcmb0": 2.725}
cosmology_parameters.update(cosmology_kwargs)
self.cosmology = FlatLambdaCDM(**cosmology_parameters)
示例3: test_to_astropy
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def test_to_astropy():
from astropy.cosmology import FlatLambdaCDM, LambdaCDM
from astropy.cosmology import FlatwCDM, wCDM
from astropy.cosmology import Flatw0waCDM, w0waCDM
# lambda CDM
for cls in [FlatLambdaCDM, LambdaCDM]:
if "Flat" in cls.__name__:
c1 = Cosmology(Omega_k=0.)
else:
c1 = Cosmology(Omega_k=0.05)
c2 = c1.to_astropy()
assert isinstance(c2, cls)
assert_allclose(c2.Ok0, c1.Omega0_k, rtol=1e-3)
# w0 CDM
for cls in [FlatwCDM, wCDM]:
if "Flat" in cls.__name__:
c1 = Cosmology(w0_fld=-0.9, Omega_k=0.)
else:
c1 = Cosmology(w0_fld=-0.9, Omega_k=0.05)
c2 = c1.to_astropy()
assert isinstance(c2, cls)
assert_allclose(c2.Ok0, c1.Omega0_k, rtol=1e-3)
assert_allclose(c2.w0, c1.w0_fld)
# wa w0 CDM
for cls in [Flatw0waCDM, w0waCDM]:
if "Flat" in cls.__name__:
c1 = Cosmology(wa_fld=0.05, w0_fld=-0.9, Omega_k=0.)
else:
c1 = Cosmology(wa_fld=0.05, w0_fld=-0.9, Omega_k=0.05)
c2 = c1.to_astropy()
assert isinstance(c2, cls)
assert_allclose(c2.Ok0, c1.Omega0_k, rtol=1e-3)
assert_allclose(c2.w0, c1.w0_fld)
assert_allclose(c2.wa, c1.wa_fld)
示例4: test_bad_no_Ob0
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def test_bad_no_Ob0():
from astropy.cosmology import FlatLambdaCDM
c = FlatLambdaCDM(Om0=0.3, H0=70) # no Ob0
with pytest.raises(ValueError):
c = Cosmology.from_astropy(c)
示例5: test_cosmology
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def test_cosmology(protoDC2):
assert isinstance(protoDC2.cosmology, FlatLambdaCDM), '`cosmology` must be a FlatLambdaCDM subclass'
print('cosmology =', protoDC2.cosmology)
示例6: __init__
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def __init__(self, z_lens, z_source, cosmo=None):
"""
:param z_lens: redshift of lens
:param z_source: redshift of source
:param cosmo: astropy cosmology instance
"""
if cosmo is None:
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self._lens_cosmo = LensCosmo(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
super(NFWVirTrunc, self).__init__()
示例7: __init__
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def __init__(self, z_lens, z_source, cosmo=None, static=False):
"""
:param z_lens: redshift of lens
:param z_source: redshift of source
:param cosmo: astropy cosmology instance
:param static: boolean, if True, only operates with fixed parameter values
"""
self._nfw = NFW()
if cosmo is None:
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self._lens_cosmo = LensCosmo(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
self._static = static
super(NFWMC, self).__init__()
示例8: _get_cosom
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def _get_cosom(self, H_0, Om0, Ode0=None):
"""
:param H_0:
:param Om0:
:param Ode0:
:return:
"""
if self._flat is True:
cosmo = FlatLambdaCDM(H0=H_0, Om0=Om0)
else:
cosmo = LambdaCDM(H0=H_0, Om0=Om0, Ode0=Ode0)
lensCosmo = LensCosmo(z_lens=self.z_lens, z_source=self.z_source, cosmo=cosmo)
return lensCosmo
示例9: cosmo2angular_diameter_distances
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def cosmo2angular_diameter_distances(H_0, omega_m, z_lens, z_source):
"""
:param H_0: Hubble constant [km/s/Mpc]
:param omega_m: dimensionless matter density at z=0
:param z_lens: deflector redshift
:param z_source: source redshift
:return: angular diameter distances Dd and Ds/Dds
"""
cosmo = FlatLambdaCDM(H0=H_0, Om0=omega_m, Ob0=0.)
lensCosmo = LensCosmo(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
Dd = lensCosmo.dd
Ds = lensCosmo.ds
Dds = lensCosmo.dds
return Dd, Ds/Dds
示例10: setup
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def setup(self):
z_L = 0.8
z_S = 3.0
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self.lensCosmo = LensCosmo(z_L, z_S, cosmo=cosmo)
示例11: setup
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def setup(self):
z_L = 0.8
z_S = 3.0
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self.nfwParam = NFWParam()
示例12: setup
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def setup(self):
self.z_L = 0.8
self.z_S = 3.0
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self.bkg = Background(cosmo=cosmo)
示例13: setup
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def setup(self):
self.z_lens, self.z_source = 0.5, 2
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self.nfw = NFW()
self.nfwmc = NFWMC(z_source=self.z_source, z_lens=self.z_lens, cosmo=cosmo)
self.lensCosmo = LensCosmo(z_lens=self.z_lens, z_source=self.z_source, cosmo=cosmo)
示例14: setup
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def setup(self):
z_lens = 0.55
z_source = 2.5
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
self.nfw = NFWVirTrunc(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
self.lensCosmo = LensCosmo(z_lens=z_lens, z_source=z_source, cosmo=cosmo)
NFWVirTrunc(z_lens=z_lens, z_source=z_source, cosmo=None)
示例15: set_cosmology
# 需要导入模块: from astropy import cosmology [as 别名]
# 或者: from astropy.cosmology import FlatLambdaCDM [as 别名]
def set_cosmology(cosmology=None):
"""
Get an instance of a astropy.cosmology.FLRW subclass.
To avoid repeatedly instantiating the same class, test if it is the same
as the last used cosmology.
Parameters
----------
cosmology: astropy.cosmology.FLRW, str, dict
Description of cosmology, one of:
None - Use DEFAULT_COSMOLOGY
Instance of astropy.cosmology.FLRW subclass
String with name of known Astropy cosmology, e.g., "Planck13"
Dictionary with arguments required to instantiate the cosmology
class.
Returns
-------
cosmo: astropy.cosmology.FLRW
Cosmology instance
"""
if cosmology is None:
cosmology = DEFAULT_COSMOLOGY
elif isinstance(cosmology, cosmo.FLRW):
cosmology = cosmology
elif isinstance(cosmology, str):
cosmology = cosmo.__dict__[cosmology]
elif isinstance(cosmology, dict):
if 'Ode0' in cosmology.keys():
if 'w0' in cosmology.keys():
cosmology = cosmo.wCDM(**cosmology)
else:
cosmology = cosmo.LambdaCDM(**cosmology)
else:
cosmology = cosmo.FlatLambdaCDM(**cosmology)
COSMOLOGY[0] = cosmology
if cosmology.name is not None:
COSMOLOGY[1] = cosmology.name
else:
COSMOLOGY[1] = repr(cosmology)