Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Figure notebooks for 'Lagrangian filtering for wave–mean flow decomposition'.

135 views
unlisted
ubuntu2204
Kernel: Python 3 (system-wide)

logo

import matplotlib.pyplot as plt import xarray as xr import numpy as np plt.rcParams.update({'font.size': 18}) plt.rc('text', usetex=True) plt.rc('text.latex',preamble=r"\usepackage{amsmath}") plt.rc('font', family='serif')
# Loading datasets ds_lp = xr.open_dataset('../Data/solver_lowpass_x_y_omega_2_Nint_1_strat_3_T_40.nc') ds_th = xr.open_dataset('../Data/solver_tophat_x_y_Nint_1_strat_3_T_40.nc')
# Initialising figure fig = plt.figure(figsize = (18,11.9)) ax0 = plt.subplot2grid((48, 12), (0, 0), colspan=4,rowspan=24) ax1 = plt.subplot2grid((48, 12), (0, 4), colspan=4,rowspan=24) ax2 = plt.subplot2grid((48, 12), (0, 8), colspan=4,rowspan=24) ax3 = plt.subplot2grid((48, 12), (24, 4), colspan=4,rowspan=24) ax4 = plt.subplot2grid((48, 12), (24, 8), colspan=4,rowspan=24) ax5 = plt.subplot2grid((48, 12), (33, 0), colspan=4,rowspan=15) axcb = plt.subplot2grid((48, 12), (27, 0), colspan=4,rowspan=2) axes = [ax0,ax1,ax2,ax3,ax4] # Plotting vmin = -1 vmax = 1 p0 = ax0.pcolormesh(ds_lp.z_inst,vmin = vmin, vmax = vmax,cmap = 'RdBu_r') ax1.pcolormesh(ds_lp.z_LM_at_mean,vmin = vmin, vmax = vmax,cmap = 'RdBu_r') ax2.pcolormesh(ds_lp.z_EM,vmin = vmin, vmax = vmax,cmap = 'RdBu_r') ax3.pcolormesh(ds_th.z_LM_at_mean,vmin = vmin, vmax = vmax,cmap = 'RdBu_r') ax4.pcolormesh(ds_th.z_EM,vmin = vmin, vmax = vmax,cmap = 'RdBu_r') fig.colorbar(p0,cax=axcb,orientation='horizontal',label='Relative vorticity',shrink=0.5) textposx = 8 textposy = 236 bbox=dict(facecolor='white', edgecolor='none', boxstyle='round') ax0.text(textposx,textposy,'a) Instantaneous',bbox=bbox) ax1.text(textposx,textposy,'b) Lagrangian, Low Pass',bbox=bbox) ax2.text(textposx,textposy,'c) Eulerian, Low Pass',bbox=bbox) ax3.text(textposx,textposy,'e) Lagrangian, Top Hat',bbox=bbox) ax4.text(textposx,textposy,'f) Eulerian, Top Hat',bbox=bbox) # Plot weight function panel t = np.linspace(-20,20,1000) g_th = np.zeros_like(t) omega_crit=2 T = 40 g_th[(t < 2) & (t> -2)] = 1/4 g_lp = (np.sin(t*omega_crit)/np.pi/t) g_lp[(t > T/2) | (t< -T/2)] = 0 ax5.plot(t,g_lp,'r',linewidth=2,label='Low-pass') ax5.plot(t,g_th,'k',linewidth=2,label='Top-hat') ax5.legend(loc='upper right',frameon=False) ax5.text(-20.5,0.6,'d)',bbox=bbox) # Formatting [ax.axes.set_xticklabels([]) for ax in axes]; [ax.axes.set_yticklabels([]) for ax in axes]; ax0.set_xticks([0,128,256]) ax0.set_yticks([0,128,256]) labels = ['0','$\pi$','$2\pi$'] ax0.set_xticklabels(labels) ax0.set_yticklabels(labels) ax0.set_xlabel('$x$') ax0.set_ylabel('$y$') ax5.set_ylim([-0.2,0.7]) ax5.set_xlabel(r'$t$') ax5.set_ylabel(r'$G(t)$') ax5.set_xticks([-20,-2,0,2,20]) ax0.set_aspect('equal',anchor='NW') ax1.set_aspect('equal',anchor='NW') ax2.set_aspect('equal',anchor='NE') ax3.set_aspect('equal',anchor='SW') ax4.set_aspect('equal',anchor='SE') plt.subplots_adjust(hspace=0.5,wspace=0.5) # Save figure fig.savefig('Figure-2.png',dpi=200,bbox_inches='tight')
Image in a Jupyter notebook

Shallow water relative vorticity for a simulation over 40 time units (T=20T=20). The mode-1 wave frequency is ω=4.17\omega = 4.17, and the low-pass filters use a cut-off frequency of ωc=2\omega_c = 2. a) Instantaneous vorticity at the interval midpoint t=20t^* = 20. b) Lagrangian and c) Eulerian low-pass at t=20t^* = 20. e) Lagrangian and f) Eulerian top-hat mean at t=20t^* = 20, computed over the interval [18,22][-18,22], i.e. T=2T = 2. d) G(t)G(t) for the low-pass and top-hat means, showing that T=2T = 2 is an appropriate averaging interval for the top-hat to compare it to the low-pass.

More data variables are available in the xarray datasets:

ds_lp