Skip to content

Commit

Permalink
Add notebook versions of Numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoresi committed Apr 24, 2024
1 parent 3b54083 commit 640eda7
Show file tree
Hide file tree
Showing 9 changed files with 2,583 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Notebooks/Themes/NumpyAndScipy-IPYNB/0-NumpyAndScipy.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "e8a4e5c8",
"metadata": {},
"source": [
"# Numpy and Scipy\n",
"\n",
"In this section we introduce the `numpy` and `scipy` packages that you will certainly use and will need to know for this course. \n",
"\n",
"`numpy` focuses on the efficient manipulation of structured data that in many languages would already be included as some sort of *array* data type. `numpy` provides routines to do many operations on arrays of data such as sorting, finding the largest or smallest element, transposing data and so on. It also provides many mathematical operations including the expected (element-by-element) functions (trigonometry, exponentials etc). \n",
"\n",
"`numpy` also provides an extensive overloading of the standard operators for manipulating lists of data (etc) that make array operations quite natural and compact in python. It is very important to understand what `numpy` is doing because it is almost impossible to avoid close encounters with these operators in everyday python. \n",
"\n",
"`numpy` has been very carefully optimised and, used correctly, will give you access to very efficient (mostly that means *fast*) code without having to leave the python environment. This means you should always look to see if there is a `numpy` function to do what you need *and never write a python loop if you can help it*. \n",
"\n",
" - [Introduction To Numpy](1-IntroductionToNumpy.md) - This notebook goes into more detail about why we need `numpy`, what the operator overloading looks like, and explores the speed benefits of using `numpy`. The other benefits are readability of your code (as long as you understand the operator overloading) and reliability because you are using pre-built code, not writing your own loops. \n",
" - [The game of life 1](2-Application-TheGameOfLife.md) - This notebook sets up an exercise: the game of life, to show how `numpy` works in a real problem. We will see how to approach problems of structured data so that we can most of the work efficiently with `numpy`.\n",
" - [The game of life 2](3-Discussion-TheGameOfLife.md) - Here we have a chance to reflect on the choices we made in the previous notebook and think about how things could be done better (or differently, anyway). \n",
"\n",
" These notebooks are not intended to be comprehensive because you will have lots of opportunity to practice looking at `numpy` code when we look at satellite images and basemaps in the [`cartopy` mapping](Notebooks/Themes/Mapping/0-Maps_with_Cartopy.md) examples, and the [`stripy` spherical meshing](Notebooks/Themes/SphericalMeshing/0-Stripy.md) examples. \n",
"\n",
" `scipy` is a collection of useful algorithms loosely bundled together. If you have ever come across the book \"Numerical Recipes\" then you will know what `scipy` is trying to do: there is usually some reasonable implementation in `scipy` for whatever problem you are faced with: interpolation, optimisation, meshing, image manipulation. It is neither comprehensive nor definitive but, like a Swiss-Army Knife, more useful in a pinch than most other tools.\n",
"\n",
" - [Introduction](4-IntroductionToScipy.md) - Really just a list of modules that `scipy` provides. Each of the modules is a collection of related functionality that has a mostly-consistent user interface."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 640eda7

Please sign in to comment.