Change file naming convention (#25)

This commit is contained in:
Richard Stiskalek 2023-01-17 11:47:11 +00:00 committed by GitHub
parent 830b1b8daf
commit 3bdadc4750
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,6 @@ import numpy
from datetime import datetime from datetime import datetime
from mpi4py import MPI from mpi4py import MPI
from os.path import join from os.path import join
from os import remove
try: try:
import csiborgtools import csiborgtools
except ModuleNotFoundError: except ModuleNotFoundError:
@ -34,8 +33,8 @@ rank = comm.Get_rank()
nproc = comm.Get_size() nproc = comm.Get_size()
# File paths # File paths
ftemp = join(utils.dumpdir, "temp_match", "match_{}.npy") fperm = join(utils.dumpdir, "overlap", "cross_{}.npy")
fperm = join(utils.dumpdir, "match", "cross_matches.npy") # fperm = join(utils.dumpdir, "match", "cross_matches.npy")
# Set up the catalogue # Set up the catalogue
paths = csiborgtools.read.CSiBORGPaths(to_new=False) paths = csiborgtools.read.CSiBORGPaths(to_new=False)
@ -53,26 +52,16 @@ for i in csiborgtools.fits.split_jobs(len(cat.n_sims), nproc)[rank]:
print("{}: rank {} working on simulation `{}`." print("{}: rank {} working on simulation `{}`."
.format(datetime.now(), rank, n), flush=True) .format(datetime.now(), rank, n), flush=True)
out = matcher.cross_knn_position_single( out = matcher.cross_knn_position_single(
i, nmult=15, dlogmass=2, init_dist=True, overlap=True, verbose=False, i, nmult=15, dlogmass=2, init_dist=True, overlap=False, verbose=False,
overlapper_kwargs={"smooth_scale": 0.5}) overlapper_kwargs={"smooth_scale": 1})
# Dump the result # Dump the result
with open(ftemp.format(n), "wb") as f: fout = fperm.format(n)
numpy.save(f, out) print("Saving results to `{}`.".format(fout))
with open(fout, "wb") as f:
numpy.save(fout, out)
comm.Barrier() comm.Barrier()
if rank == 0: if rank == 0:
print("Collecting files...", flush=True) print("All finished.")
dtype = {"names": ["match", "nsim"], "formats": [object, numpy.int32]}
matches = numpy.full(len(cat.n_sims), numpy.nan, dtype=dtype)
for i, n in enumerate(cat.n_sims):
with open(ftemp.format(n), "rb") as f:
matches["match"][i] = numpy.load(f, allow_pickle=True)
matches["nsim"][i] = n
remove(ftemp.format(n))
print("Saving results to `{}`.".format(fperm))
with open(fperm, "wb") as f:
numpy.save(f, matches)