From fc52dd9a8af5a4f4804bcecaff3cfb3d2fe6a378 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Mon, 1 Jan 2024 01:42:08 +0000 Subject: [PATCH 1/6] Overlay filename on trackstack --- Utils/TrackStack.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Utils/TrackStack.py b/Utils/TrackStack.py index 1876d018a..8dc70cd03 100644 --- a/Utils/TrackStack.py +++ b/Utils/TrackStack.py @@ -29,7 +29,8 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, hide_plot=False, showers=None, darkbackground=False, out_dir=None, - scalefactor=None, draw_constellations=False, one_core_free=False): + scalefactor=None, draw_constellations=False, one_core_free=False, + overlay_file_name=False): """ Generate a stack with aligned stars, so the sky appears static. The folder should have a platepars_all_recalibrated.json file. @@ -47,6 +48,7 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, darkbackground: [bool] force the sky background to be dark out_dir: target folder to save into scalefactor: factor to scale the canvas by; default 1, increase if image cropped + overlay_file_name: [bool] show the filename on the completed image """ start_time = time.time() # normalise the path in a platform neutral way @@ -334,6 +336,11 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, filenam = os.path.join(out_dir, os.path.basename(dir_path) + "_track_stack.jpg") else: filenam = os.path.join(dir_path, os.path.basename(dir_path) + "_track_stack.jpg") + + if overlay_file_name: + print("Overlaying filename: {}".format(os.path.basename(filenam))) + ax.text(10, stack_img.shape[0] + 30, os.path.basename(filenam), color='grey', fontsize=6, fontname='Source Sans Pro', + weight='ultralight') plt.savefig(filenam, bbox_inches='tight', pad_inches=0, dpi=dpi, facecolor='k', edgecolor='k') print('saved to {}'.format(filenam)) # @@ -476,6 +483,9 @@ def getArray(size, shared_arr): arg_parser.add_argument('-o', '--output', type=str, help="""folder to save the image in.""") + arg_parser.add_argument('-n', '--overlayfilename', action="store_true", + help="""Overlay filename on image.""") + arg_parser.add_argument('-f', '--scalefactor', type=int, help="""scale factor to apply. Increase if image is cropped""") @@ -508,4 +518,5 @@ def getArray(size, shared_arr): trackStack(dir_paths, config, background_compensation=(not cml_args.bkgnormoff), hide_plot=cml_args.hideplot, showers=showers, darkbackground=cml_args.darkbackground, out_dir=cml_args.output, scalefactor=cml_args.scalefactor, - draw_constellations=cml_args.constellations, one_core_free=cml_args.freecore) + draw_constellations=cml_args.constellations, one_core_free=cml_args.freecore, + overlay_file_name = cml_args.overlayfilename) From 1f07fc9e5c1d1a8a6f7e72c8277cbc32f7782750 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Mon, 1 Jan 2024 01:52:28 +0000 Subject: [PATCH 2/6] Overlay filename on trackstack --- Utils/TrackStack.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Utils/TrackStack.py b/Utils/TrackStack.py index 8dc70cd03..1fbf84382 100644 --- a/Utils/TrackStack.py +++ b/Utils/TrackStack.py @@ -337,6 +337,8 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, else: filenam = os.path.join(dir_path, os.path.basename(dir_path) + "_track_stack.jpg") + # Overlay the filename on the image + if overlay_file_name: print("Overlaying filename: {}".format(os.path.basename(filenam))) ax.text(10, stack_img.shape[0] + 30, os.path.basename(filenam), color='grey', fontsize=6, fontname='Source Sans Pro', From e6cc128291f1184338f135c0b2ca882f225b1f23 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Mon, 1 Jan 2024 01:52:56 +0000 Subject: [PATCH 3/6] Tidy formatting --- Utils/TrackStack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utils/TrackStack.py b/Utils/TrackStack.py index 1fbf84382..ab3d3a691 100644 --- a/Utils/TrackStack.py +++ b/Utils/TrackStack.py @@ -338,11 +338,11 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, filenam = os.path.join(dir_path, os.path.basename(dir_path) + "_track_stack.jpg") # Overlay the filename on the image - if overlay_file_name: print("Overlaying filename: {}".format(os.path.basename(filenam))) ax.text(10, stack_img.shape[0] + 30, os.path.basename(filenam), color='grey', fontsize=6, fontname='Source Sans Pro', weight='ultralight') + plt.savefig(filenam, bbox_inches='tight', pad_inches=0, dpi=dpi, facecolor='k', edgecolor='k') print('saved to {}'.format(filenam)) # From daa7c03be90cbf54903e9152ed50439d93ba91f1 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Mon, 1 Jan 2024 02:15:47 +0000 Subject: [PATCH 4/6] Add keyword arguments to docstring --- Utils/TrackStack.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Utils/TrackStack.py b/Utils/TrackStack.py index ab3d3a691..d0f312765 100644 --- a/Utils/TrackStack.py +++ b/Utils/TrackStack.py @@ -35,7 +35,7 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, platepars_all_recalibrated.json file. Arguments: - dir_path: [str] Path to the directory with image files. + dir_paths: [str] Path to the directory with image files. config: [Config instance] Keyword arguments: @@ -48,6 +48,8 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, darkbackground: [bool] force the sky background to be dark out_dir: target folder to save into scalefactor: factor to scale the canvas by; default 1, increase if image cropped + draw_constellations: [bool] Show constellation lines on stacked image + one_core_free: [bool] leave one core free whilst processing overlay_file_name: [bool] show the filename on the completed image """ start_time = time.time() From 1cdf100eb976a8ce9e7b95564f5693c17ace0a54 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Wed, 3 Jan 2024 09:35:23 +0800 Subject: [PATCH 5/6] Add option for staionID and Meteor count --- Utils/TrackStack.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Utils/TrackStack.py b/Utils/TrackStack.py index d0f312765..62f5bb15a 100644 --- a/Utils/TrackStack.py +++ b/Utils/TrackStack.py @@ -30,7 +30,7 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, hide_plot=False, showers=None, darkbackground=False, out_dir=None, scalefactor=None, draw_constellations=False, one_core_free=False, - overlay_file_name=False): + textoption=0): """ Generate a stack with aligned stars, so the sky appears static. The folder should have a platepars_all_recalibrated.json file. @@ -339,10 +339,18 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, else: filenam = os.path.join(dir_path, os.path.basename(dir_path) + "_track_stack.jpg") - # Overlay the filename on the image - if overlay_file_name: - print("Overlaying filename: {}".format(os.path.basename(filenam))) - ax.text(10, stack_img.shape[0] + 30, os.path.basename(filenam), color='grey', fontsize=6, fontname='Source Sans Pro', + # Overlay the filename on the image\ + bf = os.path.basename(filenam) + + # Overlay filename only + if textoption[0] == 1: + ax.text(10, stack_img.shape[0] + 30, bf, color='grey', fontsize=6, fontname='Source Sans Pro', + weight='ultralight') + + # Overlay stationID, YYYY-MM-DD Meteor count + if textoption[0] == 2: + annotation = "{} {}-{}-{} Meteors: {}".format(bf[0:6],bf[7:11],bf[11:13],bf[13:15],num_plotted) + ax.text(10, stack_img.shape[0] + 30, annotation, color='grey', fontsize=6, fontname='Source Sans Pro', weight='ultralight') plt.savefig(filenam, bbox_inches='tight', pad_inches=0, dpi=dpi, facecolor='k', edgecolor='k') @@ -487,8 +495,11 @@ def getArray(size, shared_arr): arg_parser.add_argument('-o', '--output', type=str, help="""folder to save the image in.""") - arg_parser.add_argument('-n', '--overlayfilename', action="store_true", - help="""Overlay filename on image.""") + arg_parser.add_argument('-t', '--textoption', nargs=1, type=int, + help="""Add text beneath image. + 0 - No text + 1 - Filename + 2 - Station id, date, meteor count""") arg_parser.add_argument('-f', '--scalefactor', type=int, help="""scale factor to apply. Increase if image is cropped""") @@ -523,4 +534,4 @@ def getArray(size, shared_arr): hide_plot=cml_args.hideplot, showers=showers, darkbackground=cml_args.darkbackground, out_dir=cml_args.output, scalefactor=cml_args.scalefactor, draw_constellations=cml_args.constellations, one_core_free=cml_args.freecore, - overlay_file_name = cml_args.overlayfilename) + textoption = cml_args.textoption) From 8eb8179f794f8834fdf69376975fdf4a56ab5d41 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Wed, 3 Jan 2024 11:51:20 +0800 Subject: [PATCH 6/6] Tested with different command strings --- Utils/TrackStack.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Utils/TrackStack.py b/Utils/TrackStack.py index 62f5bb15a..225e3a2ee 100644 --- a/Utils/TrackStack.py +++ b/Utils/TrackStack.py @@ -343,14 +343,15 @@ def trackStack(dir_paths, config, border=5, background_compensation=True, bf = os.path.basename(filenam) # Overlay filename only - if textoption[0] == 1: - ax.text(10, stack_img.shape[0] + 30, bf, color='grey', fontsize=6, fontname='Source Sans Pro', - weight='ultralight') + if textoption is not None: + if textoption[0] == 1: + ax.text(10, stack_img.shape[0] + 30, bf, color='grey', fontsize=6, fontname='Source Sans Pro', + weight='ultralight') # Overlay stationID, YYYY-MM-DD Meteor count - if textoption[0] == 2: - annotation = "{} {}-{}-{} Meteors: {}".format(bf[0:6],bf[7:11],bf[11:13],bf[13:15],num_plotted) - ax.text(10, stack_img.shape[0] + 30, annotation, color='grey', fontsize=6, fontname='Source Sans Pro', + if textoption[0] == 2: + annotation = "{} {}-{}-{} Meteors: {}".format(bf[0:6],bf[7:11],bf[11:13],bf[13:15],num_plotted) + ax.text(10, stack_img.shape[0] + 30, annotation, color='grey', fontsize=6, fontname='Source Sans Pro', weight='ultralight') plt.savefig(filenam, bbox_inches='tight', pad_inches=0, dpi=dpi, facecolor='k', edgecolor='k')