55from __future__ import absolute_import , division , print_function , unicode_literals
66
77import numpy as np
8- from scipy .interpolate import interp1d
98from astropy import cosmology
109from astropy .constants import c # the speed of light
10+ from scipy .interpolate import interp1d
1111
12-
13- __all__ = ('ra_dec_z' , )
14- __author__ = ['Duncan Campbell' ]
12+ __all__ = ("ra_dec_z" ,)
13+ __author__ = ["Duncan Campbell" ]
1514
1615
1716def ra_dec_z (x , v , cosmo = None ):
@@ -33,7 +32,7 @@ def ra_dec_z(x, v, cosmo=None):
3332 Returns
3433 -------
3534 ra : np.array
36- right accession in radians
35+ right ascension in radians
3736
3837 dec : np.array
3938 declination in radians
@@ -72,34 +71,34 @@ def ra_dec_z(x, v, cosmo=None):
7271 # calculate the observed redshift
7372 if cosmo is None :
7473 cosmo = cosmology .FlatLambdaCDM (H0 = 0.7 , Om0 = 0.3 )
75- c_km_s = c .to (' km/s' ).value
74+ c_km_s = c .to (" km/s" ).value
7675
7776 # remove h scaling from position so we can use the cosmo object
78- x = x / cosmo .h
77+ x = x / cosmo .h
7978
8079 # compute comoving distance from observer
81- r = np .sqrt (x [:, 0 ]** 2 + x [:, 1 ]** 2 + x [:, 2 ]** 2 )
80+ r = np .sqrt (x [:, 0 ] ** 2 + x [:, 1 ] ** 2 + x [:, 2 ] ** 2 )
8281
8382 # compute radial velocity
84- ct = x [:, 2 ]/ r
83+ ct = x [:, 2 ] / r
8584 st = np .sqrt (1.0 - ct ** 2 )
86- cp = x [:, 0 ]/ np .sqrt (x [:, 0 ]** 2 + x [:, 1 ]** 2 )
87- sp = x [:, 1 ]/ np .sqrt (x [:, 0 ]** 2 + x [:, 1 ]** 2 )
88- vr = v [:, 0 ]* st * cp + v [:, 1 ]* st * sp + v [:, 2 ]* ct
85+ cp = x [:, 0 ] / np .sqrt (x [:, 0 ] ** 2 + x [:, 1 ] ** 2 )
86+ sp = x [:, 1 ] / np .sqrt (x [:, 0 ] ** 2 + x [:, 1 ] ** 2 )
87+ vr = v [:, 0 ] * st * cp + v [:, 1 ] * st * sp + v [:, 2 ] * ct
8988
90- # compute cosmological redshift and add contribution from perculiar velocity
91- yy = np .arange (0 , 1 .0 , 0.001 )
89+ # compute cosmological redshift and add contribution from peculiar velocity
90+ yy = np .arange (0 , 20 .0 , 0.001 )
9291 xx = cosmo .comoving_distance (yy ).value
93- f = interp1d (xx , yy , kind = ' cubic' )
92+ f = interp1d (xx , yy , kind = " cubic" )
9493 z_cos = f (r )
95- redshift = z_cos + (vr / c_km_s )* (1.0 + z_cos )
94+ redshift = z_cos + (vr / c_km_s ) * (1.0 + z_cos )
9695
9796 # calculate spherical coordinates
98- theta = np .arccos (x [:, 2 ]/ r )
97+ theta = np .arccos (x [:, 2 ] / r )
9998 phi = np .arctan2 (x [:, 1 ], x [:, 0 ])
10099
101100 # convert spherical coordinates into ra,dec
102101 ra = phi
103- dec = theta - np .pi / 2.0
102+ dec = theta - np .pi / 2.0
104103
105104 return ra , dec , redshift
0 commit comments