From abf3c48c07ebc0f3cafc0b27e981ada0ab294adb Mon Sep 17 00:00:00 2001 From: Erik Jensen Date: Tue, 5 Nov 2024 16:26:35 +0100 Subject: [PATCH] streamline output dir wrt webpage paths; not ideal, todo: consolidate visibility.py, run_visibility.py and flows_create_visibility_plots.py --- run_visibility.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/run_visibility.py b/run_visibility.py index 54f4756..a3d37b1 100644 --- a/run_visibility.py +++ b/run_visibility.py @@ -8,6 +8,8 @@ from flows.plots import plots_interactive import flows from flows.target import Target +import re +import os.path if __name__ == '__main__': # Parse command line arguments: @@ -15,11 +17,21 @@ parser.add_argument('-t', '--target', type=str, help='TIC identifier of target.', nargs='?', default=2) parser.add_argument('-s', '--site', type=int, help='TIC identifier of target.', nargs='?', default=None) parser.add_argument('-d', '--date', type=str, help='TIC identifier of target.', nargs='?', default=None) - parser.add_argument('-o', '--output', type=str, help='TIC identifier of target.', nargs='?', default=None) + parser.add_argument('-o', '--output', type=str, help='Base output directory for visibility plots.', nargs='?', default=None) args = parser.parse_args() if args.output is None: plots_interactive() t = Target.from_tname(args.target) - flows.visibility(target=t, siteid=args.site, date=args.date, output=args.output) + + output = args.output + if output is not None: + regex_year = re.compile(r'^(\d+)') + m = regex_year.match(t.name) + year = int(m.group(1)) + output = os.path.join(output, str(year), t.name) + if not os.path.exists(output): + os.makedirs(output) + + flows.visibility(target=t, siteid=args.site, date=args.date, output=output)