In [363]:
import numpy as np
import scipy as sp
from scipy import integrate
from math import *
import matplotlib.pyplot as plt
from astropy.io import ascii
import healpix_util as hu

Define angular diameter distances for Flat LambdaCDM cosmology with $\Omega_M=0.3$ and $\Omega_{\Lambda}=0.7$ starting with definition of $E(z)=\sqrt{0.3(1+z)^3+0.7}$. As we know Angular diameter distance ($D_A$) is comoving distance ($D_C$) divided by $1+z$. We write $D_A=\frac{D_C}{1+z}=\frac{1}{1+z}\int_0^z\frac{dz}{E(z)}$


In [364]:
Ez = lambda x: 1/sqrt(0.3*(1+x)**3+0.7)  

np.vectorize(Ez)
#Calculate comoving distance of a data point using the Redshift - This definition is based on the cosmology model we take. Here the distance for E-dS universe is considered. Also note that c/H0 ratio is cancelled in the equations and hence not taken.

def DC_LCDM(z):
  return integrate.quad(Ez, 0, z)

In [365]:
z=0.35
DMLCDM=DC_LCDM(z)
DMLC=z*(z/2+1)/(z+1)
print DMLCDM[0]
print DMLC


0.321176033289
0.30462962963

In [366]:
print DMLCDM[0]*4285.714/(1+z)
print DMLC*4285.714/(1+z)


1019.60638691
967.078124829

In [367]:
th,phi=hu.randsphere(1000,'ang',theta_range=[0,0.0025], phi_range=[0,0.0025] )
thw,phiw=th,phi
#print th,phi
#print len(thw)

In [368]:
data = open("DAvspsi_z_0.35.dat",'w')
data.write("psi \t lfproper \t loproper \t DAf \t DAo \n")
#for i in range(len(thw)):
for thi,phii in zip(thw,phiw):
    for i in range(len(thw)-1):
    #print "i j"
        #print thw[i],phiw[i]
        #print thi,phii 
        #print cos(thw[i])*cos(thi)+sin(thw[i])*sin(thi)*cos(phiw[i]-phii)
        psi=acos(round(cos(thw[i])*cos(thi)+sin(thw[i])*sin(thi)*cos(phiw[i]-phii),10))
        xf1=DMLCDM[0]*sin(thw[i])*cos(phiw[i])
        yf1=DMLCDM[0]*sin(thw[i])*sin(phiw[i])
        zf1=DMLCDM[0]*cos(thw[i])
        xf2=DMLCDM[0]*sin(thi)*cos(phii)
        yf2=DMLCDM[0]*sin(thi)*sin(phii)
        zf2=DMLCDM[0]*cos(thi)
        lf=sqrt((xf1-xf2)**2+(yf1-yf2)**2+(zf1-zf2)**2)
        lfproper=lf/(1+z)
        xo1=DMLC*sin(thw[i])*cos(phiw[i])
        yo1=DMLC*sin(thw[i])*sin(phiw[i])
        zo1=DMLC*cos(thw[i])
        xo2=DMLC*sin(thi)*cos(phii)
        yo2=DMLC*sin(thi)*sin(phii)
        zo2=DMLC*cos(thi)
        lo=sqrt((xo1-xo2)**2+(yo1-yo2)**2+(zo1-zo2)**2)  
        loproper=lo/(1+z)
        if psi>0:    
            DAf=lfproper/psi
            DAo=loproper/psi
            #print psi,DAf,DAo
            data.write("%f \t %f \t %f \t %f \t %f \n"%(psi,lfproper,loproper,DAf,DAo))
    thw=np.delete(thw,0)
    phiw=np.delete(phiw,0)
        #print thw
        #print phiw
    #print "array length"
    #print len(thw)
data.close()

In [369]:
DAvspsi=ascii.read("DAvspsi_z_0.35.dat")

In [370]:
print DAvspsi


  psi    lfproper loproper   DAf      DAo   
-------- -------- -------- -------- --------
0.000475 0.000113 0.000107 0.237927  0.22567
0.000147  3.5e-05  3.3e-05 0.237447 0.225215
0.000899 0.000214 0.000203 0.237914 0.225657
 6.8e-05  1.6e-05  1.5e-05 0.239447 0.227111
0.000587  0.00014 0.000132 0.237919 0.225662
0.000548  0.00013 0.000124 0.237929 0.225671
0.001052  0.00025 0.000237 0.237901 0.225645
0.000756  0.00018 0.000171 0.237892 0.225637
 0.00029  6.9e-05  6.5e-05 0.237977 0.225717
0.000404  9.6e-05  9.1e-05 0.237891 0.225635
     ...      ...      ...      ...      ...
0.000469 0.000112 0.000106 0.237908 0.225651
0.001193 0.000284 0.000269 0.237903 0.225647
 0.00163 0.000388 0.000368 0.237907 0.225651
0.000451 0.000107 0.000102 0.237904 0.225647
0.000766 0.000182 0.000173 0.237915 0.225658
0.000437 0.000104  9.9e-05 0.237923 0.225665
0.000742 0.000177 0.000167 0.237898 0.225642
0.000426 0.000101  9.6e-05 0.237966 0.225707
0.001179 0.000281 0.000266 0.237905 0.225648
0.000864 0.000205 0.000195 0.237894 0.225638
0.000316  7.5e-05  7.1e-05 0.237844 0.225591
Length = 493253 rows

In [371]:
DAvspsi.sort('psi')

In [372]:
xint=DAvspsi['psi']*180/pi
yint=1050*np.ones(len(xint))

In [373]:
idx = np.argwhere(np.isclose(yint, DAvspsi['DAf']*4285.714 , atol=1)).reshape(-1)
print idx
print xint[idx]


[  612  1240  1411  1440  1656  1740  2146  2503  2507  2592  2949  3188
  3535  3539  3958  4127  4167  4358  4486  4634  4703  5072  5104  5148
  5160  5330  5346  5427  5494  5512  5585  5619  5806  6244  6391  6401
  7058  7163  7350  7358  7549  7722  7806  8092  8186  8265  8324  8486
  8553  8654  8716  8864  8904  9007  9206  9324  9375  9381  9407  9480
  9509  9544  9552  9618  9707  9714  9815  9818  9853  9870  9950 10014
 10177 10431 10438 10630 10653 10942 10957 10962 10981 11079 11147 11252
 11255 11264 11290 11322 11345 11379 11412 11413 11536 11546 11578 11633
 11897 11913 11995 12027 12033 12065 12074 12110 12137 12186 12212 12215
 12230 12239 12275 12287 12348 12351 12361 12525 12545 12663 12681 12724
 12780 12874 12929 13015 13089 13115 13155 13169 13204 13227 13252 13326
 13372 13435 13460 13465 13495 13514 13533 13562 13608 13616 13636 13720
 13726 13790 13802 13809 13881 13883 13951 14016 14018 14130 14132 14257
 14275 14303 14308 14316 14341 14494 14516 14546 14609 14644 14661 14685
 14738 14755 14778 14796 14897 14958 14964 15064 15121 15140 15286 15289
 15388 15454 15481 15505 15539 15541 15542 15551 15568 15591 15594 15685
 15787 15804 15845 15906 15912 15974 15988 15996 16030 16082 16109 16147
 16169 16261 16282 16350 16365 16381 16386 16392 16416 16432 16439 16462
 16536 16542]
       psi       
-----------------
0.000802140913183
0.000802140913183
0.000802140913183
0.000802140913183
0.000802140913183
0.000802140913183
0.000802140913183
0.000802140913183
0.000802140913183
0.000802140913183
              ...
 0.00229183118052
 0.00229183118052
 0.00229183118052
 0.00229183118052
 0.00229183118052
 0.00229183118052
 0.00229183118052
 0.00229183118052
 0.00229183118052
 0.00229183118052
 0.00229183118052
Length = 218 rows

In [374]:
print DAvspsi['DAo'][idx]*4285.714


     DAo     
-------------
995.052790806
994.958505098
995.459933636
 994.94993367
996.698504982
996.419933572
995.404219354
996.334219292
 996.81421926
 995.29279079
          ...
996.124219306
994.954219384
 996.44993357
996.179933588
996.111362164
996.012790742
996.681362126
 996.44993357
995.232790794
995.001362238
995.541362202
Length = 218 rows

In [376]:
plt.plot(xint,yint,label="DA=1050")
plt.plot(np.mean(xint[idx]), np.mean(yint[idx]), 'ro')
plt.plot(np.mean(xint[idx])*np.ones(500),range(800,1300),'c',label="theta=2.479")
plt.plot(np.mean(xint[idx]), np.mean(DAvspsi['DAo'][idx])*4285.714, 'ro')
plt.plot(DAvspsi['psi']*180/pi,DAvspsi['DAf']*4285.714,'g',label="DAf")
plt.plot(DAvspsi['psi']*180/pi,DAvspsi['DAo']*4285.714,'r',label="DAo")
plt.legend(frameon=0, loc='upper right')
plt.show()



In [375]: