removed mock particle tracking, since that is no longer used

This commit is contained in:
Paul M. Sutter 2025-04-21 16:23:25 -04:00
parent fc2d7157f4
commit d9efa15474
8 changed files with 71 additions and 173 deletions

View file

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