Skip to content

Commit

Permalink
changes in headers and layout
Browse files Browse the repository at this point in the history
  • Loading branch information
BCampforts committed Aug 12, 2020
1 parent 1834409 commit 29d1713
Show file tree
Hide file tree
Showing 11 changed files with 354 additions and 200 deletions.
20 changes: 7 additions & 13 deletions lessons/python/ESPIN - numerical modeling in python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"source": [
"## Advancing your science using scientific programming ##\n",
"\n",
"This series of notebooks is based on existing python software carpentry material developed by Mark Piper and and adjusted to include the example of the Icelandic Eyjafjallajökull eruption by Benjamin Campforts. \n",
"\n",
"This series of notebooks is partly based on existing materials from the python software carpentry of CSDMS developed by Mark Piper, Mariela Perignon and others, and further extended and adjusted in the framework of ESPIn 2020 by Benjamin Campforts. \n",
"\n",
"The best way to learn how to program is to solve a scientific question,\n",
"so this introduction to Python is built around the simulation of the spread of ash aerosols (ppm) over Iceland and the rest of Europe, produced by the Icelandic Eyjafjallajökull eruption in 2010. \n",
Expand All @@ -39,12 +38,12 @@
"\n",
"> ## Getting ready\n",
">\n",
"> Notebooks used in this session can be run on the CSDMS Jupyter hub. Alternatively, you can run them on your personal computer. \n",
"> You need to have Python 3.6.10 installed on your computer. For instructions on how to > install this software, visit [the CSDMS workshop page](http://mperignon.github.io/2016-05-16-csdms).\n",
"> Notebooks used in this session can be run on the CSDMS Jupyterhub. Alternatively, you can run them on your personal computer. \n",
"> You need to have Python 3 installed on your computer. We recommend installing [Anaconda](https://www.anaconda.com/products/individual), then following the instructions for setting up the ESPIn `conda` environment in the [Anaconda and conda](./conda/index.md) lesson.\n",
">\n",
"> You also need to download some files to follow this lesson:\n",
">\n",
"> 1. Download [swc_python.zip](swc_python.zip) and move it to your Desktop\n",
"> 1. Download [swc_python.zip](../../swc_python.zip) and move it to your Desktop\n",
"> 2. If it's not unzipped yet, double-click on it to unzip it. You should end up with a new folder called `swc_python`.\n",
"> 3. Access this folder from the Unix shell :\n",
"> ~~~ \n",
Expand All @@ -64,8 +63,10 @@
" <figcaption> On 14 April 2010, the Eyjafjallajökull volcano became one of the most famous volcanoes in the world causing major disruption to air traffic in northern Europe.</figcaption>\n",
"</figure>\n",
"\n",
"If you want to learn more about all this, [this is a nice EOS article](https://eos.org/research-spotlights/volcanic-ash-contributes-to-climate-cooling)\n",
"\n",
"## Goal\n",
"Your goal for today and tomorrow will be to simulate the amount of ash aerosols (ppm) over Iceland and the rest of Europe, produced by the Eyjafjallajökull volcano in its explosive phase. Special attention will be given to the ash concentration in Brussels. Aerosols are tracer elements, transported by the wind and can be modeled as an advection diffusion system. In this exercise, the units of aerosols are parts per million (ppm). Note that this exercise is a simplified version of reality: used parameter values and concentrations are all arbitrary and merely picked for the puprpose of demonstration the advection (also referred to as convection) diffusion equation. \n",
"Your goal for today and tomorrow will be to simulate the amount of ash aerosols (ppm) over Iceland and the rest of Europe, produced by the Eyjafjallajökull volcano in its explosive phase. Special attention will be given to the ash concentration in Brussels. Aerosols are tracer elements, transported by the wind and can be modeled as an advection diffusion system. In this exercise, the units of aerosols are parts per million (ppm). Note that this exercise is a simplified version of reality: used parameter values and concentrations are all arbitrary and merely picked for the purpose of demonstrating the advection (also referred to as convection) diffusion equation. \n",
"\n",
"## Topics\n",
"Before we dive into the solution of the advection-diffusion problem posed by the volcanic eruption, we need to cover some basic python programming skills: \n",
Expand All @@ -90,13 +91,6 @@
"* [Reference](reference.html)\n",
"* [csdms-software-carpentry](https://github.com/csdms/csdms-carpentry)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
33 changes: 15 additions & 18 deletions lessons/python/ESPIN-01-numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"layout: page\n",
"title: Programming with Python\n",
"subtitle: Analyzing Topographic Data\n",
"minutes: 30\n",
"---\n",
" ## Learning Objectives {.objectives}\n",
"\n",
" * Explain what a library is, and what libraries are used for\n",
" * Load a Python library and use the tools it contains\n",
" * Read data from a file into a program\n",
" * Assign values to variables\n",
" * Select individual values and subsections from data\n",
" * Perform operations on arrays of data\n",
" * Display simple graphs\n",
"# Programming with Python\n",
"## Analyzing Topographic Data\n",
"### minutes: 30\n",
"\n",
">## Learning Objectives\n",
">* Explain what a library is, and what libraries are used for\n",
">* Load a Python library and use the tools it contains\n",
">* Read data from a file into a program\n",
">* Assign values to variables\n",
">* Select individual values and subsections from data\n",
">* Perform operations on arrays of data\n",
">* Display simple graphs\n",
"\n",
"While a lot of powerful tools are built into languages like Python,\n",
"even more tools exist in [libraries](reference.html#library).\n",
Expand Down Expand Up @@ -120,7 +117,7 @@
"variable name to an object using `=`.\n",
"\n",
"\n",
"## Objects and their names {.callout}\n",
"## Objects and their names\n",
"\n",
"What happens when a function is called but the output is not assigned to\n",
"a variable is a bit more complicated than simply not saving it. The call\n",
Expand Down Expand Up @@ -181,7 +178,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
" ## Check your understanding {.challenge}\n",
" ## Check your understanding\n",
"\n",
" Track how variable names and values are connected after each statement in the following program:"
]
Expand Down Expand Up @@ -938,7 +935,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"> ## Methods vs. attributes {.callout}\n",
"> ## Methods vs. attributes\n",
"> \n",
"> `mean` is a method that belongs to the array `topo`, i.e., it is a\n",
"> function `topo` can inherently call just because of its type.\n",
Expand Down
4 changes: 2 additions & 2 deletions lessons/python/ESPIN-03-scripts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Deprecation warnings {.callout}\n",
"## Deprecation warnings\n",
"\n",
"The Bash window might be showing a message like this:"
]
Expand Down Expand Up @@ -275,7 +275,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plotting memory buffer {.callout}\n",
"## Plotting memory buffer\n",
"\n",
"You might want your script to save the figure and still show it as an interactive figure window. Every plotting command in our script adds data to a memory buffer. Waiting until all lines are plotted before showing the figure is more efficient than repeatedly redrawing the figure. The function `plt.close()` (or closing the interactive figure window) empties that buffer. If we want to save the figure, we need to include the `plt.savefig()` command before the memory buffer empties.\n",
"\n",
Expand Down
60 changes: 15 additions & 45 deletions lessons/python/ESPIN-05 Models Part 1 (Diffusion).ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@
"Benjamin Campforts, [email protected]\n",
"Lecture notes on diffusion are partly based on Prof. Dr. Frédéric Herman's course on geophysical processes \n",
"\n",
"> ## Learning Objectives \n",
">\n",
"> * Explain what a for loop does\n",
"> * Correctly write for loops to repeat simple calculations\n",
"> * Trace changes to a loop variable as the loop runs\n",
"> * Trace changes to other variables as they are updated by a for loop\n",
"\n",
"\n",
"\n",
"Many members of our community focus on developing numerical models to study how landscapes evolve over time. The simplest and most commonly used transport law used to capture the evolution of hillslopes is a diffusion equation:\n",
"\n",
"$$\\frac{\\partial z}{\\partial t} = K \\; \\frac{\\partial^2 z}{\\partial x^2}$$\n",
"\n",
"where $z$ is elevation, $x$ is the horizontal distance, and $K$ is a landscape diffusion coefficient.\n",
"\n",
"\n",
"## Diffusion\n",
"\n",
"### Introduction\n",
Expand Down Expand Up @@ -114,7 +98,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -139,21 +123,9 @@
"print(random.random(), random.random(), random.random())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### add callout and exercises from 03-loops"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -196,7 +168,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Elapsed time is: 6.171136140823364sec\n"
"Elapsed time is: 5.70633602142334sec\n"
]
}
],
Expand Down Expand Up @@ -245,7 +217,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -504,7 +476,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Elapsed time is: 18.42082691192627sec\n"
"Elapsed time is: 16.847065925598145sec\n"
]
}
],
Expand Down Expand Up @@ -586,17 +558,17 @@
"\n",
"$$ \\frac{\\Delta C}{\\Delta t} = \\frac{q_x -q_{x+dx}}{\\Delta X} \\label{eq:A6} \\tag{A6}$$\n",
"\n",
"Using the definition of a partial difference equation:\n",
"Using the definition of a differential equation:\n",
"\n",
"$$ \\frac{\\delta q}{\\delta x} = \\frac{(q_{x+dx} -q_x)}{\\Delta X} \\label{eq:A7} \\tag{A7}$$\n",
"\n",
"We obtain the following equation:\n",
"We obtain the following equation (note the use of the $\\partial$ symbol: we solve a PDE):\n",
"\n",
"$$ \\frac{\\delta C}{\\delta t} = -\\frac{\\delta q}{\\delta x} \\label{eq:2} \\tag{2}$$\n",
"$$ \\frac{\\partial C}{\\partial t} = -\\frac{\\partial q}{\\partial x} \\label{eq:2} \\tag{2}$$\n",
"By combining Eqs.(\\ref{eq:1}) and (\\ref{eq:2}), we finally obtain the heat\n",
"equation: \n",
"\n",
"$$ \\frac{\\delta C}{\\delta t} = D\\frac{\\delta^2 C}{\\delta x^2} \\label{eq:3} \\tag{3}$$\n",
"$$ \\frac{\\partial C}{\\partial t} = D\\frac{\\partial^2 C}{\\partial x^2} \\label{eq:3} \\tag{3}$$\n",
"\n",
"which depends only on the curvature (i.e. the second derivative) of the concentration and the diffusion constant. Therefore, it is sufficient to know the diffusion coefficient $D$ (which can be measured) and to measure the curvature to estimate the change in concentration over time."
]
Expand Down Expand Up @@ -631,7 +603,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -744,7 +716,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -835,9 +807,7 @@
"\n",
"**Figure:** 1D situation sketch\n",
"\n",
"Solve the spread of ash using the diffusion equation: \n",
"\n",
"$$ \\frac{\\delta C}{\\delta t} = D\\frac{\\delta^2 C}{\\delta x^2} \\label{eq:3} \\tag{3}$$\n",
"Solve the spread of ash using the diffusion equation (Eq. 3)\n",
"\n",
"Define the model parameters: \n",
"- set the diffusivity to 25 km$^2$/h\n",
Expand All @@ -852,7 +822,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -868,7 +838,7 @@
"<Figure size 432x288 with 0 Axes>"
]
},
"execution_count": 10,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -944,7 +914,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down
384 changes: 311 additions & 73 deletions lessons/python/ESPIN-06 Models Part 2 (Advection).ipynb

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions lessons/python/ESPIN-07-func.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"layout: page\n",
"title: Programming with Python\n",
"subtitle: Creating Functions\n",
"minutes: 30\n",
"---\n",
"# Programming with Python\n",
"## Creating Functions\n",
"### minutes: 30\n",
"\n",
"> ## Learning Objectives\n",
">\n",
"> * Define a function that takes parameters.\n",
Expand Down
43 changes: 0 additions & 43 deletions lessons/python/index.ipynb

This file was deleted.

Binary file added media/Stencil1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/Stencil2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/UpwindScheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added swc_python.zip
Binary file not shown.

0 comments on commit 29d1713

Please sign in to comment.