From 128a44c82e35e6c17cfcefb881fc946ce25f1ef3 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Mon, 6 Jan 2025 15:04:07 -0600 Subject: [PATCH] Increase precision of convergence rate --- polaris/ocean/convergence/analysis.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/polaris/ocean/convergence/analysis.py b/polaris/ocean/convergence/analysis.py index c644c02d0..59ef0bf46 100644 --- a/polaris/ocean/convergence/analysis.py +++ b/polaris/ocean/convergence/analysis.py @@ -218,7 +218,7 @@ def plot_convergence(self, variable_name, title, zidx): convergence_failed = False poly = np.polyfit(np.log10(refinement_array), np.log10(error_array), 1) convergence = poly[0] - conv_round = np.round(convergence, 3) + conv_round = convergence fit = refinement_array ** poly[0] * 10 ** poly[1] @@ -239,7 +239,7 @@ def plot_convergence(self, variable_name, title, zidx): ax.loglog(resolutions, order2, 'k', label='second order', alpha=0.3) ax.loglog(refinement_array, fit, 'k', - label=f'linear fit (order={conv_round})') + label=f'linear fit (order={convergence:1.3f})') ax.loglog(refinement_array, error_array, 'o', label='numerical') if self.baseline_dir is not None: @@ -255,14 +255,14 @@ def plot_convergence(self, variable_name, title, zidx): poly = np.polyfit( np.log10(refinement_array), np.log10(error_array), 1) base_convergence = poly[0] - conv_round = np.round(base_convergence, 3) + conv_round = base_convergence fit = refinement_array ** poly[0] * 10 ** poly[1] ax.loglog(refinement_array, error_array, 'o', color='#ff7f0e', label='baseline') ax.loglog(refinement_array, fit, color='#ff7f0e', label=f'linear fit, baseline ' - f'(order={conv_round})') + f'(order={base_convergence:1.3f})') ax.set_xlabel(x_label) ax.set_ylabel(f'{error_title}') ax.set_title(f'Error Convergence of {title}') @@ -273,11 +273,11 @@ def plot_convergence(self, variable_name, title, zidx): plt.close() logger.info(f'Order of convergence for {title}: ' - f'{conv_round}') + f'{conv_round:1.3f}') if conv_round < conv_thresh: logger.error(f'Error: order of convergence for {title}\n' - f' {conv_round} < min tolerance ' + f' {conv_round:1.3f} < min tolerance ' f'{conv_thresh}') convergence_failed = True