From cb609261eea1dd257ab187c04a07f9a792cdc439 Mon Sep 17 00:00:00 2001 From: "Navid C. Constantinou" Date: Sat, 24 Aug 2024 08:00:17 +1000 Subject: [PATCH] adds some diagnostic plots in demo --- demos/reanalysis-forced.ipynb | 59 ++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/demos/reanalysis-forced.ipynb b/demos/reanalysis-forced.ipynb index f66e8333..2ffcaec7 100644 --- a/demos/reanalysis-forced.ipynb +++ b/demos/reanalysis-forced.ipynb @@ -25,7 +25,7 @@ "\n", "Setting up a regional model in MOM6 can be a pain. The goal of this package is that users should spend their debugging time fixing a model that's running and doing weird things, rather than puzzling over a model that won't even start.\n", "\n", - "In running this notebook, you'll hopefully have a running MOM6 regional model. There will still be a lot of fiddling to do with the `MOM_input` file to make sure that the parameters are set up right for your domain, and you might want to manually edit some of the input files. *But*, this package should help you bypass most of the woes of regridding, encoding and understanding the arcane arts of the MOM6 boundary segment files. " + "In running this notebook, you'll hopefully have a running MOM6 regional model. There will still be a lot of fiddling to do with the `MOM_input` file to make sure that the parameters are set up right for your domain, and you might want to manually edit some of the input files. *But*, this package should help you bypass most of the woes of regridding, encoding, and understanding the arcane arts of the MOM6 boundary segment files. " ] }, { @@ -147,13 +147,22 @@ "source": [ "We can now access the horizontal and vertical grid of the regional configuration via `expt.hgrid` and `expt.vgrid` respectively.\n", "\n", - "Plotting the vertical grid with `marker = '.'` lets you see the spacing. You can use `numpy.diff` to compute the vertical spacings, e.g.,\n", - "```python\n", - "import numpy as np\n", - "np.diff(expt.vgrid.zl).plot(marker = '.')\n", - "```\n", - "shows you the vertical spacing profile.\n", - "\n", + "Plotting the vertical grid with `marker = '.'` lets us see the spacing." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "expt.vgrid.zl.plot(marker = '.', y='zl', yincrease=False, figsize=(4, 8))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "### Modular workflow!\n", "\n", "After constructing your `expt` object, if you don't like the default `hgrid` and `vgrid` you can simply modify and then save them back into the `expt` object. However, you'll then also need to save them to disk again. For example:\n", @@ -271,7 +280,7 @@ "\n", "This cuts out and interpolates the initial condition as well as all boundaries (unless you don't pass it boundaries).\n", "\n", - "The dictionary maps the MOM6 variable names to what they're called in your ocean input file. Notice how for GLORYS, the horizontal dimensions are `latitude` and `longitude`, vs `xh`, `yh`, `xq`, `yq` for MOM6. This is because for an 'A' grid type tracers share the grid with velocities so there's no difference.\n", + "The dictionary maps the MOM6 variable names to what they're called in your ocean input file. Notice how for GLORYS, the horizontal dimensions are `latitude` and `longitude`, vs `xh`, `yh`, `xq`, `yq` for MOM6. This is because for an Arakawa type A grid, tracers share the grid with velocities so there's no difference.\n", "\n", "If one of your segments is land, you can delete its string from the 'boundaries' list. You'll need to update MOM_input to reflect this though so it knows how many segments to look for, and their orientations." ] @@ -309,6 +318,30 @@ " )" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can plot our the interpolated initial condition. It’s a good idea to check and ensure things look reasonable, especially near the region’s boundaries." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axes = plt.subplots(ncols=3, figsize=(16, 4))\n", + "\n", + "expt.ic_eta.plot(ax=axes[0])\n", + "expt.ic_vels.u.sel(zl=0, method='nearest').plot(ax=axes[1])\n", + "expt.ic_vels.v.sel(zl=0, method='nearest').plot(ax=axes[2])\n", + "\n", + "axes[0].set_title(\"sea surface height\")\n", + "axes[1].set_title(\"u velocity @ surface\")\n", + "axes[2].set_title(\"v velocity @ surface\");" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -373,7 +406,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Step 8: Modify the default input directory to make a (hopefully) runnable configuration out of the box\n", + "## Step 8: Modify the default input directory to make a out-of-the-box runnable configuration\n", "\n", "This step copies the default directory and modifies the `MOM_layout` files to match your experiment by inserting the right number of x, y points and CPU layout.\n", "\n", @@ -409,7 +442,9 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "client.close()" + ] } ], "metadata": { @@ -428,7 +463,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.10.6" } }, "nbformat": 4,