Skip to content

Commit 6f34b96

Browse files
smartie2076Bachibouzouk
authored andcommitted
Beautify graphs
- Replace `_` with spaces - Use intuitive labels and correct units (from `docs/MVS_kpis_list.csv` and `docs/MVS_parameter_list.csv`
1 parent 21de38b commit 6f34b96

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

src/multi_vector_simulator/utils/analysis.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,14 @@ def loop_mvs(
439439
for excel_file in [FILE_NAME_SCALARS, FILE_NAME_TIMESERIES]:
440440
name_excel_file = excel_file + ".xlsx"
441441
new_name_excel_file = (
442-
excel_file + "_" + variable_name + "_" + str(value) + ".xlsx"
442+
excel_file
443+
+ "_"
444+
+ variable_column
445+
+ "_"
446+
+ variable_name
447+
+ "_"
448+
+ str(value)
449+
+ ".xlsx"
443450
)
444451
src_dir = os.path.join(experiment_output_directory, name_excel_file)
445452
dst_dir = os.path.join(
@@ -452,6 +459,7 @@ def loop_mvs(
452459

453460
postprocessing_kpi(
454461
variable_name=variable_name,
462+
variable_column=variable_column,
455463
variable_value_vector=dict_result_paths[scenario_name][VALUES],
456464
output_path_vector=dict_result_paths[scenario_name][EXPERIMENT_OUTPUT_PATHS],
457465
output_path_summary=loop_output_directory,
@@ -506,7 +514,11 @@ def add_parameter_to_mvs_file(
506514

507515

508516
def postprocessing_kpi(
509-
variable_name, variable_value_vector, output_path_vector, output_path_summary
517+
variable_name,
518+
variable_column,
519+
variable_value_vector,
520+
output_path_vector,
521+
output_path_summary,
510522
):
511523
"""
512524
Overwrites all output excel files "timeseries_all_flows.xlsx" and "scalars.xlsx"
@@ -595,11 +607,27 @@ def postprocessing_kpi(
595607

596608
senstivitiy_data = senstivitiy_data.transpose()
597609

610+
variable_definitions = pd.read_csv(
611+
os.path.join("docs", "MVS_parameters_list.csv"), index_col=6
612+
)
613+
unit = variable_definitions[":Unit:"][variable_name]
614+
x_label = f"{variable_name.replace('_', ' ')} of {variable_column.replace('_', ' ')} in {unit}"
615+
616+
kpi_definitions = pd.read_csv(
617+
os.path.join("docs", "MVS_kpis_list.csv"), index_col=0
618+
)
619+
598620
for kpi in KEY_INTEREST_KPI:
621+
try:
622+
name = kpi_definitions["label"][kpi]
623+
unit = kpi_definitions[":Unit:"][kpi]
624+
except:
625+
name = kpi
626+
unit = ""
599627
plot_data = pd.Series(senstivitiy_data[kpi], index=senstivitiy_data.index)
600628
plot_data.plot()
601-
plt.xlabel(variable_name)
602-
plt.ylabel(kpi)
629+
plt.xlabel(x_label)
630+
plt.ylabel(f"{name} in {unit}")
603631
plt.savefig(
604632
os.path.join(output_path_summary, f"{variable_name}_effect_on_{kpi}.png")
605633
)
@@ -612,10 +640,13 @@ def postprocessing_kpi(
612640
for scalar in other_scalars.columns:
613641
plot_data = pd.Series(other_scalars[scalar], index=other_scalars.index)
614642
plot_data.plot()
615-
plt.xlabel(variable_name)
616-
plt.ylabel(scalar)
643+
plt.xlabel(x_label)
644+
plt.ylabel(scalar.replace("_", " "))
617645
plt.savefig(
618-
os.path.join(output_path_summary, f"{variable_name}_effect_on_{scalar}.png")
646+
os.path.join(
647+
output_path_summary,
648+
f"{variable_name}_{variable_column}_effect_on_{scalar}.png",
649+
)
619650
)
620651
plt.close()
621652

0 commit comments

Comments
 (0)