From ac7c430c8041f10d42cdf5291182ecc4d9eacd9b Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Thu, 19 May 2022 11:05:59 +0200 Subject: [PATCH] Don't clobber 'i' --- .../probabilistic_assessment.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/probabilistic-analysis/probabilistic_assessment.py b/probabilistic-analysis/probabilistic_assessment.py index 55439d8..64d0164 100644 --- a/probabilistic-analysis/probabilistic_assessment.py +++ b/probabilistic-analysis/probabilistic_assessment.py @@ -691,23 +691,23 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, dump_df = dump_df[::100] # Only output every 100th row dump_df.to_csv(csv_name, float_format='%g') - for i, c in enumerate(dump_df.columns[3:]): - ax[i, j].plot(dump_df.index, + for k, c in enumerate(dump_df.columns[3:]): + ax[k, j].plot(dump_df.index, dump_df[c], '.', color='#aaaaaa', alpha=0.1, markersize=2) - ax[i, j].spines['right'].set_visible(False) - ax[i, j].spines['top'].set_visible(False) + ax[k, j].spines['right'].set_visible(False) + ax[k, j].spines['top'].set_visible(False) if j == 0: - ax[i, 0].yaxis.set_label_coords(-0.4, 0.5) + ax[k, 0].yaxis.set_label_coords(-0.4, 0.5) label = c.replace('(', '\n(') - ax[i, 0].set_ylabel(label, + ax[k, 0].set_ylabel(label, va='top', linespacing=1.5) - ax[i, j].set_xlabel('Encounter probability (%)', + ax[k, j].set_xlabel('Encounter probability (%)', labelpad=10) ax[0, j].set_title(year) @@ -769,7 +769,7 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, baseline = r[:, 1] sdd = storm_demand_dist[:, 1] - for i in range(len(slr)): + for k in range(len(slr)): pe = [ matplotlib.patheffects.Stroke(linewidth=5, foreground='#ffffff', @@ -777,8 +777,8 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, matplotlib.patheffects.Normal() ] - ax[3, 0].plot([years[i], years[i]], - [baseline[i], baseline[i] + sdd[i]], + ax[3, 0].plot([years[k], years[k]], + [baseline[k], baseline[k] + sdd[k]], c='C0', path_effects=pe) @@ -786,7 +786,7 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, r_max = (baseline + sdd).max() ax[3, 0].axhline(y=r_max, c='C3', linestyle=':') - i = len(years) - 1 + k = len(years) - 1 for a in ax[:, 0]: a.set_xlim(right=years[-1]) @@ -810,7 +810,7 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year, ax[0, 0].set_title((f'Probabilistic trajectories\n' f'(first 100 out of {n_runs:,} runs)')) ax[0, 1].set_title( - f'Probability\ndistribution\nin year {years[i]}') + f'Probability\ndistribution\nin year {years[k]}') ax[0, 0].set_ylabel('Sea level (m)', labelpad=10) ax[1, 0].set_ylabel('Bruun recession (m)', labelpad=10) ax[2, 0].set_ylabel('Underlying recession (m)', labelpad=10)