From e728e4a1521a211f271434baca754c1d3dde80f3 Mon Sep 17 00:00:00 2001 From: Paul Matthew Sutter Date: Sat, 8 Feb 2014 11:58:26 +0100 Subject: [PATCH 1/2] added periodic kdtree to partUtil --- .../void_python_tools/partUtil/partUtil.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/python_tools/void_python_tools/partUtil/partUtil.py b/python_tools/void_python_tools/partUtil/partUtil.py index a1def0e..055d0ca 100644 --- a/python_tools/void_python_tools/partUtil/partUtil.py +++ b/python_tools/void_python_tools/partUtil/partUtil.py @@ -26,6 +26,7 @@ import sys from void_python_tools.backend import * import void_python_tools.apTools as vp import pickle +from periodic_kdtree import PeriodicCKDTree NetCDFFile = Dataset ncFloat = 'f8' @@ -135,6 +136,27 @@ def loadPartVel(sampleDir): return partVel +# ----------------------------------------------------------------------------- +def getPartTree(sampleDir, partData, boxLen): + + with open(sampleDir+"/sample_info.dat", 'rb') as input: + sample = pickle.load(input) + + periodicLine = getPeriodic(sample) + + periodic = 1.*boxLen + + if not "x" in periodicLine: periodic[0] = -1 + if not "y" in periodicLine: periodic[1] = -1 + if not "z" in periodicLine: periodic[2] = -1 + + return PeriodicCKDTree(periodic, partData) + +# ----------------------------------------------------------------------------- +def getBall(partTree, center, radius): + + return partTree.query_ball_point(center, r=radius) + # ----------------------------------------------------------------------------- def shiftPart(inPart, center, periodicLine, ranges): From 7c9086efb837c770f877a15ef2afba11d3a1e7dd Mon Sep 17 00:00:00 2001 From: Paul Matthew Sutter Date: Sun, 9 Feb 2014 11:42:51 +0100 Subject: [PATCH 2/2] fixed handling of maskfile and comoving coords in loadPart --- python_tools/void_python_tools/partUtil/partUtil.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python_tools/void_python_tools/partUtil/partUtil.py b/python_tools/void_python_tools/partUtil/partUtil.py index 055d0ca..9299b04 100644 --- a/python_tools/void_python_tools/partUtil/partUtil.py +++ b/python_tools/void_python_tools/partUtil/partUtil.py @@ -27,6 +27,7 @@ from void_python_tools.backend import * import void_python_tools.apTools as vp import pickle from periodic_kdtree import PeriodicCKDTree +import os NetCDFFile = Dataset ncFloat = 'f8' @@ -95,11 +96,17 @@ def loadPart(sampleDir): boxLen = mul if isObservation == 1: - props = vp.getSurveyProps(sample.maskFile, sample.zBoundary[0], + # look for the mask file + if os.access(sample.maskFile, os.F_OK): + maskFile = sample.maskFile + else: + maskFile = sampleDir+"/"+os.path.basename(sample.maskFile) + print "Using maskfile found in:", maskFile + props = vp.getSurveyProps(maskFile, sample.zBoundary[0], sample.zBoundary[1], sample.zBoundary[0], sample.zBoundary[1], "all", - useLCDM=sample.useLCDM) + useLCDM=sample.useComoving) boxVol = props[0] volNorm = maskIndex/boxVol else: