當前位置: 首頁>>代碼示例>>Python>>正文


Python Planck13.angular_diameter_distance方法代碼示例

本文整理匯總了Python中astropy.cosmology.Planck13.angular_diameter_distance方法的典型用法代碼示例。如果您正苦於以下問題:Python Planck13.angular_diameter_distance方法的具體用法?Python Planck13.angular_diameter_distance怎麽用?Python Planck13.angular_diameter_distance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在astropy.cosmology.Planck13的用法示例。


在下文中一共展示了Planck13.angular_diameter_distance方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: lensed_sersic

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def lensed_sersic(xi1,xi2,source_cat,lens_cat):

    xlc1 = lens_cat[0]          # x position of the lens, arcseconds
    xlc2 = lens_cat[1]          # y position of the lens, arcseconds
    rlc  = 0.0                  # core size of Non-singular Isothermal Ellipsoid
    rle  = re_sv(lens_cat[2],lens_cat[5],source_cat[7])       #Einstein radius of lens, arcseconds.
    ql   = lens_cat[3]          # axis ratio b/a
    phl = lens_cat[4]           # orientation, degree
    #----------------------------------------------------------------------
    ai1,ai2,mua = lens_equation_sie(xi1,xi2,xlc1,xlc2,ql,rlc,rle,phl)

    yi1 = xi1-ai1
    yi2 = xi2-ai2

    ysc1 = source_cat[0]        # x position of the source, arcseconds
    ysc2 = source_cat[1]        # y position of the source, arcseconds
    mag_tot = source_cat[2]     # total magnitude of the source
    Reff_arc = source_cat[3]    # Effective Radius of the source, arcseconds
    qs   = source_cat[4]        # axis ratio of the source, b/a
    phs  = source_cat[5]        # orientation of the source, degree
    ndex = source_cat[6]        # index of the source
    zs = source_cat[7]          # redshift of the source

    Da_s = p13.angular_diameter_distance(zs).value
    Reff = Reff_arc*Da_s/apr*1e6 # pc
    Ieff = sersic_mag_tot_to_Ieff(mag_tot,Reff,ndex,zs) #L_sun/kpc^2
    g_limage = sersic_2d(yi1,yi2,ysc1,ysc2,Ieff,Reff_arc,qs,phs,ndex)
    g_source = sersic_2d(xi1,xi2,ysc1,ysc2,Ieff,Reff_arc,qs,phs,ndex)

    mag_lensed = mag_tot - np.log(np.sum(g_limage)/np.sum(g_source))

    return mag_lensed, g_limage
開發者ID:linan7788626,項目名稱:hack_with_Matt,代碼行數:34,代碼來源:SL1.py

示例2: producing_lensed_images

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def producing_lensed_images(xi1,xi2,source_cat,lens_cat):

    xlc1 = lens_cat[0]
    xlc2 = lens_cat[1]
    ql   = lens_cat[2]
    rlc  = 0.0
    rle  = re_sv(lens_cat[3],lens_cat[5],source_cat[7])       #Einstein radius of lens Arc Seconds.

    phl = lens_cat[4]
    #----------------------------------------------------------------------
    ai1,ai2,mua = lens_equation_sie(xi1,xi2,xlc1,xlc2,ql,rlc,rle,phl)

    yi1 = xi1-ai1*0.0
    yi2 = xi2-ai2*0.0

    ysc1 = source_cat[0]
    ysc2 = source_cat[1]
    mag_tot = source_cat[2]
    Reff_arc = np.sqrt(source_cat[3]*source_cat[4])
    qs   = np.sqrt(source_cat[3]/source_cat[4])
    phs  = source_cat[5]
    ndex = source_cat[6]
    zs = source_cat[7]

    #g_limage = sersic_SB_2D_tot(yi1,yi2,ysc1,ysc2,mag_tot,Reff_arc,qs,phs,zs)
    Da_s = p13.angular_diameter_distance(2.0).value
    Reff = Reff_arc*Da_s/apr*1e6 # pc
    Ieff = sersic_mag_tot_to_Ieff(mag_tot,Reff,ndex,zs)
    g_limage = sersic_2d(yi1,yi2,ysc1,ysc2,Ieff,Reff_arc,qs,phs,ndex)

    return g_limage
開發者ID:linan7788626,項目名稱:hack_with_Matt,代碼行數:33,代碼來源:catalogize_lensed_images.py

示例3: get_redmapper

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def get_redmapper(objID, ir, z, z_err, transverse, dz):
	'''
	Find the corresponding galaxy cluster in the redMaPPer catalog
	First check against member catalog, then check radially
	If multiple clusters match, choose the one with least angular separation
	'''
	
	# If the galaxy is too close, physical separations become too great on the sky
	# Restrict redshifts to at least 0.01
	if z < 0.01:
		return None
	
	member = rm_m.find_one({'ObjID':objID})
	if member is not None:
		return rm_c.find_one({'ID':member['ID']})
	
	# Maximum separation
	max_sep = float(transverse * u.Mpc / cosmo.angular_diameter_distance(z) * u.rad / u.deg)
	
	best_sep = np.inf
	cluster = None
	for temp_c in rm_c.find({'RAdeg':{'$gt':ir.ra.deg-max_sep, '$lt':ir.ra.deg+max_sep}, 'DEdeg':{'$gt':ir.dec.deg-max_sep, '$lt':ir.dec.deg+max_sep}, \
							 '$or':[{'zspec':{'$gt':z-dz, '$lt':z+dz}}, {'zlambda':{'$gt':z-dz, '$lt':z+dz}}]}):
		current_sep = ir.separation( coord.SkyCoord(temp_c['RAdeg'], temp_c['DEdeg'], unit=(u.deg,u.deg), frame='icrs') )
		if (current_sep < best_sep) and (current_sep < max_sep*u.deg):
			best_sep = current_sep
			cluster = temp_c
	
	return cluster
開發者ID:MatthewJA,項目名稱:rgz-analysis,代碼行數:31,代碼來源:bending_analysis.py

示例4: get_catalog

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def get_catalog(df, weights=None, shear=False, lens=False, z_lens=None):
    """Return TreeCorr Catalog in Mpc."""
    if z_lens is None:
        raise ValueError('must enter a value for z_lens')
    else:
        dA_lens = cosmo.angular_diameter_distance(z_lens)
    if type(df) != pd.core.frame.DataFrame:
        raise TypeError('df must be a dataframe')

    if lens is True:
        cdf_zslice = df[np.isclose(df.z, z_lens)]
        x_lens_mpc = pix2rad(cdf_zslice['x[0]']) * dA_lens
        y_lens_mpc = pix2rad(cdf_zslice['x[1]']) * dA_lens
        cat = treecorr.Catalog(x=x_lens_mpc, y=y_lens_mpc)

    elif shear is True:
        # insert function to select on zphot & P(z) conditions
        # sdf_z = df[df.zphot > z_lens && 90% P(z) above z_lens]
        x_shear_mpc = pix2rad(df['x[0]']) * dA_lens  # tbr
        y_shear_mpc = pix2rad(df['x[1]']) * dA_lens  # tbr

        cat = treecorr.Catalog(x=x_shear_mpc, y=y_shear_mpc,
                               g1=df['e[0]'], g2=df['e[1]'])
    else:
        x_mpc = pix2rad(df['x[0]']) * dA_lens
        y_mpc = pix2rad(df['x[1]']) * dA_lens
        cat = treecorr.Catalog(x=x_mpc, y=y_mpc)

    if weights is not None:
        cat.k = np.ones(df.shape[0])
        for w in weights:
            cat.k *= df[w].values

    return cat
開發者ID:jesford,項目名稱:MagniPy,代碼行數:36,代碼來源:catalog_munging.py

