mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
cleaned up catalog utlities
This commit is contained in:
parent
694692cb8a
commit
0a16653e9b
2 changed files with 68 additions and 73 deletions
|
@ -144,10 +144,11 @@ def loadPartVel(sampleDir):
|
||||||
return partVel
|
return partVel
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def getPartTree(sampleDir, partData, boxLen):
|
def getPartTree(catalog):
|
||||||
|
|
||||||
with open(sampleDir+"/sample_info.dat", 'rb') as input:
|
sample = catalog.sampleInfo
|
||||||
sample = pickle.load(input)
|
partData = catalog.partData
|
||||||
|
boxLen = catalog.boxLen
|
||||||
|
|
||||||
periodicLine = getPeriodic(sample)
|
periodicLine = getPeriodic(sample)
|
||||||
|
|
||||||
|
@ -222,7 +223,12 @@ class Catalog:
|
||||||
sampleInfo = None
|
sampleInfo = None
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def loadVoidCatalog(sampleDir, dataPortion="central"):
|
def loadVoidCatalog(sampleDir, dataPortion="central", loadPart=True):
|
||||||
|
# loads a void catalog
|
||||||
|
# sampleDir: path to VIDE output directory
|
||||||
|
# dataPortion: "central" or "all"
|
||||||
|
# loadPart: if True, also load particle information
|
||||||
|
|
||||||
#print " Loading particle data..."
|
#print " Loading particle data..."
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
@ -246,31 +252,6 @@ def loadVoidCatalog(sampleDir, dataPortion="central"):
|
||||||
catalog.boxLen[2] = ranges[2][1] - ranges[2][0]
|
catalog.boxLen[2] = ranges[2][1] - ranges[2][0]
|
||||||
File.close()
|
File.close()
|
||||||
|
|
||||||
print "Loading all particles..."
|
|
||||||
partData, boxLen, volNorm, isObservationData, ranges = loadPart(sampleDir)
|
|
||||||
numPartTot = len(partData)
|
|
||||||
catalog.numPartTot = numPartTot
|
|
||||||
catalog.partPos = partData
|
|
||||||
catalog.part = []
|
|
||||||
for i in xrange(len(partData)):
|
|
||||||
catalog.part.append(Bunch(x = partData[i][0],
|
|
||||||
y = partData[i][1],
|
|
||||||
z = partData[i][2],
|
|
||||||
volume = 0,
|
|
||||||
ra = 0,
|
|
||||||
dec = 0,
|
|
||||||
redshift = 0,
|
|
||||||
uniqueID = 0))
|
|
||||||
|
|
||||||
|
|
||||||
print "Loading volumes..."
|
|
||||||
volFile = sampleDir+"/vol_"+sample.fullName+".dat"
|
|
||||||
File = file(volFile)
|
|
||||||
chk = np.fromfile(File, dtype=np.int32,count=1)
|
|
||||||
vols = np.fromfile(File, dtype=np.float32,count=numPartTot)
|
|
||||||
for ivol in xrange(len(vols)):
|
|
||||||
catalog.part[ivol].volume = vols[ivol] / volNorm
|
|
||||||
|
|
||||||
print "Loading voids..."
|
print "Loading voids..."
|
||||||
fileName = sampleDir+"/untrimmed_voidDesc_"+dataPortion+"_"+sample.fullName+".out"
|
fileName = sampleDir+"/untrimmed_voidDesc_"+dataPortion+"_"+sample.fullName+".out"
|
||||||
catData = np.loadtxt(fileName, comments="#", skiprows=2)
|
catData = np.loadtxt(fileName, comments="#", skiprows=2)
|
||||||
|
@ -342,40 +323,65 @@ def loadVoidCatalog(sampleDir, dataPortion="central"):
|
||||||
|
|
||||||
iLine += 1
|
iLine += 1
|
||||||
|
|
||||||
print "Loading zone-void membership info..."
|
if loadPart:
|
||||||
zoneFile = sampleDir+"/voidZone_"+sample.fullName+".dat"
|
print "Loading all particles..."
|
||||||
catalog.void2Zones = []
|
partData, boxLen, volNorm, isObservationData, ranges = loadPart(sampleDir)
|
||||||
File = file(zoneFile)
|
numPartTot = len(partData)
|
||||||
numZonesTot = np.fromfile(File, dtype=np.int32,count=1)
|
catalog.numPartTot = numPartTot
|
||||||
catalog.numZonesTot = numZonesTot
|
catalog.partPos = partData
|
||||||
for iZ in xrange(numZonesTot):
|
catalog.part = []
|
||||||
numZones = np.fromfile(File, dtype=np.int32,count=1)
|
for i in xrange(len(partData)):
|
||||||
catalog.void2Zones.append(Bunch(numZones = numZones,
|
catalog.part.append(Bunch(x = partData[i][0],
|
||||||
zoneIDs = []))
|
y = partData[i][1],
|
||||||
|
z = partData[i][2],
|
||||||
|
volume = 0,
|
||||||
|
ra = 0,
|
||||||
|
dec = 0,
|
||||||
|
redshift = 0,
|
||||||
|
uniqueID = 0))
|
||||||
|
|
||||||
|
|
||||||
|
print "Loading volumes..."
|
||||||
|
volFile = sampleDir+"/vol_"+sample.fullName+".dat"
|
||||||
|
File = file(volFile)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
vols = np.fromfile(File, dtype=np.float32,count=numPartTot)
|
||||||
|
for ivol in xrange(len(vols)):
|
||||||
|
catalog.part[ivol].volume = vols[ivol] / volNorm
|
||||||
|
|
||||||
for p in xrange(numZones):
|
print "Loading zone-void membership info..."
|
||||||
zoneID = np.fromfile(File, dtype=np.int32,count=1)
|
zoneFile = sampleDir+"/voidZone_"+sample.fullName+".dat"
|
||||||
catalog.void2Zones[iZ].zoneIDs.append(zoneID)
|
catalog.void2Zones = []
|
||||||
|
File = file(zoneFile)
|
||||||
|
numZonesTot = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
catalog.numZonesTot = numZonesTot
|
||||||
|
for iZ in xrange(numZonesTot):
|
||||||
|
numZones = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
catalog.void2Zones.append(Bunch(numZones = numZones,
|
||||||
|
zoneIDs = []))
|
||||||
|
|
||||||
|
for p in xrange(numZones):
|
||||||
|
zoneID = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
catalog.void2Zones[iZ].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"
|
||||||
catalog.zones2Parts = []
|
catalog.zones2Parts = []
|
||||||
File = file(zonePartFile)
|
File = file(zonePartFile)
|
||||||
chk = np.fromfile(File, dtype=np.int32,count=1)
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
numZonesTot = np.fromfile(File, dtype=np.int32,count=1)
|
numZonesTot = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
for iZ in xrange(numZonesTot):
|
for iZ in xrange(numZonesTot):
|
||||||
numPart = np.fromfile(File, dtype=np.int32,count=1)
|
numPart = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
catalog.zones2Parts.append(Bunch(numPart = numPart,
|
catalog.zones2Parts.append(Bunch(numPart = numPart,
|
||||||
partIDs = []))
|
partIDs = []))
|
||||||
|
|
||||||
for p in xrange(numPart):
|
for p in xrange(numPart):
|
||||||
partID = np.fromfile(File, dtype=np.int32,count=1)
|
partID = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
catalog.zones2Parts[iZ].partIDs.append(partID)
|
catalog.zones2Parts[iZ].partIDs.append(partID)
|
||||||
|
|
||||||
return catalog
|
return catalog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def getVoidPart(catalog, voidID):
|
def getVoidPart(catalog, voidID):
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
#+
|
#+
|
||||||
__all__=['plotRedshiftDistribution', 'plotSizeDistribution', 'plot1dProfiles',
|
__all__=['plotNumberFunction',]
|
||||||
'plotMarg1d', 'plotNumberDistribution', 'plotVoidDistribution']
|
|
||||||
|
|
||||||
from void_python_tools.backend.classes import *
|
from void_python_tools.backend.classes import *
|
||||||
from plotDefs import *
|
from plotDefs import *
|
||||||
|
@ -40,7 +39,7 @@ def fill_between(x, y1, y2=0, ax=None, **kwargs):
|
||||||
ax.add_patch(p)
|
ax.add_patch(p)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def plotNumberFunction(sampleDirList=None, figDir="./",
|
def plotNumberFunction(catalogList, figDir="./",
|
||||||
plotName="numberfunc",
|
plotName="numberfunc",
|
||||||
dataPortion="central"):
|
dataPortion="central"):
|
||||||
|
|
||||||
|
@ -50,22 +49,12 @@ plt.clf()
|
||||||
plt.xlabel("$R_{eff}$ [$h^{-1}Mpc$]", fontsize=14)
|
plt.xlabel("$R_{eff}$ [$h^{-1}Mpc$]", fontsize=14)
|
||||||
plt.ylabel(r"log ($n$ (> R) [$h^3$ Gpc$^{-3}$])", fontsize=14)
|
plt.ylabel(r"log ($n$ (> R) [$h^3$ Gpc$^{-3}$])", fontsize=14)
|
||||||
|
|
||||||
for (iSample,sampleDir) in enumerate(sampleDirList):
|
for (iSample,catalog) in enumerate(catalogList):
|
||||||
with open(workDir+sampleDir+"/sample_info.dat", 'rb') as input:
|
sample = catalog.sampleInfo
|
||||||
sample = pickle.load(input)
|
data = catalog.voids[:].radius
|
||||||
filename = sampleDir+"/centers_"+dataPortion+"_"+sample.fullName+".out"
|
|
||||||
if not os.access(filename, os.F_OK):
|
|
||||||
print "File not found: ", filename
|
|
||||||
else:
|
|
||||||
data = np.loadtxt(filename, comments="#")[:,4]
|
|
||||||
|
|
||||||
if sample.dataType == "observation":
|
if sample.dataType == "observation":
|
||||||
# look for the mask file
|
maskFile = sample.maskFile
|
||||||
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
|
|
||||||
|
|
||||||
boxVol = vp.getSurveyProps(maskFile,
|
boxVol = vp.getSurveyProps(maskFile,
|
||||||
sample.zBoundary[0], sample.zBoundary[1],
|
sample.zBoundary[0], sample.zBoundary[1],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue