From 53da693e9eb2612ef194ff8a4250f7867da34a41 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Thu, 19 May 2022 11:25:07 +0200 Subject: [PATCH] Add profile and block IDs to diagnostic output files --- .../probabilistic_assessment.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/probabilistic-analysis/probabilistic_assessment.py b/probabilistic-analysis/probabilistic_assessment.py index 64d0164..885255f 100644 --- a/probabilistic-analysis/probabilistic_assessment.py +++ b/probabilistic-analysis/probabilistic_assessment.py @@ -624,6 +624,12 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, float_format='%g') if output_diagnostics: + # Generate basename for diagnostic files + diag_basename = (f"{beach_scenario} " + f"{profile_type} " + f"block-{prof['block']} " + f"profile-{prof['profile']}") + # Save probabilistic diagnostics year_idx = year == years @@ -684,10 +690,8 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, 0, 100, num=n_runs + 2)[1:-1] dump_df = dump_df.set_index('Encounter probability (%)') - csv_name = os.path.join( - 'diagnostics', - '{} {} {}.csv'.format(beach_scenario, year, - profile_type)) + csv_name = os.path.join('diagnostics', + diag_basename + '.csv') dump_df = dump_df[::100] # Only output every 100th row dump_df.to_csv(csv_name, float_format='%g') @@ -716,9 +720,8 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, y=0.92) if output_diagnostics: - figname = os.path.join( - 'diagnostics', - f'{beach_scenario} {profile_type} scatter.png') + figname = os.path.join('diagnostics', + diag_basename + ' scatter.png') plt.savefig(figname, bbox_inches='tight', dpi=300) plt.close(fig) @@ -825,9 +828,8 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, a.spines['top'].set_visible(False) a.spines['right'].set_visible(False) - figname = os.path.join( - 'diagnostics', - f'{beach_scenario} {profile_type} timeseries.png') + figname = os.path.join('diagnostics', + diag_basename + ' timeseries.png') plt.savefig(figname, bbox_inches='tight', dpi=300) plt.close(fig)