示例5: r200

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def r200(z,M_200): ## unit: arcsec

	critical_density = Planck13.critical_density(z).si.value # unit: kg/m^3
	m2arcs = np.degrees(1.0/Planck13.angular_diameter_distance(z).si.value)*3600.
	critical_density  = critical_density*Planck13.H0/100./m2arcs**3/2e30 # unit: Msun/arcsec^3/h

	r200_cube = 200*critical_density/M_200/(4./3.*np.pi)
	r200 = r200_cube**(1./3.)

	return r200
開發者ID:jwhsueh,項目名稱:SHARP_jw,代碼行數:12,代碼來源:NFWprofile.py

示例6: sersic_SB_2D_tot

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def sersic_SB_2D_tot(xi1,xi2,xc1,xc2,mag_tot,Reff_arc,ql,pha,z,ndex=4.0):

    #Dl_s = p13.luminosity_distance(z).value
    Da_s = p13.angular_diameter_distance(z).value
    Reff = Reff_arc*Da_s/apr*1e6
    mueff=sersic_mag_tot_to_mueff(mag_tot,Reff,ndex,z)
    bn = 2.0*ndex-1/3.0+0.009876/ndex
    (xi1new,xi2new) = xy_rotate(xi1, xi2, xc1, xc2, pha)
    R_arc = np.sqrt((xi1new**2)*ql+(xi2new**2)/ql)/Reff_arc
    res = mueff + (2.5*bn)/np.log(10.0)*((R_arc/Reff_arc)**(1.0/ndex)-1.0)
    return res
開發者ID:linan7788626,項目名稱:hack_with_Matt,代碼行數:13,代碼來源:catalogize_lensed_images.py

示例7: lens_img_cat

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def lens_img_cat(lens_cat):
    xlc1 = lens_cat[0]
    xlc2 = lens_cat[1]
    ql = lens_cat[2]
    sigmav = lens_cat[3]
    phl = lens_cat[4]
    zl = lens_cat[5]
    ndex = 4

    zl_array, sv_array, re_array, le_array=np.loadtxt("./apj512628t1_ascii.txt",comments='#', usecols=(0,1,2,3),unpack=True)
    Reff_r,Iebar_r = vd_matching(sigmav,sv_array, re_array, le_array)
    Ieff_r = sersic.sersic_Iebar_to_Ieff(Iebar_r,Reff_r,ndex)
    mag_tot = sersic.sersic_mag_in_Rcut(Ieff_r,Reff_r*1e3,ndex,zl)

    Da_l = p13.angular_diameter_distance(zl).value
    Reff_arc = Reff_r*0.001/Da_l*apr
    return [xlc1, xlc2, mag_tot, Reff_arc/np.sqrt(ql), Reff_arc*np.sqrt(ql), phl, ndex, zl, lens_cat[6]]
開發者ID:linan7788626,項目名稱:hack_with_Matt,代碼行數:19,代碼來源:matching_for_lens_galaxy.py

示例8: __init__

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
    def __init__(self, redshifts, cosmology='Planck13', cm='DuttonMaccio'):
        if type(redshifts) != np.ndarray:
            redshifts = np.array(redshifts)
        if redshifts.ndim != 1:
            raise ValueError("Input redshift array must have 1 dimension.")
        if np.sum(redshifts < 0.) > 0:
            raise ValueError("Redshifts cannot be negative.")

        if cosmology == 'Planck13':
            from astropy.cosmology import Planck13 as cosmo
        elif cosmology == 'WMAP9':
            from astropy.cosmology import WMAP9 as cosmo
        elif cosmology == 'WMAP7':
            from astropy.cosmology import WMAP7 as cosmo
        elif cosmology == 'WMAP5':
            from astropy.cosmology import WMAP5 as cosmo
        else:
            raise ValueError('Input cosmology must be one of: \
                              Planck13, WMAP9, WMAP7, WMAP5.')
        self._cosmo = cosmo

        if cm == 'DuttonMaccio':
            self._cm = 'DuttonMaccio'
        elif cm == 'Prada':
            self._cm = 'Prada'
        elif cm == 'Duffy':
            self._cm = 'Duffy'
        else:
            raise ValueError('Input concentration-mass relation must be \
                              one of: DuttonMaccio, Prada, Duffy.')

        self.describe = "Ensemble of galaxy clusters and their properties."
        self.number = redshifts.shape[0]
        self._z = redshifts
        self._rho_crit = cosmo.critical_density(self._z)
        self._massrich_norm = 2.7 * (10**13) * units.Msun
        self._massrich_slope = 1.4
        self._df = pd.DataFrame(self._z, columns=['z'])
        self._Dang_l = cosmo.angular_diameter_distance(self._z)
        self._m200 = None
        self._n200 = None
        self._r200 = None
        self._rs = None
        self._c200 = None
        self._deltac = None
