mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
removed mock particle tracking, since that is no longer used
This commit is contained in:
parent
fc2d7157f4
commit
d9efa15474
8 changed files with 71 additions and 173 deletions
|
@ -32,7 +32,6 @@ import shutil
|
|||
import glob
|
||||
import subprocess
|
||||
import sys
|
||||
from pylab import figure
|
||||
from netCDF4 import Dataset
|
||||
from backend.classes import *
|
||||
from backend.cosmologyTools import *
|
||||
|
@ -120,7 +119,7 @@ def launchPrep(sample, binPath, workDir=None, inputDataDir=None,
|
|||
sample.zRange[1], sample.zRange[0], sample.zRange[1], "all",
|
||||
sample.omegaM, useComoving=useComoving)
|
||||
|
||||
numTracers = int(open(outputDir+"/mask_index.txt", "r").read())
|
||||
numTracers = int(open("total_particles.txt", "r").read())
|
||||
sample.meanPartSep = (1.*numTracers/boxVol/nbar)**(-1/3.)
|
||||
|
||||
# flag edge galaxies with python routine for now
|
||||
|
@ -158,7 +157,7 @@ def launchPrep(sample, binPath, workDir=None, inputDataDir=None,
|
|||
sample.zRange[1], sample.zRange[0], sample.zRange[1], "all",
|
||||
sample.omegaM, useComoving=useComoving)
|
||||
|
||||
numTracers = int(open(outputDir+"/mask_index.txt", "r").read())
|
||||
numTracers = int(open("total_particles.txt", "r").read())
|
||||
sample.meanPartSep = (1.*numTracers/boxVol/nbar)**(-1/3.)
|
||||
|
||||
if os.access(parmFile, os.F_OK): os.unlink(parmFile)
|
||||
|
@ -169,8 +168,7 @@ def launchPrep(sample, binPath, workDir=None, inputDataDir=None,
|
|||
if os.access("comoving_distance.txt", os.F_OK):
|
||||
os.system("mv %s %s" % ("comoving_distance.txt", outputDir))
|
||||
|
||||
if os.access("mask_index.txt", os.F_OK):
|
||||
os.system("mv %s %s" % ("mask_index.txt", outputDir))
|
||||
if os.access("total_particles.txt", os.F_OK):
|
||||
os.system("mv %s %s" % ("total_particles.txt", outputDir))
|
||||
|
||||
if os.access("galaxies.txt", os.F_OK):
|
||||
|
@ -333,10 +331,8 @@ def launchPrep(sample, binPath, workDir=None, inputDataDir=None,
|
|||
if os.access(parmFile, os.F_OK):
|
||||
os.unlink(parmFile)
|
||||
|
||||
if os.access("mask_index.txt", os.F_OK):
|
||||
os.system("mv %s %s" % ("mask_index.txt", outputDir))
|
||||
if os.access("total_particles.txt", os.F_OK):
|
||||
os.system("mv %s %s" % ("total_particles.txt", outputDir))
|
||||
#os.system("mv %s %s" % ("sample_info.txt", outputDir))
|
||||
|
||||
# save this sample's information
|
||||
with open(outputDir+"/sample_info.dat", mode='wb') as output:
|
||||
|
@ -382,15 +378,9 @@ def launchZobov(sample, binPath, outputDir=None, logDir=None, continueRun=None,
|
|||
if os.access(vozScript, os.F_OK):
|
||||
os.unlink(vozScript)
|
||||
|
||||
if sample.dataType == "observation":
|
||||
maskIndex = open(outputDir+"/mask_index.txt", "r").read()
|
||||
totalPart = open(outputDir+"/total_particles.txt", "r").read()
|
||||
maxDen = mergingThreshold*float(maskIndex)/float(totalPart)
|
||||
else:
|
||||
maskIndex = -1
|
||||
maxDen = mergingThreshold
|
||||
if numZobovDivisions == 1:
|
||||
print(" WARNING! You are using a single ZOBOV division with a simulation. Periodic boundaries will not be respected!")
|
||||
maxDen = mergingThreshold
|
||||
if sample.dataType == "simulation" and numZobovDivisions == 1:
|
||||
print(" WARNING! You are using a single ZOBOV division with a simulation. Periodic boundaries will not be respected!")
|
||||
|
||||
if not (continueRun and jobSuccessful(logFile, "Done!\n")):
|
||||
for fileName in glob.glob(outputDir+"/part._"+sampleName+".*"):
|
||||
|
@ -404,7 +394,7 @@ def launchZobov(sample, binPath, outputDir=None, logDir=None, continueRun=None,
|
|||
|
||||
cmd = [binPath+"/vozinit", datafile, "0.1", "1.0", str(numZobovDivisions), \
|
||||
"_"+sampleName, str(numZobovThreads), \
|
||||
binPath, outputDir, str(maskIndex)]
|
||||
binPath, outputDir]
|
||||
log = open(logFile, 'w')
|
||||
subprocess.call(cmd, stdout=log, stderr=log)
|
||||
log.close()
|
||||
|
@ -483,21 +473,24 @@ def launchZobov(sample, binPath, outputDir=None, logDir=None, continueRun=None,
|
|||
else:
|
||||
volFileToUse = outputDir+"/vol_"+sampleName+".dat"
|
||||
|
||||
# double-check to make sure galaxies were flagged correctly.
|
||||
# if any non-edge galaxies have bad tesselations, flag them
|
||||
# also, re-weight the volumes of any edge galaxies to prevent watershed
|
||||
# from spilling outside of survey region
|
||||
# Zobov places guard particles at the domain walls; adjacenies to these
|
||||
# guard particles are not tracked in the final tesselation.
|
||||
# Therefore, if a galaxy marked as "interior" is missing an adjancency, that
|
||||
# means it erroneously connected to a guard particle.
|
||||
#
|
||||
# Re-weight the volumes of any edge galaxies to prevent watershed
|
||||
# from spilling outside of survey region.
|
||||
if sample.dataType == "observation":
|
||||
|
||||
log = open(logFile, 'a')
|
||||
log.write("\nDouble-checking all edge flags.\n\n")
|
||||
log.write("\nDouble-checking all edge flags.\n")
|
||||
|
||||
# read in the edge flag information
|
||||
edgeFile = outputDir+"/galaxy_edge_flags.txt"
|
||||
edgeFlags = np.loadtxt(edgeFile, dtype=np.int32)
|
||||
|
||||
# load in and count adjacenies
|
||||
log.write("Loading adjancies...\n")
|
||||
log.write(" Loading adjancies...\n")
|
||||
part = []
|
||||
adjFile = outputDir+"adj_"+sampleName+".dat"
|
||||
with open(adjFile, mode="rb") as File:
|
||||
|
@ -516,21 +509,18 @@ def launchZobov(sample, binPath, outputDir=None, logDir=None, continueRun=None,
|
|||
part[p].adjs.append(pAdj)
|
||||
part[pAdj].adjs.append(p)
|
||||
|
||||
# if the number of expected adjancies != actual adjacenies, this galaxy
|
||||
# connected to a guard point on the boundary. This is fine for edge
|
||||
# galaxies, but occasionally interior galaxies slip through the
|
||||
# boundary handling, so we'll mark those as an edge
|
||||
for p in range(numPart):
|
||||
nHave = len(part[p].adjs)
|
||||
nExpected = nadjPerPart[p]
|
||||
#print("Working on %d: %d vs %d" % (p, nHave, nExpected))
|
||||
if nHave != nExpected and edgeFlags[p] == 0:
|
||||
log.write("Found an unflagged galaxy: %d. Correcting.\n" % (p))
|
||||
|
||||
# an interior galaxy slipped through the boundary
|
||||
if edgeFlags[p] == 0 and nHave != nExpected:
|
||||
log.write(" Found an unflagged galaxy: %d. Correcting.\n" % (p))
|
||||
edgeFlags[p] = 4
|
||||
|
||||
# re-write the new edge flag information
|
||||
np.savetxt(edgeFile, edgeFlags, fmt="%d")
|
||||
log.write("\nDone double-checking. New flags saved.\n")
|
||||
log.write(" Done double-checking. New flags saved.\n")
|
||||
|
||||
# read in the appropriate volume file
|
||||
log.write("Re-weighting edge galaxy volumes...\n")
|
||||
|
@ -599,15 +589,11 @@ def launchPrune(sample, binPath,
|
|||
open(outputDir+"/voidDesc_"+sampleName+".out"))
|
||||
numVoids -= 2
|
||||
|
||||
maxDen = mergingThreshold
|
||||
if sample.dataType == "observation":
|
||||
mockIndex = open(outputDir+"/mask_index.txt", "r").read()
|
||||
totalPart = open(outputDir+"/total_particles.txt", "r").read()
|
||||
maxDen = mergingThreshold*float(mockIndex)/float(totalPart)
|
||||
observationLine = " --isObservation"
|
||||
#periodicLine = " --periodic=''"
|
||||
else:
|
||||
mockIndex = -1
|
||||
maxDen = mergingThreshold
|
||||
observationLine = ""
|
||||
|
||||
periodicLine = " --periodic='" + getPeriodic(sample) + "'"
|
||||
|
@ -646,7 +632,6 @@ def launchPrune(sample, binPath,
|
|||
cmd += " --partEdge=" + outputDir+"galaxy_edge_flags.txt"
|
||||
cmd += " --extraInfo=" + outputDir+"/zobov_slice_"+str(sampleName)+".par"
|
||||
cmd += " --tolerance=" + str(boundaryTolerance)
|
||||
cmd += " --mockIndex=" + str(mockIndex)
|
||||
cmd += " --maxCentralDen=" + str(maxDen)
|
||||
cmd += " --zMin=" + str(sample.zRange[0])
|
||||
cmd += " --zMax=" + str(sample.zRange[1])
|
||||
|
|
|
@ -49,7 +49,6 @@ def loadPart(sampleDir):
|
|||
ranges[2][0] = getattr(File, 'range_z_min')
|
||||
ranges[2][1] = getattr(File, 'range_z_max')
|
||||
isObservation = getattr(File, 'is_observation')
|
||||
maskIndex = getattr(File, 'mask_index')
|
||||
File.close()
|
||||
mul = np.zeros((3))
|
||||
mul[:] = ranges[:,1] - ranges[:,0]
|
||||
|
@ -100,24 +99,8 @@ def loadPart(sampleDir):
|
|||
uniqueID = np.fromfile(File, dtype=np.int64,count=Np)
|
||||
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||
|
||||
## TEST - outputting of mock particles is temporary for debugging
|
||||
mockPart = []
|
||||
if isObservation == 1:
|
||||
mockPartx = x[maskIndex+1:Np]
|
||||
mockParty = y[maskIndex+1:Np]
|
||||
mockPartz = z[maskIndex+1:Np]
|
||||
|
||||
x = x[0:maskIndex]# * 100/300000
|
||||
y = y[0:maskIndex]# * 100/300000
|
||||
z = z[0:maskIndex]# * 100/300000
|
||||
RA = RA[0:maskIndex]
|
||||
Dec = Dec[0:maskIndex]
|
||||
redshift = redshift[0:maskIndex]
|
||||
uniqueID = uniqueID[0:maskIndex]
|
||||
|
||||
partData = np.column_stack((x,y,z))
|
||||
extraData = np.column_stack((RA,Dec,redshift,uniqueID))
|
||||
mockPart = np.column_stack((mockPartx, mockParty, mockPartz))
|
||||
|
||||
boxLen = mul
|
||||
|
||||
|
@ -144,7 +127,7 @@ def loadPart(sampleDir):
|
|||
|
||||
isObservationData = isObservation == 1
|
||||
|
||||
return partData, boxLen, volNorm, isObservationData, ranges, extraData, mockPart
|
||||
return partData, boxLen, volNorm, isObservationData, ranges, extraData
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def getVolNorm(sampleDir):
|
||||
|
@ -161,7 +144,6 @@ def getVolNorm(sampleDir):
|
|||
ranges[2][0] = getattr(File, 'range_z_min')
|
||||
ranges[2][1] = getattr(File, 'range_z_max')
|
||||
isObservation = getattr(File, 'is_observation')
|
||||
maskIndex = getattr(File, 'mask_index')
|
||||
File.close()
|
||||
mul = np.zeros((3))
|
||||
mul[:] = ranges[:,1] - ranges[:,0]
|
||||
|
@ -193,7 +175,7 @@ def getVolNorm(sampleDir):
|
|||
selectionFuncFile=sample.selFunFile,
|
||||
useComoving=sample.useComoving)
|
||||
boxVol = props[0]
|
||||
volNormObs = maskIndex/boxVol
|
||||
volNormObs = Np/boxVol
|
||||
|
||||
return volNorm, volNormObs
|
||||
|
||||
|
@ -457,11 +439,10 @@ def loadVoidCatalog(sampleDir, dataPortion="central", loadParticles=True,
|
|||
|
||||
if loadParticles:
|
||||
print("Loading all particles...")
|
||||
partData, boxLen, volNorm, isObservationData, ranges, extraData, mockPart = loadPart(sampleDir)
|
||||
partData, boxLen, volNorm, isObservationData, ranges, extraData = loadPart(sampleDir)
|
||||
numPartTot = len(partData)
|
||||
catalog.numPartTot = numPartTot
|
||||
catalog.partPos = partData
|
||||
catalog.mockPart = mockPart
|
||||
catalog.part = []
|
||||
for i in range(len(partData)):
|
||||
catalog.part.append(Bunch(x = partData[i][0],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue