Skip to content

Commit

Permalink
Accepting only sim2root directory (structure) as input; added output …
Browse files Browse the repository at this point in the history
…directory
  • Loading branch information
lwpiotr committed Feb 16, 2024
1 parent a18207a commit 32e8ad4
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions scripts/convert_efield2voltage.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ def manage_args():
description="Calculation of DU response in volt for first event in Efield input file."
)
parser.add_argument(
"file",
help="Efield input data file in GRANDROOT format.",
type=argparse.FileType("r"),
"directory",
help="Simulation output data directory in GRANDROOT format.",
# type=argparse.FileType("r"),
)
# parser.add_argument(
# "file",
# help="Efield input data file in GRANDROOT format.",
# type=argparse.FileType("r"),
# )
parser.add_argument(
"--no_noise",
action="store_false",
Expand All @@ -76,12 +81,18 @@ def manage_args():
parser.add_argument(
"-o",
"--out_file",
default="",
default=None,
help="output file in GRANDROOT format. If the file exists it is overwritten.",
required=True,
# required=True,
# PB with option ???
# type=argparse.FileType("w"),
)
parser.add_argument(
"-od",
"--out_directory",
default=None,
help="output directory in GRANDROOT format. If not given, is it the same as input directory",
)
parser.add_argument(
"--verbose",
choices=["debug", "info", "warning", "error", "critical"],
Expand Down Expand Up @@ -136,14 +147,20 @@ def manage_args():
logger.info("Computing voltage from the input electric field.")

args = manage_args()

# If no output directory given, define it as input directory
if args.out_directory is None:
args.out_directory = args.directory

# define a handler for logger : standard only
mlg.create_output_for_logger(args.verbose, log_stdout=True)
logger.info(mlg.string_begin_script())
# =============================================
seed = None if args.seed==-1 else args.seed
logger.info(f"seed used for random number generator is {seed}.")

signal = Efield2Voltage(args.file.name, args.out_file, seed=seed, padding_factor=args.padding_factor)
# signal = Efield2Voltage(args.file.name, args.out_file, seed=seed, padding_factor=args.padding_factor)
signal = Efield2Voltage(args.directory, args.out_file, output_directory=args.out_directory, seed=seed, padding_factor=args.padding_factor)
signal.params["add_noise"] = args.no_noise
signal.params["add_rf_chain"] = args.no_rf_chain
signal.params["lst"] = args.lst
Expand Down

0 comments on commit 32e8ad4

Please sign in to comment.