Note
Go to the end to download the full example code.
Gill Model: Kelvin Wave¶
This example simulates the Kelvin-wave experiment. The horizontal snapshot shows its equatorially trapped circulation, while the cross sections show the associated vertical structure.
import numpy as np
from easyclimate.field.simulation.gill import (
simulate,
plot_snapshot,
plot_cross_sections,
)
Run the Kelvin-wave experiment.
result_kelvin_wave = simulate(case = "kelvin_wave")
result_kelvin_wave
<xarray.Dataset> Size: 313kB
Dimensions: (y: 61, x: 128, y_staggered: 60, z: 20)
Coordinates:
* y (y) float64 488B -7.725 -7.468 -7.21 ... 7.21 7.468 7.725
* x (x) float64 1kB -18.85 -18.56 -18.26 ... 17.97 18.26 18.56
* y_staggered (y_staggered) float64 480B -7.725 -7.468 -7.21 ... 7.21 7.468
* z (z) float64 160B 0.0 0.1653 0.3307 0.496 ... 2.811 2.976 3.142
Data variables:
q (y, x) float64 62kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0
eta (y, x) float64 62kB 8.858e-08 1.089e-07 ... 3.859e-08 6.483e-08
u (y, x) float64 62kB 1.978e-08 4.136e-08 ... -2.569e-09
v (y, x) float64 62kB 1.065e-08 1.007e-08 ... -1.083e-08
v_staggered (y_staggered, x) float64 61kB 2.131e-08 ... -2.165e-08
Attributes: (12/17)
case: kelvin_wave
case_label: Kelvin wave
short_name: KelvinWave
t: 10.0
nt: 100
nx: 128
... ...
damping: 0.0
kernel: reyon
dt: 0.1
dx: 0.2945243112740431
dy: 0.25750759455654043
dz: 0.16534698176788384xarray.Dataset
- y: 61
- x: 128
- y_staggered: 60
- z: 20
- y(y)float64-7.725 -7.468 -7.21 ... 7.468 7.725
array([-7.725228, -7.46772 , -7.210213, -6.952705, -6.695197, -6.43769 , -6.180182, -5.922675, -5.665167, -5.407659, -5.150152, -4.892644, -4.635137, -4.377629, -4.120122, -3.862614, -3.605106, -3.347599, -3.090091, -2.832584, -2.575076, -2.317568, -2.060061, -1.802553, -1.545046, -1.287538, -1.03003 , -0.772523, -0.515015, -0.257508, 0. , 0.257508, 0.515015, 0.772523, 1.03003 , 1.287538, 1.545046, 1.802553, 2.060061, 2.317568, 2.575076, 2.832584, 3.090091, 3.347599, 3.605106, 3.862614, 4.120122, 4.377629, 4.635137, 4.892644, 5.150152, 5.407659, 5.665167, 5.922675, 6.180182, 6.43769 , 6.695197, 6.952705, 7.210213, 7.46772 , 7.725228]) - x(x)float64-18.85 -18.56 ... 18.26 18.56
array([-18.849556, -18.555032, -18.260507, -17.965983, -17.671459, -17.376934, -17.08241 , -16.787886, -16.493361, -16.198837, -15.904313, -15.609788, -15.315264, -15.02074 , -14.726216, -14.431691, -14.137167, -13.842643, -13.548118, -13.253594, -12.95907 , -12.664545, -12.370021, -12.075497, -11.780972, -11.486448, -11.191924, -10.8974 , -10.602875, -10.308351, -10.013827, -9.719302, -9.424778, -9.130254, -8.835729, -8.541205, -8.246681, -7.952156, -7.657632, -7.363108, -7.068583, -6.774059, -6.479535, -6.185011, -5.890486, -5.595962, -5.301438, -5.006913, -4.712389, -4.417865, -4.12334 , -3.828816, -3.534292, -3.239767, -2.945243, -2.650719, -2.356194, -2.06167 , -1.767146, -1.472622, -1.178097, -0.883573, -0.589049, -0.294524, 0. , 0.294524, 0.589049, 0.883573, 1.178097, 1.472622, 1.767146, 2.06167 , 2.356194, 2.650719, 2.945243, 3.239767, 3.534292, 3.828816, 4.12334 , 4.417865, 4.712389, 5.006913, 5.301438, 5.595962, 5.890486, 6.185011, 6.479535, 6.774059, 7.068583, 7.363108, 7.657632, 7.952156, 8.246681, 8.541205, 8.835729, 9.130254, 9.424778, 9.719302, 10.013827, 10.308351, 10.602875, 10.8974 , 11.191924, 11.486448, 11.780972, 12.075497, 12.370021, 12.664545, 12.95907 , 13.253594, 13.548118, 13.842643, 14.137167, 14.431691, 14.726216, 15.02074 , 15.315264, 15.609788, 15.904313, 16.198837, 16.493361, 16.787886, 17.08241 , 17.376934, 17.671459, 17.965983, 18.260507, 18.555032]) - y_staggered(y_staggered)float64-7.725 -7.468 -7.21 ... 7.21 7.468
array([-7.725228, -7.46772 , -7.210213, -6.952705, -6.695197, -6.43769 , -6.180182, -5.922675, -5.665167, -5.407659, -5.150152, -4.892644, -4.635137, -4.377629, -4.120122, -3.862614, -3.605106, -3.347599, -3.090091, -2.832584, -2.575076, -2.317568, -2.060061, -1.802553, -1.545046, -1.287538, -1.03003 , -0.772523, -0.515015, -0.257508, 0. , 0.257508, 0.515015, 0.772523, 1.03003 , 1.287538, 1.545046, 1.802553, 2.060061, 2.317568, 2.575076, 2.832584, 3.090091, 3.347599, 3.605106, 3.862614, 4.120122, 4.377629, 4.635137, 4.892644, 5.150152, 5.407659, 5.665167, 5.922675, 6.180182, 6.43769 , 6.695197, 6.952705, 7.210213, 7.46772 ]) - z(z)float640.0 0.1653 0.3307 ... 2.976 3.142
array([0. , 0.165347, 0.330694, 0.496041, 0.661388, 0.826735, 0.992082, 1.157429, 1.322776, 1.488123, 1.65347 , 1.818817, 1.984164, 2.149511, 2.314858, 2.480205, 2.645552, 2.810899, 2.976246, 3.141593])
- q(y, x)float640.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
array([[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], shape=(61, 128)) - eta(y, x)float648.858e-08 1.089e-07 ... 6.483e-08
array([[ 8.85824765e-08, 1.08927996e-07, 1.25087474e-07, ..., 1.08673639e-08, 3.85915996e-08, 6.48327818e-08], [ 1.75325862e-07, 2.36288272e-07, 2.88170255e-07, ..., -3.74217642e-08, 3.57896960e-08, 1.07625778e-07], [ 4.97672457e-07, 6.70561429e-07, 8.17681100e-07, ..., -1.05778696e-07, 1.01897694e-07, 3.05658212e-07], ..., [ 4.97672457e-07, 6.70561429e-07, 8.17681100e-07, ..., -1.05778696e-07, 1.01897694e-07, 3.05658212e-07], [ 1.75325862e-07, 2.36288272e-07, 2.88170255e-07, ..., -3.74217642e-08, 3.57896960e-08, 1.07625778e-07], [ 8.85824765e-08, 1.08927996e-07, 1.25087474e-07, ..., 1.08673640e-08, 3.85915996e-08, 6.48327818e-08]], shape=(61, 128)) - u(y, x)float641.978e-08 4.136e-08 ... -2.569e-09
array([[ 1.97777340e-08, 4.13647617e-08, 6.13621648e-08, ..., -4.61122846e-08, -2.48176775e-08, -2.56934090e-09], [ 1.63656655e-07, 2.30134011e-07, 2.87767446e-07, ..., -6.21910674e-08, 1.46306227e-08, 9.08900662e-08], [ 5.42053381e-07, 7.27971895e-07, 8.85914858e-07, ..., -1.08410781e-07, 1.15669190e-07, 3.35304059e-07], ..., [ 5.42053381e-07, 7.27971895e-07, 8.85914858e-07, ..., -1.08410781e-07, 1.15669190e-07, 3.35304059e-07], [ 1.63656655e-07, 2.30134011e-07, 2.87767446e-07, ..., -6.21910674e-08, 1.46306227e-08, 9.08900662e-08], [ 1.97777340e-08, 4.13647617e-08, 6.13621648e-08, ..., -4.61122846e-08, -2.48176775e-08, -2.56934089e-09]], shape=(61, 128)) - v(y, x)float641.065e-08 1.007e-08 ... -1.083e-08
array([[ 1.06525986e-08, 1.00687668e-08, 9.09799797e-09, ..., 9.93702590e-09, 1.05854377e-08, 1.08270570e-08], [ 4.00592027e-08, 3.67641272e-08, 3.20562270e-08, ..., 4.04995954e-08, 4.19635278e-08, 4.18148254e-08], [ 9.85432759e-08, 8.63385099e-08, 7.08158034e-08, ..., 1.11299793e-07, 1.11268428e-07, 1.06961079e-07], ..., [-9.85432759e-08, -8.63385099e-08, -7.08158034e-08, ..., -1.11299793e-07, -1.11268428e-07, -1.06961079e-07], [-4.00592027e-08, -3.67641272e-08, -3.20562270e-08, ..., -4.04995955e-08, -4.19635279e-08, -4.18148254e-08], [-1.06525986e-08, -1.00687668e-08, -9.09799797e-09, ..., -9.93702591e-09, -1.05854377e-08, -1.08270570e-08]], shape=(61, 128)) - v_staggered(y_staggered, x)float642.131e-08 2.014e-08 ... -2.165e-08
array([[ 2.13051972e-08, 2.01375336e-08, 1.81959959e-08, ..., 1.98740518e-08, 2.11708753e-08, 2.16541140e-08], [ 5.88132081e-08, 5.33907208e-08, 4.59164581e-08, ..., 6.11251391e-08, 6.27561803e-08, 6.19755368e-08], [ 1.38273344e-07, 1.19286299e-07, 9.57151487e-08, ..., 1.61474448e-07, 1.59780675e-07, 1.51946621e-07], ..., [-1.38273344e-07, -1.19286299e-07, -9.57151488e-08, ..., -1.61474448e-07, -1.59780675e-07, -1.51946621e-07], [-5.88132081e-08, -5.33907208e-08, -4.59164581e-08, ..., -6.11251391e-08, -6.27561804e-08, -6.19755368e-08], [-2.13051972e-08, -2.01375336e-08, -1.81959959e-08, ..., -1.98740518e-08, -2.11708753e-08, -2.16541140e-08]], shape=(60, 128))
- case :
- kelvin_wave
- case_label :
- Kelvin wave
- short_name :
- KelvinWave
- t :
- 10.0
- nt :
- 100
- nx :
- 128
- ny :
- 60
- nz :
- 20
- lx :
- 37.69911184307752
- ly :
- 15.707963267948966
- lz :
- 3.141592653589793
- damping :
- 0.0
- kernel :
- reyon
- dt :
- 0.1
- dx :
- 0.2945243112740431
- dy :
- 0.25750759455654043
- dz :
- 0.16534698176788384
Plot eta and the horizontal wind vector field.
plot_snapshot(
result_kelvin_wave,
quiver_kwargs={"scale": 8},
contourf_kwargs = {"levels": np.linspace(-1, 1, 21)}
)

<Axes: title={'center': 'Kelvin wave\nt = 10.00'}, xlabel='x', ylabel='y'>
Plot the derived vertical cross-section diagnostics.
plot_cross_sections(
result_kelvin_wave,
contourf_uw_kwargs = {"levels": np.linspace(-0.2, 0.2, 21)},
contourf_vw_kwargs = {"levels": np.linspace(-0.1, 0.1, 21)},
contourf_u_kwargs = {"levels": np.linspace(-0.1, 0.1, 21)}
)

<Figure size 800x800 with 6 Axes>
Total running time of the script: (0 minutes 5.792 seconds)