Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:18

0001 # This file is part of the ACTS project.
0002 #
0003 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 #
0005 # This Source Code Form is subject to the terms of the Mozilla Public
0006 # License, v. 2.0. If a copy of the MPL was not distributed with this
0007 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 import argparse
0010 import os
0011 import sys
0012 
0013 # ------------------------------------------------------------------------------
0014 # Options parsing
0015 # ------------------------------------------------------------------------------
0016 
0017 """ Parent parser that contains plotting options """
0018 
0019 
0020 def plotting_options():
0021 
0022     parser = argparse.ArgumentParser(add_help=False)
0023 
0024     parser.add_argument(
0025         "--inputdir",
0026         "-i",
0027         help=("Directory containing input data files."),
0028         default="./",
0029         type=str,
0030     )
0031     parser.add_argument(
0032         "--outdir",
0033         "-o",
0034         help=("Output directory for plots."),
0035         default="./plots/",
0036         type=str,
0037     )
0038     parser.add_argument(
0039         "--output_format",
0040         "-of",
0041         help=("Format of the plot files (svg|png|pdf)."),
0042         default="pdf",
0043         type=str,
0044     )
0045 
0046     return parser
0047 
0048 
0049 """ Parse plotting options from commandline """
0050 
0051 
0052 def parse_plotting_options(args, logging):
0053 
0054     # Check input path
0055     if args.inputdir and not os.path.isdir(args.inputdir):
0056         logging.error(f"Plot data director does not exist! ({args.inputdir})")
0057         sys.exit(1)
0058 
0059     # Check output path
0060     if not os.path.isdir(args.outdir):
0061         os.mkdir(args.outdir, 0o755)
0062 
0063     if args.output_format not in ["svg", "png", "pdf"]:
0064         logging.error(f"Unknown output file format: {out_format}")
0065         sys.exit(1)
0066 
0067     return args.inputdir, args.outdir, args.output_format