Clean up logic flow

master
Dan Howe 3 years ago
parent bf916f5f25
commit 28c16a3e2f

@ -464,6 +464,12 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year,
figsize=(16, 24),
sharey='row')
# Check whether to save probabilistic diagnostics
for _, bp in pd.DataFrame(diagnostics).iterrows():
if ((str(prof['block']) == str(bp['block']))
and (prof['profile'] == bp['profile'])):
output_diagnostics = True
# Loop through years
pbar_year = tqdm(output_years, leave=False)
for j, year in enumerate(pbar_year):
@ -595,12 +601,7 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year,
header=False,
float_format='%g')
# Check whether to save probabilistic diagnostics
for _, bp in pd.DataFrame(diagnostics).iterrows():
if not ((str(prof['block']) == str(bp['block'])) and
(prof['profile'] == bp['profile'])):
continue # Don't save
if output_diagnostics:
# Save probabilistic diagnostics
year_idx = year == years
@ -657,15 +658,14 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year,
ascending=False)
# Add encounter probabilities
dump_df['Encounter probability (%)'] = np.linspace(0,
100,
num=n_runs +
2)[1:-1]
dump_df['Encounter probability (%)'] = np.linspace(
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'.format(beach_scenario, year,
profile_type))
dump_df.to_csv(csv_name, float_format='%g')
for i, c in enumerate(dump_df.columns[3:]):
@ -679,19 +679,24 @@ def process(beach_name, beach_scenario, n_runs, start_year, end_year,
if j == 0:
ax[i, 0].yaxis.set_label_coords(-0.4, 0.5)
label = c.replace('(', '\n(')
ax[i, 0].set_ylabel(label, va='top', linespacing=1.5)
ax[i, 0].set_ylabel(label,
va='top',
linespacing=1.5)
ax[i, j].set_xlabel('Encounter probability (%)', labelpad=10)
ax[i, j].set_xlabel('Encounter probability (%)',
labelpad=10)
ax[0, j].set_title(year)
fig.suptitle('{}, block {}, profile {}'.format(
beach_scenario, prof['block'], prof['profile']),
y=0.92)
if output_diagnostics:
figname = os.path.join(
'diagnostics', '{} {}.png'.format(beach_scenario,
profile_type))
'diagnostics',
f'{beach_scenario} {profile_type} scatter.png')
plt.savefig(figname, bbox_inches='tight', dpi=300)
plt.close(fig)
def main():

Loading…
Cancel
Save