mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
added voidID property to particles in catalog output
This commit is contained in:
parent
326756b2bc
commit
4c6ec4ba82
1 changed files with 42 additions and 27 deletions
|
@ -295,6 +295,7 @@ class Catalog:
|
||||||
boxLen = np.zeros((3))
|
boxLen = np.zeros((3))
|
||||||
ranges = np.zeros((3,2))
|
ranges = np.zeros((3,2))
|
||||||
part = None
|
part = None
|
||||||
|
partPos = None
|
||||||
zones2Parts = None
|
zones2Parts = None
|
||||||
void2Zones = None
|
void2Zones = None
|
||||||
voids = None
|
voids = None
|
||||||
|
@ -302,13 +303,14 @@ class Catalog:
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def loadVoidCatalog(sampleDir, dataPortion="central", loadParticles=True,
|
def loadVoidCatalog(sampleDir, dataPortion="central", loadParticles=True,
|
||||||
untrimmed=False):
|
loadAdjacencies = True, untrimmed=False):
|
||||||
|
|
||||||
# loads a void catalog
|
# loads a void catalog
|
||||||
# by default, loads parent-level voids with central densities greater than 0.2*mean
|
# by default, loads parent-level voids with central densities greater than 0.2*mean
|
||||||
# sampleDir: path to VIDE output directory
|
# sampleDir: path to VIDE output directory
|
||||||
# dataPortion: "central" or "all"
|
# dataPortion: "central" or "all"
|
||||||
# loadParticles: if True, also load particle information
|
# loadParticles: if True, also load particle information
|
||||||
|
# loadAdjacencies: if True, also load particle adjacency information
|
||||||
# untrimmed: if True, catalog contains all voids, regardless of density or hierarchy level
|
# untrimmed: if True, catalog contains all voids, regardless of density or hierarchy level
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
@ -448,6 +450,7 @@ def loadVoidCatalog(sampleDir, dataPortion="central", loadParticles=True,
|
||||||
dec = extraData[i][1],
|
dec = extraData[i][1],
|
||||||
redshift = extraData[i][2],
|
redshift = extraData[i][2],
|
||||||
uniqueID = extraData[i][3],
|
uniqueID = extraData[i][3],
|
||||||
|
voidID = -1,
|
||||||
edgeFlag = 0))
|
edgeFlag = 0))
|
||||||
|
|
||||||
|
|
||||||
|
@ -473,46 +476,51 @@ def loadVoidCatalog(sampleDir, dataPortion="central", loadParticles=True,
|
||||||
for ivol in range(len(vols)):
|
for ivol in range(len(vols)):
|
||||||
catalog.part[ivol].volume = vols[ivol] / volNorm
|
catalog.part[ivol].volume = vols[ivol] / volNorm
|
||||||
|
|
||||||
print(" Loading adjacencies...")
|
if loadAdjacencies:
|
||||||
adjFile = sampleDir+"adj_"+sample.fullName+".dat"
|
print(" Loading adjacencies...")
|
||||||
with open(adjFile, mode="rb") as File:
|
adjFile = sampleDir+"adj_"+sample.fullName+".dat"
|
||||||
numPart = np.fromfile(File, dtype=np.int32,count=1)[0]
|
with open(adjFile, mode="rb") as File:
|
||||||
|
numPart = np.fromfile(File, dtype=np.int32,count=1)[0]
|
||||||
|
|
||||||
# this the total number of adjancies per particle
|
# this the total number of adjancies per particle
|
||||||
nadjPerPart = np.fromfile(File, dtype=np.int32,count=numPart)
|
nadjPerPart = np.fromfile(File, dtype=np.int32,count=numPart)
|
||||||
|
|
||||||
# but the file only stores one half of each pair, so we need to match
|
# but the file only stores one half of each pair,
|
||||||
|
# so we need to match
|
||||||
|
for p in range(numPart):
|
||||||
|
nin = np.fromfile(File, dtype=np.int32, count=1)[0]
|
||||||
|
for n in range(nin):
|
||||||
|
pAdj = np.fromfile(File, dtype=np.int32, count=1)[0]
|
||||||
|
if (p < pAdj):
|
||||||
|
catalog.part[p].adjs.append(pAdj)
|
||||||
|
catalog.part[pAdj].adjs.append(p)
|
||||||
|
|
||||||
|
|
||||||
|
print(" Sanity checking adjacenies...")
|
||||||
for p in range(numPart):
|
for p in range(numPart):
|
||||||
nin = np.fromfile(File, dtype=np.int32, count=1)[0]
|
catalog.part[p].nadjs = len(catalog.part[p].adjs)
|
||||||
for n in range(nin):
|
nHave = len(catalog.part[p].adjs)
|
||||||
pAdj = np.fromfile(File, dtype=np.int32, count=1)[0]
|
nExpected = nadjPerPart[p]
|
||||||
if (p < pAdj):
|
|
||||||
catalog.part[p].adjs.append(pAdj)
|
|
||||||
catalog.part[pAdj].adjs.append(p)
|
|
||||||
|
|
||||||
|
# interior galaxies should not connect to
|
||||||
print(" Sanity checking adjacenies...")
|
if (nHave != nExpected and catalog.part[p].edgeFlag == 0):
|
||||||
for p in range(numPart):
|
print(" Error for particle %d: Have %d adj, expected %d (flag: %d)" % (p, nHave, nExpected, catalog.part[p].edgeFlag))
|
||||||
catalog.part[p].nadjs = len(catalog.part[p].adjs)
|
# end load adjacencies
|
||||||
nHave = len(catalog.part[p].adjs)
|
|
||||||
nExpected = nadjPerPart[p]
|
|
||||||
if (nHave != nExpected and catalog.part[p].edgeFlag == 0):
|
|
||||||
print(" Error for particle %d: Have %d adj, expected %d (flag: %d)" % (p, nHave, nExpected, catalog.part[p].edgeFlag))
|
|
||||||
|
|
||||||
print(" Loading zone-void membership info...")
|
print(" Loading zone-void membership info...")
|
||||||
zoneFile = sampleDir+"/voidZone_"+sample.fullName+".dat"
|
zoneFile = sampleDir+"/voidZone_"+sample.fullName+".dat"
|
||||||
catalog.void2Zones = []
|
catalog.void2Zones = []
|
||||||
with open(zoneFile, mode="rb") as File:
|
with open(zoneFile, mode="rb") as File:
|
||||||
numZonesTot = np.fromfile(File, dtype=np.int32,count=1)[0]
|
numVoidsTot = np.fromfile(File, dtype=np.int32,count=1)[0]
|
||||||
catalog.numZonesTot = numZonesTot
|
catalog.numVoidsTot = numVoidsTot
|
||||||
for iZ in range(numZonesTot):
|
for iVoid in range(numVoidsTot):
|
||||||
numZones = np.fromfile(File, dtype=np.int32,count=1)[0]
|
numZones = np.fromfile(File, dtype=np.int32,count=1)[0]
|
||||||
catalog.void2Zones.append(Bunch(numZones = numZones,
|
catalog.void2Zones.append(Bunch(numZones = numZones,
|
||||||
zoneIDs = []))
|
zoneIDs = []))
|
||||||
|
|
||||||
for p in range(numZones):
|
for iZ in range(numZones):
|
||||||
zoneID = np.fromfile(File, dtype=np.int32,count=1)[0]
|
zoneID = np.fromfile(File, dtype=np.int32,count=1)[0]
|
||||||
catalog.void2Zones[iZ].zoneIDs.append(zoneID)
|
catalog.void2Zones[iVoid].zoneIDs.append(zoneID)
|
||||||
|
|
||||||
print(" Loading particle-zone membership info...")
|
print(" Loading particle-zone membership info...")
|
||||||
zonePartFile = sampleDir+"/voidPart_"+sample.fullName+".dat"
|
zonePartFile = sampleDir+"/voidPart_"+sample.fullName+".dat"
|
||||||
|
@ -529,6 +537,13 @@ def loadVoidCatalog(sampleDir, dataPortion="central", loadParticles=True,
|
||||||
partID = np.fromfile(File, dtype=np.int32,count=1)[0]
|
partID = np.fromfile(File, dtype=np.int32,count=1)[0]
|
||||||
catalog.zones2Parts[iZ].partIDs.append(partID)
|
catalog.zones2Parts[iZ].partIDs.append(partID)
|
||||||
|
|
||||||
|
print(" Matching particles to voids...")
|
||||||
|
for void in catalog.voids:
|
||||||
|
voidID = void.voidID
|
||||||
|
for zoneID in catalog.void2Zones[voidID].zoneIDs:
|
||||||
|
for partID in catalog.zones2Parts[zoneID].partIDs:
|
||||||
|
catalog.part[partID].voidID = voidID
|
||||||
|
|
||||||
print("Done loading catalog.")
|
print("Done loading catalog.")
|
||||||
return catalog
|
return catalog
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue