From ea3faa2e4cbc92fff3e1546fe76600ad4808e836 Mon Sep 17 00:00:00 2001 From: "P.M. Sutter" Date: Wed, 28 Oct 2015 21:58:36 -0400 Subject: [PATCH] added error handling on read of sselection function file --- .../apTools/profiles/getSurveyProps.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python_tools/void_python_tools/apTools/profiles/getSurveyProps.py b/python_tools/void_python_tools/apTools/profiles/getSurveyProps.py index 5a3bf5d..9999468 100644 --- a/python_tools/void_python_tools/apTools/profiles/getSurveyProps.py +++ b/python_tools/void_python_tools/apTools/profiles/getSurveyProps.py @@ -44,7 +44,14 @@ def getSurveyProps(maskFile, zmin, zmax, selFunMin, selFunMax, portion, selectio selFunMax *= 3000 volume = area * (zmax**3 - zmin**3) / 3 - if selectionFuncFile != None: + if selectionFuncFile == None: + nbar = 1.0 + + elif not os.access(selectionFuncFile, os.F_OK): + print " Warning, selection function file %s not found, using default of uniform selection." % selectionFuncFile + nbar = 1.0 + + else: selfunc = np.genfromtxt(selectionFuncFile) selfunc = np.array(selfunc) selfunc[:,0] = selfunc[:,0]/100. @@ -72,8 +79,6 @@ def getSurveyProps(maskFile, zmin, zmax, selFunMin, selFunMax, portion, selectio nbar = ntotal / area / nbar - else: - nbar = 1.0 #print "PROPERTIES: ", volume, nbar