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:
Richard Stiskalek 2023-04-29 14:38:21 +01:00 committed by GitHub
parent c14be720b5
commit b5fefe4196
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 24 deletions

View file

@ -115,9 +115,9 @@ class RealisationsMatcher:
Parameters Parameters
---------- ----------
cat0 : :py:class:`csiborgtools.read.ClumpsCatalogue` cat0 : :py:class:`csiborgtools.read.HaloCatalogue`
Halo catalogue of the reference simulation. Halo catalogue of the reference simulation.
catx : :py:class:`csiborgtools.read.ClumpsCatalogue` catx : :py:class:`csiborgtools.read.HaloCatalogue`
Halo catalogue of the cross simulation. Halo catalogue of the cross simulation.
halos0_archive : `NpzFile` object halos0_archive : `NpzFile` object
Archive of halos' particles of the reference simulation, keys must Archive of halos' particles of the reference simulation, keys must
@ -198,10 +198,8 @@ class RealisationsMatcher:
except KeyError: except KeyError:
halox = halosx_archive[str(kf)] halox = halosx_archive[str(kf)]
minsx, maxsx = get_halolims( minsx, maxsx = get_halolims(
halox, halox, ncells=self.overlapper.inv_clength,
ncells=self.overlapper.inv_clength, nshift=self.overlapper.nshift)
nshift=self.overlapper.nshift,
)
for p in ("x", "y", "z"): for p in ("x", "y", "z"):
halox[p] = self.overlapper.pos2cell(halox[p]) halox[p] = self.overlapper.pos2cell(halox[p])
cross_halos[kf] = halox cross_halos[kf] = halox
@ -768,9 +766,8 @@ def calculate_overlap(delta1, delta2, cellmins, delta_bckg):
@jit(nopython=True) @jit(nopython=True)
def calculate_overlap_indxs( def calculate_overlap_indxs(delta1, delta2, cellmins, delta_bckg, nonzero,
delta1, delta2, cellmins, delta_bckg, nonzero, mass1, mass2 mass1, mass2):
):
r""" r"""
Overlap between two clumps whose density fields are evaluated on the Overlap between two clumps whose density fields are evaluated on the
same grid and `nonzero1` enumerates the non-zero cells of `delta1. This is same grid and `nonzero1` enumerates the non-zero cells of `delta1. This is
@ -841,15 +838,14 @@ def dist_centmass(clump):
Center of mass coordinates. Center of mass coordinates.
""" """
# CM along each dimension # CM along each dimension
cmx, cmy, cmz = [ cmx, cmy, cmz = [numpy.average(clump[p], weights=clump["M"])
numpy.average(clump[p], weights=clump["M"]) for p in ("x", "y", "z") for p in ("x", "y", "z")]
]
# Particle distance from the CM # Particle distance from the CM
dist = numpy.sqrt( dist = numpy.sqrt(
numpy.square(clump["x"] - cmx) numpy.square(clump["x"] - cmx)
+ numpy.square(clump["y"] - cmy) + numpy.square(clump["y"] - cmy)
+ numpy.square(clump["z"] - cmz) + numpy.square(clump["z"] - cmz)
) )
return dist, numpy.asarray([cmx, cmy, cmz]) return dist, numpy.asarray([cmx, cmy, cmz])
@ -876,9 +872,8 @@ def dist_percentile(dist, qs, distmax=0.075):
return x return x
def radius_neighbours( def radius_neighbours(knn, X, radiusX, radiusKNN, nmult=1.0,
knn, X, radiusX, radiusKNN, nmult=1.0, enforce_int32=False, verbose=True enforce_int32=False, verbose=True):
):
""" """
Find all neigbours of a trained KNN model whose center of mass separation Find all neigbours of a trained KNN model whose center of mass separation
is less than `nmult` times the sum of their respective radii. is less than `nmult` times the sum of their respective radii.

View file

@ -27,12 +27,12 @@ class PairOverlap:
Parameters Parameters
---------- ----------
cat0, catx: :py:class:`csiborgtools.read.ClumpsCatalogue` cat0 : :py:class:`csiborgtools.read.HaloCatalogue`
Halo catalogues corresponding to the reference and cross Halo catalogue corresponding to the reference simulation.
simulations. catx : :py:class:`csiborgtools.read.HaloCatalogue`
fskel : str, optional Halo catalogue corresponding to the cross simulation.
Path to the overlap. By default `None`, i.e. paths : py:class`csiborgtools.read.CSiBORGPaths`
`/mnt/extraspace/rstiskalek/csiborg/overlap/cross_{}_{}.npz`. CSiBORG paths object.
min_mass : float, optional min_mass : float, optional
Minimum :math:`M_{\rm tot} / M_\odot` mass in the reference catalogue. Minimum :math:`M_{\rm tot} / M_\odot` mass in the reference catalogue.
By default no threshold. By default no threshold.
@ -44,7 +44,7 @@ class PairOverlap:
_catx = None _catx = None
_data = 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._cat0 = cat0
self._catx = catx self._catx = catx

View file

@ -93,7 +93,7 @@ for i, nsim in enumerate(paths.get_ics(tonew=True)):
# the end save these. # the end save these.
cat = csiborgtools.read.ClumpsCatalogue(nsim, paths, load_fitted=False, cat = csiborgtools.read.ClumpsCatalogue(nsim, paths, load_fitted=False,
rawdata=True) 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] jobs = csiborgtools.fits.split_jobs(parent_ids.size, nproc)[rank]
for i in tqdm(jobs) if verbose else jobs: for i in tqdm(jobs) if verbose else jobs:
clid = parent_ids[i] 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_mask = numpy.isin(clump_ids, mmain_indxs, assume_unique=True)
mmain_particles = part0[mmain_mask] 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) raddist, cmpos = csiborgtools.match.dist_centmass(mmain_particles)
patchsize = csiborgtools.match.dist_percentile(raddist, [99], patchsize = csiborgtools.match.dist_percentile(raddist, [99],