mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-06-28 10:51:10 +00:00
Periodic neighbours (#84)
* Edit the HMF plot * Add periodic dist 2 points * Add boxsize to RVSSphere * Add periodic distance * Adding periodic distance * Add imports * Change arguments * Update bounds * Lower min number of particles * Change kwargs * Add paths overlap quijote * Add some comments
This commit is contained in:
parent
c7e447df01
commit
c7b600d0ad
14 changed files with 196 additions and 61 deletions
|
@ -59,10 +59,10 @@ def do_auto(args, config, cats, nsim, paths):
|
|||
-------
|
||||
None
|
||||
"""
|
||||
rvs_gen = csiborgtools.clustering.RVSinsphere(args.Rmax)
|
||||
knncdf = csiborgtools.clustering.kNN_1DCDF()
|
||||
cat = cats[nsim]
|
||||
knn = cat.knn(in_initial=False)
|
||||
rvs_gen = csiborgtools.clustering.RVSinsphere(args.Rmax, cat.boxsize)
|
||||
knncdf = csiborgtools.clustering.kNN_1DCDF()
|
||||
knn = cat.knn(in_initial=False, subtract_observer=False, periodic=True)
|
||||
rs, cdf = knncdf(
|
||||
knn, rvs_gen=rvs_gen, nneighbours=config["nneighbours"],
|
||||
rmin=config["rmin"], rmax=config["rmax"],
|
||||
|
@ -97,9 +97,9 @@ def do_cross_rand(args, config, cats, nsim, paths):
|
|||
-------
|
||||
None
|
||||
"""
|
||||
rvs_gen = csiborgtools.clustering.RVSinsphere(args.Rmax)
|
||||
cat = cats[nsim]
|
||||
knn1 = cat.knn(in_initial=False)
|
||||
rvs_gen = csiborgtools.clustering.RVSinsphere(args.Rmax, cat.boxsize)
|
||||
knn1 = cat.knn(in_initial=False, subtract_observer=False, periodic=True)
|
||||
|
||||
knn2 = NearestNeighbors()
|
||||
pos2 = rvs_gen(len(cat).shape[0])
|
||||
|
@ -126,7 +126,7 @@ if __name__ == "__main__":
|
|||
help="Simulation name")
|
||||
parser.add_argument("--nsims", type=int, nargs="+", default=None,
|
||||
help="Indices of simulations to cross. If `-1` processes all simulations.") # noqa
|
||||
parser.add_argument("--Rmax", type=float, default=155/0.705,
|
||||
parser.add_argument("--Rmax", type=float, default=155,
|
||||
help="High-resolution region radius") # noqa
|
||||
parser.add_argument("--verbose", type=lambda x: bool(strtobool(x)),
|
||||
default=False)
|
||||
|
|
|
@ -37,12 +37,12 @@ except ModuleNotFoundError:
|
|||
|
||||
|
||||
def do_auto(args, config, cats, nsim, paths):
|
||||
cat = cats[nsim]
|
||||
tpcf = csiborgtools.clustering.Mock2PCF()
|
||||
rvs_gen = csiborgtools.clustering.RVSinsphere(args.Rmax)
|
||||
rvs_gen = csiborgtools.clustering.RVSinsphere(args.Rmax, cat.boxsize)
|
||||
bins = numpy.logspace(
|
||||
numpy.log10(config["rpmin"]), numpy.log10(config["rpmax"]),
|
||||
config["nrpbins"] + 1,)
|
||||
cat = cats[nsim]
|
||||
|
||||
pos = cat.position(in_initial=False, cartesian=True)
|
||||
nrandom = int(config["randmult"] * pos.shape[0])
|
||||
|
@ -59,7 +59,7 @@ if __name__ == "__main__":
|
|||
help="Simulation name")
|
||||
parser.add_argument("--nsims", type=int, nargs="+", default=None,
|
||||
help="Indices of simulations to cross. If `-1` processes all simulations.") # noqa
|
||||
parser.add_argument("--Rmax", type=float, default=155/0.705,
|
||||
parser.add_argument("--Rmax", type=float, default=155,
|
||||
help="High-resolution region radius.")
|
||||
parser.add_argument("--verbose", type=lambda x: bool(strtobool(x)),
|
||||
default=False, help="Verbosity flag.")
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
"""
|
||||
Script to calculate the particle centre of mass, Lagrangian patch size in the
|
||||
initial snapshot. The initial snapshot particles are read from the sorted
|
||||
files.
|
||||
initial snapshot.
|
||||
|
||||
The initial snapshot particles are read from the sorted files.
|
||||
"""
|
||||
from argparse import ArgumentParser
|
||||
from datetime import datetime
|
||||
|
@ -74,7 +75,7 @@ def _main(nsim, simname, verbose):
|
|||
|
||||
# Initialise the overlapper.
|
||||
if simname == "csiborg":
|
||||
kwargs = {"box_size": 2048, "bckg_halfsize": 475}
|
||||
kwargs = {"box_size": 2048, "bckg_halfsize": 512}
|
||||
else:
|
||||
kwargs = {"box_size": 512, "bckg_halfsize": 256}
|
||||
overlapper = csiborgtools.match.ParticleOverlap(**kwargs)
|
||||
|
@ -86,7 +87,7 @@ def _main(nsim, simname, verbose):
|
|||
hid2map)
|
||||
|
||||
# Skip if the halo has no particles or is too small.
|
||||
if part is None or part.size < 100:
|
||||
if part is None or part.size < 40:
|
||||
continue
|
||||
|
||||
pos, mass = part[:, :3], part[:, 3]
|
||||
|
|
|
@ -57,12 +57,13 @@ def pair_match(nsim0, nsimx, simname, sigma, verbose):
|
|||
None
|
||||
"""
|
||||
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
|
||||
smooth_kwargs = {"sigma": sigma, "mode": "wrap"}
|
||||
smooth_kwargs = {"sigma": sigma, "mode": "constant", "cval": 0}
|
||||
|
||||
if simname == "csiborg":
|
||||
overlapper_kwargs = {"box_size": 2048, "bckg_halfsize": 475}
|
||||
overlapper_kwargs = {"box_size": 2048, "bckg_halfsize": 512}
|
||||
mass_kind = "fof_totpartmass"
|
||||
bounds = {mass_kind: (1e13, None)}
|
||||
bounds = {"dist": (0, 155), mass_kind: (10**13.25, None)}
|
||||
|
||||
cat0 = csiborgtools.read.CSiBORGHaloCatalogue(
|
||||
nsim0, paths, bounds=bounds, load_fitted=False,
|
||||
with_lagpatch=True)
|
||||
|
@ -72,11 +73,14 @@ def pair_match(nsim0, nsimx, simname, sigma, verbose):
|
|||
elif simname == "quijote":
|
||||
overlapper_kwargs = {"box_size": 512, "bckg_halfsize": 256}
|
||||
mass_kind = "group_mass"
|
||||
bounds = {mass_kind: (1e14, None)}
|
||||
bounds = {mass_kind: (10**13.25, None)}
|
||||
|
||||
cat0 = csiborgtools.read.QuijoteHaloCatalogue(
|
||||
nsim0, paths, 4, load_fitted=False, with_lagpatch=True)
|
||||
nsim0, paths, 4, bounds=bounds, load_fitted=False,
|
||||
with_lagpatch=True)
|
||||
catx = csiborgtools.read.QuijoteHaloCatalogue(
|
||||
nsimx, paths, 4, load_fitted=False, with_lagpatch=True)
|
||||
nsimx, paths, 4, bounds=bounds, load_fitted=False,
|
||||
with_lagpatch=True)
|
||||
else:
|
||||
raise ValueError(f"Unknown simulation name: `{simname}`.")
|
||||
|
||||
|
@ -116,7 +120,7 @@ def pair_match(nsim0, nsimx, simname, sigma, verbose):
|
|||
for j, match in enumerate(matches):
|
||||
match_hids[i][j] = catx["index"][match]
|
||||
|
||||
fout = paths.overlap(nsim0, nsimx, smoothed=False)
|
||||
fout = paths.overlap(simname, nsim0, nsimx, smoothed=False)
|
||||
if verbose:
|
||||
print(f"{datetime.now()}: saving to ... `{fout}`.", flush=True)
|
||||
numpy.savez(fout, ref_hids=cat0["index"], match_hids=match_hids,
|
||||
|
@ -135,7 +139,7 @@ def pair_match(nsim0, nsimx, simname, sigma, verbose):
|
|||
match_indxs, smooth_kwargs,
|
||||
verbose=verbose)
|
||||
|
||||
fout = paths.overlap(nsim0, nsimx, smoothed=True)
|
||||
fout = paths.overlap(simname, nsim0, nsimx, smoothed=True)
|
||||
if verbose:
|
||||
print(f"{datetime.now()}: saving to ... `{fout}`.", flush=True)
|
||||
numpy.savez(fout, smoothed_overlap=smoothed_overlap, sigma=sigma)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue