From 0cc5529b0813ee06212581b303fc123ea083e49f Mon Sep 17 00:00:00 2001 From: "P.M. Sutter" Date: Thu, 25 Apr 2013 18:13:24 -0500 Subject: [PATCH] checking for periodicity now pushed to function --- .../void_python_tools/backend/classes.py | 10 ++ .../void_python_tools/backend/launchers.py | 92 +++++++++++++------ 2 files changed, 72 insertions(+), 30 deletions(-) diff --git a/python_tools/void_python_tools/backend/classes.py b/python_tools/void_python_tools/backend/classes.py index 7736a47..72701bd 100644 --- a/python_tools/void_python_tools/backend/classes.py +++ b/python_tools/void_python_tools/backend/classes.py @@ -20,6 +20,7 @@ # classes and routines used to support scripts import os +from numpy import abs 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)+\ "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): mod = __import__(name) components = name.split('.') diff --git a/python_tools/void_python_tools/backend/launchers.py b/python_tools/void_python_tools/backend/launchers.py index 7926f6d..ee5e9a3 100644 --- a/python_tools/void_python_tools/backend/launchers.py +++ b/python_tools/void_python_tools/backend/launchers.py @@ -84,9 +84,8 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None, parmFile = os.getcwd()+"/generate_"+sample.fullName+".par" - file(parmFile, mode="w").write(conf) - if regenerate or not (continueRun and jobSuccessful(logFile, "Done!\n")): + file(parmFile, mode="w").write(conf) cmd = "%s --configFile=%s &> %s" % (binPath,parmFile,logFile) os.system(cmd) if jobSuccessful(logFile, "Done!\n"): @@ -98,8 +97,7 @@ def launchGenerate(sample, binPath, workDir=None, inputDataDir=None, else: print "already done!" - if os.access(parmFile, os.F_OK): - os.unlink(parmFile) + if os.access(parmFile, os.F_OK): os.unlink(parmFile) if os.access("contour_map.fits", os.F_OK): 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() maxDen = 0.2*float(mockIndex)/float(totalPart) observationLine = " --isObservation" - periodicLine = " --periodic=''" + #periodicLine = " --periodic=''" else: mockIndex = -1 maxDen = 0.2 observationLine = "" - 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 += "' " + #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 += "' " + + periodicLine = " --periodic='" + getPeriodic + "'" if not (continueRun and (jobSuccessful(logFile, "NetCDF: Not a valid ID\n") \ or jobSuccessful(logFile, "Done!\n"))): @@ -377,12 +377,12 @@ def launchVoidOverlap(sample1, sample2, sample1Dir, sample2Dir, sampleName1 = sample1.fullName sampleName2 = sample2.fullName - periodicLine = " --periodic='" - if sample1.dataType != "observation": - if sample1.numSubvolumes == 1: periodicLine += "xy" - if np.abs(sample1.zBoundaryMpc[1] - sample1.zBoundaryMpc[0] - sample1.boxLen) <= 1.e-1: - periodicLine += "z" - periodicLine += "' " + periodicLine = " --periodic='" + getPeriodic(sample1) + "' " + #if sample1.dataType != "observation": + # if sample1.numSubvolumes == 1: periodicLine += "xy" + # if np.abs(sample1.zBoundaryMpc[1] - sample1.zBoundaryMpc[0] - sample1.boxLen) <= 1.e-1: + # periodicLine += "z" + #periodicLine += "' " if not (continueRun and jobSuccessful(logFile, "Done!\n")): cmd = binPath @@ -390,7 +390,7 @@ def launchVoidOverlap(sample1, sample2, sample1Dir, sample2Dir, str(sampleName1) cmd += " --volFile1=" + sample1Dir+"/vol_" + \ str(sampleName1)+".dat" - cmd += " --voidFile1=" + sample1Dir+"/untrimmed_voidDesc_" + \ + cmd += " --voidFile1=" + sample1Dir+"/voidDesc_" + \ thisDataPortion+"_"+str(sampleName1)+".out" cmd += " --infoFile1=" + sample1Dir+"/zobov_slice_" + \ str(sampleName1)+".par" @@ -506,6 +506,17 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None, rMinToUse = stack.rMin 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=""" desc %s partzone %s @@ -529,6 +540,7 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None, boundaryDistances %s %s %s + %s """ % \ (zobovDir+"/voidDesc_"+thisDataPortion+"_"+sampleName+".out", zobovDir+"/voidPart_"+sampleName+".dat", @@ -551,11 +563,11 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None, zobovDir+"/barycenters_"+thisDataPortion+"_"+sampleName+".out", zobovDir+"/boundaryDistances_"+thisDataPortion+"_"+sampleName+".out", rescaleFlag, - idListFlag + idListFlag, + periodicLine ) parmFile = os.getcwd()+("/%sstack_"%prefixRun)+sample.fullName+".par" - fp = file(parmFile, mode="w") fp.write(conf) @@ -584,6 +596,7 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None, else: print "already done!" + if os.access(parmFile, os.F_OK): os.unlink(parmFile) return minDist = None @@ -662,7 +675,17 @@ def launchStack(sample, stack, binPath, thisDataPortion=None, logDir=None, nbar = 1.0 else: 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 + " " + \ thisDataPortion + " " + \ @@ -1091,10 +1114,8 @@ def launchFit(sample, stack, logFile=None, voidDir=None, figDir=None, else: rescaleFactor = 1.0 - vp.draw_fit(*args, delta_tick=0.2, vmax=10.0, delta_v=0.1, - nocontour=True, model_max=10.0, delta_model=1.0, - #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, + 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, showContours=showContours, rescaleFactor=rescaleFactor) @@ -1513,14 +1534,20 @@ def launchLikelihood(dataPortions=None, logDir=None, workDir=None, # ----------------------------------------------------------------------------- def launchEstimateErrorBars(workDir=None, nullDir=None, numNulls=None, - dataPortion=None): + dataPortion=None, nullDirList=None): IVALUE = 0 IERROR = 1 # open first null file to get sizes - nullFile = nullDir + "/" + str(1) + "/calculatedExpansions_" + \ - str(dataPortion) + ".txt" + if nullDirList == None: + nullFile = nullDir + "/" + str(1) + "/calculatedExpansions_" + \ + str(dataPortion) + ".txt" + else: + nullFile = nullDirList[0] + "/calculatedExpansions_" + str(dataPortion) + \ + ".txt" + numNulls = len(nullDirList) + fp = open(nullFile, "r") binLine = fp.readline() numSamples = int(binLine.split(" ")[0]) @@ -1534,8 +1561,13 @@ def launchEstimateErrorBars(workDir=None, nullDir=None, numNulls=None, nullData = np.zeros([numNulls, numBins, 2]) for iNull in xrange(numNulls): - nullFile = nullDir + "/" + str(iNull) + "/calculatedExpansions_" + \ - str(dataPortion) + ".txt" + if nullDirList == None: + nullFile = nullDir + "/" + str(iNull) + "/calculatedExpansions_" + \ + str(dataPortion) + ".txt" + else: + nullFile = nullDirList[iNull] + "/calculatedExpansions_" + \ + str(dataPortion) + ".txt" + fp = open(nullFile, "r") binLine = fp.readline()