plotting now supports cumulative number distributions

This commit is contained in:
P.M. Sutter 2012-11-13 13:55:40 -06:00
parent 9cdc037946
commit 93ba823764
3 changed files with 67 additions and 2 deletions

View file

@ -111,5 +111,7 @@ if (startCatalogStage <= 4) and (endCatalogStage >= 4):
dataPortion=thisDataPortion, setName=catalogName)
plotSizeDistribution(workDir, dataSampleList, figDir, showPlot=False,
dataPortion=thisDataPortion, setName=catalogName)
plotNumberDistribution(workDir, dataSampleList, figDir, showPlot=False,
dataPortion=thisDataPortion, setName=catalogName)
print "\n Done!"

View file

@ -1,3 +1,5 @@
LIGHT_SPEED = 299792.458
colorList = ['r', 'b', 'g', 'y', 'c', 'm', 'y',
'brown', 'grey',
'darkred', 'orange', 'pink', 'darkblue',

View file

@ -1,11 +1,12 @@
__all__=['plotRedshiftDistribution', 'plotSizeDistribution', 'plot1dProfiles',
'plotMarg1d']
'plotMarg1d', 'plotNumberDistribution']
from void_python_tools.backend.classes import *
from plotDefs import *
import numpy as np
import os
import pylab as plt
import void_python_tools.apTools as vp
# -----------------------------------------------------------------------------
def plotRedshiftDistribution(workDir=None, sampleList=None, figDir=None,
@ -43,7 +44,7 @@ def plotRedshiftDistribution(workDir=None, sampleList=None, figDir=None,
zMax = sample.zRange[1]
range = (zMin, zMax)
nbins = np.ceil((zMax-zMin)/0.1)
nbins = np.ceil((zMax-zMin)/0.02)
thisMax = np.max(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")