mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
bug fixed related to different boundary handling procedure. no guarantee that it's correct (yet) but it runs
This commit is contained in:
parent
03c8f773b6
commit
dd181da42a
6 changed files with 40 additions and 36 deletions
|
@ -67,8 +67,9 @@ class Sample:
|
|||
dataUnit = 1
|
||||
fullName = "lss.dr72dim.dat"
|
||||
nickName = "dim"
|
||||
zobovDir = ""
|
||||
outputDir = ""
|
||||
maskFile = "rast_window_512.fits"
|
||||
nsideForMask = 128
|
||||
selFunFile = "czselfunc.all.dr72dim.dat"
|
||||
zBoundary = (0.0, 0.1)
|
||||
zBoundaryMpc = (0., 300)
|
||||
|
@ -98,7 +99,7 @@ class Sample:
|
|||
stacks = []
|
||||
|
||||
def __init__(self, dataFile="", fullName="", dataUnit=1,
|
||||
nickName="", maskFile="", selFunFile="",
|
||||
nickName="", maskFile="", nsideForMask=128, selFunFile="",
|
||||
zBoundary=(), zRange=(), zBoundaryMpc=(), shiftSimZ=False,
|
||||
minVoidRadius=-1, fakeDensity=0.01, volumeLimited=True,
|
||||
numAPSlices=1,
|
||||
|
@ -114,6 +115,7 @@ class Sample:
|
|||
self.fullName = fullName
|
||||
self.nickName = nickName
|
||||
self.maskFile = maskFile
|
||||
self.nsideForMask = nsideForMask
|
||||
self.selFunFile = selFunFile
|
||||
self.zBoundary = zBoundary
|
||||
self.zBoundaryMpc = zBoundaryMpc
|
||||
|
@ -127,7 +129,7 @@ class Sample:
|
|||
self.isCombo = isCombo
|
||||
self.comboList = comboList
|
||||
self.numAPSlices = numAPSlices
|
||||
self.zobovDir = None
|
||||
self.outputDir = None
|
||||
self.profileBinSize = profileBinSize
|
||||
self.dataType = dataType
|
||||
self.boxLen = boxLen
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
import numpy as np
|
||||
import scipy.integrate as integrate
|
||||
import os
|
||||
from backend import *
|
||||
#from backend import *
|
||||
|
||||
__all__=['expansion', 'comovingDistance', 'aveExpansion']
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ def launchPrep(sample, binPath, workDir=None, inputDataDir=None,
|
|||
sampleName = sample.fullName
|
||||
|
||||
if regenerate:
|
||||
inputParameterFlag = "inputParameter " + outputDir +
|
||||
inputParameterFlag = "inputParameter " + outputDir + \
|
||||
"/zobov_slice_"+sampleName+".par"
|
||||
outputFile = outputDir + "/regenerated_zobov_slice_" + sampleName
|
||||
else:
|
||||
|
@ -67,14 +67,12 @@ def launchPrep(sample, binPath, workDir=None, inputDataDir=None,
|
|||
datafile = inputDataDir+"/"+sample.dataFile
|
||||
|
||||
if sample.maskFile == "":
|
||||
maskFile = outputDir + "/constructed_mask.fits"
|
||||
figureOutMask(dataFile, sample.nsideForMask, maskFile)
|
||||
else:
|
||||
maskFile = sample.maskFile
|
||||
sample.maskFile = outputDir + "/constructed_mask.fits"
|
||||
figureOutMask(datafile, sample.nsideForMask, sample.maskFile)
|
||||
|
||||
edgeGalFile = outputDir + "/galaxy_edge_flags.txt"
|
||||
edgeMaskFile = outputDir + "/mask_edge_map.fits"
|
||||
findEdgeGalaxies(dataFile, maskFile, edgeGalFile, edgeMaskFile,
|
||||
findEdgeGalaxies(datafile, sample.maskFile, edgeGalFile, edgeMaskFile,
|
||||
sample.zBoundary[0], sample.zBoundary[1], sample.omegaM,
|
||||
useComoving)
|
||||
|
||||
|
@ -94,7 +92,7 @@ def launchPrep(sample, binPath, workDir=None, inputDataDir=None,
|
|||
%s
|
||||
%s
|
||||
omegaM %g
|
||||
""" % (datafile, maskFile, outputFile,
|
||||
""" % (datafile, sample.maskFile, outputFile,
|
||||
outputDir+"/zobov_slice_"+sampleName+".par",
|
||||
sample.zBoundary[0], sample.zBoundary[1], sample.fakeDensity,
|
||||
useComovingFlag, inputParameterFlag, sample.omegaM)
|
||||
|
|
|
@ -24,6 +24,7 @@ import numpy as np
|
|||
import healpy as healpy
|
||||
import os
|
||||
from backend import *
|
||||
from backend.cosmologyTools import *
|
||||
|
||||
__all__=['getSurveyProps', 'getNside', 'figureOutMask', 'findEdgeGalaxies']
|
||||
|
||||
|
@ -44,6 +45,8 @@ def getSurveyProps(maskFile, zmin, zmax, selFunMin, selFunMax, portion,
|
|||
zmin = zmin * LIGHT_SPEED/100.
|
||||
zmax = zmax * LIGHT_SPEED/100.
|
||||
|
||||
volume = area * (zmax**3 - zmin**3) / 3
|
||||
|
||||
if selectionFuncFile == None:
|
||||
nbar = 1.0
|
||||
|
||||
|
@ -119,7 +122,7 @@ def figureOutMask(galFile, nside, outMaskFile):
|
|||
pix = healpy.ang2pix(nside, theta, phi)
|
||||
mask[pix] = 1.
|
||||
|
||||
healpy.write_map(outMaskFile, mask, overwrite=True)
|
||||
healpy.write_map(outMaskFile, mask, overwrite=True, dtype=np.dtype('float64'))
|
||||
|
||||
return mask
|
||||
|
||||
|
@ -129,12 +132,12 @@ def figureOutMask(galFile, nside, outMaskFile):
|
|||
def findEdgeGalaxies(galFile, maskFile, edgeGalFile, edgeMaskFile,
|
||||
zmin, zmax, omegaM, useComoving=False):
|
||||
|
||||
if useComoving:
|
||||
zmin = LIGHT_SPEED/100.*comovingDistance(zmin, Om=omegaM)
|
||||
zmax = LIGHT_SPEED/100.*comovingDistance(zmax, Om=omegaM)
|
||||
else:
|
||||
zmin *= LIGHT_SPEED/100.
|
||||
zmax *= LIGHT_SPEED/100.
|
||||
#if useComoving:
|
||||
# zmin = LIGHT_SPEED/100.*comovingDistance(zmin, Om=omegaM)
|
||||
# zmax = LIGHT_SPEED/100.*comovingDistance(zmax, Om=omegaM)
|
||||
#else:
|
||||
# zmin *= LIGHT_SPEED/100.
|
||||
# zmax *= LIGHT_SPEED/100.
|
||||
|
||||
|
||||
mask = healpy.read_map(maskFile)
|
||||
|
@ -151,32 +154,33 @@ def findEdgeGalaxies(galFile, maskFile, edgeGalFile, edgeMaskFile,
|
|||
z = float(line[5])
|
||||
|
||||
if useComoving:
|
||||
z = LIGHT_SPEED/100.*comovingDistance(z, Om=omegaM)
|
||||
z = comovingDistance(z/LIGHT_SPEED, Om=omegaM)
|
||||
else:
|
||||
z *= LIGHT_SPEED/100.
|
||||
|
||||
phi, theta = convertAngle(RA, Dec)
|
||||
|
||||
# check the mask edges
|
||||
neighbors = healpy.get_all_neighbors(nside, theta, phi)
|
||||
neighbors = healpy.get_all_neighbours(nside, theta, phi)
|
||||
isOnMaskEdge = any(p == 0 for p in neighbors)
|
||||
|
||||
# check the redshift boundaries
|
||||
tol = 0.01 # TODO: made this user-adjustable
|
||||
zBuffer = (zmax-zmin)*tol
|
||||
isOnHighZEdge = (z >= zmax-buffer)
|
||||
isOnLowZEdge = (z <= zmin+buffer)
|
||||
zbuffer = (zmax-zmin)*tol
|
||||
isOnHighZEdge = (z >= zmax-zbuffer)
|
||||
isOnLowZEdge = (z <= zmin+zbuffer)
|
||||
|
||||
print("DOING %f %f %f %f\n" % (zbuffer, z, zmax, zmin) )
|
||||
if isOnMaskEdge:
|
||||
edgeFile.write("1")
|
||||
edgeFile.write("1\n")
|
||||
elif isOnHighZEdge:
|
||||
edgeFile.write("2")
|
||||
edgeFile.write("2\n")
|
||||
elif isOnLowZEdge:
|
||||
edgeFile.write("3")
|
||||
edgeFile.write("3\n")
|
||||
else:
|
||||
edgeFile.write("0")
|
||||
edgeFile.write("0\n")
|
||||
|
||||
edgeFile.close()
|
||||
healpy.write_map(edgeMaskFile, edgeMask, overwrite=True)
|
||||
healpy.write_map(edgeMaskFile, edgeMask, overwrite=True, dtype=np.dtype('float64'))
|
||||
|
||||
return
|
||||
|
|
|
@ -75,11 +75,11 @@ for sample in dataSampleList:
|
|||
sampleName = sample.fullName
|
||||
|
||||
print(" Working with data set", sampleName, "...")
|
||||
zobovDir = workDir+"/sample_"+sampleName+"/"
|
||||
sample.zobovDir = zobovDir
|
||||
outputDir = workDir+"/sample_"+sampleName+"/"
|
||||
sample.outputDir = outputDir
|
||||
|
||||
if not os.access(zobovDir, os.F_OK):
|
||||
os.makedirs(zobovDir)
|
||||
if not os.access(outputDir, os.F_OK):
|
||||
os.makedirs(outputDir)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
if (startCatalogStage <= 1) and (endCatalogStage >= 1) and not sample.isCombo:
|
||||
|
@ -94,7 +94,7 @@ for sample in dataSampleList:
|
|||
GENERATE_PATH = CTOOLS_PATH+"/prepSimulation"
|
||||
|
||||
launchPrep(sample, GENERATE_PATH, workDir=workDir,
|
||||
inputDataDir=inputDataDir, zobovDir=zobovDir,
|
||||
inputDataDir=inputDataDir, outputDir=outputDir,
|
||||
figDir=figDir, logFile=logFile, useComoving=sample.useComoving,
|
||||
continueRun=continueRun, regenerate=regenerateFlag)
|
||||
|
||||
|
@ -103,7 +103,7 @@ for sample in dataSampleList:
|
|||
print(" Extracting voids with ZOBOV...", end=' ')
|
||||
sys.stdout.flush()
|
||||
|
||||
launchZobov(sample, ZOBOV_PATH, zobovDir=zobovDir, logDir=logDir,
|
||||
launchZobov(sample, ZOBOV_PATH, outputDir=outputDir, logDir=logDir,
|
||||
continueRun=continueRun, numZobovDivisions=numZobovDivisions,
|
||||
numZobovThreads=numZobovThreads,
|
||||
mergingThreshold=mergingThreshold)
|
||||
|
@ -119,7 +119,7 @@ for sample in dataSampleList:
|
|||
PRUNE_PATH = CTOOLS_PATH+"/pruneVoids"
|
||||
|
||||
launchPrune(sample, PRUNE_PATH,
|
||||
logFile=logFile, zobovDir=zobovDir,
|
||||
logFile=logFile, outputDir=outputDir,
|
||||
useComoving=sample.useComoving, continueRun=continueRun,
|
||||
mergingThreshold=mergingThreshold,
|
||||
boundaryTolerance=boundaryTolerance)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue