In [33]:
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 [52]:
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 [53]:
Ezo = lambda x: 1/sqrt(0.9*(1+x)**3+0.1*(1+x)**2)

np.vectorize(Ezo)
#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_OU(z):
  return np.sinh(integrate.quad(Ezo, 0, z))

In [54]:
z=2.34
DMLCDM=DC_LCDM(z)
DMLC=DC_OU(z)
print DMLCDM[0]
print DMLC[0]


1.31579183875
1.06081745967

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


1688.35554025
1361.18570011

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

In [57]:
data = open("DAvspsi_zou_2.34.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),6))
        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[0]*sin(thw[i])*cos(phiw[i])
        yo1=DMLC[0]*sin(thw[i])*sin(phiw[i])
        zo1=DMLC[0]*cos(thw[i])
        xo2=DMLC[0]*sin(thi)*cos(phii)
        yo2=DMLC[0]*sin(thi)*sin(phii)
        zo2=DMLC[0]*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 [58]:
DAvspsi=ascii.read("DAvspsi_zou_2.34.dat")

In [59]:
print DAvspsi


  psi    lfproper loproper   DAf      DAo   
-------- -------- -------- -------- --------
0.397644 0.155621 0.125465 0.391358 0.315521
0.412052 0.161182 0.129948 0.391169 0.315369
0.408635 0.159864 0.128886 0.391215 0.315405
0.546838 0.212752 0.171525 0.389059 0.313667
0.209596 0.082419 0.066448 0.393229 0.317029
0.185322 0.072902 0.058775 0.393381 0.317151
0.512672 0.199763 0.161053  0.38965 0.314143
0.311868 0.122363 0.098652 0.392356 0.316325
 0.37561 0.147103 0.118598 0.391638 0.315746
0.389268 0.152386 0.122856 0.391467 0.315608
     ...      ...      ...      ...      ...
0.713199 0.275048 0.221749 0.385653 0.310921
0.258889 0.101705 0.081996 0.392851 0.316724
0.631596 0.244702 0.197283 0.387434 0.312357
0.457311 0.178591 0.143984 0.390525 0.314849
0.435692 0.170287 0.137288 0.390841 0.315104
0.765422  0.29423 0.237214 0.384403 0.309913
0.381355 0.149326  0.12039 0.391566 0.315688
0.668679 0.258546 0.208445 0.386651 0.311726
0.512413 0.199664 0.160973 0.389654 0.314147
0.360833 0.141381 0.113984 0.391817 0.315891
0.624405 0.242007 0.195111 0.387581 0.312475
Length = 498496 rows

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

In [61]:
xint=DAvspsi['psi']
yint=1662*np.ones(len(xint))
#print xint

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


[444331 444333 444338 444339 444340 444341 444342 444344 444345 444346
 444347 444348 444349 444350 444351 444352 444353 444354 444355 444356
 444357 444358 444359 444360 444361 444362 444363 444364 444365 444366
 444367 444368 444369 444370 444371 444372 444373 444374 444375 444376
 444377 444378 444379 444380 444381 444382 444383 444384 444385 444386
 444387 444388 444389 444390 444391 444392 444393 444394 444395 444396
 444397 444398 444399 444400 444401 444402 444403 444404 444405 444406
 444407 444408 444409 444410 444411 444412 444413 444414 444415 444416
 444417 444418 444419 444420 444421 444422 444423 444424 444425 444426
 444427 444428 444429 444430 444431 444432 444433 444434 444435 444436
 444437 444438 444439 444440 444441 444442 444443 444444 444445 444446
 444447 444448 444449 444450 444451 444452 444453 444454 444455 444456
 444457 444458 444459 444460 444461 444462 444463 444464 444465 444466
 444467 444468 444469 444470 444471 444472 444473 444474 444475 444476
 444477 444478 444479 444480 444481 444482 444483 444484 444485 444486
 444487 444488 444489 444490 444491 444492 444493 444494 444495 444496
 444497 444498 444499 444500 444501 444502 444503 444504 444505 444506
 444507 444508 444509 444510 444511 444512 444513 444514 444515 444516
 444517 444518 444519 444520 444521 444522 444523 444524 444525 444526
 444527 444528 444529 444530 444531 444532 444533 444534 444535 444536
 444537 444538 444539 444540 444541 444542 444543 444544 444545 444546
 444547 444548 444549 444550 444551 444552 444553 444554 444555 444556
 444557 444558 444559 444560 444561 444562 444563 444564 444565 444566
 444567 444568 444569 444570 444571 444572 444573 444574 444575 444576
 444577 444578 444579 444580 444581 444582 444583 444584 444585 444586
 444587 444588 444589 444590 444591 444592 444593 444594 444595 444596
 444597 444598 444599 444600 444601 444602 444603 444604 444605 444606
 444607 444608 444609 444610 444611 444612 444613 444614 444615 444616
 444617 444618 444619 444620 444621 444622 444623 444624 444625 444626
 444627 444628 444629 444630 444631 444632 444633 444634 444635 444636
 444637 444638 444639 444640 444641 444642 444643 444644 444645 444646
 444647 444648 444649 444650 444651 444652 444653 444654 444655 444656
 444657 444658 444659 444660 444661 444662 444663 444664 444665 444666
 444667 444668 444669 444670 444671 444672 444673 444674 444675 444676
 444677 444678 444679 444680 444681 444682 444683 444684 444685 444686
 444687 444688 444689 444690 444691 444692 444693 444694 444695 444696
 444697 444698 444699 444700 444701 444702 444703 444704 444705 444706
 444707 444708 444709 444710 444711 444712 444713 444714 444715 444716
 444717 444718 444719 444720 444721 444722 444723 444724 444725 444726
 444727 444728 444729 444730 444731 444732 444733 444734 444735 444736
 444737 444738 444739 444740 444741 444742 444743 444744 444745 444746
 444747 444748 444749 444750 444751 444752 444753 444754 444755 444756
 444757 444758 444759 444760 444761 444762 444763 444764 444765 444766
 444767 444768 444769 444770 444771 444772 444773 444774 444775 444776
 444777 444778 444779 444780 444781 444782 444783 444784 444785 444786
 444787 444788 444789 444790 444791 444792 444793 444794 444795 444796
 444797 444798 444799 444800 444801 444802 444803 444804 444805 444806
 444807 444808 444809 444810 444811 444812 444813 444814 444815 444816
 444817 444818 444819 444820 444821 444822 444823 444824 444825 444826
 444827 444828 444829 444830 444831 444832 444833 444834 444835 444836
 444837 444838 444839 444840 444841 444842 444843 444844 444845 444846
 444847 444848 444849 444850 444851 444852 444853 444854 444855 444856
 444857 444858 444859 444860 444861 444862 444863 444864 444865 444866
 444867 444868 444869 444870 444871 444872 444873 444874 444875 444876
 444877 444878 444879 444880 444881 444882 444883 444884 444885 444886
 444887 444888 444889 444890 444891 444892 444893 444894 444895 444896
 444897 444898 444899 444900 444901 444902 444903 444904 444905 444906
 444907 444908 444909 444910 444911 444912 444913 444914 444915 444916
 444917 444918 444919 444920 444921 444922 444923 444924 444925 444926
 444927 444928 444929 444930 444931 444932 444933 444934 444935 444936
 444937 444938 444939 444940 444941 444942 444943 444944 444945 444946
 444947 444948 444949 444950 444951 444952 444953 444954 444955 444956
 444957 444958 444959 444960 444961 444962 444963 444964 444965 444966
 444967 444968 444969 444970 444971 444972 444973 444974 444975 444976
 444977 444978 444979 444980 444981 444982 444983 444984 444985 444986
 444987 444988 444989 444990 444991 444992 444993 444994 444995 444996
 444997 444998 444999 445000 445001 445002 445003 445004 445005 445006
 445007 445008 445009 445010 445011 445012 445013 445014 445015 445016
 445017 445018 445019 445020 445021 445022 445023 445024 445025 445026
 445027 445028 445029 445030 445031 445032 445035 445036 445040 445044
 445045 445048]
0.613514591168

In [63]:
print np.mean(DAvspsi['DAo'][idx])*4285.714


1339.93790212

In [64]:
plt.plot(xint,yint,label="DA=1662")
plt.plot(np.mean(xint[idx]), np.mean(yint[idx]), 'ro')
plt.plot(np.mean(xint[idx])*np.ones(1200),range(800,2000),'c',label="theta=inters")
plt.plot(xint[idx].mean(), np.mean(DAvspsi['DAo'][idx])*4285.714, 'ro')
plt.plot(DAvspsi['psi'],DAvspsi['DAf']*4285.714,'g',label="DAf")
plt.plot(DAvspsi['psi'],DAvspsi['DAo']*4285.714,'r',label="DAo")
plt.legend(frameon=0, loc='upper right')
plt.show()



In [64]:


In [64]: