diff --git a/04_nemo_idealized.ipynb b/04_nemo_idealized.ipynb index 34773a8..b6fb85b 100644 --- a/04_nemo_idealized.ipynb +++ b/04_nemo_idealized.ipynb @@ -6,7 +6,7 @@ "source": [ "# NEMO Example \n", "\n", - "For this example, the NEMO output files have already been saved as netCDF with the right coordinate names. The [xorca](https://github.com/willirath/xorca) package is designed to open NEMO datasets so they are understandable by xgcm. The [xnemogcm](https://github.com/rcaneill/xnemogcm) does a similar work on idealized configurations.\n", + "For this example, the NEMO output files have already been saved as netCDF with the right coordinate names. The [xnemogcm](https://github.com/rcaneill/xnemogcm) package is designed to open NEMO datasets so they are understandable by xgcm.\n", "\n", "Below are some example of how to make calculations using xgcm.\n", "\n", @@ -23,307 +23,1915 @@ "import numpy as np\n", "import xgcm\n", "from matplotlib import pyplot as plt\n", + "\n", + "xr.set_options(display_expand_attrs=False, display_expand_data=False)\n", + "\n", "%matplotlib inline\n", - "plt.rcParams['figure.figsize'] = (6,10)" + "plt.rcParams['figure.figsize'] = (4,5)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'0.8.1'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xgcm.__version__" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we open the NEMO example dataset, from the BASIN configuration.\n", + "\n", + "We get a dataset produced for the purpose of this documentation, as the time average of the reference run of the paper \n", + "The Polar Transition from Alpha to Beta Regions Set by a Surface Buoyancy Flux Inversion, [Caneill et al 2022, JPO](https://doi.org/10.1175/JPO-D-21-0295.1)\n", + "\n", + "\n", + "Link to the dataset: [](https://doi.org/10.5281/zenodo.7795560)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
<xarray.Dataset>\n", + "Dimensions: (z_c: 36, axis_nbounds: 2, y_c: 79, x_c: 42, x_f: 42,\n", + " y_f: 79, z_f: 36)\n", + "Coordinates: (12/18)\n", + " * z_c (z_c) int64 0 1 2 3 4 5 6 7 8 ... 27 28 29 30 31 32 33 34 35\n", + " * x_c (x_c) int64 0 1 2 3 4 5 6 7 8 ... 33 34 35 36 37 38 39 40 41\n", + " * y_c (y_c) int64 0 1 2 3 4 5 6 7 8 ... 70 71 72 73 74 75 76 77 78\n", + " gdept_1d (z_c) float64 ...\n", + " * x_f (x_f) float64 0.5 1.5 2.5 3.5 4.5 ... 38.5 39.5 40.5 41.5\n", + " * y_f (y_f) float64 0.5 1.5 2.5 3.5 4.5 ... 75.5 76.5 77.5 78.5\n", + " ... ...\n", + " gphit (y_c, x_c) float64 ...\n", + " gphiu (y_c, x_f) float64 ...\n", + " gphiv (y_f, x_c) float64 ...\n", + " gphif (y_f, x_f) float64 ...\n", + " gdept_0 (z_c, y_c, x_c) float64 ...\n", + " gdepw_0 (z_f, y_c, x_c) float64 ...\n", + "Dimensions without coordinates: axis_nbounds\n", + "Data variables: (12/46)\n", + " deptht_bounds (z_c, axis_nbounds) float32 ...\n", + " e3t (z_c, y_c, x_c) float32 ...\n", + " thetao (z_c, y_c, x_c) float32 ...\n", + " so (z_c, y_c, x_c) float32 ...\n", + " tos (y_c, x_c) float32 ...\n", + " zos (y_c, x_c) float32 ...\n", + " ... ...\n", + " hv_0 (y_f, x_c) float64 ...\n", + " tmask (z_c, y_c, x_c) int8 ...\n", + " umask (z_c, y_c, x_f) int8 ...\n", + " vmask (z_c, y_f, x_c) int8 ...\n", + " fmask (z_c, y_f, x_f) int8 ...\n", + " mbathy (y_c, x_c) int32 ...
<xarray.DataArray ()>\n", + "6.281e-11
<xarray.DataArray ()>\n", + "4.189e-09\n", + "Coordinates:\n", + " z_c int64 0\n", + " gdept_1d float64 5.0
<xarray.DataArray ()>\n", - "array(True)
array(True)
<xarray.DataArray (y_f: 79, x_f: 42, z_c: 36)>\n", + "1.319e-12 2.52e-12 2.39e-11 9.742e-11 1.771e-10 ... 0.0 0.0 0.0 0.0 0.0\n", + "Coordinates:\n", + " * x_f (x_f) float64 0.5 1.5 2.5 3.5 4.5 5.5 ... 37.5 38.5 39.5 40.5 41.5\n", + " * y_f (y_f) float64 0.5 1.5 2.5 3.5 4.5 5.5 ... 74.5 75.5 76.5 77.5 78.5\n", + " glamf (y_f, x_f) float64 0.0 1.0 2.0 3.0 4.0 ... 38.0 39.0 40.0 41.0\n", + " gphif (y_f, x_f) float64 -0.5 -0.5 -0.5 -0.5 ... 61.01 61.01 61.01 61.01\n", + " * z_c (z_c) int64 0 1 2 3 4 5 6 7 8 9 ... 26 27 28 29 30 31 32 33 34 35\n", + " gdept_1d (z_c) float64 ..." ], "text/plain": [ - "
<xarray.DataArray ()>\n", - "array(5.44218669e-19)
array(5.44218669e-19)
<xarray.DataArray 'Fv' (z_c: 35, y_f: 79, x_c: 42)>\n", + "0.0 0.8437 -0.004764 -0.6617 -0.8594 -0.7288 -0.5642 ... 0.0 0.0 0.0 0.0 0.0 0.0\n", + "Coordinates:\n", + " * z_c (z_c) int64 0 1 2 3 4 5 6 7 8 9 ... 25 26 27 28 29 30 31 32 33 34\n", + " * x_c (x_c) int64 0 1 2 3 4 5 6 7 8 9 ... 32 33 34 35 36 37 38 39 40 41\n", + " gdept_1d (z_c) float64 ...\n", + " * y_f (y_f) float64 0.5 1.5 2.5 3.5 4.5 5.5 ... 74.5 75.5 76.5 77.5 78.5\n", + " glamv (y_f, x_c) float64 ...\n", + " gphiv (y_f, x_c) float64 ..." ], "text/plain": [ - "
<xarray.DataArray ()>\n", - "array(True)
array(True)
<xarray.DataArray 'Fv_transformed' (y_f: 79, x_c: 42, depth_T_uniform: 100)>\n", + "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 0.0\n", + "Coordinates:\n", + " * x_c (x_c) int64 0 1 2 3 4 5 6 7 8 ... 34 35 36 37 38 39 40 41\n", + " * y_f (y_f) float64 0.5 1.5 2.5 3.5 4.5 ... 75.5 76.5 77.5 78.5\n", + " glamv (y_f, x_c) float64 ...\n", + " gphiv (y_f, x_c) float64 ...\n", + " * depth_T_uniform (depth_T_uniform) float64 20.0 60.0 ... 3.94e+03 3.98e+03" ], "text/plain": [ - "
<xarray.DataArray ()>\n", - "array(2.07489191e-17)
array(2.07489191e-17)
<xarray.DataArray 'thetao' (y_c: 79, x_c: 42, dim_0: 1)>\n", + "nan nan nan nan nan nan nan nan nan nan ... nan nan nan nan nan nan nan nan nan\n", + "Coordinates:\n", + " * x_c (x_c) int64 0 1 2 3 4 5 6 7 8 9 ... 32 33 34 35 36 37 38 39 40 41\n", + " * y_c (y_c) int64 0 1 2 3 4 5 6 7 8 9 ... 69 70 71 72 73 74 75 76 77 78\n", + " glamt (y_c, x_c) float64 -0.5 0.5 1.5 2.5 3.5 ... 37.5 38.5 39.5 40.5\n", + " gphit (y_c, x_c) float64 -0.9999 -0.9999 -0.9999 ... 60.76 60.76 60.76\n", + "Dimensions without coordinates: dim_0" ], "text/plain": [ - "