開發者ID:inonchiu,項目名稱:cluster-lensing,代碼行數:47,代碼來源:clusters.py

示例9: lens_img_cat

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def lens_img_cat(lens_cat):
    xlc1 = lens_cat[0]
    xlc2 = lens_cat[1]
    ql = lens_cat[2]
    sigmav = lens_cat[3]
    phl = lens_cat[4]
    zl = lens_cat[5]

    zl_array, sv_array, re_array, le_array=np.loadtxt("./apj512628t1_ascii.txt",comments='#', usecols=(0,1,2,3),unpack=True)

    Reff_r,log10_Ieff_r = return_re_le(sigmav,sv_array, re_array, le_array)
    #Dl_l = p13.luminosity_distance(zl)
    Da_l = p13.angular_diameter_distance(zl).value
    Reff_arc = Reff_r/Da_l*apr*0.001 # arcsec
    Ieff_r = 10.0**(log10_Ieff_r) #/3.61 # http://www.astro.spbu.ru/staff/resh/Lectures/lec2.pdf
    ndex = 4
    mag_tot = sersic.sersic_mag_in_Rcut(Ieff_r,Reff_r,ndex)

    return [xlc1, xlc2, mag_tot, Reff_arc/np.sqrt(ql), Reff_arc*np.sqrt(ql), phl, ndex, zl]
開發者ID:linan7788626,項目名稱:hack_with_Matt,代碼行數:21,代碼來源:amatching.py

示例10: get_amf

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def get_amf(ir, z, z_err, transverse, dz):
	'''
	Find the corresponding galaxy cluster in the WHL15 catalog
	If multiple clusters match, choose the one with least angular separation
	'''
	
	# If the galaxy is too close, physical separations become too great on the sky
	# Restrict redshifts to at least 0.01
	if z < 0.01:
		return None
	
	# Maximum separation
	max_sep = float(transverse * u.Mpc / cosmo.angular_diameter_distance(z) * u.rad / u.deg)
	
	best_sep = np.inf
	cluster = None
	for temp_c in amf.find({'ra':{'$gt':ir.ra.deg-max_sep, '$lt':ir.ra.deg+max_sep}, 'dec':{'$gt':ir.dec.deg-max_sep, '$lt':ir.dec.deg+max_sep}, \
							'z':{'$gt':z-dz, '$lt':z+dz}}):
		current_sep = ir.separation( coord.SkyCoord(temp_c['ra'], temp_c['dec'], unit=(u.deg,u.deg), frame='icrs') )
		if (current_sep < best_sep) and (current_sep < max_sep*u.deg):
			best_sep = current_sep
			cluster = temp_c
	
	return cluster
開發者ID:MatthewJA,項目名稱:rgz-analysis,代碼行數:26,代碼來源:bending_analysis.py

示例11: re_sv

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def re_sv(sv,z1,z2):
    Da_s = p13.angular_diameter_distance(z2).value
    Da_ls = p13.angular_diameter_distance_z1z2(z1,z2).value
    res = 4.0*np.pi*(sv**2.0/(const.c.value/1e3)**2.0)*Da_ls/Da_s*apr
    return res
