mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
Merge branch 'master' of bitbucket.org:cosmicvoids/void_identification
This commit is contained in:
commit
aa3410bc78
1 changed files with 58 additions and 44 deletions
|
@ -391,21 +391,22 @@ if (args.script or args.all) and haloFileBase != "":
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
# estimate number of halos to get density
|
# estimate number of halos to get density
|
||||||
if haloFileDummy == '':
|
#if haloFileDummy == '':
|
||||||
dataFile = catalogDir+haloFileBase+fileNums[0]
|
# dataFile = catalogDir+haloFileBase+fileNums[0]
|
||||||
else:
|
#else:
|
||||||
dataFile = catalogDir+haloFileBase.replace(haloFileDummy, fileNums[0])
|
# dataFile = catalogDir+haloFileBase.replace(haloFileDummy, fileNums[0])
|
||||||
|
#
|
||||||
|
#inFile = open(dataFile, 'r')
|
||||||
|
#numPart = 0
|
||||||
|
#for (iLine, line) in enumerate(inFile):
|
||||||
|
# if iLine < haloFileNumComLines: continue
|
||||||
|
# line = line.split(haloFileColSep)
|
||||||
|
# if minHaloMass == "none" or float(line[haloFileMCol]) > minHaloMass:
|
||||||
|
# numPart += 1
|
||||||
|
#inFile.close()
|
||||||
|
|
||||||
inFile = open(dataFile, 'r')
|
#minRadius = 2*int(np.ceil(lbox/numPart**(1./3.)))
|
||||||
numPart = 0
|
minRadies = 10
|
||||||
for (iLine, line) in enumerate(inFile):
|
|
||||||
if iLine < haloFileNumComLines: continue
|
|
||||||
line = line.split(haloFileColSep)
|
|
||||||
if minHaloMass == "none" or float(line[haloFileMCol]) > minHaloMass:
|
|
||||||
numPart += 1
|
|
||||||
inFile.close()
|
|
||||||
|
|
||||||
minRadius = 2*int(np.ceil(lbox/numPart**(1./3.)))
|
|
||||||
|
|
||||||
setName = prefix+"halos_min"+str(minHaloMass)
|
setName = prefix+"halos_min"+str(minHaloMass)
|
||||||
writeScript(setName, prefix+"halos_min"+str(minHaloMass)+"_z", "multidark",
|
writeScript(setName, prefix+"halos_min"+str(minHaloMass)+"_z", "multidark",
|
||||||
|
@ -436,29 +437,40 @@ if (args.halos or args.all) and haloFileBase != "":
|
||||||
fileNums[iRedshift])
|
fileNums[iRedshift])
|
||||||
inFile = open(dataFile, 'r')
|
inFile = open(dataFile, 'r')
|
||||||
numPart = 0
|
numPart = 0
|
||||||
for (iLine, line) in enumerate(inFile):
|
if dataFormat == "sdf":
|
||||||
if iLine < haloFileNumComLines: continue
|
for line in inFile:
|
||||||
line = line.split(haloFileColSep)
|
if "nhalos" in line:
|
||||||
if minHaloMass == "none" or float(line[haloFileMCol]) > minHaloMass:
|
numPart = int(line.split()[3].strip(';'))
|
||||||
numPart += 1
|
break
|
||||||
inFile.close()
|
inFile.close()
|
||||||
|
else:
|
||||||
|
for (iLine, line) in enumerate(inFile):
|
||||||
|
if iLine < haloFileNumComLines: continue
|
||||||
|
line = line.split(haloFileColSep)
|
||||||
|
if minHaloMass == "none" or float(line[haloFileMCol]) > minHaloMass:
|
||||||
|
numPart += 1
|
||||||
|
inFile.close()
|
||||||
|
|
||||||
sampleName = prefix+"halos_min"+str(minHaloMass)+"_z"+fileNums[iRedshift]
|
sampleName = prefix+"halos_min"+str(minHaloMass)+"_z"+fileNums[iRedshift]
|
||||||
outFile = open(catalogDir+"/"+sampleName+".dat", 'w')
|
outFileName = catalogDir+"/"+sampleName+".dat"
|
||||||
|
outFile = open(outFileName, 'w')
|
||||||
outFile.write("%f\n" %(lbox))
|
outFile.write("%f\n" %(lbox))
|
||||||
outFile.write("%s\n" %(omegaM))
|
outFile.write("%s\n" %(omegaM))
|
||||||
outFile.write("%s\n" %(hubble))
|
outFile.write("%s\n" %(hubble))
|
||||||
outFile.write("%s\n" %(redshift))
|
outFile.write("%s\n" %(redshift))
|
||||||
outFile.write("%d\n" %(numPart))
|
outFile.write("%d\n" %(numPart))
|
||||||
|
outFile.close()
|
||||||
|
|
||||||
if dataFormat == "sdf":
|
if dataFormat == "sdf":
|
||||||
# TODO process halo file with SDFcvt
|
SDFcvt_PATH = "@CMAKE_BINARY_DIR@/external/libsdf/apps/SDFcvt/SDFcvt.x86_64"
|
||||||
SDFcvt_PATH = "@CMAKE_BINARY_DIR@/ep_build/sdf/bin/SDFcvt/"
|
if minHaloMass == "none": minHaloMass = 0.0
|
||||||
outFile = open(catalogDir+"/"+sampleName+".dat", 'w')
|
command = "%s %s mass id x y z vz vy vx | awk '{if ($1>%g) print $2, $3, $4, $5, $6, $7, $8}'>>%s" % (SDFcvt_PATH, dataFile, minHaloMass, outFileName )
|
||||||
|
os.system(command)
|
||||||
|
outFile = open(outFileName, 'a')
|
||||||
outFile.write("-99 -99 -99 -99 -99 -99 -99\n")
|
outFile.write("-99 -99 -99 -99 -99 -99 -99\n")
|
||||||
outFile.close()
|
outFile.close()
|
||||||
else:
|
else:
|
||||||
outFile = open(catalogDir+"/"+sampleName+".dat", 'w')
|
outFile = open(outFileName, 'a')
|
||||||
inFile = open(dataFile, 'r')
|
inFile = open(dataFile, 'r')
|
||||||
for (iHalo,line) in enumerate(inFile):
|
for (iHalo,line) in enumerate(inFile):
|
||||||
if iHalo < haloFileNumComLines: continue
|
if iHalo < haloFileNumComLines: continue
|
||||||
|
@ -525,7 +537,7 @@ if (args.script or args.all) and haloFileBase != "":
|
||||||
print " Doing HOD scripts"
|
print " Doing HOD scripts"
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
for thisHod in hodParmList:
|
for thisHod in hodParmList:
|
||||||
print " ", thisHod['name']
|
print " ", thisHod['name']
|
||||||
setName = prefix+"hod_"+thisHod['name']
|
setName = prefix+"hod_"+thisHod['name']
|
||||||
writeScript(setName, prefix+"hod_"+thisHod['name']+"_z", "multidark",
|
writeScript(setName, prefix+"hod_"+thisHod['name']+"_z", "multidark",
|
||||||
scriptDir, catalogDir, fileNums, redshifts,
|
scriptDir, catalogDir, fileNums, redshifts,
|
||||||
|
@ -537,28 +549,30 @@ if (args.script or args.all) and haloFileBase != "":
|
||||||
if (args.hod or args.all) and haloFileBase != "":
|
if (args.hod or args.all) and haloFileBase != "":
|
||||||
print " Doing HOD"
|
print " Doing HOD"
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
for thisHod in hodParmList:
|
for (iRedshift, redshift) in enumerate(redshifts):
|
||||||
print " ", thisHod['name']
|
print " z = ", redshift
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
for (iRedshift, redshift) in enumerate(redshifts):
|
|
||||||
print " z = ", redshift
|
if haloFileDummy == '':
|
||||||
|
haloFile = catalogDir+haloFileBase+fileNums[iRedshift]
|
||||||
|
else:
|
||||||
|
haloFile = catalogDir+haloFileBase.replace(haloFileDummy,
|
||||||
|
fileNums[iRedshift])
|
||||||
|
|
||||||
|
if dataFormat == "sdf":
|
||||||
|
inFile = haloFile
|
||||||
|
outFile = haloFile+"_temp"
|
||||||
|
SDFcvt_PATH = "@CMAKE_BINARY_DIR@/external/libsdf/apps/SDFcvt/SDFcvt.x86_64"
|
||||||
|
command = "%s %s mass x y z vx vy vz>>%s" % (SDFcvt_PATH, inFile, outFile)
|
||||||
|
os.system(command)
|
||||||
|
haloFile = outFile
|
||||||
|
|
||||||
|
for thisHod in hodParmList:
|
||||||
|
print " ", thisHod['name']
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
parFileName = "./hod.par"
|
parFileName = "./hod.par"
|
||||||
parFile = open(parFileName, 'w')
|
parFile = open(parFileName, 'w')
|
||||||
if haloFileDummy == '':
|
|
||||||
haloFile = catalogDir+haloFileBase+fileNums[iRedshift]
|
|
||||||
else:
|
|
||||||
haloFile = catalogDir+haloFileBase.replace(haloFileDummy,
|
|
||||||
fileNums[iRedshift])
|
|
||||||
|
|
||||||
if dataFormat == "sdf":
|
|
||||||
# TODO process halo file with SDFcvt
|
|
||||||
inFile = haloFile
|
|
||||||
outFile = haloFile+"_temp"
|
|
||||||
|
|
||||||
haloFile = outFile
|
|
||||||
|
|
||||||
parFile.write(parFileText.format(omegaM=omegaM,
|
parFile.write(parFileText.format(omegaM=omegaM,
|
||||||
hubble=hubble,
|
hubble=hubble,
|
||||||
redshift=redshift,
|
redshift=redshift,
|
||||||
|
@ -584,6 +598,6 @@ if (args.hod or args.all) and haloFileBase != "":
|
||||||
os.system("mv %s/hod.mock %s" % (catalogDir, outFileName))
|
os.system("mv %s/hod.mock %s" % (catalogDir, outFileName))
|
||||||
os.system("rm %s/hod.*" % catalogDir)
|
os.system("rm %s/hod.*" % catalogDir)
|
||||||
|
|
||||||
os.system("rm %s" % haloFile)
|
if dataFormat == "sdf": os.system("rm %s" % haloFile)
|
||||||
|
|
||||||
print " Done!"
|
print " Done!"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue