Skip to content

Commit 499e03c

Browse files
Merge pull request #65 from upb-lea/new_femmt
Pareto plot save additional file formats
2 parents c906667 + a4150eb commit 499e03c

File tree

5 files changed

+41
-24
lines changed

5 files changed

+41
-24
lines changed

dct/dctmainctl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def log_software_versions(filepath: str) -> None:
101101
f'hct=={version("hct")}\n'
102102
f'mag-net-hub=={version("mag-net-hub")}\n'
103103
f'numpy=={version("numpy")}\n'
104-
f'pandas=={version("pandas")}\n')
104+
f'pandas=={version("pandas")}\n'
105+
f'matplotlib=={version("matplotlib")}\n')
105106

106107
@staticmethod
107108
def set_up_folder_structure(toml_prog_flow: tc.FlowControl) -> None:

dct/generate_toml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def generate_flow_control_toml(working_directory: str) -> None:
8181
subdirectory = "06_summary"
8282
8383
[configuration_data_files]
84+
general_configuration_file = "DabGeneralConf.toml"
8485
circuit_configuration_file = "DabCircuitConf.toml"
8586
inductor_configuration_file = "DabInductorConf.toml"
8687
transformer_configuration_file = "DabTransformerConf.toml"

dct/plot_control.py

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# python libraries
44
import os
5+
import pickle
56

67
# 3rd party libraries
78
from matplotlib import pyplot as plt
@@ -16,9 +17,9 @@ class ParetoPlots:
1617
"""Generate PDF plots to see the results of single Pareto steps (circuit, inductor, transformer, heat sink)."""
1718

1819
@staticmethod
19-
def generate_pdf_pareto(x_values_list: list, y_values_list: list, color_list: list, alpha: float,
20-
x_label: str, y_label: str, label_list: list[str | None], fig_name: str,
21-
xlim: list | None = None, ylim: list | None = None) -> None:
20+
def generate_pareto_plot(x_values_list: list, y_values_list: list, color_list: list, alpha: float,
21+
x_label: str, y_label: str, label_list: list[str | None], fig_name_path: str,
22+
xlim: list | None = None, ylim: list | None = None) -> None:
2223
"""
2324
Generate multiple Pareto plot in one PDF file.
2425
@@ -35,8 +36,8 @@ def generate_pdf_pareto(x_values_list: list, y_values_list: list, color_list: li
3536
:type y_label: str
3637
:param label_list: list of different Pareto plot labels in a legend
3738
:type label_list: list[str | None]
38-
:param fig_name: filename, will be saved as pdf
39-
:type fig_name: str
39+
:param fig_name_path: filename, will be saved as pdf
40+
:type fig_name_path: str
4041
:param xlim: x-axis limitation [x_min, x_max]
4142
:type xlim: list[float]
4243
:param ylim: y-axis limitation [y_min, y_max]
@@ -62,8 +63,20 @@ def generate_pdf_pareto(x_values_list: list, y_values_list: list, color_list: li
6263
plt.grid()
6364
plt.tight_layout()
6465
# make sure to not generate a filename.pdf.pdf (twice ".pdf").
65-
fig_name = fig_name.replace(".pdf", "")
66-
plt.savefig(f"{fig_name}.pdf")
66+
fig_name_path = fig_name_path.replace(".pdf", "")
67+
path, fig_name = os.path.split(fig_name_path)
68+
69+
if not os.path.exists(f"{path}/pdf"):
70+
os.mkdir(f"{path}/pdf")
71+
if not os.path.exists(f"{path}/png"):
72+
os.mkdir(f"{path}/png")
73+
if not os.path.exists(f"{path}/pkl"):
74+
os.mkdir(f"{path}/pkl")
75+
plt.savefig(f"{path}/pdf/{fig_name}.pdf")
76+
plt.savefig(f"{path}/png/{fig_name}.png")
77+
# Save the figure as pickle file type, for later view
78+
with open(f"{path}/pkl/{fig_name}.pkl", "wb") as f:
79+
pickle.dump(fig, f)
6780

6881
@staticmethod
6982
def read_circuit_numbers_from_filestructure(toml_prog_flow: dct.FlowControl) -> list[str]:
@@ -102,9 +115,9 @@ def plot_circuit_results(toml_prog_flow: dct.FlowControl, is_pre_summary: bool =
102115
else:
103116
fig_name = os.path.join(toml_prog_flow.general.project_directory, toml_prog_flow.summary.subdirectory, "circuit")
104117

105-
ParetoPlots.generate_pdf_pareto([df_circuit["values_0"]], [df_circuit["values_1"]], color_list=[dct.colors()["black"]], alpha=0.5,
106-
x_label=r"$\mathcal{L}_\mathrm{v}$ / \%", y_label=r"$\mathcal{L}_\mathrm{i}$ / A²",
107-
label_list=[None], fig_name=fig_name)
118+
ParetoPlots.generate_pareto_plot([df_circuit["values_0"]], [df_circuit["values_1"]], color_list=[dct.colors()["black"]], alpha=0.5,
119+
x_label=r"$\mathcal{L}_\mathrm{v}$ / \%", y_label=r"$\mathcal{L}_\mathrm{i}$ / A²",
120+
label_list=[None], fig_name_path=fig_name)
108121

109122
@staticmethod
110123
def plot_inductor_results(toml_prog_flow: dct.FlowControl, is_pre_summary: bool = False) -> None:
@@ -155,9 +168,9 @@ def plot_inductor_results(toml_prog_flow: dct.FlowControl, is_pre_summary: bool
155168
else:
156169
fig_name = os.path.join(toml_prog_flow.general.project_directory, toml_prog_flow.summary.subdirectory, f"inductor_c{circuit_number}")
157170

158-
ParetoPlots.generate_pdf_pareto(x_values_list, y_values_list, color_list=["black", "red", "green"], alpha=0.5, x_label=r'$V_\mathrm{ind}$ / cm³',
159-
y_label=r'$P_\mathrm{ind}$ / W', label_list=label_list,
160-
fig_name=fig_name, xlim=[x_scale_min, x_scale_max], ylim=[y_scale_min, y_scale_max])
171+
ParetoPlots.generate_pareto_plot(x_values_list, y_values_list, color_list=["black", "red", "green"], alpha=0.5, x_label=r'$V_\mathrm{ind}$ / cm³',
172+
y_label=r'$P_\mathrm{ind}$ / W', label_list=label_list,
173+
fig_name_path=fig_name, xlim=[x_scale_min, x_scale_max], ylim=[y_scale_min, y_scale_max])
161174

162175
@staticmethod
163176
def plot_transformer_results(toml_prog_flow: dct.FlowControl, is_pre_summary: bool = False) -> None:
@@ -207,9 +220,9 @@ def plot_transformer_results(toml_prog_flow: dct.FlowControl, is_pre_summary: bo
207220
else:
208221
fig_name = os.path.join(toml_prog_flow.general.project_directory, toml_prog_flow.summary.subdirectory, f"transformer_c{circuit_number}")
209222

210-
ParetoPlots.generate_pdf_pareto(x_values_list, y_values_list, color_list=["black", "red", "green"], alpha=0.5, x_label=r'$V_\mathrm{ind}$ / cm³',
211-
y_label=r'$P_\mathrm{ind}$ / W', label_list=label_list,
212-
fig_name=fig_name, xlim=[x_scale_min, x_scale_max], ylim=[y_scale_min, y_scale_max])
223+
ParetoPlots.generate_pareto_plot(x_values_list, y_values_list, color_list=["black", "red", "green"], alpha=0.5, x_label=r'$V_\mathrm{ind}$ / cm³',
224+
y_label=r'$P_\mathrm{ind}$ / W', label_list=label_list,
225+
fig_name_path=fig_name, xlim=[x_scale_min, x_scale_max], ylim=[y_scale_min, y_scale_max])
213226

214227
@staticmethod
215228
def plot_heat_sink_results(toml_prog_flow: dct.FlowControl, is_pre_summary: bool = False) -> None:
@@ -258,10 +271,10 @@ def plot_heat_sink_results(toml_prog_flow: dct.FlowControl, is_pre_summary: bool
258271
fig_name = os.path.join(toml_prog_flow.general.project_directory, toml_prog_flow.summary.subdirectory, "heat_sink")
259272

260273
# plot all the different heat sink areas
261-
ParetoPlots.generate_pdf_pareto(x_values_list, y_values_list, color_list, alpha=0.5,
262-
x_label=r'$V_\mathrm{HS}$ / cm³', y_label=r'$R_\mathrm{th,HS}$ / (K/W)',
263-
label_list=legend_list,
264-
fig_name=fig_name)
274+
ParetoPlots.generate_pareto_plot(x_values_list, y_values_list, color_list, alpha=0.5,
275+
x_label=r'$V_\mathrm{HS}$ / cm³', y_label=r'$R_\mathrm{th,HS}$ / (K/W)',
276+
label_list=legend_list,
277+
fig_name_path=fig_name)
265278

266279
@staticmethod
267280
def plot_summary(toml_prog_flow: dct.FlowControl, is_pre_summary: bool = False) -> None:
@@ -298,6 +311,6 @@ def plot_summary(toml_prog_flow: dct.FlowControl, is_pre_summary: bool = False)
298311
y_scale_min = 0.9 * df_filtered["total_mean_loss"].min()
299312
y_scale_max = 1.1 * df_filtered["total_mean_loss"].max()
300313

301-
ParetoPlots.generate_pdf_pareto(x_values_list, y_values_list, label_list=label_list, color_list=["red", "green"], alpha=0.5,
302-
x_label=r"$V_\mathrm{DAB}$ / cm³", y_label=r"$P_\mathrm{DAB,mean}$ / W",
303-
fig_name=fig_name, xlim=[x_scale_min, x_scale_max], ylim=[y_scale_min, y_scale_max])
314+
ParetoPlots.generate_pareto_plot(x_values_list, y_values_list, label_list=label_list, color_list=["red", "green"], alpha=0.5,
315+
x_label=r"$V_\mathrm{DAB}$ / cm³", y_label=r"$P_\mathrm{DAB,mean}$ / W",
316+
fig_name_path=fig_name, xlim=[x_scale_min, x_scale_max], ylim=[y_scale_min, y_scale_max])

docs/wordlist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,5 +359,6 @@ tdb
359359
materialdatabase
360360
txt
361361
MTB
362+
DabGeneralConf
362363
TomlGeneral
363364

workspace/progFlow.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
subdirectory = "06_summary"
4848

4949
[configuration_data_files]
50+
general_configuration_file = "DabGeneralConf.toml"
5051
circuit_configuration_file = "DabCircuitConf.toml"
5152
inductor_configuration_file = "DabInductorConf.toml"
5253
transformer_configuration_file = "DabTransformerConf.toml"

0 commit comments

Comments
 (0)