mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-22 17:18:02 +00:00
Update init matching procedure (#50)
* pep8 * fix convention * Update script * enforce optimisation boundaries to be finite * Update TODO * Remove sky matching * FIx a small bug * fix bug * Remove import * Add halo fitted quantities * Update nbs * update README * Add load_initial comments * Rename nbs * Delete nb * Update imports * Rename function * Update matcher * Add overlap paths * Update the matching script * Update verbosity * Add verbosity flags * Simplify make_bckg_delta * bug fix * fix bug * lala * la * Add overlap paths * Update limit * pep8 * Some pep8 stuff * pep8 * Minor corrections * Update paths * Add number of particles check * Fix bug * pep8 comments
This commit is contained in:
parent
c14be720b5
commit
b5fefe4196
3 changed files with 22 additions and 24 deletions
|
@ -115,9 +115,9 @@ class RealisationsMatcher:
|
|||
|
||||
Parameters
|
||||
----------
|
||||
cat0 : :py:class:`csiborgtools.read.ClumpsCatalogue`
|
||||
cat0 : :py:class:`csiborgtools.read.HaloCatalogue`
|
||||
Halo catalogue of the reference simulation.
|
||||
catx : :py:class:`csiborgtools.read.ClumpsCatalogue`
|
||||
catx : :py:class:`csiborgtools.read.HaloCatalogue`
|
||||
Halo catalogue of the cross simulation.
|
||||
halos0_archive : `NpzFile` object
|
||||
Archive of halos' particles of the reference simulation, keys must
|
||||
|
@ -198,10 +198,8 @@ class RealisationsMatcher:
|
|||
except KeyError:
|
||||
halox = halosx_archive[str(kf)]
|
||||
minsx, maxsx = get_halolims(
|
||||
halox,
|
||||
ncells=self.overlapper.inv_clength,
|
||||
nshift=self.overlapper.nshift,
|
||||
)
|
||||
halox, ncells=self.overlapper.inv_clength,
|
||||
nshift=self.overlapper.nshift)
|
||||
for p in ("x", "y", "z"):
|
||||
halox[p] = self.overlapper.pos2cell(halox[p])
|
||||
cross_halos[kf] = halox
|
||||
|
@ -768,9 +766,8 @@ def calculate_overlap(delta1, delta2, cellmins, delta_bckg):
|
|||
|
||||
|
||||
@jit(nopython=True)
|
||||
def calculate_overlap_indxs(
|
||||
delta1, delta2, cellmins, delta_bckg, nonzero, mass1, mass2
|
||||
):
|
||||
def calculate_overlap_indxs(delta1, delta2, cellmins, delta_bckg, nonzero,
|
||||
mass1, mass2):
|
||||
r"""
|
||||
Overlap between two clumps whose density fields are evaluated on the
|
||||
same grid and `nonzero1` enumerates the non-zero cells of `delta1. This is
|
||||
|
@ -841,9 +838,8 @@ def dist_centmass(clump):
|
|||
Center of mass coordinates.
|
||||
"""
|
||||
# CM along each dimension
|
||||
cmx, cmy, cmz = [
|
||||
numpy.average(clump[p], weights=clump["M"]) for p in ("x", "y", "z")
|
||||
]
|
||||
cmx, cmy, cmz = [numpy.average(clump[p], weights=clump["M"])
|
||||
for p in ("x", "y", "z")]
|
||||
# Particle distance from the CM
|
||||
dist = numpy.sqrt(
|
||||
numpy.square(clump["x"] - cmx)
|
||||
|
@ -876,9 +872,8 @@ def dist_percentile(dist, qs, distmax=0.075):
|
|||
return x
|
||||
|
||||
|
||||
def radius_neighbours(
|
||||
knn, X, radiusX, radiusKNN, nmult=1.0, enforce_int32=False, verbose=True
|
||||
):
|
||||
def radius_neighbours(knn, X, radiusX, radiusKNN, nmult=1.0,
|
||||
enforce_int32=False, verbose=True):
|
||||
"""
|
||||
Find all neigbours of a trained KNN model whose center of mass separation
|
||||
is less than `nmult` times the sum of their respective radii.
|
||||
|
|
|
@ -27,12 +27,12 @@ class PairOverlap:
|
|||
|
||||
Parameters
|
||||
----------
|
||||
cat0, catx: :py:class:`csiborgtools.read.ClumpsCatalogue`
|
||||
Halo catalogues corresponding to the reference and cross
|
||||
simulations.
|
||||
fskel : str, optional
|
||||
Path to the overlap. By default `None`, i.e.
|
||||
`/mnt/extraspace/rstiskalek/csiborg/overlap/cross_{}_{}.npz`.
|
||||
cat0 : :py:class:`csiborgtools.read.HaloCatalogue`
|
||||
Halo catalogue corresponding to the reference simulation.
|
||||
catx : :py:class:`csiborgtools.read.HaloCatalogue`
|
||||
Halo catalogue corresponding to the cross simulation.
|
||||
paths : py:class`csiborgtools.read.CSiBORGPaths`
|
||||
CSiBORG paths object.
|
||||
min_mass : float, optional
|
||||
Minimum :math:`M_{\rm tot} / M_\odot` mass in the reference catalogue.
|
||||
By default no threshold.
|
||||
|
@ -44,7 +44,7 @@ class PairOverlap:
|
|||
_catx = None
|
||||
_data = None
|
||||
|
||||
def __init__(self, cat0, catx, fskel=None, min_mass=None, max_dist=None):
|
||||
def __init__(self, cat0, catx, paths, min_mass=None, max_dist=None):
|
||||
self._cat0 = cat0
|
||||
self._catx = catx
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ for i, nsim in enumerate(paths.get_ics(tonew=True)):
|
|||
# the end save these.
|
||||
cat = csiborgtools.read.ClumpsCatalogue(nsim, paths, load_fitted=False,
|
||||
rawdata=True)
|
||||
parent_ids = cat["index"][cat.ismain][:500]
|
||||
parent_ids = cat["index"][cat.ismain]
|
||||
jobs = csiborgtools.fits.split_jobs(parent_ids.size, nproc)[rank]
|
||||
for i in tqdm(jobs) if verbose else jobs:
|
||||
clid = parent_ids[i]
|
||||
|
@ -101,6 +101,9 @@ for i, nsim in enumerate(paths.get_ics(tonew=True)):
|
|||
|
||||
mmain_mask = numpy.isin(clump_ids, mmain_indxs, assume_unique=True)
|
||||
mmain_particles = part0[mmain_mask]
|
||||
# If the number of particles is too small, we skip this halo.
|
||||
if mmain_particles.size < 100:
|
||||
continue
|
||||
|
||||
raddist, cmpos = csiborgtools.match.dist_centmass(mmain_particles)
|
||||
patchsize = csiborgtools.match.dist_percentile(raddist, [99],
|
||||
|
|
Loading…
Reference in a new issue