Reformat help_msg dict and doc strings

这个提交包含在:
nmannall
2024-03-04 16:16:26 +00:00
父节点 67535c0add
当前提交 20b45fcb78

查看文件

@@ -44,34 +44,48 @@ args_defaults = {
# Argument help messages (used for CLI argparse)
help_msg = {
"scenes": "(list, req): Scenes to run the model. Multiple scene objects "
"can given in order to run multiple simulation runs. Each scene "
"must contain the essential simulation objects",
"inputfile": "(str, opt): Input file path. Can also run simulation by " "providing an input file.",
"scenes": (
"(list, req): Scenes to run the model. Multiple scene objects can given in order to run"
" multiple simulation runs. Each scene must contain the essential simulation objects"
),
"inputfile": "(str, opt): Input file path. Can also run simulation by providing an input file.",
"outputfile": "(str, req): File path to the output data file.",
"n": "(int, req): Number of required simulation runs.",
"i": "(int, opt): Model number to start/restart simulation from. It would "
"typically be used to restart a series of models from a specific "
"model number, with the n argument, e.g. to restart from A-scan 45 "
"when creating a B-scan with 60 traces.",
"taskfarm": "(bool, opt): Flag to use Message Passing Interface (MPI) task farm. "
"This option is most usefully combined with n to allow individual "
"models to be farmed out using a MPI task farm, e.g. to create a "
"B-scan with 60 traces and use MPI to farm out each trace. For "
"further details see the performance section of the User Guide.",
"gpu": "(list/bool, opt): Flag to use NVIDIA GPU or list of NVIDIA GPU " "device ID(s) for specific GPU card(s).",
"opencl": "(list/bool, opt): Flag to use OpenCL or list of OpenCL device " "ID(s) for specific compute device(s).",
"i": (
"(int, opt): Model number to start/restart simulation from. It would typically be used to"
" restart a series of models from a specific model number, with the n argument, e.g. to"
" restart from A-scan 45 when creating a B-scan with 60 traces."
),
"taskfarm": (
"(bool, opt): Flag to use Message Passing Interface (MPI) task farm. This option is most"
" usefully combined with n to allow individual models to be farmed out using a MPI task"
" farm, e.g. to create a B-scan with 60 traces and use MPI to farm out each trace. For"
" further details see the performance section of the User Guide."
),
"gpu": (
"(list/bool, opt): Flag to use NVIDIA GPU or list of NVIDIA GPU device ID(s) for specific"
" GPU card(s)."
),
"opencl": (
"(list/bool, opt): Flag to use OpenCL or list of OpenCL device ID(s) for specific compute"
" device(s)."
),
"subgrid": "(bool, opt): Flag to use sub-gridding.",
"autotranslate": "(bool, opt): For sub-gridding - auto translate objects "
"with main grid coordinates to their equivalent local "
"grid coordinate within the subgrid. If this option is "
"off users must specify sub-grid object point within the "
"global subgrid space.",
"geometry_only": "(bool, opt): Build a model and produce any geometry " "views but do not run the simulation.",
"geometry_fixed": "(bool, opt): Run a series of models where the geometry " "does not change between models.",
"write_processed": "(bool, opt): Writes another input file after any "
"Python code (#python blocks) and in the original input "
"file has been processed.",
"autotranslate": (
"(bool, opt): For sub-gridding - auto translate objects with main grid coordinates to their"
" equivalent local grid coordinate within the subgrid. If this option is off users must"
" specify sub-grid object point within the global subgrid space."
),
"geometry_only": (
"(bool, opt): Build a model and produce any geometry views but do not run the simulation."
),
"geometry_fixed": (
"(bool, opt): Run a series of models where the geometry does not change between models."
),
"write_processed": (
"(bool, opt): Writes another input file after any Python code (#python blocks) and in the"
" original input file has been processed."
),
"log_level": "(int, opt): Level of logging to use.",
"log_file": "(bool, opt): Write logging information to file.",
}
@@ -94,44 +108,47 @@ def run(
log_level=args_defaults["log_level"],
log_file=args_defaults["log_file"],
):
"""Entry point for application programming interface (API). Runs the
simulation for the given list of scenes.
"""Entry point for application programming interface (API).
Runs the simulation for the given list of scenes.
Args:
scenes: list of the scenes to run the model. Multiple scene objects can
be given in order to run multiple simulation runs. Each scene
must contain the essential simulation objects.
inputfile: optional string for input file path. Can also run simulation
by providing an input file.
scenes: list of the scenes to run the model. Multiple scene
objects can be given in order to run multiple simulation
runs. Each scene must contain the essential simulation
objects.
inputfile: optional string for input file path. Can also run
simulation by providing an input file.
outputfile: string for file path to the output data file
n: optional int for number of required simulation runs.
i: optional int for model number to start/restart simulation from.
It would typically be used to restart a series of models from a
specific model number, with the n argument, e.g. to restart from
A-scan 45 when creating a B-scan with 60 traces.
taskfarm: optional boolean flag to use Message Passing Interface (MPI) task
farm. This option is most usefully combined with n to allow
individual models to be farmed out using a MPI task farm,
e.g. to create a B-scan with 60 traces and use MPI to farm out
each trace. For further details see the performance section of
the User Guide
gpu: optional list/boolean to use NVIDIA GPU or list of NVIDIA GPU device
ID(s) for specific GPU card(s).
opencl: optional list/boolean to use OpenCL or list of OpenCL device ID(s)
for specific compute device(s).
i: optional int for model number to start/restart simulation
from. It would typically be used to restart a series of
models from a specific model number, with the n argument,
e.g. to restart from A-scan 45 when creating a B-scan with
60 traces.
taskfarm: optional boolean flag to use Message Passing Interface
(MPI) task farm. This option is most usefully combined with
n to allow individual models to be farmed out using a MPI
task farm, e.g. to create a B-scan with 60 traces and use
MPI to farm out each trace. For further details see the
performance section of the User Guide
gpu: optional list/boolean to use NVIDIA GPU or list of NVIDIA
GPU device ID(s) for specific GPU card(s).
opencl: optional list/boolean to use OpenCL or list of OpenCL
device ID(s) for specific compute device(s).
subgrid: optional boolean to use sub-gridding.
autotranslate: optional boolean for sub-gridding to auto translate
objects with main grid coordinates to their equivalent
local grid coordinate within the subgrid. If this option
is off users must specify sub-grid object point within
the global subgrid space.
autotranslate: optional boolean for sub-gridding to auto
translate objects with main grid coordinates to their
equivalent local grid coordinate within the subgrid. If this
option is off users must specify sub-grid object point
within the global subgrid space.
geometry_only: optional boolean to build a model and produce any
geometry views but do not run the simulation.
geometry_fixed: optional boolean to run a series of models where the
geometry does not change between models.
write_processed: optional boolean to write another input file after any
#python blocks (which are deprecated) in the
original input file has been processed.
geometry views but do not run the simulation.
geometry_fixed: optional boolean to run a series of models where
the geometry does not change between models.
write_processed: optional boolean to write another input file
after any #python blocks (which are deprecated) in the
original input file has been processed.
log_level: optional int for level of logging to use.
log_file: optional boolean to write logging information to file.
"""
@@ -163,16 +180,26 @@ def cli():
"""Entry point for command line interface (CLI)."""
# Parse command line arguments
parser = argparse.ArgumentParser(prog="gprMax", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser = argparse.ArgumentParser(
prog="gprMax", formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("inputfile", help=help_msg["inputfile"])
parser.add_argument("-outputfile", "-o", help=help_msg["outputfile"])
parser.add_argument("-n", default=args_defaults["n"], type=int, help=help_msg["n"])
parser.add_argument("-i", type=int, help=help_msg["i"])
parser.add_argument("-taskfarm", action="store_true", default=args_defaults["taskfarm"], help=help_msg["taskfarm"])
parser.add_argument(
"-taskfarm",
action="store_true",
default=args_defaults["taskfarm"],
help=help_msg["taskfarm"],
)
parser.add_argument("-gpu", type=int, action="append", nargs="*", help=help_msg["gpu"])
parser.add_argument("-opencl", type=int, action="append", nargs="*", help=help_msg["opencl"])
parser.add_argument(
"--geometry-only", action="store_true", default=args_defaults["geometry_only"], help=help_msg["geometry_only"]
"--geometry-only",
action="store_true",
default=args_defaults["geometry_only"],
help=help_msg["geometry_only"],
)
parser.add_argument(
"--geometry-fixed",
@@ -186,8 +213,15 @@ def cli():
default=args_defaults["write_processed"],
help=help_msg["write_processed"],
)
parser.add_argument("--log-level", type=int, default=args_defaults["log_level"], help=help_msg["log_level"])
parser.add_argument("--log-file", action="store_true", default=args_defaults["log_file"], help=help_msg["log_file"])
parser.add_argument(
"--log-level", type=int, default=args_defaults["log_level"], help=help_msg["log_level"]
)
parser.add_argument(
"--log-file",
action="store_true",
default=args_defaults["log_file"],
help=help_msg["log_file"],
)
args = parser.parse_args()
results = run_main(args)
@@ -202,8 +236,9 @@ def run_main(args):
args: namespace with arguments from either API or CLI.
Returns:
results: dict that can contain useful results/data from simulation.
Enables these to be propagated to calling script.
results: dict that can contain useful results/data from
simulation. Enables these to be propagated to calling
script.
"""
results = {}