mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
checking for periodicity now pushed to function
This commit is contained in:
parent
c088a87809
commit
0cc5529b08
2 changed files with 72 additions and 30 deletions
|
@ -20,6 +20,7 @@
|
||||||
# classes and routines used to support scripts
|
# classes and routines used to support scripts
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from numpy import abs
|
||||||
|
|
||||||
LIGHT_SPEED = 299792.458
|
LIGHT_SPEED = 299792.458
|
||||||
|
|
||||||
|
@ -188,6 +189,15 @@ def getStackSuffix(zMin, zMax, rMin, rMax, dataPortion, customLine=""):
|
||||||
return "z"+str(zMin)+"-"+str(zMax)+"_"+str(rMin)+"-"+str(rMax)+\
|
return "z"+str(zMin)+"-"+str(zMax)+"_"+str(rMin)+"-"+str(rMax)+\
|
||||||
"Mpc"+customLine+"_"+dataPortion
|
"Mpc"+customLine+"_"+dataPortion
|
||||||
|
|
||||||
|
def getPeriodic(sample):
|
||||||
|
periodicLine = ""
|
||||||
|
if sample.dataType != "observation":
|
||||||
|
if sample.numSubvolumes == 1: periodicLine += "xy"
|
||||||
|
if abs(sample.zBoundaryMpc[1] - sample.zBoundaryMpc[0] - \
|
||||||
|
sample.boxLen) <= 1.e-1:
|
||||||
|
periodicLine += "z"
|
||||||
|
return periodicLine
|
||||||
|
|
||||||
def my_import(name):
|
def my_import(name):
|
||||||
mod = __import__(name)
|
mod = __import__(name)
|
||||||
components = name.split('.')
|
components = name.split('.')
|
||||||
|
|
|
@ -84,9 +84,8 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
||||||
|
|
||||||
parmFile = os.getcwd()+"/generate_"+sample.fullName+".par"
|
parmFile = os.getcwd()+"/generate_"+sample.fullName+".par"
|
||||||
|
|
||||||
file(parmFile, mode="w").write(conf)
|
|
||||||
|
|
||||||
if regenerate or not (continueRun and jobSuccessful(logFile, "Done!\n")):
|
if regenerate or not (continueRun and jobSuccessful(logFile, "Done!\n")):
|
||||||
|
file(parmFile, mode="w").write(conf)
|
||||||
cmd = "%s --configFile=%s &> %s" % (binPath,parmFile,logFile)
|
cmd = "%s --configFile=%s &> %s" % (binPath,parmFile,logFile)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
if jobSuccessful(logFile, "Done!\n"):
|
if jobSuccessful(logFile, "Done!\n"):
|
||||||
|
@ -98,8 +97,7 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None,
|
||||||
else:
|
else:
|
||||||
print "already done!"
|
print "already done!"
|
||||||
|
|
||||||
if os.access(parmFile, os.F_OK):
|
if os.access(parmFile, os.F_OK): os.unlink(parmFile)
|
||||||
os.unlink(parmFile)
|
|
||||||
|
|
||||||
if os.access("contour_map.fits", os.F_OK):
|
if os.access("contour_map.fits", os.F_OK):
|
||||||
os.system("mv %s %s" % ("contour_map.fits", zobovDir))
|
os.system("mv %s %s" % ("contour_map.fits", zobovDir))
|
||||||
|
@ -316,18 +314,20 @@ def launchPrune(sample, binPath,
|
||||||
totalPart = open(zobovDir+"/total_particles.txt", "r").read()
|
totalPart = open(zobovDir+"/total_particles.txt", "r").read()
|
||||||
maxDen = 0.2*float(mockIndex)/float(totalPart)
|
maxDen = 0.2*float(mockIndex)/float(totalPart)
|
||||||
observationLine = " --isObservation"
|
observationLine = " --isObservation"
|
||||||
periodicLine = " --periodic=''"
|
#periodicLine = " --periodic=''"
|
||||||
else:
|
else:
|
||||||
mockIndex = -1
|
mockIndex = -1
|
||||||
maxDen = 0.2
|
maxDen = 0.2
|
||||||
observationLine = ""
|
observationLine = ""
|
||||||
|
|
||||||
periodicLine = " --periodic='"
|
#periodicLine = " --periodic='"
|
||||||
if sample.numSubvolumes == 1: periodicLine += "xy"
|
#if sample.numSubvolumes == 1: periodicLine += "xy"
|
||||||
if np.abs(sample.zBoundaryMpc[1] - sample.zBoundaryMpc[0] - \
|
#if np.abs(sample.zBoundaryMpc[1] - sample.zBoundaryMpc[0] - \
|
||||||
sample.boxLen) <= 1.e-1:
|
# sample.boxLen) <= 1.e-1:
|
||||||
periodicLine += "z"
|
# periodicLine += "z"
|
||||||
periodicLine += "' "
|
#periodicLine += "' "
|
||||||
|
|
||||||
|
periodicLine = " --periodic='" + getPeriodic + "'"
|
||||||
|
|
||||||
if not (continueRun and (jobSuccessful(logFile, "NetCDF: Not a valid ID\n") \
|
if not (continueRun and (jobSuccessful(logFile, "NetCDF: Not a valid ID\n") \
|
||||||
or jobSuccessful(logFile, "Done!\n"))):
|
or jobSuccessful(logFile, "Done!\n"))):
|
||||||
|
@ -377,12 +377,12 @@ def launchVoidOverlap(sample1, sample2, sample1Dir, sample2Dir,
|
||||||
sampleName1 = sample1.fullName
|
sampleName1 = sample1.fullName
|
||||||
sampleName2 = sample2.fullName
|
sampleName2 = sample2.fullName
|
||||||
|
|
||||||
periodicLine = " --periodic='"
|
periodicLine = " --periodic='" + getPeriodic(sample1) + "' "
|
||||||
if sample1.dataType != "observation":
|
#if sample1.dataType != "observation":
|
||||||
if sample1.numSubvolumes == 1: periodicLine += "xy"
|
# if sample1.numSubvolumes == 1: periodicLine += "xy"
|
||||||
if np.abs(sample1.zBoundaryMpc[1] - sample1.zBoundaryMpc[0] - sample1.boxLen) <= 1.e-1:
|
# if np.abs(sample1.zBoundaryMpc[1] - sample1.zBoundaryMpc[0] - sample1.boxLen) <= 1.e-1:
|
||||||
periodicLine += "z"
|
# periodicLine += "z"
|
||||||
periodicLine += "' "
|
#periodicLine += "' "
|
||||||
|
|
||||||
if not (continueRun and jobSuccessful(logFile, "Done!\n")):
|
if not (continueRun and jobSuccessful(logFile, "Done!\n")):
|
||||||
cmd = binPath
|
cmd = binPath
|
||||||
|
@ -390,7 +390,7 @@ def launchVoidOverlap(sample1, sample2, sample1Dir, sample2Dir,
|
||||||
str(sampleName1)
|
str(sampleName1)
|
||||||
cmd += " --volFile1=" + sample1Dir+"/vol_" + \
|
cmd += " --volFile1=" + sample1Dir+"/vol_" + \
|
||||||
str(sampleName1)+".dat"
|
str(sampleName1)+".dat"
|
||||||
cmd += " --voidFile1=" + sample1Dir+"/untrimmed_voidDesc_" + \
|
cmd += " --voidFile1=" + sample1Dir+"/voidDesc_" + \
|
||||||
thisDataPortion+"_"+str(sampleName1)+".out"
|
thisDataPortion+"_"+str(sampleName1)+".out"
|
||||||
cmd += " --infoFile1=" + sample1Dir+"/zobov_slice_" + \
|
cmd += " --infoFile1=" + sample1Dir+"/zobov_slice_" + \
|
||||||
str(sampleName1)+".par"
|
str(sampleName1)+".par"
|
||||||
|
@ -506,6 +506,17 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None,
|
||||||
rMinToUse = stack.rMin
|
rMinToUse = stack.rMin
|
||||||
rMaxToUse = stack.rMax
|
rMaxToUse = stack.rMax
|
||||||
|
|
||||||
|
periodicLine = "periodic='" + getPeriodic(sample) + "'"
|
||||||
|
#if sample.dataType == "observation":
|
||||||
|
# periodicLine = "periodic=''"
|
||||||
|
#else:
|
||||||
|
# periodicLine = "periodic='"
|
||||||
|
# if sample.numSubvolumes == 1: periodicLine += "xy"
|
||||||
|
# if np.abs(sample.zBoundaryMpc[1] - sample.zBoundaryMpc[0] - \
|
||||||
|
# sample.boxLen) <= 1.e-1:
|
||||||
|
# periodicLine += "z"
|
||||||
|
# periodicLine += "' "
|
||||||
|
|
||||||
conf="""
|
conf="""
|
||||||
desc %s
|
desc %s
|
||||||
partzone %s
|
partzone %s
|
||||||
|
@ -529,6 +540,7 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None,
|
||||||
boundaryDistances %s
|
boundaryDistances %s
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
|
%s
|
||||||
""" % \
|
""" % \
|
||||||
(zobovDir+"/voidDesc_"+thisDataPortion+"_"+sampleName+".out",
|
(zobovDir+"/voidDesc_"+thisDataPortion+"_"+sampleName+".out",
|
||||||
zobovDir+"/voidPart_"+sampleName+".dat",
|
zobovDir+"/voidPart_"+sampleName+".dat",
|
||||||
|
@ -551,11 +563,11 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None,
|
||||||
zobovDir+"/barycenters_"+thisDataPortion+"_"+sampleName+".out",
|
zobovDir+"/barycenters_"+thisDataPortion+"_"+sampleName+".out",
|
||||||
zobovDir+"/boundaryDistances_"+thisDataPortion+"_"+sampleName+".out",
|
zobovDir+"/boundaryDistances_"+thisDataPortion+"_"+sampleName+".out",
|
||||||
rescaleFlag,
|
rescaleFlag,
|
||||||
idListFlag
|
idListFlag,
|
||||||
|
periodicLine
|
||||||
)
|
)
|
||||||
|
|
||||||
parmFile = os.getcwd()+("/%sstack_"%prefixRun)+sample.fullName+".par"
|
parmFile = os.getcwd()+("/%sstack_"%prefixRun)+sample.fullName+".par"
|
||||||
|
|
||||||
fp = file(parmFile, mode="w")
|
fp = file(parmFile, mode="w")
|
||||||
fp.write(conf)
|
fp.write(conf)
|
||||||
|
|
||||||
|
@ -584,6 +596,7 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None,
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "already done!"
|
print "already done!"
|
||||||
|
if os.access(parmFile, os.F_OK): os.unlink(parmFile)
|
||||||
return
|
return
|
||||||
|
|
||||||
minDist = None
|
minDist = None
|
||||||
|
@ -662,7 +675,17 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None,
|
||||||
nbar = 1.0
|
nbar = 1.0
|
||||||
else:
|
else:
|
||||||
nbar = 1.0
|
nbar = 1.0
|
||||||
boxVol = sample.boxLen**3
|
|
||||||
|
iX = float(sample.mySubvolume[0])
|
||||||
|
iY = float(sample.mySubvolume[1])
|
||||||
|
xMin = iX/sample.numSubvolumes * sample.boxLen
|
||||||
|
yMin = iY/sample.numSubvolumes * sample.boxLen
|
||||||
|
xMax = (iX+1)/sample.numSubvolumes * sample.boxLen
|
||||||
|
yMax = (iY+1)/sample.numSubvolumes * sample.boxLen
|
||||||
|
zMin = sample.zBoundaryMpc[0]
|
||||||
|
zMax = sample.zBoundaryMpc[1]
|
||||||
|
|
||||||
|
boxVol = (xMax-xMin)*(yMax-yMin)*(zMax-zMin)
|
||||||
|
|
||||||
summaryLine = runSuffix + " " + \
|
summaryLine = runSuffix + " " + \
|
||||||
thisDataPortion + " " + \
|
thisDataPortion + " " + \
|
||||||
|
@ -1091,10 +1114,8 @@ def launchFit(sample, stack, logFile=None, voidDir=None, figDir=None,
|
||||||
else:
|
else:
|
||||||
rescaleFactor = 1.0
|
rescaleFactor = 1.0
|
||||||
|
|
||||||
vp.draw_fit(*args, delta_tick=0.2, vmax=10.0, delta_v=0.1,
|
vp.draw_fit(*args, delta_tick=0.2, vmax=1.0, delta_v=0.01,
|
||||||
nocontour=True, model_max=10.0, delta_model=1.0,
|
nocontour=True, model_max=1.0, delta_model=0.1,
|
||||||
#vp.draw_fit(*args, delta_tick=0.2, vmax=1.0, delta_v=0.01,
|
|
||||||
# nocontour=True, model_max=1.0, delta_model=0.1,
|
|
||||||
plotTitle=plotTitle, show_ratio=showRatio,
|
plotTitle=plotTitle, show_ratio=showRatio,
|
||||||
showContours=showContours,
|
showContours=showContours,
|
||||||
rescaleFactor=rescaleFactor)
|
rescaleFactor=rescaleFactor)
|
||||||
|
@ -1513,14 +1534,20 @@ def launchLikelihood(dataPortions=None, logDir=None, workDir=None,
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def launchEstimateErrorBars(workDir=None, nullDir=None, numNulls=None,
|
def launchEstimateErrorBars(workDir=None, nullDir=None, numNulls=None,
|
||||||
dataPortion=None):
|
dataPortion=None, nullDirList=None):
|
||||||
|
|
||||||
IVALUE = 0
|
IVALUE = 0
|
||||||
IERROR = 1
|
IERROR = 1
|
||||||
|
|
||||||
# open first null file to get sizes
|
# open first null file to get sizes
|
||||||
nullFile = nullDir + "/" + str(1) + "/calculatedExpansions_" + \
|
if nullDirList == None:
|
||||||
str(dataPortion) + ".txt"
|
nullFile = nullDir + "/" + str(1) + "/calculatedExpansions_" + \
|
||||||
|
str(dataPortion) + ".txt"
|
||||||
|
else:
|
||||||
|
nullFile = nullDirList[0] + "/calculatedExpansions_" + str(dataPortion) + \
|
||||||
|
".txt"
|
||||||
|
numNulls = len(nullDirList)
|
||||||
|
|
||||||
fp = open(nullFile, "r")
|
fp = open(nullFile, "r")
|
||||||
binLine = fp.readline()
|
binLine = fp.readline()
|
||||||
numSamples = int(binLine.split(" ")[0])
|
numSamples = int(binLine.split(" ")[0])
|
||||||
|
@ -1534,8 +1561,13 @@ def launchEstimateErrorBars(workDir=None, nullDir=None, numNulls=None,
|
||||||
nullData = np.zeros([numNulls, numBins, 2])
|
nullData = np.zeros([numNulls, numBins, 2])
|
||||||
|
|
||||||
for iNull in xrange(numNulls):
|
for iNull in xrange(numNulls):
|
||||||
nullFile = nullDir + "/" + str(iNull) + "/calculatedExpansions_" + \
|
if nullDirList == None:
|
||||||
str(dataPortion) + ".txt"
|
nullFile = nullDir + "/" + str(iNull) + "/calculatedExpansions_" + \
|
||||||
|
str(dataPortion) + ".txt"
|
||||||
|
else:
|
||||||
|
nullFile = nullDirList[iNull] + "/calculatedExpansions_" + \
|
||||||
|
str(dataPortion) + ".txt"
|
||||||
|
|
||||||
fp = open(nullFile, "r")
|
fp = open(nullFile, "r")
|
||||||
|
|
||||||
binLine = fp.readline()
|
binLine = fp.readline()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue