mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-23 02:28:02 +00:00
2185846e90
* Updat ebounds * fix mistake * add plot script * fix which sims * Add Poisson * Just docs * Hide things to __main__ * Rename paths * Move old script * Remove radpos * Paths renaming * Paths renaming * Remove trunk stuff * Add import * Add nearest neighbour search * Add Quijote fiducial indices * Add final snapshot matching * Add fiducial observer selection * add boxsizes * Add reading functions * Little stuff * Bring back the fiducial observer * Add arguments * Add quijote paths * Add notes * Get this running * Add yaml * Remove Poisson stuff * Get the 2PCF script running * Add not finished htings * Remove comment * Verbosity only on 0th rank! * Update plotting style * Add nearest neighbour CDF * Save radial distance too * Add centres * Add basic plotting
79 lines
2.4 KiB
Python
79 lines
2.4 KiB
Python
# This program is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by the
|
|
# Free Software Foundation; either version 3 of the License, or (at your
|
|
# option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
# Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
"""
|
|
Script to match all pairs of CSiBORG simulations. Mathches main haloes whose
|
|
mass is above 1e12 solar masses.
|
|
"""
|
|
from argparse import ArgumentParser
|
|
from datetime import datetime
|
|
from distutils.util import strtobool
|
|
from itertools import combinations
|
|
from random import Random
|
|
|
|
from mpi4py import MPI
|
|
|
|
try:
|
|
import csiborgtools
|
|
except ModuleNotFoundError:
|
|
import sys
|
|
|
|
sys.path.append("../")
|
|
import csiborgtools
|
|
|
|
from taskmaster import master_process, worker_process
|
|
|
|
from match_singlematch import pair_match
|
|
|
|
# Argument parser
|
|
parser = ArgumentParser()
|
|
parser.add_argument("--sigma", type=float, default=None)
|
|
parser.add_argument("--smoothen", type=lambda x: bool(strtobool(x)),
|
|
default=None)
|
|
parser.add_argument("--verbose", type=lambda x: bool(strtobool(x)),
|
|
default=False)
|
|
args = parser.parse_args()
|
|
|
|
comm = MPI.COMM_WORLD
|
|
rank = comm.Get_rank()
|
|
nproc = comm.Get_size()
|
|
|
|
|
|
def get_combs():
|
|
"""
|
|
Get the list of all pairs of simulations, then permute them with a known
|
|
seed to minimise loading the same files simultaneously.
|
|
"""
|
|
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
|
|
ics = paths.get_ics("csiborg")
|
|
combs = list(combinations(ics, 2))
|
|
Random(42).shuffle(combs)
|
|
return combs
|
|
|
|
|
|
def do_work(comb):
|
|
nsim0, nsimx = comb
|
|
pair_match(nsim0, nsimx, args.sigma, args.smoothen, args.verbose)
|
|
|
|
|
|
if nproc > 1:
|
|
if rank == 0:
|
|
combs = get_combs()
|
|
master_process(combs, comm, verbose=True)
|
|
else:
|
|
worker_process(do_work, comm, verbose=False)
|
|
else:
|
|
combs = get_combs()
|
|
for comb in combs:
|
|
print(f"{datetime.now()}: completing task `{comb}`.", flush=True)
|
|
do_work(comb)
|