From c2b8a5358cc68023359c7a42c4d6812adb15376f Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 12 Oct 2023 16:32:04 +0100 Subject: [PATCH 1/4] output numbers and ylabel on no scan fix --- process/io/plot_radial_build.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/process/io/plot_radial_build.py b/process/io/plot_radial_build.py index 480276ee0a..59ae4ec84d 100644 --- a/process/io/plot_radial_build.py +++ b/process/io/plot_radial_build.py @@ -313,11 +313,11 @@ def main(args=None): # Getting the scanned variable name m_file = mf.MFile(filename=input_file) - try: - nsweep_ref = int(m_file.data["nsweep"].get_scan(-1)) - scan_var_name = nsweep_list[nsweep_ref - 1] - except Exception: + nsweep_ref = int(m_file.data["nsweep"].get_scan(-1)) + if nsweep_ref == 0: scan_var_name = "Null" + else: + scan_var_name = nsweep_list[nsweep_ref - 1] radial_labels = [ "Machine Bore", @@ -420,7 +420,7 @@ def main(args=None): end_scan = radial_labels.index("Plasma") else: end_scan = len(radial_build) - + plt.figure(figsize=(8, 6)) for kk in range((len(radial_build[:end_scan, 0]))): if kk == 0: lower = np.zeros(len(radial_build[kk, :])) @@ -431,7 +431,7 @@ def main(args=None): radial_build[kk, :], left=lower, height=0.8, - label=radial_labels[kk], + label=f"{radial_labels[kk]}\n {radial_build[kk][0]}", color=radial_color[kk], edgecolor="black", linewidth=0.05, @@ -444,7 +444,10 @@ def main(args=None): plt.yticks([]) plt.legend( - bbox_to_anchor=(0.5, -0.15), loc="upper center", fontsize=legend_size, ncol=4 + bbox_to_anchor=(0.5, -0.15), + loc="upper center", + fontsize=legend_size, + ncol=4, ) plt.xlabel("Radius [m]") plt.tight_layout() From 4838002cd9e0b5154ebea1644e454bd33c7f09f7 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 12 Oct 2023 16:38:46 +0100 Subject: [PATCH 2/4] numbers in legend switch option --- process/io/plot_radial_build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/process/io/plot_radial_build.py b/process/io/plot_radial_build.py index 59ae4ec84d..d0a1e8fa07 100644 --- a/process/io/plot_radial_build.py +++ b/process/io/plot_radial_build.py @@ -62,6 +62,14 @@ def parse_args(args): help="Show inboard build only, default = False ", ) + parser.add_argument( + "-nm", + "--numbers", + action="store_true", + default=False, + help="Show widths of components in the legend", + ) + return parser.parse_args(args) @@ -431,7 +439,7 @@ def main(args=None): radial_build[kk, :], left=lower, height=0.8, - label=f"{radial_labels[kk]}\n {radial_build[kk][0]}", + label=f"{radial_labels[kk]}" + f"\n {radial_build[kk][0]} m" * args.numbers, color=radial_color[kk], edgecolor="black", linewidth=0.05, From 772e94aa5afeffd2c7cd4dda4357993ad0ee2a95 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 12 Oct 2023 16:51:59 +0100 Subject: [PATCH 3/4] numbers output warning --- process/io/plot_radial_build.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/process/io/plot_radial_build.py b/process/io/plot_radial_build.py index d0a1e8fa07..9ca68b2c2d 100644 --- a/process/io/plot_radial_build.py +++ b/process/io/plot_radial_build.py @@ -67,7 +67,7 @@ def parse_args(args): "--numbers", action="store_true", default=False, - help="Show widths of components in the legend", + help="Show widths of components in the legend. Only use non-scan MFILE's as will only show last values", ) return parser.parse_args(args) @@ -439,7 +439,9 @@ def main(args=None): radial_build[kk, :], left=lower, height=0.8, - label=f"{radial_labels[kk]}" + f"\n {radial_build[kk][0]} m" * args.numbers, + label=f"{radial_labels[kk]}" + f"\n {radial_build[kk][0]} m" * args.numbers + & scan_var_name + == "Null", color=radial_color[kk], edgecolor="black", linewidth=0.05, From d51f044f4f838638a4019c452de700f0885870b0 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 12 Oct 2023 16:54:08 +0100 Subject: [PATCH 4/4] removed null instance --- process/io/plot_radial_build.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/process/io/plot_radial_build.py b/process/io/plot_radial_build.py index 9ca68b2c2d..1e6f017830 100644 --- a/process/io/plot_radial_build.py +++ b/process/io/plot_radial_build.py @@ -439,9 +439,7 @@ def main(args=None): radial_build[kk, :], left=lower, height=0.8, - label=f"{radial_labels[kk]}" + f"\n {radial_build[kk][0]} m" * args.numbers - & scan_var_name - == "Null", + label=f"{radial_labels[kk]}" + f"\n {radial_build[kk][0]} m" * args.numbers, color=radial_color[kk], edgecolor="black", linewidth=0.05,