Slight re-organization of C/C++ tools. Significant modifications to support observational data. Python and pipeline scripts added

This commit is contained in:
P.M. Sutter 2012-10-31 10:43:15 -05:00
parent 15496df4ff
commit 14abbc2018
42 changed files with 16252 additions and 557 deletions

View file

@ -0,0 +1,2 @@
from chi2 import *
from profiles import *

View file

@ -0,0 +1,3 @@
from velocityProfileFitNative import *
from likelihood import *
from cosmologyTools import *

View file

@ -0,0 +1,94 @@
# a suite of functions to compute expansion rates, angular diameter
# distances, and expected void stretching
import numpy as np
import scipy.integrate as integrate
__all__=['expansion', 'angularDiameter', 'expectedStretch', 'aveStretch', 'aveExpansion', 'aveStretchCone', 'aveWeightedStretch']
# returns 1/E(z) for the given cosmology
def expansion(z, Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
wz = w0 + wa*z/(1+z)
ez = Om * (1+z)**3 + (Ot-Om)# * (1+z)**(3.+3*wz)
ez = 1./np.sqrt(ez)
return ez
# returns D_A(z) for the given cosmology
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
def aveStretch(zStart, zEnd, Om = 0.27, Ot = 1.0, w0 = -1.0, wa = 0.0):
if zStart == 0.0: zStart = 1.e-6
ave = integrate.quad(expectedStretch, zStart, zEnd, args=(Om, Ot, w0, wa))[0]
ave /= (zEnd-zStart)
return ave
# -----------------------------------------------------------------------------
# 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):
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
# 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):
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]
return ave/volume
# -----------------------------------------------------------------------------
# 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):
if zStart == 0.0: zStart = 1.e-6
ave = integrate.quad(expansion, zStart, zEnd, args=(Om, Ot, w0, wa))[0]
ave = (zEnd-zStart)/ave
return ave

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,6 @@
from build import *
from draw import *
from fit import *
from mcmc import *
from generateExpFigure import *
from getSurveyProps import *

View file

@ -0,0 +1,53 @@
import numpy as np
import healpy as healpy
import scipy.integrate
__all__=['getSurveyProps']
# returns the volume and galaxy density for a given redshit slice
def getSurveyProps(maskFile, zmin, zmax, selFunMin, selFunMax, portion, selectionFuncFile=None):
mask = healpy.read_map(maskFile)
area = (1.*np.size(np.where(mask > 0)) / np.size(mask)) * 4.*np.pi
zmin = zmin * 3000
zmax = zmax * 3000
volume = area * (zmax**3 - zmin**3) / 3
if selectionFuncFile != None:
selfunc = np.genfromtxt(selectionFuncFile)
selfunc = np.array(selfunc)
selfunc[:,0] = selfunc[:,0]/100.
selfuncUnity = selfunc
selfuncUnity[:,1] = 1.0
selfuncMin = selfunc[0,0]
selfuncMax = selfunc[-1,0]
selfuncDx = selfunc[1,0] - selfunc[0,0]
selfuncN = np.size(selfunc[:,0])
selFunMin *= 3000
selFunMax *= 3000
selFunMin = max(selFunMin, selfuncMin)
selFunMax = min(selFunMax, selfuncMax)
def f(z): return selfunc[np.ceil((z-selfuncMin)/selfuncDx), 1]*z**2
def fTotal(z): return selfuncUnity[np.ceil((z-selfuncMin)/selfuncDx), 1]*z**2
zrange = np.linspace(selFunMin, selFunMax)
nbar = scipy.integrate.quad(f, selFunMin, selFunMax)
nbar = nbar[0]
ntotal = scipy.integrate.quad(fTotal, 0.0, max(selfuncUnity[:,0]))
#ntotal = scipy.integrate.quad(f, 0.0, max(selfunc[:,0]))
ntotal = ntotal[0]
nbar = ntotal / area / nbar
else:
nbar = 1.0
#print "PROPERTIES: ", volume, nbar
return (volume, nbar)