mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
start of code to do 'merger-tree' of subsamples
This commit is contained in:
parent
a6278b9fc6
commit
9ec3b1f0ee
4 changed files with 166 additions and 6 deletions
18
crossCompare/analysis/datasetsToAnalyze.py
Executable file
18
crossCompare/analysis/datasetsToAnalyze.py
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
|
||||||
|
workDir = "/home/psutter2/workspace/Voids/"
|
||||||
|
figDir = "./figs"
|
||||||
|
|
||||||
|
sampleDirList = [
|
||||||
|
"multidark/md_ss0.1_pv/sample_md_ss0.1_pv_z0.56_d00/",
|
||||||
|
"multidark/md_halos_min1.393e12_pv/sample_md_halos_min1.393e12_pv_z0.56_d00/",
|
||||||
|
"random/ran_ss0.000175/sample_ran_ss0.000175_z0.56_d00/",
|
||||||
|
"random/ran_ss0.1/sample_ran_ss0.1_z0.56_d00/",
|
||||||
|
"multidark/md_hod_dr9mid_pv/sample_md_hod_dr9mid_pv_z0.56_d00/",
|
||||||
|
"multidark/md_ss0.000175_pv/sample_md_ss0.000175_pv_z0.56_d00/",
|
||||||
|
"sdss_dr9/sample_lss.dr9cmassmid.dat/",
|
||||||
|
"lanl/masked/masked_lanl_hod_dr9mid_pv/sample_masked_lanl_hod_dr9mid_pv_z0.0/" ]
|
||||||
|
|
||||||
|
dataPortion = "central"
|
||||||
|
|
121
crossCompare/analysis/mergerTree.py
Executable file
121
crossCompare/analysis/mergerTree.py
Executable file
|
@ -0,0 +1,121 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# plots cumulative distributions of number counts
|
||||||
|
|
||||||
|
from void_python_tools.backend import *
|
||||||
|
from void_python_tools.plotting import *
|
||||||
|
import void_python_tools.apTools as vp
|
||||||
|
import imp
|
||||||
|
import pickle
|
||||||
|
import os
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
plotNameBase = "compdist"
|
||||||
|
|
||||||
|
obsFudgeFactor = 1.0 # what fraction of the volume are we *reall* capturing?
|
||||||
|
#obsFudgeFactor = .66 # what fraction of the volume are we *reall* capturing?
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='Plot.')
|
||||||
|
parser.add_argument('--show', dest='showPlot', action='store_const',
|
||||||
|
const=True, default=False,
|
||||||
|
help='display the plot (default: just write eps)')
|
||||||
|
parser.add_argument('--parmFile', dest='parmFile', default='datasetsToPlot.py',
|
||||||
|
help='path to parameter file')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
filename = args.parmFile
|
||||||
|
print " Loading parameters from", filename
|
||||||
|
if not os.access(filename, os.F_OK):
|
||||||
|
print " Cannot find parameter file %s!" % filename
|
||||||
|
exit(-1)
|
||||||
|
parms = imp.load_source("name", filename)
|
||||||
|
globals().update(vars(parms))
|
||||||
|
|
||||||
|
if not os.access(figDir, os.F_OK):
|
||||||
|
os.makedirs(figDir)
|
||||||
|
|
||||||
|
dataSampleList = []
|
||||||
|
|
||||||
|
for sampleDir in sampleDirList:
|
||||||
|
with open(workDir+sampleDir+"/sample_info.dat", 'rb') as input:
|
||||||
|
dataSampleList.append(pickle.load(input))
|
||||||
|
|
||||||
|
plt.clf()
|
||||||
|
plt.xlabel("Void Radius [Mpc/h]")
|
||||||
|
plt.ylabel(r"N > R [$h^3$ Gpc$^{-3}$]")
|
||||||
|
plt.yscale('log')
|
||||||
|
plt.xlim(xmax=120.)
|
||||||
|
|
||||||
|
plotName = plotNameBase
|
||||||
|
allData = []
|
||||||
|
|
||||||
|
for (iSample,sample) in enumerate(dataSampleList):
|
||||||
|
|
||||||
|
sampleName = sample.fullName
|
||||||
|
lineTitle = sampleName
|
||||||
|
|
||||||
|
if sample.dataType == "observation":
|
||||||
|
boxVol = vp.getSurveyProps(sample.maskFile,
|
||||||
|
sample.zBoundary[0], sample.zBoundary[1],
|
||||||
|
sample.zRange[0], sample.zRange[1], "all",
|
||||||
|
selectionFuncFile=None)[0]
|
||||||
|
#selectionFuncFile=sample.selFunFile)[0]
|
||||||
|
boxVol *= obsFudgeFactor
|
||||||
|
else:
|
||||||
|
boxVol = sample.boxLen*sample.boxLen*(sample.zBoundaryMpc[1] -
|
||||||
|
sample.zBoundaryMpc[0])
|
||||||
|
|
||||||
|
boxVol *= 1.e-9 # Mpc->Gpc
|
||||||
|
|
||||||
|
filename = workDir+"/"+sampleDirList[iSample]+"/centers_"+dataPortion+"_"+\
|
||||||
|
sampleName+".out"
|
||||||
|
if not os.access(filename, os.F_OK):
|
||||||
|
print "File not found: ", filename
|
||||||
|
continue
|
||||||
|
|
||||||
|
data = np.loadtxt(filename, comments="#")
|
||||||
|
if data.ndim == 1:
|
||||||
|
print " Too few!"
|
||||||
|
continue
|
||||||
|
data = data[:,4]
|
||||||
|
indices = np.arange(0, len(data), 1)
|
||||||
|
sorted = np.sort(data)
|
||||||
|
|
||||||
|
plt.plot(sorted, indices[::-1]/boxVol, '-',
|
||||||
|
label=lineTitle, color=colorList[iSample],
|
||||||
|
linewidth=linewidth)
|
||||||
|
|
||||||
|
hist, bin_edges = np.histogram(data, bins=100, range=(0,100))
|
||||||
|
allData.append(hist)
|
||||||
|
|
||||||
|
plt.legend(title = "Samples", loc = "upper right", prop={'size':8})
|
||||||
|
#plt.title(plotTitle)
|
||||||
|
|
||||||
|
plt.savefig(figDir+"/fig_"+plotName+".pdf", bbox_inches="tight")
|
||||||
|
plt.savefig(figDir+"/fig_"+plotName+".eps", bbox_inches="tight")
|
||||||
|
plt.savefig(figDir+"/fig_"+plotName+".png", bbox_inches="tight")
|
||||||
|
|
||||||
|
dataFile = figDir+"/data_"+plotName+".dat"
|
||||||
|
fp = open(dataFile, 'w')
|
||||||
|
fp.write("# R [Mpc/h], N [h^3 Gpc^-3]\n")
|
||||||
|
fp.write("# ")
|
||||||
|
for sample in dataSampleList:
|
||||||
|
fp.write(sample.fullName+" ")
|
||||||
|
fp.write("\n")
|
||||||
|
for i in xrange(100):
|
||||||
|
fp.write(str(bin_edges[i]) + " ")
|
||||||
|
for iSample in xrange(len(dataSampleList)):
|
||||||
|
fp.write(str(allData[iSample][i])+" ")
|
||||||
|
fp.write("\n")
|
||||||
|
fp.close()
|
||||||
|
|
||||||
|
if args.showPlot:
|
||||||
|
os.system("display %s" % figDir+"/fig_"+plotName+".png")
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,13 @@ figDir = "./figs"
|
||||||
|
|
||||||
sampleDirList = [
|
sampleDirList = [
|
||||||
"multidark/md_ss0.1_pv/sample_md_ss0.1_pv_z0.56_d00/",
|
"multidark/md_ss0.1_pv/sample_md_ss0.1_pv_z0.56_d00/",
|
||||||
"multidark/md_halos_min1.23e+13_pv/sample_md_halos_min1.23e+13_pv_z0.56_d00/",
|
"multidark/md_halos_min1.393e12_pv/sample_md_halos_min1.393e12_pv_z0.56_d00/",
|
||||||
"random/ran_ss0.0004/sample_ran_ss0.0004_z0.56_d00/",
|
"random/ran_ss0.000175/sample_ran_ss0.000175_z0.56_d00/",
|
||||||
"random/ran_ss0.1/sample_ran_ss0.1_z0.56_d00/",
|
"random/ran_ss0.1/sample_ran_ss0.1_z0.56_d00/",
|
||||||
"multidark/md_hod_dr9mid_pv/sample_md_hod_dr9mid_pv_z0.56_d00/",
|
"multidark/md_hod_dr9mid_pv/sample_md_hod_dr9mid_pv_z0.56_d00/",
|
||||||
"multidark/md_ss0.0004_pv/sample_md_ss0.0004_pv_z0.56_d00/",
|
"multidark/md_ss0.000175_pv/sample_md_ss0.000175_pv_z0.56_d00/",
|
||||||
"sdss_dr9/sample_lss.dr9cmassmid.dat/" ]
|
"sdss_dr9/sample_lss.dr9cmassmid.dat/",
|
||||||
|
"lanl/masked/masked_lanl_hod_dr9mid_pv/sample_masked_lanl_hod_dr9mid_pv_z0.0/" ]
|
||||||
|
|
||||||
dataPortion = "central"
|
dataPortion = "central"
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ import argparse
|
||||||
|
|
||||||
plotNameBase = "compdist"
|
plotNameBase = "compdist"
|
||||||
|
|
||||||
obsFudgeFactor = .66 # what fraction of the volume are we *reall* capturing?
|
obsFudgeFactor = 1.0 # what fraction of the volume are we *reall* capturing?
|
||||||
|
#obsFudgeFactor = .66 # what fraction of the volume are we *reall* capturing?
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Plot.')
|
parser = argparse.ArgumentParser(description='Plot.')
|
||||||
parser.add_argument('--show', dest='showPlot', action='store_const',
|
parser.add_argument('--show', dest='showPlot', action='store_const',
|
||||||
|
@ -52,6 +53,7 @@ plt.yscale('log')
|
||||||
plt.xlim(xmax=120.)
|
plt.xlim(xmax=120.)
|
||||||
|
|
||||||
plotName = plotNameBase
|
plotName = plotNameBase
|
||||||
|
allData = []
|
||||||
|
|
||||||
for (iSample,sample) in enumerate(dataSampleList):
|
for (iSample,sample) in enumerate(dataSampleList):
|
||||||
|
|
||||||
|
@ -62,7 +64,8 @@ for (iSample,sample) in enumerate(dataSampleList):
|
||||||
boxVol = vp.getSurveyProps(sample.maskFile,
|
boxVol = vp.getSurveyProps(sample.maskFile,
|
||||||
sample.zBoundary[0], sample.zBoundary[1],
|
sample.zBoundary[0], sample.zBoundary[1],
|
||||||
sample.zRange[0], sample.zRange[1], "all",
|
sample.zRange[0], sample.zRange[1], "all",
|
||||||
selectionFuncFile=sample.selFunFile)[0]
|
selectionFuncFile=None)[0]
|
||||||
|
#selectionFuncFile=sample.selFunFile)[0]
|
||||||
boxVol *= obsFudgeFactor
|
boxVol *= obsFudgeFactor
|
||||||
else:
|
else:
|
||||||
boxVol = sample.boxLen*sample.boxLen*(sample.zBoundaryMpc[1] -
|
boxVol = sample.boxLen*sample.boxLen*(sample.zBoundaryMpc[1] -
|
||||||
|
@ -88,6 +91,9 @@ for (iSample,sample) in enumerate(dataSampleList):
|
||||||
label=lineTitle, color=colorList[iSample],
|
label=lineTitle, color=colorList[iSample],
|
||||||
linewidth=linewidth)
|
linewidth=linewidth)
|
||||||
|
|
||||||
|
hist, bin_edges = np.histogram(data, bins=100, range=(0,100))
|
||||||
|
allData.append(hist)
|
||||||
|
|
||||||
plt.legend(title = "Samples", loc = "upper right", prop={'size':8})
|
plt.legend(title = "Samples", loc = "upper right", prop={'size':8})
|
||||||
#plt.title(plotTitle)
|
#plt.title(plotTitle)
|
||||||
|
|
||||||
|
@ -95,6 +101,20 @@ plt.savefig(figDir+"/fig_"+plotName+".pdf", bbox_inches="tight")
|
||||||
plt.savefig(figDir+"/fig_"+plotName+".eps", bbox_inches="tight")
|
plt.savefig(figDir+"/fig_"+plotName+".eps", bbox_inches="tight")
|
||||||
plt.savefig(figDir+"/fig_"+plotName+".png", bbox_inches="tight")
|
plt.savefig(figDir+"/fig_"+plotName+".png", bbox_inches="tight")
|
||||||
|
|
||||||
|
dataFile = figDir+"/data_"+plotName+".dat"
|
||||||
|
fp = open(dataFile, 'w')
|
||||||
|
fp.write("# R [Mpc/h], N [h^3 Gpc^-3]\n")
|
||||||
|
fp.write("# ")
|
||||||
|
for sample in dataSampleList:
|
||||||
|
fp.write(sample.fullName+" ")
|
||||||
|
fp.write("\n")
|
||||||
|
for i in xrange(100):
|
||||||
|
fp.write(str(bin_edges[i]) + " ")
|
||||||
|
for iSample in xrange(len(dataSampleList)):
|
||||||
|
fp.write(str(allData[iSample][i])+" ")
|
||||||
|
fp.write("\n")
|
||||||
|
fp.close()
|
||||||
|
|
||||||
if args.showPlot:
|
if args.showPlot:
|
||||||
os.system("display %s" % figDir+"/fig_"+plotName+".png")
|
os.system("display %s" % figDir+"/fig_"+plotName+".png")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue