mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
preparing public version
This commit is contained in:
parent
c57359197c
commit
ad3e5d1577
25 changed files with 934 additions and 1500 deletions
|
@ -17,6 +17,4 @@
|
|||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#+
|
||||
from velocityProfileFitNative import *
|
||||
from likelihood import *
|
||||
from cosmologyTools import *
|
||||
|
|
|
@ -24,7 +24,7 @@ import numpy as np
|
|||
import scipy.integrate as integrate
|
||||
from void_python_tools.backend import *
|
||||
|
||||
__all__=['expansion', 'angularDiameter', 'expectedStretch', 'aveStretch', 'aveExpansion', 'aveStretchCone', 'aveWeightedStretch']
|
||||
__all__=['expansion', 'angularDiameter', 'aveExpansion']
|
||||
|
||||
# returns 1/E(z) for the given cosmology
|
||||
def expansion(z, Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
|
||||
|
@ -41,114 +41,7 @@ def eosDE(z, w0 = -1.0, wa = 0.0):
|
|||
def angularDiameter(z, Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
|
||||
da = integrate.quad(expansion, 0.0, z, args=(Om, Ot, w0, wa))[0]
|
||||
return da
|
||||
|
||||
|
||||
# returns expected void stretch for the given cosmology
|
||||
def expectedStretch(z, Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
|
||||
ez = 1./expansion(z, Om=Om, Ot=Ot, w0=w0, wa=wa)
|
||||
da = angularDiameter(z, Om=Om, Ot=Ot, w0=w0, wa=wa)
|
||||
return ez*da/z
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# returns average expected void stretch for a given redshift range
|
||||
# assuming a cone
|
||||
def aveStretchCone(zStart, zEnd, skyFrac = 0.19, Om = 0.27, Ot = 1.0,
|
||||
w0 = -1.0, wa = 0.0):
|
||||
#print "assuming observation!", skyFrac
|
||||
if zStart == 0.0: zStart = 1.e-6
|
||||
|
||||
h1 = zStart
|
||||
h2 = zEnd
|
||||
|
||||
r1 = skyFrac * 4* np.pi * zStart**2
|
||||
r2 = skyFrac * 4 * np.pi * zEnd**2
|
||||
|
||||
# surface area of a slice within a cone
|
||||
def coneSlice(x, h, r):
|
||||
return np.pi * (r/h*x)**2
|
||||
|
||||
def coneFunc(z, h, r, Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
|
||||
return coneSlice(z, h, r) * expectedStretch(z, Om, Ot, w0, wa)
|
||||
|
||||
aveHigh = integrate.quad(coneFunc, 0.0, zEnd, args=(h2, r2, Om, Ot, w0, wa), full_output=1)[0]
|
||||
aveLow = integrate.quad(coneFunc, 0.0, zStart, args=(h1, r1, Om, Ot, w0, wa), full_output=1)[0]
|
||||
volumeHigh = integrate.quad(coneSlice, 0.0, zEnd, args=(h2, r2))[0]
|
||||
volumeLow = integrate.quad(coneSlice, 0.0, zStart, args=(h1, r1))[0]
|
||||
|
||||
return (aveHigh-aveLow)/(volumeHigh-volumeLow)
|
||||
|
||||
# returns average expected void stretch for a given redshift range
|
||||
def aveStretch(sample, zStart, zEnd,
|
||||
Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
|
||||
if zStart == 0.0: zStart = 1.e-6
|
||||
|
||||
if sample.dataType == "observation":
|
||||
stretch = aveStretchCone(zStart, zEnd,
|
||||
skyFrac=sample.skyFraction, Om=Om, Ot=Ot,
|
||||
w0=w0, wa=wa)
|
||||
else:
|
||||
ave = integrate.quad(expectedStretch, zStart, zEnd,
|
||||
args=(Om, Ot, w0, wa))[0]
|
||||
ave /= (zEnd-zStart)
|
||||
stretch = ave
|
||||
|
||||
# if in comoving space, calculate stretch for fiducial cosmology
|
||||
# and take relative amount
|
||||
if not sample.useLightCone or sample.useComoving:
|
||||
if sample.dataType == "observation":
|
||||
stretchFid = aveStretchCone(zStart, zEnd,
|
||||
skyFrac=sample.skyFraction, Om=sample.omegaM, Ot=Ot,
|
||||
w0=w0, wa=wa)
|
||||
else:
|
||||
ave = integrate.quad(expectedStretch, zStart, zEnd,
|
||||
args=(sample.omegaM, Ot, w0, wa))[0]
|
||||
ave /= (zEnd-zStart)
|
||||
stretchFid = ave
|
||||
|
||||
stretch = stretchFid/stretch
|
||||
|
||||
return stretch
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# returns average expected void stretch for a given redshift range
|
||||
# weighted by an actual void distribution
|
||||
def aveWeightedStretch(zStart, zEnd, skyFrac = 0.19, Om = 0.27, Ot = 1.0,
|
||||
w0 = -1.0, wa = 0.0, dist=None, bins=None,
|
||||
useComoving=True, OmFid=None):
|
||||
if zStart == 0.0: zStart = 1.e-6
|
||||
|
||||
def weightedSlice(x):
|
||||
return np.interp(x, bins[:-1], dist)
|
||||
|
||||
def weightedFunc(z, Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
|
||||
return expectedStretch(z, Om, Ot, w0, wa) *\
|
||||
weightedSlice(z)
|
||||
|
||||
ave = integrate.quad(weightedFunc, zStart, zEnd, args=(Om, Ot, w0, wa),
|
||||
full_output=1)[0]
|
||||
volume = integrate.quad(weightedSlice, zStart, zEnd, full_output=1)[0]
|
||||
|
||||
if volume == 0.0: volume = 1.0
|
||||
stretch = ave/volume
|
||||
|
||||
# if in comoving space, calculate stretch for fiducial cosmology
|
||||
# and take relative amount
|
||||
if useComoving:
|
||||
ave = integrate.quad(weightedFunc, zStart, zEnd, args=(OmFid,
|
||||
Ot, w0, wa),
|
||||
full_output=1)[0]
|
||||
volume = integrate.quad(weightedSlice, zStart, zEnd, full_output=1)[0]
|
||||
|
||||
if volume == 0.0: volume = 1.0
|
||||
stretchFid = ave/volume
|
||||
|
||||
if stretchFid != 0.0:
|
||||
stretch = stretchFid/stretch
|
||||
|
||||
return stretch
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# returns average expected expansion for a given redshift range
|
||||
def aveExpansion(zStart, zEnd, Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
|
||||
|
|
|
@ -17,10 +17,4 @@
|
|||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#+
|
||||
from build import *
|
||||
from draw import *
|
||||
from fit import *
|
||||
from inertia import *
|
||||
from mcmc import *
|
||||
from generateExpFigure import *
|
||||
from getSurveyProps import *
|
||||
|
|
|
@ -19,4 +19,3 @@
|
|||
#+
|
||||
from classes import *
|
||||
from launchers import *
|
||||
from catalogPrep import *
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,7 +34,7 @@ ncFloat = 'f8'
|
|||
|
||||
# -----------------------------------------------------------------------------
|
||||
def loadPart(sampleDir):
|
||||
#print " Loading particle data..."
|
||||
print " Loading particle data..."
|
||||
sys.stdout.flush()
|
||||
|
||||
with open(sampleDir+"/sample_info.dat", 'rb') as input:
|
||||
|
|
|
@ -2,72 +2,12 @@ import numpy as np
|
|||
|
||||
def cic( x, Lbox, Lboxcut = 0, Nmesh = 128, weights = None ):
|
||||
|
||||
if weights == None: weights = 1
|
||||
wm = np.mean(weights)
|
||||
ws = np.mean(weights**2)
|
||||
|
||||
d = np.mod(x/(Lbox+2*Lboxcut)*Nmesh,1)
|
||||
|
||||
box = ([Lboxcut,Lbox+Lboxcut],[Lboxcut,Lbox+Lboxcut],[Lboxcut,Lbox+Lboxcut])
|
||||
|
||||
rho = np.histogramdd(x, range = box, bins = Nmesh, weights = weights*(1-d[:,0])*(1-d[:,1])*(1-d[:,2]))[0] \
|
||||
+ np.roll(np.histogramdd(x, range = box, bins = Nmesh, weights = weights*d[:,0]*(1-d[:,1])*(1-d[:,2]))[0],1,0) \
|
||||
+ np.roll(np.histogramdd(x, range = box, bins = Nmesh, weights = weights*(1-d[:,0])*d[:,1]*(1-d[:,2]))[0],1,1) \
|
||||
+ np.roll(np.histogramdd(x, range = box, bins = Nmesh, weights = weights*(1-d[:,0])*(1-d[:,1])*d[:,2])[0],1,2) \
|
||||
+ np.roll(np.roll(np.histogramdd(x, range = box, bins = Nmesh, weights = weights*d[:,0]*d[:,1]*(1-d[:,2]))[0],1,0),1,1) \
|
||||
+ np.roll(np.roll(np.histogramdd(x, range = box, bins = Nmesh, weights = weights*d[:,0]*(1-d[:,1])*d[:,2])[0],1,0),1,2) \
|
||||
+ np.roll(np.roll(np.histogramdd(x, range = box, bins = Nmesh, weights = weights*(1-d[:,0])*d[:,1]*d[:,2])[0],1,1),1,2) \
|
||||
+ np.roll(np.roll(np.roll(np.histogramdd(x, range = box, bins = Nmesh, weights = weights*d[:,0]*d[:,1]*d[:,2])[0],1,0),1,1),1,2)
|
||||
|
||||
rho /= wm
|
||||
|
||||
rho = rho/rho.mean() - 1.
|
||||
|
||||
return (rho, wm, ws)
|
||||
|
||||
return
|
||||
|
||||
def powcor( d1, d2, Lbox, Nmesh = 128, Nbin = 100, scale = 'lin', cor = False ):
|
||||
|
||||
# Fourier transform
|
||||
d1 = np.fft.fftn(d1)
|
||||
d2 = np.fft.fftn(d2)
|
||||
|
||||
# CIC correction
|
||||
wid = np.indices(np.shape(d1)) - Nmesh/2
|
||||
#wid[np.where(wid >= Nmesh/2)] -= Nmesh
|
||||
wid = wid*np.pi/Nmesh + 1e-100
|
||||
wcic = np.prod(np.sin(wid)/wid,0)**2
|
||||
|
||||
# Shell average power spectrum
|
||||
dk = 2*np.pi/Lbox
|
||||
Pk = np.conj(d1)*d2*(Lbox/Nmesh**2)**3
|
||||
Pk = np.fft.fftshift(Pk)/wcic**2
|
||||
|
||||
(Nm, km, Pkm, SPkm) = shellavg(np.real(Pk), dk, Nmesh, Nbin = Nbin, xmin = 0., xmax = Nmesh*dk/2, scale = scale)
|
||||
|
||||
# Inverse Fourier transform and shell average correlation function
|
||||
if cor == True:
|
||||
dx = Lbox/Nmesh
|
||||
Xr = np.fft.ifftshift(np.fft.ifftn(np.fft.ifftshift(Pk)))*(Nmesh/Lbox)**3
|
||||
|
||||
(Nmx, rm, Xrm, SXrm) = shellavg(np.real(Xr), dx, Nmesh, Nbin = Nbin, xmin = dx, xmax = 140., scale = scale)
|
||||
|
||||
return ((Nm, km, Pkm, SPkm),(Nmx, rm, Xrm, SXrm))
|
||||
|
||||
else: return (Nm, km, Pkm, SPkm)
|
||||
|
||||
return
|
||||
|
||||
def shellavg( f, dx, Nmesh, Nbin = 100, xmin = 0., xmax = 1., scale = 'lin' ):
|
||||
|
||||
x = np.indices(np.shape(f)) - Nmesh/2
|
||||
#x[np.where(x >= Nmesh/2)] -= Nmesh
|
||||
x = dx*np.sqrt(np.sum(x**2,0))
|
||||
if scale == 'lin': bins = xmin+(xmax-xmin)* (np.arange(Nbin+1)/float(Nbin))
|
||||
if scale == 'log': bins = xmin*(xmax/xmin)**(np.arange(Nbin+1)/float(Nbin))
|
||||
|
||||
Nm = np.histogram(x, bins = bins)[0]
|
||||
xm = np.histogram(x, bins = bins, weights = x)[0]/Nm
|
||||
fm = np.histogram(x, bins = bins, weights = f)[0]/Nm
|
||||
fs = np.sqrt((np.histogram(x, bins = bins, weights = f**2)[0]/Nm - fm**2)/(Nm-1))
|
||||
|
||||
return (Nm, xm, fm, fs)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue