From 7e5a51d9318984588b835bef3e7f52a0b5c0390e Mon Sep 17 00:00:00 2001 From: "Paul M. Sutter" Date: Fri, 7 Jun 2024 11:58:36 +0200 Subject: [PATCH] redshift boundary tolerance is now user-selectable --- c_source/pruning/pruneVoids.cpp | 4 ++-- .../example_observation/example_observation.py | 4 ++++ python_source/backend/classes.py | 5 ++++- python_source/backend/launchers.py | 2 +- python_source/backend/surveyTools.py | 16 +++++++++------- python_source/vide_pipeline/__main__.py | 3 +-- python_source/vide_pipeline/defaults.py | 4 ---- python_source/voidUtil/plotUtil.py | 8 +++++--- 8 files changed, 26 insertions(+), 20 deletions(-) diff --git a/c_source/pruning/pruneVoids.cpp b/c_source/pruning/pruneVoids.cpp index adad968..f8de89a 100644 --- a/c_source/pruning/pruneVoids.cpp +++ b/c_source/pruning/pruneVoids.cpp @@ -851,8 +851,8 @@ int main(int argc, char **argv) { // toss out voids near non-periodic box edges iGood = 0; for (iVoid = 0; iVoid < voids.size(); iVoid++) { - if (tolerance*voids[iVoid].maxRadius > voids[iVoid].nearestEdge || - tolerance*voids[iVoid].radius > voids[iVoid].nearestEdge) { + if (voids[iVoid].maxRadius > voids[iVoid].nearestEdge || + voids[iVoid].radius > voids[iVoid].nearestEdge) { numNearZ++; } else { voids[iGood++] = voids[iVoid]; diff --git a/examples/example_observation/example_observation.py b/examples/example_observation/example_observation.py index 6f63fd4..15ead2d 100644 --- a/examples/example_observation/example_observation.py +++ b/examples/example_observation/example_observation.py @@ -99,6 +99,10 @@ newSample = Sample( # max and min redshifts where you want to find voids zRange = (0.1, 0.15), + # width of redshift boundaries to flag edge galaxies + # (interpreted as boundaryWidth*(zMax-zMin)) + boundaryWidth = 0.1, + # leave this at -1 for mean particle separation, # or specify your own in Mpc/h minVoidRadius = -1, diff --git a/python_source/backend/classes.py b/python_source/backend/classes.py index 2321c94..1266e5b 100644 --- a/python_source/backend/classes.py +++ b/python_source/backend/classes.py @@ -73,6 +73,7 @@ class Sample: selFunFile = "czselfunc.all.dr72dim.dat" zBoundary = (0.0, 0.1) zBoundaryMpc = (0., 300) + boundaryWidth = 0.02 shiftSimZ = False zRange = (0.0, 0.1) omegaM = 0.27 @@ -100,7 +101,8 @@ class Sample: def __init__(self, dataFile="", fullName="", dataUnit=1, nickName="", maskFile="", nsideForMask=128, selFunFile="", - zBoundary=(), zRange=(), zBoundaryMpc=(), shiftSimZ=False, + zBoundary=(), zRange=(), zBoundaryMpc=(), boundaryWidth=0.1, + shiftSimZ=False, minVoidRadius=-1, fakeDensity=0.01, volumeLimited=True, numAPSlices=1, includeInHubble=True, partOfCombo=False, isCombo=False, @@ -119,6 +121,7 @@ class Sample: self.selFunFile = selFunFile self.zBoundary = zBoundary self.zBoundaryMpc = zBoundaryMpc + self.boundaryWidth = boundaryWidth self.shiftSimZ = shiftSimZ self.zRange = zRange self.minVoidRadius = minVoidRadius diff --git a/python_source/backend/launchers.py b/python_source/backend/launchers.py index 10f7436..5d30bf7 100644 --- a/python_source/backend/launchers.py +++ b/python_source/backend/launchers.py @@ -74,7 +74,7 @@ def launchPrep(sample, binPath, workDir=None, inputDataDir=None, edgeMaskFile = outputDir + "/mask_edge_map.fits" findEdgeGalaxies(datafile, sample.maskFile, edgeGalFile, edgeMaskFile, sample.zBoundary[0], sample.zBoundary[1], sample.omegaM, - useComoving) + useComoving, sample.boundaryWidth) if useComoving: useComovingFlag = "useComoving" diff --git a/python_source/backend/surveyTools.py b/python_source/backend/surveyTools.py index 798b143..b9f1423 100644 --- a/python_source/backend/surveyTools.py +++ b/python_source/backend/surveyTools.py @@ -130,11 +130,13 @@ def figureOutMask(galFile, nside, outMaskFile): # figures out which galaxies live on a mask edge, and also writes the edge # map to an auxillary file def findEdgeGalaxies(galFile, maskFile, edgeGalFile, edgeMaskFile, - zmin, zmax, omegaM, useComoving=False): + zmin, zmax, omegaM, useComoving, boundaryWidth): - #if useComoving: - # zmin = LIGHT_SPEED/100.*comovingDistance(zmin, Om=omegaM) - # zmax = LIGHT_SPEED/100.*comovingDistance(zmax, Om=omegaM) + if useComoving: + zmin = comovingDistance(zmin, Om=omegaM) + zmax = comovingDistance(zmax, Om=omegaM) + #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. @@ -166,8 +168,7 @@ def findEdgeGalaxies(galFile, maskFile, edgeGalFile, edgeMaskFile, isOnMaskEdge = any(mask[p] == 0 for p in neighbors) # check the redshift boundaries - tol = 0.05 # TODO: made this user-adjustable - zbuffer = (zmax-zmin)*tol + zbuffer = (zmax-zmin)*boundaryWidth isOnHighZEdge = (z >= zmax-zbuffer) isOnLowZEdge = (z <= zmin+zbuffer) @@ -182,6 +183,7 @@ def findEdgeGalaxies(galFile, maskFile, edgeGalFile, edgeMaskFile, edgeFile.write("0\n") edgeFile.close() - healpy.write_map(edgeMaskFile, edgeMask, overwrite=True, dtype=np.dtype('float64')) + healpy.write_map(edgeMaskFile, edgeMask, overwrite=True, + dtype=np.dtype('float64')) return diff --git a/python_source/vide_pipeline/__main__.py b/python_source/vide_pipeline/__main__.py index b624712..716c1f1 100644 --- a/python_source/vide_pipeline/__main__.py +++ b/python_source/vide_pipeline/__main__.py @@ -121,8 +121,7 @@ for sample in dataSampleList: launchPrune(sample, PRUNE_PATH, logFile=logFile, outputDir=outputDir, useComoving=sample.useComoving, continueRun=continueRun, - mergingThreshold=mergingThreshold, - boundaryTolerance=boundaryTolerance) + mergingThreshold=mergingThreshold) # ------------------------------------------------------------------------- if (startCatalogStage <= 4) and (endCatalogStage >= 4): diff --git a/python_source/vide_pipeline/defaults.py b/python_source/vide_pipeline/defaults.py index 627b3b1..b552865 100644 --- a/python_source/vide_pipeline/defaults.py +++ b/python_source/vide_pipeline/defaults.py @@ -143,10 +143,6 @@ numZobovThreads = 2 # 1e-9 (or smaller != 0) -> Do not merge anything mergingThreshold = 1.e-9 -# when trimming away voids near the bounaries, what multiple of the radius to -# use for safety -boundaryTolerance = 1.0 - # simulation information numPart = 512*512*512 lbox = 999.983 # Mpc/h diff --git a/python_source/voidUtil/plotUtil.py b/python_source/voidUtil/plotUtil.py index bdba618..1132b59 100644 --- a/python_source/voidUtil/plotUtil.py +++ b/python_source/voidUtil/plotUtil.py @@ -25,6 +25,7 @@ import numpy as np import os import pylab as plt import backend.cosmologyTools as vp +import backend.surveyTools as sp from voidUtil import getArray, shiftPart, getVoidPart def fill_between(x, y1, y2=0, ax=None, **kwargs): @@ -77,17 +78,18 @@ def plotNumberFunction(catalogList, if sample.dataType == "observation": maskFile = sample.maskFile - boxVol = vp.getSurveyProps(maskFile, + boxVol = sp.getSurveyProps(maskFile, sample.zBoundary[0], sample.zBoundary[1], sample.zRange[0], sample.zRange[1], "all", - selectionFuncFile=sample.selFunFile)[0] + selectionFuncFile=sample.selFunFile, + omegaM=sample.omegaM)[0] else: boxVol = sample.boxLen*sample.boxLen*(sample.zBoundaryMpc[1] - sample.zBoundaryMpc[0]) boxVol *= 1.e-9 # Mpc->Gpc - bins = 100./binWidth + bins = int(100./binWidth) hist, binEdges = np.histogram(data, bins=bins, range=(0., 100.)) binCenters = 0.5*(binEdges[1:] + binEdges[:-1])