mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
incorporated volume-weighting in zobov
This commit is contained in:
parent
e46508815a
commit
cea02c5e31
1 changed files with 66 additions and 7 deletions
|
@ -37,6 +37,7 @@ from netCDF4 import Dataset
|
||||||
from void_python_tools.backend.classes import *
|
from void_python_tools.backend.classes import *
|
||||||
import pickle
|
import pickle
|
||||||
import void_python_tools.apTools as vp
|
import void_python_tools.apTools as vp
|
||||||
|
import scipy.interpolate
|
||||||
|
|
||||||
NetCDFFile = Dataset
|
NetCDFFile = Dataset
|
||||||
ncFloat = 'f8' # Double precision
|
ncFloat = 'f8' # Double precision
|
||||||
|
@ -344,17 +345,75 @@ def launchZobov(sample, binPath, zobovDir=None, logDir=None, continueRun=None,
|
||||||
subprocess.call(cmd, stdout=log, stderr=log)
|
subprocess.call(cmd, stdout=log, stderr=log)
|
||||||
log.close()
|
log.close()
|
||||||
|
|
||||||
# TODO re-weight the volumes based on selection function
|
# re-weight the volumes based on selection function
|
||||||
#volFile = zobovDir+"/vol_"+sampleName+".dat"
|
if sample.dataType == "observation" and \
|
||||||
#File = file(volFile)
|
sample.selFunFile != None:
|
||||||
#chk = np.fromfile(File, dtype=np.int32,count=1)
|
|
||||||
#vols = np.fromfile(File, dtype=np.float32,count=numPartTot)
|
# load volumes
|
||||||
|
volFile = zobovDir+"/vol_"+sampleName+".dat"
|
||||||
|
File = file(volFile)
|
||||||
|
numPartTot = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
vols = np.fromfile(File, dtype=np.float32,count=numPartTot)
|
||||||
|
File.close()
|
||||||
|
|
||||||
|
# load redshifts
|
||||||
|
partFile = sampleDir+"/zobov_slice_"+sample.fullName
|
||||||
|
File = file(partFile)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
Np = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
|
||||||
|
# x
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
redshifts = np.fromfile(File, dtype=np.float32,count=Np)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
|
||||||
|
# y
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
redshifts = np.fromfile(File, dtype=np.float32,count=Np)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
|
||||||
|
# z
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
redshifts = np.fromfile(File, dtype=np.float32,count=Np)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
|
||||||
|
# RA
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
redshifts = np.fromfile(File, dtype=np.float32,count=Np)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
|
||||||
|
# Dec
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
redshifts = np.fromfile(File, dtype=np.float32,count=Np)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
|
||||||
|
# z
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
redshifts = np.fromfile(File, dtype=np.float32,count=Np)
|
||||||
|
chk = np.fromfile(File, dtype=np.int32,count=1)
|
||||||
|
File.close()
|
||||||
|
|
||||||
|
# build selection function interpolation
|
||||||
|
selfuncData = np.genfromtxt(sample.selFunFile)
|
||||||
|
selfunc = interpolate.interp1d(selfuncData[:,0], selfuncData[:,1],
|
||||||
|
kind='cubic')
|
||||||
|
# re-weight and write
|
||||||
|
vols *= selfunc(redshifts)
|
||||||
|
|
||||||
|
volFile = zobovDir+"/vol_"+sampleName+".dat"
|
||||||
|
File = file(volFile, 'w')
|
||||||
|
chk.astype('np.int32').tofile(File)
|
||||||
|
vols.astype('np.float32').tofile(File)
|
||||||
|
|
||||||
|
volFileToUse = zobovDir+"/vol_weighted"+sampleName+".dat"
|
||||||
|
else:
|
||||||
|
volFileToUse = zobovDir+"/vol_"+sampleName+".dat"
|
||||||
|
|
||||||
|
|
||||||
cmd = [binPath+"../c_tools/zobov2/jozov2/jozov2", \
|
cmd = [binPath+"../c_tools/zobov2/jozov2/jozov2", \
|
||||||
zobovDir+"/adj_"+sampleName+".dat", \
|
zobovDir+"/adj_"+sampleName+".dat", \
|
||||||
zobovDir+"/vol_weighted_"+sampleName+".dat", \
|
voleFileToUse, \
|
||||||
#zobovDir+"/vol_"+sampleName+".dat", \
|
|
||||||
zobovDir+"/voidPart_"+sampleName+".dat", \
|
zobovDir+"/voidPart_"+sampleName+".dat", \
|
||||||
zobovDir+"/voidZone_"+sampleName+".dat", \
|
zobovDir+"/voidZone_"+sampleName+".dat", \
|
||||||
zobovDir+"/voidDesc_"+sampleName+".out", \
|
zobovDir+"/voidDesc_"+sampleName+".out", \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue