Skip to content

Commit 87edae3

Browse files
authored
Fix full-output for evaluation MFiles (#3867)
* Output run type only for evaluation mfiles * Correct PROCESS run summary for evalulation MFiles
1 parent 525d92c commit 87edae3

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

process/io/plot_proc.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import argparse
1717
import json
1818
import os
19+
import textwrap
1920
from argparse import RawTextHelpFormatter
2021
from importlib import resources
2122

@@ -60,6 +61,7 @@
6061
vacuum_vessel_geometry_single_null,
6162
)
6263
from process.impurity_radiation import read_impurity_file
64+
from process.io.mfile import MFileErrorClass
6365
from process.objectives import OBJECTIVE_NAMES
6466
from process.superconducting_tf_coil import SUPERCONDUCTING_TF_TYPES
6567

@@ -7112,7 +7114,9 @@ def plot_header(axis, mfile_data, scan):
71127114
(f"!{mfile_data.data['date'].get_scan(-1)}", "Date:", ""),
71137115
(f"!{mfile_data.data['time'].get_scan(-1)}", "Time:", ""),
71147116
(f"!{mfile_data.data['username'].get_scan(-1)}", "User:", ""),
7115-
(
7117+
("!Evaluation", "Run type", "")
7118+
if isinstance(mfile_data.data["minmax"], MFileErrorClass)
7119+
else (
71167120
f"!{OBJECTIVE_NAMES[abs(int(mfile_data.data['minmax'].get_scan(-1)))]}",
71177121
"Optimising:",
71187122
"",
@@ -10838,22 +10842,28 @@ def plot_cover_page(axis, mfile_data, scan, fig, colour_scheme):
1083810842
branch_name = mfile_data.data["branch_name"].get_scan(-1)
1083910843
fileprefix = mfile_data.data["fileprefix"].get_scan(-1)
1084010844
optmisation_switch = mfile_data.data["ioptimz"].get_scan(-1)
10841-
minmax_switch = mfile_data.data["minmax"].get_scan(-1)
10845+
minmax_switch = mfile_data.data["minmax"].get_scan(-1) or "N/A"
1084210846
ifail = mfile_data.data["ifail"].get_scan(-1)
1084310847
nvars = mfile_data.data["nvar"].get_scan(-1)
1084410848
# Objective_function_name
1084510849
objf_name = mfile_data.data["objf_name"].get_scan(-1)
1084610850
# Square_root_of_the_sum_of_squares_of_the_constraint_residuals
1084710851
sqsumsq = mfile_data.data["sqsumsq"].get_scan(-1)
1084810852
# VMCON_convergence_parameter
10849-
convergence_parameter = mfile_data.data["convergence_parameter"].get_scan(-1)
10853+
convergence_parameter = (
10854+
mfile_data.data["convergence_parameter"].get_scan(-1) or "N/A"
10855+
)
1085010856
# Number_of_optimising_solver_iterations
10851-
nviter = mfile_data.data["nviter"].get_scan(-1)
10857+
nviter = int(mfile_data.data["nviter"].get_scan(-1)) or "N/A"
1085210858

1085310859
# Objective name with minimising/maximising
10854-
if minmax_switch >= 0:
10860+
if isinstance(minmax_switch, str):
10861+
objective_text = ""
10862+
elif minmax_switch >= 0:
10863+
minmax_switch = int(minmax_switch)
1085510864
objective_text = f"• Minimising {objf_name}"
1085610865
else:
10866+
minmax_switch = int(minmax_switch)
1085710867
objective_text = f"• Maximising {objf_name}"
1085810868

1085910869
axis.text(
@@ -10892,15 +10902,10 @@ def plot_cover_page(axis, mfile_data, scan, fig, colour_scheme):
1089210902
# Box 2: File/Branch Info
1089310903
# Wrap the whole "Branch Name: ..." line if too long
1089410904
max_line_len = 60
10895-
branch_line = f"• Branch Name: {branch_name}"
10896-
if isinstance(branch_line, str) and len(branch_line) > max_line_len:
10897-
# Insert a newline every max_line_len characters
10898-
branch_line = "\n".join([
10899-
branch_line[i : i + max_line_len]
10900-
for i in range(0, len(branch_line), max_line_len)
10901-
])
10905+
branch_line = textwrap.fill(f"• Branch Name: {branch_name}", max_line_len)
10906+
fileprefix = textwrap.fill(f"File Prefix: {fileprefix}", max_line_len)
1090210907

10903-
file_info = f"• Tag Number: {tagno}\n{branch_line}\nFile Prefix: {fileprefix}"
10908+
file_info = f"• Tag Number: {tagno}\n{branch_line}\n{fileprefix}"
1090410909
axis.text(
1090510910
0.1,
1090610911
0.57,
@@ -10920,13 +10925,13 @@ def plot_cover_page(axis, mfile_data, scan, fig, colour_scheme):
1092010925
# Box 3: Run Settings
1092110926
settings_info = (
1092210927
f"• Optimisation Switch: {int(optmisation_switch)}\n"
10923-
f"• Figure of Merit Switch (minmax): {int(minmax_switch)}\n"
10928+
f"• Figure of Merit Switch (minmax): {minmax_switch}\n"
1092410929
f"• Fail Status (ifail): {int(ifail)}\n"
1092510930
f"• Number of Iteration Variables: {int(nvars)}\n"
1092610931
f"{objective_text}\n"
1092710932
f"• Constraint Residuals (sqrt sum sq): {sqsumsq}\n"
1092810933
f"• Convergence Parameter: {convergence_parameter}\n"
10929-
f"• Solver Iterations: {int(nviter)}"
10934+
f"• Solver Iterations: {nviter}"
1093010935
)
1093110936
axis.text(
1093210937
0.1,

0 commit comments

Comments
 (0)