2023-01-12 14:31:21 +01:00
|
|
|
"""
|
|
|
|
Some preconfigured ArgumentParser
|
|
|
|
"""
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
2023-02-02 16:42:16 +01:00
|
|
|
def MyArgumentParser(
|
|
|
|
default_fig_dir='./figures',
|
|
|
|
default_show_plots=False,
|
2023-02-02 17:55:37 +01:00
|
|
|
default_data_dir='./ZH_airshower',
|
2023-02-02 16:42:16 +01:00
|
|
|
**kwargs):
|
2023-01-12 14:31:21 +01:00
|
|
|
"""
|
2023-02-02 16:42:16 +01:00
|
|
|
A somewhat preconfigured ArgumentParser to be shared across
|
|
|
|
multiple scripts.
|
2023-01-12 14:31:21 +01:00
|
|
|
|
|
|
|
Set show_plots=True to by default enable showing plots.
|
2023-01-12 14:49:54 +01:00
|
|
|
Likewise, set fig_dir=None to by default disable saving figures.
|
2023-01-12 14:31:21 +01:00
|
|
|
"""
|
|
|
|
parser = ArgumentParser(**kwargs)
|
|
|
|
|
|
|
|
# Whether to show plots
|
2023-02-02 16:42:16 +01:00
|
|
|
group1 = parser.add_mutually_exclusive_group(required=False)
|
|
|
|
group1.add_argument('--show-plots', action='store_true', default=default_show_plots, help='Default: %(default)s')
|
|
|
|
group1.add_argument('--no-show-plots', dest='show-plots', action='store_false')
|
2023-01-12 14:31:21 +01:00
|
|
|
|
2023-02-02 17:55:37 +01:00
|
|
|
# Data directory
|
|
|
|
parser.add_argument('--data-dir', type=str, default=default_data_dir, help='Path to Data Directory. (Default: %(default)s)')
|
|
|
|
|
2023-01-12 14:49:54 +01:00
|
|
|
# Figures directory
|
2023-02-02 16:42:16 +01:00
|
|
|
parser.add_argument('--fig-dir', type=str, default=default_fig_dir, help='Set None to disable saving figures. (Default: %(default)s)')
|
2023-01-12 14:49:54 +01:00
|
|
|
|
2023-01-12 14:31:21 +01:00
|
|
|
return parser
|