mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
now also compute K-S statistic among different number functions while plotting
This commit is contained in:
parent
168ef7a0d7
commit
8e1b94949d
1 changed files with 68 additions and 33 deletions
|
@ -11,6 +11,7 @@ import os
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import argparse
|
import argparse
|
||||||
|
from scipy.stats import ks_2samp
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -19,6 +20,8 @@ plotNameBase = "compdist"
|
||||||
obsFudgeFactor = 1.0 # 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?
|
#obsFudgeFactor = .66 # what fraction of the volume are we *reall* capturing?
|
||||||
|
|
||||||
|
linewidth = 1
|
||||||
|
|
||||||
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',
|
||||||
const=True, default=False,
|
const=True, default=False,
|
||||||
|
@ -27,6 +30,10 @@ parser.add_argument('--parmFile', dest='parmFile', default='datasetsToPlot.py',
|
||||||
help='path to parameter file')
|
help='path to parameter file')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
nErrorBars = 10
|
||||||
|
plotMax = 120
|
||||||
|
errorBarsX = np.linspace(0, plotMax, num=nErrorBars)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
filename = args.parmFile
|
filename = args.parmFile
|
||||||
|
@ -50,11 +57,14 @@ plt.clf()
|
||||||
plt.xlabel("Void Radius [Mpc/h]")
|
plt.xlabel("Void Radius [Mpc/h]")
|
||||||
plt.ylabel(r"N > R [$h^3$ Gpc$^{-3}$]")
|
plt.ylabel(r"N > R [$h^3$ Gpc$^{-3}$]")
|
||||||
plt.yscale('log')
|
plt.yscale('log')
|
||||||
plt.xlim(xmax=120.)
|
plt.xlim(xmax=plotMax)
|
||||||
|
|
||||||
plotName = plotNameBase
|
plotName = plotNameBase
|
||||||
allData = []
|
allData = []
|
||||||
|
|
||||||
|
for dataPortion in dataPortions:
|
||||||
|
print "Data portion:", dataPortion
|
||||||
|
sizeList = []
|
||||||
for (iSample,sample) in enumerate(dataSampleList):
|
for (iSample,sample) in enumerate(dataSampleList):
|
||||||
|
|
||||||
sampleName = sample.fullName
|
sampleName = sample.fullName
|
||||||
|
@ -85,11 +95,28 @@ for (iSample,sample) in enumerate(dataSampleList):
|
||||||
continue
|
continue
|
||||||
data = data[:,4]
|
data = data[:,4]
|
||||||
indices = np.arange(0, len(data), 1)
|
indices = np.arange(0, len(data), 1)
|
||||||
sorted = np.sort(data)
|
numVoids = indices[::-1]/boxVol
|
||||||
|
voidSizes = np.sort(data)
|
||||||
|
|
||||||
plt.plot(sorted, indices[::-1]/boxVol, '-',
|
sizeList.append(voidSizes)
|
||||||
label=lineTitle, color=colorList[iSample],
|
myErrorBarsX = []
|
||||||
linewidth=linewidth)
|
errorBarsY = []
|
||||||
|
errorBarsDY = []
|
||||||
|
errorBarsIdx = []
|
||||||
|
for errorBarLoc in errorBarsX:
|
||||||
|
nearestIdx = (np.abs(voidSizes-errorBarLoc)).argmin()
|
||||||
|
if nearestIdx == 0: continue
|
||||||
|
myErrorBarsX.append(errorBarLoc)
|
||||||
|
errorBarsIdx.append(nearestIdx)
|
||||||
|
errorBarsY.append(numVoids[nearestIdx])
|
||||||
|
errorBarsDY.append(np.sqrt(numVoids[nearestIdx]))
|
||||||
|
|
||||||
|
thisPlot = plt.plot(voidSizes, numVoids, '-',
|
||||||
|
color=colorList[iSample],
|
||||||
|
linewidth=linewidth, label=lineTitle)
|
||||||
|
plt.errorbar(myErrorBarsX, errorBarsY, errorBarsDY,
|
||||||
|
ecolor=colorList[iSample],
|
||||||
|
fmt=None, label='_nolegend_', capsize=0)
|
||||||
|
|
||||||
hist, bin_edges = np.histogram(data, bins=100, range=(0,100))
|
hist, bin_edges = np.histogram(data, bins=100, range=(0,100))
|
||||||
allData.append(hist)
|
allData.append(hist)
|
||||||
|
@ -97,6 +124,14 @@ for (iSample,sample) in enumerate(dataSampleList):
|
||||||
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)
|
||||||
|
|
||||||
|
# compute K-S statistic for all pairs of sets
|
||||||
|
for (i,sample1) in enumerate(dataSampleList):
|
||||||
|
for (j,sample2) in enumerate(dataSampleList):
|
||||||
|
if j <= i: continue
|
||||||
|
ks, pval = ks_2samp(sizeList[i][:], sizeList[j][:])
|
||||||
|
print sample1.fullName, sample2.fullName, pval
|
||||||
|
|
||||||
|
|
||||||
plt.savefig(figDir+"/fig_"+plotName+".pdf", bbox_inches="tight")
|
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")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue