- fixed bug where omegaM was always 0.3 regardless of user input

- wrote out flagging of boundary and edge galaxies
- turned off placing of boundary particles
This commit is contained in:
Paul M. Sutter 2024-06-05 17:28:16 +02:00
parent aded7a7c2c
commit f59fee9bf8
4 changed files with 164 additions and 102 deletions

View file

@ -29,24 +29,20 @@ __all__=['getSurveyProps', 'getNside', 'figureOutMask', 'findEdgeGalaxies']
# -----------------------------------------------------------------------------
# returns the volume and galaxy density for a given redshit slice
def getSurveyProps(maskFile, zmin, zmax, selFunMin, selFunMax, portion, selectionFuncFile=None, useComoving=False):
def getSurveyProps(maskFile, zmin, zmax, selFunMin, selFunMax, portion,
omegaM, selectionFuncFile=None, useComoving=False):
LIGHT_SPEED = 299792.458
#LIGHT_SPEED = 299792.458
mask = healpy.read_map(maskFile)
area = (1.*np.size(np.where(mask > 0)) / np.size(mask)) * 4.*np.pi
if useComoving:
zmin = LIGHT_SPEED/100.*angularDiameter(zmin, Om=0.27)
zmax = LIGHT_SPEED/100.*angularDiameter(zmax, Om=0.27)
selFunMin = LIGHT_SPEED/100.*angularDiameter(selFunMin, Om=0.27)
selFunMax = LIGHT_SPEED/100.*angularDiameter(selFunMax, Om=0.27)
zmin = LIGHT_SPEED/100.*angularDiameter(zmin, Om=omegaM)
zmax = LIGHT_SPEED/100.*angularDiameter(zmax, Om=omegaM)
else:
zmin = zmin * 3000
zmax = zmax * 3000
selFunMin *= 3000
selFunMax *= 3000
volume = area * (zmax**3 - zmin**3) / 3
zmin = zmin * LIGHT_SPEED/100.
zmax = zmax * LIGHT_SPEED/100.
if selectionFuncFile == None:
nbar = 1.0
@ -90,40 +86,91 @@ def getSurveyProps(maskFile, zmin, zmax, selFunMin, selFunMax, portion, selectio
# -----------------------------------------------------------------------------
# returns the nside resolution from the given maskfile
def getNside(maskFile):
nside = 1.0
return nside
mask = healpy.read_map(maskFile)
return healpy.get_nside(mask)
# -----------------------------------------------------------------------------
# computes the mask from a given datafile and writes it to a file
# helper function to convert RA,dec to phi,theta
def convertAngle(RA, Dec):
phi = np.pi/180.*RA
theta = Dec*np.pi/180.
theta = np.pi/2. - Dec*np.pi/180.
return phi, theta
# -----------------------------------------------------------------------------
# computes the mask from a given galaxy datafile and writes it to a file
def figureOutMask(galFile, nside, outMaskFile):
npix = healpy.nside2npix(nside)
mask = np.zeros((npix))
for line in open(galFile):
line = line.split()
RA = np.float(line[3])
Dec = np.float(line[4])
z = np.float(line[5])
for line in open(galFile):
line = line.split()
RA = np.float(line[3])
Dec = np.float(line[4])
z = np.float(line[5])
phi = np.pi/180.*RA
theta = Dec*np.pi/180.
theta = np.pi/2. - Dec*np.pi/180.
pos = np.zeros((3))
phi, theta = convertAngle(RA, Dec)
pix = healpy.ang2pix(nside, theta, phi)
mask[pix] = 1.
pix = healpy.ang2pix(nside, theta, phi)
mask[pix] = 1.
healpy.write_map(outMaskFile, mask)
healpy.write_map(outMaskFile, mask)
return mask
# -----------------------------------------------------------------------------
# figures out which galaxies live on a mask edge, and also writes the edge
# map to an auxillary file
def findEdgeGalaxies(galFile, maskFile):
def findEdgeGalaxies(galFile, maskFile, edgeGalFile, edgeMaskFile,
zmin, zmax, omegaM, useComoving=False):
if useComoving:
zmin = LIGHT_SPEED/100.*angularDiameter(zmin, Om=omegaM)
zmax = LIGHT_SPEED/100.*angularDiameter(zmax, Om=omegaM)
else:
zmin *= LIGHT_SPEED/100.
zmax *= LIGHT_SPEED/100.
mask = healpy.read_map(maskFile)
nside = healpy.get_nside(mask)
npix = healpy.nside2npix(nside)
edgeMask = np.zeros((npix))
edgeFile = open(edgeGalFile, "w")
for line in open(galFile):
line = line.split()
RA = np.float(line[3])
Dec = np.float(line[4])
z = np.float(line[5])
if useComoving:
z = LIGHT_SPEED/100.*angularDiameter(z, Om=omegaM)
else:
z *= LIGHT_SPEED/100.
phi, theta = convertAngle(RA, Dec)
isOnEdge = False
# check the mask edges
neighbors = healpy.get_all_neighbors(nside, theta, phi)
isOnEdge = any(p == 0 for p in neighbors):
# check the redshift boundaries
if isOnEdge:
edgeFile.write("1")
else:
edgeFile.write("0")
edgeFile.close()
healpy.write_map(edgeMaskFile, edgeMask)
return