開發者ID:linan7788626,項目名稱:hack_with_Matt,代碼行數:7,代碼來源:catalogize_lensed_images.py

示例12: make_r_coor

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
    resb = 0.2
    stheta = 35.0

    source_cat = [ys1, ys2, mag_srcs, resa, resb, stheta, ndex, zs]
    lens_cat = [xl1, xl2, ql, vd, phi, zd, lid]

    dsx = 0.01
    nnn = 1000

    xi1, xi2 = make_r_coor(nnn,dsx)

    lensed_images = producing_lensed_images(xi1,xi2,source_cat,lens_cat)


    Dl_s = p13.luminosity_distance(zs).value
    Da_s = p13.angular_diameter_distance(zs).value
    Reff_arc = np.sqrt(resa*resb)
    Reff = Reff_arc*Da_s/apr*1e6 # pc
    ndex = 4.0
    Ieff = sersic_mag_tot_to_Ieff(mag_srcs,Reff,ndex,zs)
    Ltot = sersic_L_Rcut(Ieff,Reff,ndex)

    MAG = sersic_Abs_MAG_Rcut(Ieff,Reff,ndex)
    mueff = sersic_mag_tot_to_mueff(24,Reff,ndex,2.0)
    Ieff2 = 10.0**((21.572+5.12-mueff)*0.4)
    #Ltmp = np.sum(sersic_2d(xi1,xi2,0.0,0.0,Ieff,Reff_arc,0.5,35.0,ndex))*(dsx*Da_s/apr*1e6)**2.0
    Ltmp = np.sum(lensed_images)*(dsx*Da_s/apr*1e6)**2.0
    magtmp = 5.12 - 2.5*np.log10(Ltmp)+5.0*np.log10(Dl_s*1e6/10.0)

    pyfits.writeto(str(magtmp)+"_lensed_images.fits",lensed_images, clobber=True)
開發者ID:linan7788626,項目名稱:hack_with_Matt,代碼行數:32,代碼來源:catalogize_lensed_images.py

示例13: get_cluster_match

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def get_cluster_match(source):
	'''
	Given a source from RGZ, match it to a cluster and calculate the redshift-dependent bending parameters
	'''
	
	ir = coord.SkyCoord(source['SDSS']['ra'], source['SDSS']['dec'], unit=(u.deg,u.deg), frame='icrs') if 'SDSS' in source else \
		 coord.SkyCoord(source['AllWISE']['ra'], source['AllWISE']['dec'], unit=(u.deg,u.deg), frame='icrs')
	z, z_err = get_z(source)
	
	# Match to cluster catalogs
	cluster_w = get_whl(ir, z, z_err, 15, 0.04*(1+z))
	whl_prop = {}
	if cluster_w is not None:
		c_pos = coord.SkyCoord(cluster_w['RAdeg'], cluster_w['DEdeg'], unit=(u.deg,u.deg), frame='icrs')
		c_sep_arc = c_pos.separation(ir)
		c_sep_mpc = float(cosmo.angular_diameter_distance(cluster_w['zspec'] if 'zspec' in cluster_w else cluster_w['zphot'])/u.Mpc * c_sep_arc.to(u.rad)/u.rad)
		c_pos_angle = c_pos.position_angle(ir)
		whl_prop = {'ra':c_pos.ra.deg, 'dec':c_pos.dec.deg, 'separation_deg':c_sep_arc.deg, 'separation_Mpc':c_sep_mpc, 'position_angle':c_pos_angle.wrap_at(2*np.pi*u.rad).deg}
		for key in ['_id', 'N500', 'N500sp', 'RL*500', 'name', 'r500', 'zphot', 'zspec']:
			if key in cluster_w:
				whl_prop[key] = cluster_w[key]
	
	# Only continue if a cluster was matched
	if cluster_w is None: #and cluster_r is None and cluster_a is None:
		
		output("%s didn't match to a cluster" % source['RGZ']['zooniverse_id'])
		return
	
	else:
		
		z = cluster_w['zspec'] if 'zspec' in cluster_w else cluster_w['zphot']
		
		# Using the 'contour' method
		tail_lengths_apparent = [source['using_contour']['tail_deg_0']*u.deg, source['using_contour']['tail_deg_1']*u.deg]
		tail_lengths_physical = []
		for tail in tail_lengths_apparent:
			tail_lengths_physical.append(cosmo.angular_diameter_distance(z) * tail.to(u.rad)/u.rad)
		using_contour = {'tail_kpc_0':float(tail_lengths_physical[0]/u.kpc), 'tail_kpc_1':float(tail_lengths_physical[1]/u.kpc), 'size_kpc':float(sum(tail_lengths_physical)/u.kpc)}
		source['using_contour'].update(using_contour)
		
		# Using the 'peak' method
		tail_lengths_apparent = [source['using_peaks']['tail_deg_0']*u.deg, source['using_peaks']['tail_deg_1']*u.deg]
		tail_lengths_physical = []
		for tail in tail_lengths_apparent:
			tail_lengths_physical.append(cosmo.angular_diameter_distance(z) * tail.to(u.rad)/u.rad)
		using_peaks = {'tail_kpc_0':float(tail_lengths_physical[0]/u.kpc), 'tail_kpc_1':float(tail_lengths_physical[1]/u.kpc), 'size_kpc':float(sum(tail_lengths_physical)/u.kpc)}
		source['using_peaks'].update(using_peaks)
		
		# Calculate the orientation angle
