-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move the processing code to this repo
- Loading branch information
1 parent
7599351
commit 74d8512
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python | ||
# | ||
# FPFS shear estimator | ||
# Copyright 20221013 Xiangchong Li. | ||
# | ||
# 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. | ||
# | ||
|
||
import schwimmbad | ||
from argparse import ArgumentParser | ||
from configparser import ConfigParser, ExtendedInterpolation | ||
from fpfs.tasks import ProcessSimulationTask | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = ArgumentParser(description="fpfs measurement") | ||
parser.add_argument( | ||
"--config", | ||
required=True, | ||
type=str, | ||
help="configure file name", | ||
) | ||
parser.add_argument( | ||
"--min_id", | ||
required=True, | ||
type=int, | ||
help="minimum ID, e.g. 0", | ||
) | ||
parser.add_argument( | ||
"--max_id", | ||
required=True, | ||
type=int, | ||
help="maximum ID, e.g. 4000", | ||
) | ||
group = parser.add_mutually_exclusive_group() | ||
group.add_argument( | ||
"--ncores", | ||
dest="n_cores", | ||
default=1, | ||
type=int, | ||
help="Number of processes (uses multiprocessing).", | ||
) | ||
group.add_argument( | ||
"--mpi", | ||
dest="mpi", | ||
default=False, | ||
action="store_true", | ||
help="Run with MPI.", | ||
) | ||
args = parser.parse_args() | ||
pool = schwimmbad.choose_pool(mpi=args.mpi, processes=args.n_cores) | ||
worker = ProcessSimulationTask(args.config) | ||
refs = list(range(args.min_id, args.max_id)) | ||
for r in pool.map(worker.run, refs): | ||
pass | ||
pool.close() |