mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-14 02:23:32 +01:00
ZH: use argparse for fig_dir
This commit is contained in:
parent
8c1eb516e8
commit
8ec7ab05ed
10 changed files with 15 additions and 11 deletions
|
@ -29,7 +29,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
fname = "ZH_airshower/mysim.sry"
|
fname = "ZH_airshower/mysim.sry"
|
||||||
|
|
||||||
fig_dir = "./figures/"
|
fig_dir = args.fig_dir
|
||||||
show_plots = args.show_plots
|
show_plots = args.show_plots
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
|
@ -43,7 +43,7 @@ if __name__ == "__main__":
|
||||||
fname_dir = path.dirname(fname)
|
fname_dir = path.dirname(fname)
|
||||||
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
||||||
|
|
||||||
fig_dir = "./figures" # set None to disable saving
|
fig_dir = args.fig_dir # set None to disable saving
|
||||||
|
|
||||||
if not path.isfile(antennas_fname):
|
if not path.isfile(antennas_fname):
|
||||||
print("Antenna file cannot be found, did you try generating a beacon?")
|
print("Antenna file cannot be found, did you try generating a beacon?")
|
||||||
|
|
|
@ -33,7 +33,7 @@ if __name__ == "__main__":
|
||||||
fname_dir = path.dirname(fname)
|
fname_dir = path.dirname(fname)
|
||||||
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
||||||
|
|
||||||
fig_dir = "./figures" # set None to disable saving
|
fig_dir = args.fig_dir # set None to disable saving
|
||||||
|
|
||||||
if not path.isfile(antennas_fname):
|
if not path.isfile(antennas_fname):
|
||||||
print("Antenna file cannot be found, did you try generating a beacon?")
|
print("Antenna file cannot be found, did you try generating a beacon?")
|
||||||
|
|
|
@ -33,7 +33,7 @@ if __name__ == "__main__":
|
||||||
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
||||||
time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname
|
time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname
|
||||||
|
|
||||||
fig_dir = "./figures" # set None to disable saving
|
fig_dir = args.fig_dir # set None to disable saving
|
||||||
|
|
||||||
if not path.isfile(antennas_fname):
|
if not path.isfile(antennas_fname):
|
||||||
print("Antenna file cannot be found, did you try generating a beacon?")
|
print("Antenna file cannot be found, did you try generating a beacon?")
|
||||||
|
|
|
@ -34,7 +34,7 @@ if __name__ == "__main__":
|
||||||
fname_dir = path.dirname(fname)
|
fname_dir = path.dirname(fname)
|
||||||
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
||||||
time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname
|
time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname
|
||||||
fig_dir = "./figures" # set None to disable saving
|
fig_dir = args.fig_dir # set None to disable saving
|
||||||
|
|
||||||
basenames, time_diffs, f_beacons, true_phase_diffs, k_periods = beacon.read_baseline_time_diffs_hdf5(time_diffs_fname)
|
basenames, time_diffs, f_beacons, true_phase_diffs, k_periods = beacon.read_baseline_time_diffs_hdf5(time_diffs_fname)
|
||||||
|
|
||||||
|
|
|
@ -150,12 +150,12 @@ if __name__ == "__main__":
|
||||||
atm = AtmoCal()
|
atm = AtmoCal()
|
||||||
|
|
||||||
from scriptlib import MyArgumentParser
|
from scriptlib import MyArgumentParser
|
||||||
parser = MyArgumentParser()
|
parser = MyArgumentParser(default_fig_dir="./figures/periods_from_shower_figures/")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
fname = "ZH_airshower/mysim.sry"
|
fname = "ZH_airshower/mysim.sry"
|
||||||
|
|
||||||
fig_dir = "./figures/periods_from_shower_figures/"
|
fig_dir = args.fig_dir
|
||||||
fig_subdir = path.join(fig_dir, 'shifts/')
|
fig_subdir = path.join(fig_dir, 'shifts/')
|
||||||
show_plots = args.show_plots
|
show_plots = args.show_plots
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
fname = "ZH_airshower/mysim.sry"
|
fname = "ZH_airshower/mysim.sry"
|
||||||
|
|
||||||
fig_dir = "./figures" # set None to disable saving
|
fig_dir = args.fig_dir # set None to disable saving
|
||||||
show_plots = args.show_plots
|
show_plots = args.show_plots
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
|
@ -34,7 +34,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
fname = "ZH_airshower/mysim.sry"
|
fname = "ZH_airshower/mysim.sry"
|
||||||
|
|
||||||
fig_dir = "./figures/"
|
fig_dir = args.fig_dir
|
||||||
fig_subdir = path.join(fig_dir, 'reconstruction')
|
fig_subdir = path.join(fig_dir, 'reconstruction')
|
||||||
show_plots = args.show_plots
|
show_plots = args.show_plots
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
fname = "ZH_airshower/mysim.sry"
|
fname = "ZH_airshower/mysim.sry"
|
||||||
|
|
||||||
fig_dir = "./figures/"
|
fig_dir = args.fig_dir
|
||||||
show_plots = args.show_plots
|
show_plots = args.show_plots
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
|
@ -4,11 +4,12 @@ Some preconfigured ArgumentParser
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
def MyArgumentParser(default_show_plots=False, **kwargs):
|
def MyArgumentParser(default_fig_dir='./figures', default_show_plots=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
A somewhat preconfigured ArgumentParser
|
A somewhat preconfigured ArgumentParser
|
||||||
|
|
||||||
Set show_plots=True to by default enable showing plots.
|
Set show_plots=True to by default enable showing plots.
|
||||||
|
Likewise, set fig_dir=None to by default disable saving figures.
|
||||||
"""
|
"""
|
||||||
parser = ArgumentParser(**kwargs)
|
parser = ArgumentParser(**kwargs)
|
||||||
|
|
||||||
|
@ -17,4 +18,7 @@ def MyArgumentParser(default_show_plots=False, **kwargs):
|
||||||
parser.add_argument('--no-show-plots', dest='show-plots', action='store_false')
|
parser.add_argument('--no-show-plots', dest='show-plots', action='store_false')
|
||||||
parser.set_defaults(show_plots=default_show_plots)
|
parser.set_defaults(show_plots=default_show_plots)
|
||||||
|
|
||||||
|
# Figures directory
|
||||||
|
parser.add_argument('--fig-dir', type=str, default=default_fig_dir)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
Loading…
Reference in a new issue