#		for cluster,prop in zip([cluster_w,cluster_r,cluster_a], [whl_prop,rm_prop,amf_prop]):
#			if cluster is not None:
		cluster, prop = cluster_w, whl_prop
		for method,using in zip(['contour','peaks'], [source['using_contour'],source['using_peaks']]):
			orientation = coord.angles.Angle(prop['position_angle'] - using['bisector'], unit=u.deg).wrap_at(360.*u.deg).deg
			if orientation > 180.:
				orientation = 360. - orientation
			prop['orientation_%s' % method] = orientation
		
		# Compile all results
		if cluster_w is not None:
			source['WHL'] = whl_prop
#		if cluster_r is not None:
#			source['redMaPPer'] = rm_prop
#		if cluster_a is not None:
#			source['AMFDR9'] = amf_prop
		
		return source
開發者ID:MatthewJA,項目名稱:rgz-analysis,代碼行數:69,代碼來源:bending_analysis.py

示例14: get_bending

# 需要導入模塊: from astropy.cosmology import Planck13 [as 別名]
# 或者: from astropy.cosmology.Planck13 import angular_diameter_distance [as 別名]
def get_bending(source, peak_count):
	'''
	Calculate all the bending parameters that don't depend on the cluster
	'''
	
	assert (peak_count in [2, 3]), 'Not a valid morphology'
	subject = subjects.find_one({'zooniverse_id':source['zooniverse_id']})
	
	# Get pixel-to-WCS conversion
	fid = subject['metadata']['source']
	fits_loc = pathdict[fid]
	w = wcs.WCS(fits.getheader(fits_loc, 0))
	
	# Get the location of the source
	ir = coord.SkyCoord(source['SDSS']['ra'], source['SDSS']['dec'], unit=(u.deg,u.deg), frame='icrs') if 'SDSS' in source else \
		 coord.SkyCoord(source['AllWISE']['ra'], source['AllWISE']['dec'], unit=(u.deg,u.deg), frame='icrs')
	ir_pos = w.wcs_world2pix(np.array([[ir.ra.deg,ir.dec.deg]]), 1)
	z, z_err = get_z(source)
	peaks = source['radio']['peaks']
	peak_pos = w.wcs_world2pix(np.array([ [peak['ra'],peak['dec']] for peak in peaks ]), 1)
	
	# Get image parameters for this source
	data = get_data(subject)
	contour_tree = get_contours(w, ir_pos, peak_pos, data, peak_count)
	peaks = get_global_peaks(w, peak_pos, peaks, contour_tree)
	if len(peaks) != 2:
		output("%s didn't have 2 tails" % source['zooniverse_id'])
		return
	
	contour_list = [child.path for child in contour_tree.children if any(child.contains(peak_pos))]
	
	# Using the 'contour' method
	bending_angles = get_angles(w, ir, 'contour', contour_list)
	tail_lengths_apparent = get_tail_lengths(w, ir, 'contour', contour_list)
	for tail in tail_lengths_apparent:
			tail_lengths_physical.append(cosmo.angular_diameter_distance(z) * tail.to(u.rad)/u.rad)
	ratios = peak_edge_ratio(w, ir, peaks, tail_lengths_apparent)
	asymmetry = ratios[1]/ratios[0]
	using_contour = {'tail_deg_0':tail_lengths_apparent[0], 'tail_deg_1':tail_lengths_apparent[1], 'size_deg':sum(tail_lengths_apparent), 'tail_kpc_0':float(tail_lengths_physical[0]/u.kpc), 'tail_kpc_1':float(tail_lengths_physical[1]/u.kpc), 'size_kpc':float(sum(tail_lengths_physical)/u.kpc), 'ratio_0':ratios[0], 'ratio_1':ratios[1], 'asymmetry':max(asymmetry,1./asymmetry)}
	using_contour.update(bending_angles)
	for key in using_contour.keys():
		if type(using_contour[key]) is coord.angles.Angle:
			using_contour[key] = using_contour[key].deg
	
	# Using the 'peak' method
	bending_angles = get_angles(w, ir, 'peak', peaks)
	tail_lengths_apparent = get_tail_lengths(w, ir, 'peak', contour_list, peaks)
	for tail in tail_lengths_apparent:
			tail_lengths_physical.append(cosmo.angular_diameter_distance(z) * tail.to(u.rad)/u.rad)
	ratios = peak_edge_ratio(w, ir, peaks, tail_lengths_apparent)
	asymmetry = ratios[1]/ratios[0]
	using_peaks = {'tail_deg_0':tail_lengths_apparent[0], 'tail_deg_1':tail_lengths_apparent[1], 'size_deg':sum(tail_lengths_apparent), 'tail_kpc_0':float(tail_lengths_physical[0]/u.kpc), 'tail_kpc_1':float(tail_lengths_physical[1]/u.kpc), 'size_kpc':float(sum(tail_lengths_physical)/u.kpc), 'ratio_0':ratios[0], 'ratio_1':ratios[1], 'asymmetry':max(asymmetry,1./asymmetry)}
	using_peaks.update(bending_angles)
	for key in using_peaks.keys():
		if type(using_peaks[key]) is coord.angles.Angle:
			using_peaks[key] = using_peaks[key].deg
	
	morphology = 'double' if peak_count == 2 else 'triple'
	rgz = {'RGZ_id':source['catalog_id'], 'zooniverse_id':source['zooniverse_id'], 'ir_consensus':source['consensus']['ir_level'], 'radio_consensus':source['consensus']['radio_level'], 'peaks':peaks, 'components':source['radio']['components'], 'morphology':morphology}
	entry = {'RGZ':rgz, 'using_contour':using_contour, 'using_peaks':using_peaks}
	if 'SDSS' in source:
		entry['SDSS'] = source['SDSS']
	if 'AllWISE' in source:
		entry['AllWISE'] = source['AllWISE']
	
	return entry
開發者ID:MatthewJA,項目名稱:rgz-analysis,代碼行數:68,代碼來源:bending_analysis.py


注:本文中的astropy.cosmology.Planck13.angular_diameter_distance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。