Skip to content

Commit

Permalink
Remove convergence plot from viz steps
Browse files Browse the repository at this point in the history
  • Loading branch information
cbegeman committed Oct 9, 2023
1 parent 85d4d1e commit c5a60df
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
22 changes: 0 additions & 22 deletions polaris/ocean/tasks/inertial_gravity_wave/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def __init__(self, component, resolutions, taskdir):
filename=f'output_{mesh_name}.nc',
target=f'../forward/{mesh_name}/output.nc')

self.add_output_file('convergence.png')
self.add_output_file('comparison.png')

def run(self):
Expand Down Expand Up @@ -117,24 +116,3 @@ def run(self):
size='large', ha='right', va='center')

fig.savefig('comparison.png', bbox_inches='tight', pad_inches=0.1)

# Convergence plots
fig = plt.figure()
ax = fig.add_subplot(111)
p = np.polyfit(np.log10(resolutions), np.log10(rmse), 1)
conv = np.round(p[0], 3)
ax.loglog(resolutions, rmse, '-ok', label=f'numerical (order={conv})')

c = rmse[0] * 1.5 / resolutions[0]
order1 = c * np.power(resolutions, 1)
c = rmse[0] * 1.5 / resolutions[0]**2
order2 = c * np.power(resolutions, 2)

ax.loglog(resolutions, order1, '--k', label='first order', alpha=0.3)
ax.loglog(resolutions, order2, 'k', label='second order', alpha=0.3)
ax.set_xlabel('resolution (km)')
ax.set_ylabel('RMS error (m)')
ax.invert_xaxis()
ax.set_title('Error Convergence')
ax.legend(loc='lower left')
fig.savefig('convergence.png', bbox_inches='tight', pad_inches=0.1)
23 changes: 1 addition & 22 deletions polaris/ocean/tasks/manufactured_solution/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, component, resolutions, taskdir):
filename=f'output_{mesh_name}.nc',
target=f'../forward/{mesh_name}/output.nc')

self.add_output_file('convergence.png')
self.add_output_file('comparison.png')

def run(self):
"""
Expand Down Expand Up @@ -114,24 +114,3 @@ def run(self):
size='large', ha='right', va='center')

fig.savefig('comparison.png', bbox_inches='tight', pad_inches=0.1)

# Convergence polts
fig = plt.figure()
ax = fig.add_subplot(111)
p = np.polyfit(np.log10(resolutions), np.log10(rmse), 1)
conv = np.round(p[0], 3)
ax.loglog(resolutions, rmse, '-ok', label=f'numerical (order={conv})')

c = rmse[0] * 1.5 / resolutions[0]
order1 = c * np.power(resolutions, 1)
c = rmse[0] * 1.5 / resolutions[0]**2
order2 = c * np.power(resolutions, 2)

ax.loglog(resolutions, order1, '--k', label='first order', alpha=0.3)
ax.loglog(resolutions, order2, 'k', label='second order', alpha=0.3)
ax.set_xlabel('resolution (km)')
ax.set_ylabel('RMS error (m)')
ax.set_title('Error Convergence')
ax.invert_xaxis()
ax.legend(loc='lower left')
fig.savefig('convergence.png', bbox_inches='tight', pad_inches=0.1)

0 comments on commit c5a60df

Please sign in to comment.