本文整理汇总了Python中astropy.cosmology.FlatLambdaCDM.angular_diameter_distance_z1z2方法的典型用法代码示例。如果您正苦于以下问题:Python FlatLambdaCDM.angular_diameter_distance_z1z2方法的具体用法?Python FlatLambdaCDM.angular_diameter_distance_z1z2怎么用?Python FlatLambdaCDM.angular_diameter_distance_z1z2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.cosmology.FlatLambdaCDM
的用法示例。
在下文中一共展示了FlatLambdaCDM.angular_diameter_distance_z1z2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _LS
# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import angular_diameter_distance_z1z2 [as 别名]
def _LS(lense, source, rand, weight = None, Boost = False):
"""
Calculate Lensing Signal deltaSigma, Boost Factor, Corrected deltaSigma
parameter
---------
lense : lense catalog
source : source catalog (shear catalog that contains e1, e2)
rand : random catalog
"""
import treecorr
weight_lense, weight_source, weight_rand = weight
z_s_min = 0.7
z_s_max = 1.0
num_lense_bin = 3
num_source_bin = 3
z_l_bins = np.linspace(0.45, 0.55, num_lense_bin)
z_s_bins = np.linspace(z_s_min, z_s_max, num_source_bin)
#matrix1, matrix2 = np.mgrid[0:z_l_bins.size, 0:z_s_bins.size]
source = source[ (source['DESDM_ZP'] > z_s_min ) & (source['DESDM_ZP'] < z_s_max )]
lense = lense[ (lense['DESDM_ZP'] > 0.45) & (lense['DESDM_ZP'] < 0.55) ]
rand = rand[ (rand['Z'] > 0.45) & (rand['Z'] < 0.55) ]
z_l_bincenter, lense_binned_cat,_ = divide_bins( lense, Tag = 'DESDM_ZP', min = 0.45, max = 0.55, bin_num = num_lense_bin)
z_r_bincenter, rand_binned_cat,_ = divide_bins( rand, Tag = 'Z', min = 0.45, max = 0.55, bin_num = num_lense_bin)
z_s_bincenter, source_binned_cat,_ = divide_bins( source, Tag = 'DESDM_ZP', min = z_s_min, max = z_s_max, bin_num = num_source_bin)
# angular diameter
from astropy.cosmology import FlatLambdaCDM
cosmo = FlatLambdaCDM(H0=70,Om0=0.274)
from astropy import constants as const
from astropy import units as u
h = 0.7
c = const.c.to(u.megaparsec / u.s)
G = const.G.to(u.megaparsec**3 / (u.M_sun * u.s**2))
dA_l = cosmo.angular_diameter_distance(z_l_bins) * h
dA_s = cosmo.angular_diameter_distance(z_s_bins) * h
matrix1, matrix2 = np.mgrid[0:z_l_bins.size, 0:z_s_bins.size]
dA_ls = cosmo.angular_diameter_distance_z1z2(z_l_bins[matrix1],z_s_bins[matrix2]) * h
dA_l_matrix = dA_l[matrix1]
dA_s_matrix = dA_s[matrix2]
Sigma_critical = c**2 / (4 * np.pi * G) * dA_s_matrix/(dA_l_matrix * dA_ls)
min_sep_1 = 0.001
bin_size = 0.4
nbins = 30
theta = [min_sep_1 * np.exp(bin_size * i) for i in range(nbins) ]
r_p_bins = theta * dA_l[0]
if Boost is True:
n_SL = []
n_SR = []
N_SL = []
N_SR = []
weight = 1./(Sigma_critical)**2
weight = np.ones(Sigma_critical.shape)
print " ** To do : add Boost codes Weight "
for i, S in enumerate(source_binned_cat):
source_cat = treecorr.Catalog(ra=S['RA'], dec=S['DEC'], ra_units='deg', dec_units='deg')
for (j, dA), L, R in zip( enumerate(dA_l), lense_binned_cat, rand_binned_cat ):
min_sep = theta[0] * dA_l[0]/dA
lense_cat = treecorr.Catalog(ra=L['RA'], dec=L['DEC'], ra_units='deg', dec_units='deg')
rand_cat = treecorr.Catalog(ra=R['RA'], dec=R['DEC'], ra_units='deg', dec_units='deg')
SL = treecorr.NNCorrelation(min_sep=min_sep, bin_size=bin_size, nbins = nbins, sep_units='degree')
SR = treecorr.NNCorrelation(min_sep=min_sep, bin_size=bin_size, nbins = nbins, sep_units='degree')
SL.process(lense_cat, source_cat)
SR.process(rand_cat, source_cat)
w = 1./weight[j,i]**2
n_SL.append(w * SL.npairs/np.sum(SL.npairs))
n_SR.append(w * SR.npairs/np.sum(SR.npairs))
N_SL.append(SL.npairs)
N_SR.append(SR.npairs)
N_SL_list = np.sum( N_SL, axis = 0)
N_SR_list = np.sum( N_SR, axis = 0)
n_SL_list = np.sum( n_SL, axis = 0)
n_SR_list = np.sum( n_SR, axis = 0)
BoostFactor = n_SL_list/n_SR_list
nbar = 1e-4
P = 1e+4
w_FKP = 1./(nbar*P + 1)
#.........这里部分代码省略.........