bug fixed related to different boundary handling procedure. no guarantee that it's correct (yet) but it runs

This commit is contained in:
Paul M. Sutter 2024-06-06 00:49:53 +02:00
parent 03c8f773b6
commit dd181da42a
6 changed files with 40 additions and 36 deletions

View file

@ -24,6 +24,7 @@ import numpy as np
import healpy as healpy
import os
from backend import *
from backend.cosmologyTools import *
__all__=['getSurveyProps', 'getNside', 'figureOutMask', 'findEdgeGalaxies']
@ -44,6 +45,8 @@ def getSurveyProps(maskFile, zmin, zmax, selFunMin, selFunMax, portion,
zmin = zmin * LIGHT_SPEED/100.
zmax = zmax * LIGHT_SPEED/100.
volume = area * (zmax**3 - zmin**3) / 3
if selectionFuncFile == None:
nbar = 1.0
@ -119,7 +122,7 @@ def figureOutMask(galFile, nside, outMaskFile):
pix = healpy.ang2pix(nside, theta, phi)
mask[pix] = 1.
healpy.write_map(outMaskFile, mask, overwrite=True)
healpy.write_map(outMaskFile, mask, overwrite=True, dtype=np.dtype('float64'))
return mask
@ -129,12 +132,12 @@ def figureOutMask(galFile, nside, outMaskFile):
def findEdgeGalaxies(galFile, maskFile, edgeGalFile, edgeMaskFile,
zmin, zmax, omegaM, useComoving=False):
if useComoving:
zmin = LIGHT_SPEED/100.*comovingDistance(zmin, Om=omegaM)
zmax = LIGHT_SPEED/100.*comovingDistance(zmax, Om=omegaM)
else:
zmin *= LIGHT_SPEED/100.
zmax *= LIGHT_SPEED/100.
#if useComoving:
# zmin = LIGHT_SPEED/100.*comovingDistance(zmin, Om=omegaM)
# zmax = LIGHT_SPEED/100.*comovingDistance(zmax, Om=omegaM)
#else:
# zmin *= LIGHT_SPEED/100.
# zmax *= LIGHT_SPEED/100.
mask = healpy.read_map(maskFile)
@ -151,32 +154,33 @@ def findEdgeGalaxies(galFile, maskFile, edgeGalFile, edgeMaskFile,
z = float(line[5])
if useComoving:
z = LIGHT_SPEED/100.*comovingDistance(z, Om=omegaM)
z = comovingDistance(z/LIGHT_SPEED, Om=omegaM)
else:
z *= LIGHT_SPEED/100.
phi, theta = convertAngle(RA, Dec)
# check the mask edges
neighbors = healpy.get_all_neighbors(nside, theta, phi)
neighbors = healpy.get_all_neighbours(nside, theta, phi)
isOnMaskEdge = any(p == 0 for p in neighbors)
# check the redshift boundaries
tol = 0.01 # TODO: made this user-adjustable
zBuffer = (zmax-zmin)*tol
isOnHighZEdge = (z >= zmax-buffer)
isOnLowZEdge = (z <= zmin+buffer)
zbuffer = (zmax-zmin)*tol
isOnHighZEdge = (z >= zmax-zbuffer)
isOnLowZEdge = (z <= zmin+zbuffer)
print("DOING %f %f %f %f\n" % (zbuffer, z, zmax, zmin) )
if isOnMaskEdge:
edgeFile.write("1")
edgeFile.write("1\n")
elif isOnHighZEdge:
edgeFile.write("2")
edgeFile.write("2\n")
elif isOnLowZEdge:
edgeFile.write("3")
edgeFile.write("3\n")
else:
edgeFile.write("0")
edgeFile.write("0\n")
edgeFile.close()
healpy.write_map(edgeMaskFile, edgeMask, overwrite=True)
healpy.write_map(edgeMaskFile, edgeMask, overwrite=True, dtype=np.dtype('float64'))
return