mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
plotting now supports cumulative number distributions
This commit is contained in:
parent
9cdc037946
commit
93ba823764
3 changed files with 67 additions and 2 deletions
|
@ -111,5 +111,7 @@ if (startCatalogStage <= 4) and (endCatalogStage >= 4):
|
||||||
dataPortion=thisDataPortion, setName=catalogName)
|
dataPortion=thisDataPortion, setName=catalogName)
|
||||||
plotSizeDistribution(workDir, dataSampleList, figDir, showPlot=False,
|
plotSizeDistribution(workDir, dataSampleList, figDir, showPlot=False,
|
||||||
dataPortion=thisDataPortion, setName=catalogName)
|
dataPortion=thisDataPortion, setName=catalogName)
|
||||||
|
plotNumberDistribution(workDir, dataSampleList, figDir, showPlot=False,
|
||||||
|
dataPortion=thisDataPortion, setName=catalogName)
|
||||||
|
|
||||||
print "\n Done!"
|
print "\n Done!"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
LIGHT_SPEED = 299792.458
|
||||||
|
|
||||||
colorList = ['r', 'b', 'g', 'y', 'c', 'm', 'y',
|
colorList = ['r', 'b', 'g', 'y', 'c', 'm', 'y',
|
||||||
'brown', 'grey',
|
'brown', 'grey',
|
||||||
'darkred', 'orange', 'pink', 'darkblue',
|
'darkred', 'orange', 'pink', 'darkblue',
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
__all__=['plotRedshiftDistribution', 'plotSizeDistribution', 'plot1dProfiles',
|
__all__=['plotRedshiftDistribution', 'plotSizeDistribution', 'plot1dProfiles',
|
||||||
'plotMarg1d']
|
'plotMarg1d', 'plotNumberDistribution']
|
||||||
|
|
||||||
from void_python_tools.backend.classes import *
|
from void_python_tools.backend.classes import *
|
||||||
from plotDefs import *
|
from plotDefs import *
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
import pylab as plt
|
import pylab as plt
|
||||||
|
import void_python_tools.apTools as vp
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def plotRedshiftDistribution(workDir=None, sampleList=None, figDir=None,
|
def plotRedshiftDistribution(workDir=None, sampleList=None, figDir=None,
|
||||||
|
@ -43,7 +44,7 @@ def plotRedshiftDistribution(workDir=None, sampleList=None, figDir=None,
|
||||||
zMax = sample.zRange[1]
|
zMax = sample.zRange[1]
|
||||||
|
|
||||||
range = (zMin, zMax)
|
range = (zMin, zMax)
|
||||||
nbins = np.ceil((zMax-zMin)/0.1)
|
nbins = np.ceil((zMax-zMin)/0.02)
|
||||||
|
|
||||||
thisMax = np.max(data[:,5])
|
thisMax = np.max(data[:,5])
|
||||||
thisMin = np.min(data[:,5])
|
thisMin = np.min(data[:,5])
|
||||||
|
@ -215,3 +216,63 @@ def plotMarg1d(workDir=None, sampleList=None, figDir=None,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
def plotNumberDistribution(workDir=None, sampleList=None, figDir=None,
|
||||||
|
plotNameBase="numberdist",
|
||||||
|
showPlot=False, dataPortion=None, setName=None):
|
||||||
|
|
||||||
|
plt.clf()
|
||||||
|
plt.xlabel("Void Radius (Mpc/h)")
|
||||||
|
plt.ylabel(r"N > R [h^3 Mpc^{-3}]")
|
||||||
|
|
||||||
|
plotTitle = setName
|
||||||
|
|
||||||
|
plotName = plotNameBase
|
||||||
|
|
||||||
|
plt.yscale('log')
|
||||||
|
|
||||||
|
for (iSample,sample) in enumerate(sampleList):
|
||||||
|
|
||||||
|
sampleName = sample.fullName
|
||||||
|
lineTitle = sampleName
|
||||||
|
|
||||||
|
if sample.dataType == "observation":
|
||||||
|
boxVol = vp.getSurveyProps(sample.maskFile, stack.zMin, stack.zMax,
|
||||||
|
sample.zRange[0], sample.zRange[1], "all",
|
||||||
|
selectionFuncFile=sample.selFunFile)[0]
|
||||||
|
else:
|
||||||
|
boxVol = sample.boxLen*sample.boxLen*(zBoundaryMpc[1]-zBoundaryMpc[0])
|
||||||
|
|
||||||
|
filename = workDir+"/sample_"+sampleName+"/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)
|
||||||
|
|
||||||
|
plt.legend(title = "Samples", loc = "upper right")
|
||||||
|
plt.title(plotTitle)
|
||||||
|
|
||||||
|
plt.xlim(xMin, xMax)
|
||||||
|
#plt.xlim(xMin, xMax*1.4) # make room for legend
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
if showPlot:
|
||||||
|
os.system("display %s" % figDir+"/fig_"+plotName+".png")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue