central density calculation now uses correct normalization from survey volume

This commit is contained in:
Paul M. Sutter 2025-04-23 15:22:07 -04:00
parent 96a3ee422f
commit 5bff8c0da3
5 changed files with 67 additions and 55 deletions

View file

@ -88,6 +88,8 @@ class Sample:
includeInHubble = True
partOfCombo = False
isCombo = False
volNormZobov = 0
volNormObs = 0
comboList = []

View file

@ -608,6 +608,8 @@ def launchPrune(sample, binPath,
else:
minRadius = sample.minVoidRadius
volNormZobov, volNormObs = getVolNorm(sample)
if not (continueRun and (jobSuccessful(logFile, "NetCDF: Not a valid ID\n") \
or jobSuccessful(logFile, "Done!\n"))):
cmd = binPath
@ -626,6 +628,8 @@ def launchPrune(sample, binPath,
cmd += volFileLine
cmd += useComovingFlag
cmd += " --omegaM=" + str(sample.omegaM)
cmd += " --volNormZobov=" + str(volNormZobov)
cmd += " --volNormObs=" + str(volNormObs)
cmd += " --outputDir=" + outputDir
cmd += " --sampleName=" + str(sampleName)
log = open(logFile, 'w')

View file

@ -27,7 +27,11 @@ import os
from backend import *
from backend.cosmologyTools import *
__all__=['getSurveyProps', 'getNside', 'figureOutMask', 'findEdgeGalaxies']
from netCDF4 import Dataset
NetCDFFile = Dataset
ncFloat = 'f8'
__all__=['getSurveyProps', 'getVolNorm', 'getNside', 'figureOutMask', 'findEdgeGalaxies']
# -----------------------------------------------------------------------------
# returns the survey volume and scaled galaxy density for a given redshit slice
@ -93,6 +97,60 @@ def getSurveyProps(sample):
return (volume, nbar)
# -----------------------------------------------------------------------------
# returns the volume normalization factors:
# normalization used by zobov (assumes cubmic volume)
# normalization used in galaxy survey volume for observations
def getVolNorm(sample):
sampleDir = sample.outputDir
infoFile = sampleDir+"/zobov_slice_"+sample.fullName+".par"
File = NetCDFFile(infoFile, 'r')
ranges = np.zeros((3,2))
ranges[0][0] = getattr(File, 'range_x_min')
ranges[0][1] = getattr(File, 'range_x_max')
ranges[1][0] = getattr(File, 'range_y_min')
ranges[1][1] = getattr(File, 'range_y_max')
ranges[2][0] = getattr(File, 'range_z_min')
ranges[2][1] = getattr(File, 'range_z_max')
isObservation = getattr(File, 'is_observation')
File.close()
mul = np.zeros((3))
mul[:] = ranges[:,1] - ranges[:,0]
# getting the total number of tracers is an adventure depending
# on which verison of VIDE we're pulling up
maskIndexFile = sampleDir+"/mask_index.txt"
totalPartFile = sampleDir+"/total_particles.txt"
if os.path.exists(maskIndexFile):
nTot = float(open(totalPartFile, "r").read())
nGal = float(open(maskIndexFile, "r").read())
else:
nTot = float(open(totalPartFile, "r").read())
nGal = nTot
boxLen = mul
boxVol = np.prod(boxLen)
volNormZobov = nTot/boxVol
volNormObs = volNormZobov
if isObservation == 1:
if os.access(sample.maskFile, os.F_OK):
maskFile = sample.maskFile
else:
maskFile = sampleDir+"/"+os.path.basename(sample.maskFile)
print("Using maskfile found in: " + maskFile)
props = getSurveyProps(sample)
surveyVol = props[0]
volNormObs = nGal/surveyVol
return volNormZobov, volNormObs
# -----------------------------------------------------------------------------
# returns the nside resolution from the given maskfile
def getNside(maskFile):