2023-02-05 11:46:19 +00:00
|
|
|
# Copyright (C) 2022 Richard Stiskalek
|
|
|
|
# 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 test running the CSiBORG realisations matcher.
|
|
|
|
"""
|
|
|
|
import numpy
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
from distutils.util import strtobool
|
|
|
|
from datetime import datetime
|
|
|
|
from os.path import join
|
|
|
|
try:
|
|
|
|
import csiborgtools
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
import sys
|
|
|
|
sys.path.append("../")
|
|
|
|
import csiborgtools
|
|
|
|
import utils
|
|
|
|
|
|
|
|
# Argument parser
|
|
|
|
parser = ArgumentParser()
|
2023-03-09 14:55:38 +00:00
|
|
|
parser.add_argument("--nsim0", type=int)
|
|
|
|
parser.add_argument("--nsimx", type=int)
|
2023-02-05 11:46:19 +00:00
|
|
|
parser.add_argument("--nmult", type=float)
|
|
|
|
parser.add_argument("--overlap", type=lambda x: bool(strtobool(x)))
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# File paths
|
2023-03-09 14:55:38 +00:00
|
|
|
fout = join(
|
|
|
|
utils.dumpdir, "overlap", "cross_{}_{}.npz".format(args.nsim0, args.nsimx))
|
2023-02-05 11:46:19 +00:00
|
|
|
|
|
|
|
print("{}: loading catalogues.".format(datetime.now()), flush=True)
|
2023-03-09 14:55:38 +00:00
|
|
|
cat0 = csiborgtools.read.HaloCatalogue(args.nsim0)
|
|
|
|
catx = csiborgtools.read.HaloCatalogue(args.nsimx)
|
2023-02-05 11:46:19 +00:00
|
|
|
|
2023-02-08 12:05:32 +00:00
|
|
|
matcher = csiborgtools.match.RealisationsMatcher()
|
2023-02-05 11:46:19 +00:00
|
|
|
print("{}: crossing the simulations.".format(datetime.now()), flush=True)
|
2023-02-08 12:05:32 +00:00
|
|
|
indxs, match_indxs, cross = matcher.cross(
|
2023-03-09 14:55:38 +00:00
|
|
|
args.nsim0, args.nsimx, cat0, catx, overlap=args.overlap)
|
|
|
|
|
2023-02-05 11:46:19 +00:00
|
|
|
# Dump the result
|
|
|
|
print("Saving results to `{}`.".format(fout), flush=True)
|
|
|
|
with open(fout, "wb") as f:
|
2023-02-08 12:05:32 +00:00
|
|
|
numpy.savez(fout, indxs=indxs, match_indxs=match_indxs, cross=cross)
|
2023-02-05 11:46:19 +00:00
|
|
|
|
|
|
|
print("All finished.", flush=True)
|