-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from amoodie/joss_zsylvester_review
JOSS zsylvester review
- Loading branch information
Showing
13 changed files
with
319 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "70c593eb-e479-4b4c-ad52-2d578bfad177", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"# Simple model run example\n", | ||
"\n", | ||
"This Jupyter Notebook shows how to configure and run a model simulation, and how to examine the model outputs.\n", | ||
"\n", | ||
"This document supplements the [10-minute tutorial](https://deltarcm.org/pyDeltaRCM/guides/10min.html) and [User Guide](https://deltarcm.org/pyDeltaRCM/guides/user_guide.html), but is not a complete guide to the model." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ac5919f8-0779-4ac1-b728-bb6c1361ef82", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pyDeltaRCM" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d2d7db35-4f4b-4111-8269-e40478378ac8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import numpy as np\n", | ||
"import netCDF4\n", | ||
"import matplotlib.pyplot as plt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7121c3ca-4c8b-4d5e-9642-b76b35f68a72", | ||
"metadata": {}, | ||
"source": [ | ||
"First, we will configure a YAML file to input to the model." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "169fd14b-3d16-4569-a91f-0523dbbad30d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%writefile eg_config.yaml\n", | ||
"\n", | ||
"f_bedload: 0.25\n", | ||
"h0: 2\n", | ||
"u0: 1.1\n", | ||
"save_eta_figs: True\n", | ||
"save_eta_grids: True\n", | ||
"save_velocity_grids: True\n", | ||
"save_dt: 250000" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "46e6dd75-bd65-4dc3-81a1-29369eb87c6f", | ||
"metadata": {}, | ||
"source": [ | ||
"In the following cell, we instantiate the model with the yaml file we just created, run the model for 1000 steps, and finalize.\n", | ||
"\n", | ||
"**WARNING** executing the run will likely take 30-40 minutes." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a87a3c1d-60bf-4916-b531-1ded37d89050", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"mdl = pyDeltaRCM.DeltaModel('eg_config.yaml')\n", | ||
"\n", | ||
"for _ in range(0, 1000):\n", | ||
" mdl.update()\n", | ||
"\n", | ||
"mdl.finalize()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "57bb6af2-d7a4-4f0a-88b1-d6f29594aa02", | ||
"metadata": {}, | ||
"source": [ | ||
"With the model completed, we can see the final state:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a86fd13d-ffb7-4c31-85c7-be3bd4533001", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = plt.subplots()\n", | ||
"ax.imshow(mdl.eta, cmap='cividis')\n", | ||
"plt.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a2488676-78da-4387-b933-4a237da2ca9f", | ||
"metadata": {}, | ||
"source": [ | ||
"We can also access the history of the run in the output NetCDF4 file." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7e02e59a-f615-4f58-b100-208d466f2df8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data = netCDF4.Dataset(os.path.join('deltaRCM_Output', 'pyDeltaRCM_output.nc')) # this is the default location for the output file" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "32b652fa-6158-412d-a4e8-d0fcdc41c31f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"nt = 3\n", | ||
"ts = np.linspace(0, data['eta'].shape[0]-1,\n", | ||
" num=nt, dtype=int) # linearly interpolate ts\n", | ||
"\n", | ||
"# make the timeseries plot\n", | ||
"fig, ax = plt.subplots(1, nt, figsize=(11, 2), dpi=300)\n", | ||
"for i, t in enumerate(ts):\n", | ||
" ax[i].imshow(data['eta'][t, :, :], cmap='cividis')\n", | ||
" ax[i].axes.get_xaxis().set_ticks([])\n", | ||
" ax[i].axes.get_yaxis().set_ticks([])\n", | ||
"\n", | ||
"plt.tight_layout()\n", | ||
"plt.show()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.