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

@ -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):