mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
fixed and calrified zobov vs survey normalization schemes
This commit is contained in:
parent
a670b86295
commit
cee027a759
3 changed files with 57 additions and 36 deletions
|
@ -270,7 +270,10 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
part = (PART *) malloc(numPartTot * sizeof(PART));
|
part = (PART *) malloc(numPartTot * sizeof(PART));
|
||||||
temp = (float *) malloc(numPartTot * sizeof(float));
|
temp = (float *) malloc(numPartTot * sizeof(float));
|
||||||
|
|
||||||
|
// this is the volume normalization understood by zobov,
|
||||||
|
// which is all particles (including mock boundary galaxies used in old
|
||||||
|
// versions of VIDE) divided by the total volume of the bounding box
|
||||||
volNorm = numPartTot/(boxLen[0]*boxLen[1]*boxLen[2]);
|
volNorm = numPartTot/(boxLen[0]*boxLen[1]*boxLen[2]);
|
||||||
printf(" VOL NORM = %f\n", volNorm);
|
printf(" VOL NORM = %f\n", volNorm);
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,7 @@ def findEdgeGalaxies(galFile, maskFile, edgeGalFile, contourFile,
|
||||||
|
|
||||||
# paint galaxy flags onto healpix map for diagnostics
|
# paint galaxy flags onto healpix map for diagnostics
|
||||||
# TODO - drop this when done testing
|
# TODO - drop this when done testing
|
||||||
log.write(" Saving diagnostic map to file...\n")
|
log.write(" Saving diagnostic maps to file...\n")
|
||||||
flagMap = np.zeros(len(contourMap))
|
flagMap = np.zeros(len(contourMap))
|
||||||
justEdgeRA = RA[flagList == 1]
|
justEdgeRA = RA[flagList == 1]
|
||||||
justEdgeDec = Dec[flagList == 1]
|
justEdgeDec = Dec[flagList == 1]
|
||||||
|
@ -244,13 +244,28 @@ def findEdgeGalaxies(galFile, maskFile, edgeGalFile, contourFile,
|
||||||
phi, theta = convertAngle(justEdgeRA, justEdgeDec)
|
phi, theta = convertAngle(justEdgeRA, justEdgeDec)
|
||||||
|
|
||||||
ipix = healpy.ang2pix(nside, theta, phi)
|
ipix = healpy.ang2pix(nside, theta, phi)
|
||||||
np.put(flagMap, ipix, 1)
|
for i in ipix:
|
||||||
|
flagMap[i] += 1
|
||||||
|
#np.put(flagMap, ipix, 1)
|
||||||
|
|
||||||
healpy.write_map(outputDir+"/flagged_galaxies.fits", flagMap,
|
healpy.write_map(outputDir+"/flagged_galaxies.fits", flagMap,
|
||||||
overwrite=True,
|
overwrite=True,
|
||||||
dtype=np.dtype('float64'))
|
dtype=np.dtype('float64'))
|
||||||
|
|
||||||
|
|
||||||
|
allGalMap = np.zeros(len(contourMap))
|
||||||
|
phi, theta = convertAngle(RA, Dec)
|
||||||
|
|
||||||
|
ipix = healpy.ang2pix(nside, theta, phi)
|
||||||
|
for i in ipix:
|
||||||
|
allGalMap[i] += 1
|
||||||
|
#np.put(allGalMap, ipix, 1)
|
||||||
|
|
||||||
|
healpy.write_map(outputDir+"/all_galaxies.fits", allGalMap,
|
||||||
|
overwrite=True,
|
||||||
|
dtype=np.dtype('float64'))
|
||||||
|
|
||||||
|
|
||||||
# # output galaxy edge flags
|
# # output galaxy edge flags
|
||||||
# edgeFile = open(edgeGalFile, "w")
|
# edgeFile = open(edgeGalFile, "w")
|
||||||
#
|
#
|
||||||
|
|
|
@ -49,6 +49,12 @@ def loadPart(sampleDir):
|
||||||
ranges[2][0] = getattr(File, 'range_z_min')
|
ranges[2][0] = getattr(File, 'range_z_min')
|
||||||
ranges[2][1] = getattr(File, 'range_z_max')
|
ranges[2][1] = getattr(File, 'range_z_max')
|
||||||
isObservation = getattr(File, 'is_observation')
|
isObservation = getattr(File, 'is_observation')
|
||||||
|
|
||||||
|
# old verison of VIDe includes the boundary tracers in the file
|
||||||
|
nGal = 0
|
||||||
|
if hasattr(File, 'mask_index'):
|
||||||
|
nGal = getattr(File, 'mask_index')
|
||||||
|
|
||||||
File.close()
|
File.close()
|
||||||
mul = np.zeros((3))
|
mul = np.zeros((3))
|
||||||
mul[:] = ranges[:,1] - ranges[:,0]
|
mul[:] = ranges[:,1] - ranges[:,0]
|
||||||
|
@ -99,31 +105,22 @@ def loadPart(sampleDir):
|
||||||
uniqueID = np.fromfile(File, dtype=np.int64,count=Np)
|
uniqueID = np.fromfile(File, dtype=np.int64,count=Np)
|
||||||
chk = np.fromfile(File, dtype=np.int32,count=1)
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
|
||||||
|
# if it's an old catalog, trim it
|
||||||
|
if nGal > 0:
|
||||||
|
x = x[0:nGal]
|
||||||
|
y = y[0:nGal]
|
||||||
|
z = z[0:nGal]
|
||||||
|
RA = RA[0:nGal]
|
||||||
|
Dec = Dec[0:nGal]
|
||||||
|
redshift = redshift[0:nGal]
|
||||||
|
uniqueID = uniqueID[0:nGal]
|
||||||
|
|
||||||
partData = np.column_stack((x,y,z))
|
partData = np.column_stack((x,y,z))
|
||||||
extraData = np.column_stack((RA,Dec,redshift,uniqueID))
|
extraData = np.column_stack((RA,Dec,redshift,uniqueID))
|
||||||
|
|
||||||
boxLen = mul
|
boxLen = mul
|
||||||
|
|
||||||
# TODO - should use built-in volNorm function instead
|
|
||||||
|
|
||||||
#if isObservation == 1:
|
|
||||||
# # look for the mask file
|
|
||||||
# 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(maskFile, sample.zBoundary[0],
|
|
||||||
# sample.zBoundary[1],
|
|
||||||
# sample.zBoundary[0],
|
|
||||||
# sample.zBoundary[1], "all",
|
|
||||||
# selectionFuncFile=sample.selFunFile,
|
|
||||||
# useComoving=sample.useComoving)
|
|
||||||
# boxVol = props[0]
|
|
||||||
# volNorm = maskIndex/boxVol
|
|
||||||
#else:
|
|
||||||
boxVol = np.prod(boxLen)
|
boxVol = np.prod(boxLen)
|
||||||
volNorm = len(x)/boxVol
|
volNorm = Np/boxVol # this is the zobov normalization
|
||||||
|
|
||||||
isObservationData = isObservation == 1
|
isObservationData = isObservation == 1
|
||||||
|
|
||||||
|
@ -148,19 +145,25 @@ def getVolNorm(sampleDir):
|
||||||
mul = np.zeros((3))
|
mul = np.zeros((3))
|
||||||
mul[:] = ranges[:,1] - ranges[:,0]
|
mul[:] = ranges[:,1] - ranges[:,0]
|
||||||
|
|
||||||
partFile = sampleDir+"/zobov_slice_"+sample.fullName
|
# getting the total number of tracers is an adventure depending
|
||||||
with open(partFile, mode="rb") as File:
|
# on which verison of VIDE we're pulling up
|
||||||
chk = np.fromfile(File, dtype=np.int32,count=1)
|
maskIndexFile = sampleDir+"/mask_index.txt"
|
||||||
Np = np.fromfile(File, dtype=np.int32,count=1)[0]
|
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
|
boxLen = mul
|
||||||
|
|
||||||
boxVol = np.prod(boxLen)
|
boxVol = np.prod(boxLen)
|
||||||
volNorm = Np/boxVol
|
volNormZobov = nTot/boxVol
|
||||||
volNormObs = volNorm
|
volNormObs = volNormZobov
|
||||||
|
|
||||||
if isObservation == 1:
|
if isObservation == 1:
|
||||||
# look for the mask file
|
|
||||||
if os.access(sample.maskFile, os.F_OK):
|
if os.access(sample.maskFile, os.F_OK):
|
||||||
maskFile = sample.maskFile
|
maskFile = sample.maskFile
|
||||||
else:
|
else:
|
||||||
|
@ -174,10 +177,10 @@ def getVolNorm(sampleDir):
|
||||||
sample.omegaM,
|
sample.omegaM,
|
||||||
selectionFuncFile=sample.selFunFile,
|
selectionFuncFile=sample.selFunFile,
|
||||||
useComoving=sample.useComoving)
|
useComoving=sample.useComoving)
|
||||||
boxVol = props[0]
|
surveyVol = props[0]
|
||||||
volNormObs = Np/boxVol
|
volNormObs = nGal/surveyVol
|
||||||
|
|
||||||
return volNorm, volNormObs
|
return volNormZobov, volNormObs
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
@ -278,7 +281,7 @@ class Catalog:
|
||||||
numVoids = 0
|
numVoids = 0
|
||||||
numPartTot = 0
|
numPartTot = 0
|
||||||
numZonesTot = 0
|
numZonesTot = 0
|
||||||
volNorm = 0 # normalization used by zobov across entire volumne
|
volNormZobov = 0 # normalization used by zobov across entire volumne
|
||||||
volNormObs = 0 # normalization based on average density of survey volume
|
volNormObs = 0 # normalization based on average density of survey volume
|
||||||
boxLen = np.zeros((3))
|
boxLen = np.zeros((3))
|
||||||
ranges = np.zeros((3,2))
|
ranges = np.zeros((3,2))
|
||||||
|
@ -324,8 +327,8 @@ def loadVoidCatalog(sampleDir, dataPortion="central", loadParticles=True,
|
||||||
catalog.ranges = ranges
|
catalog.ranges = ranges
|
||||||
File.close()
|
File.close()
|
||||||
|
|
||||||
volNorm, volNormObs = getVolNorm(sampleDir)
|
volNormZobov, volNormObs = getVolNorm(sampleDir)
|
||||||
catalog.volNorm = volNorm
|
catalog.volNormZobov = volNormZobov
|
||||||
catalog.volNormObs = volNormObs
|
catalog.volNormObs = volNormObs
|
||||||
|
|
||||||
if untrimmed:
|
if untrimmed:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue