Commit ab95f8bf authored by Inigo Aldazabal's avatar Inigo Aldazabal

intro removed and now in LaTeX

parent a5415d6c
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# SciPy tutorial\n",
"\n",
"PySS15 22-24th October 2015 - San Sebastian\n",
"\n",
"### Iñigo Aldazabal (inigo_aldazabal@ehu.eus)\n",
"\n",
"[https://github.com/iamc/PySS15-Scipy-tutorial](https://github.com/iamc/PySS15-scientific-python-tutorial)\n",
"\n",
"![logos](images/scipy-pyss15.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Why Python for Scientific Computing?\n",
"\n",
"Python is inherently slow compared to C/C++ or FORTRAN, so why\n",
"Python for Scientific Computing?\n",
"\n",
"Python is slow, but...\n",
"\n",
"> Syntactically, Python code looks like executable pseudo code. Program development using Python is 5-10 times faster than using C/C++...\n",
">\n",
"> The best approach is often to write only the performance-critical parts of the application in C++ or Java, and use Python for all higher-level control and customization.\n",
"> \n",
">\n",
"> &mdash; <cite>Guido van Rossum</cite>\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#So we have...\n",
"\n",
"\n",
"* A general purpose language with a huge spectrum of freely available libraries for almost anything you can think of.\n",
"\n",
"* A very easy to learn (and read) language that smoothly interfaces with C/C++ and FORTRAN (eg. calculation kernels).\n",
"\n",
"* Lots of wrappers for well stablished, fast and long time tested numerical packages.\n",
"\n",
"* Lots of high level utility libraries for scientific computing: plotting, data analisys, paralelization, ...\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Python Scientific Computing Environment![imagen](images/scipy_cover.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"![imagen](images/scipy_cover_selection.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# NumPY"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"#Scipy\n",
"\n",
"SciPy is a collection of mathematical algorithms and convenience functions built on the Numpy extension of Python. It adds significant power to the interactive Python session by providing the user with high-level commands and classes for manipulating and visualizing data. With SciPy an interactive Python session becomes a data-processing and system-prototyping environment rivaling sytems such as MATLAB, IDL, Octave, R-Lab, and SciLab."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## SciPy subpackages\n",
"\n",
"* cluster: Clustering algorithms\n",
"* constants: Physical and mathematical constants\n",
"* fftpack: Fast Fourier Transform routines\n",
"* integrate: Integration and ordinary differential equation solvers\n",
"* interpolate: Interpolation and smoothing splines\n",
"* io: Input and Output\n",
"* linalg: Linear algebra\n",
"* maxentropy: Maximum entropy methods\n",
"* ndimage: N-dimensional image processing\n",
"* odr: Orthogonal distance regression\n",
"* optimize: Optimization and root-finding \n",
"* signal: Signal processing\n",
"* sparse: Sparse matrices and associated routines\n",
"* spatial: Spatial data structures and algorithms\n",
"* special: Special functions\n",
"* stats: Statistical distributions and functions\n",
"* weave: C/C++ integration"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"#Matplotlib"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"![IPython](images/ipython_logo-s.png)\n",
"\n",
"#IPython\n",
"\n",
"The **IPython Notebook** is a web-based interactive computing system that enables users to author documents that include live code, narrative text, LaTeX equations, HTML, images and video.\n",
"\n",
"These documents contain a full record of a computation and its results and can be shared on email, Dropbox, version control systems (like git/GitHub) or nbviewer.ipython.org.\n",
"\n",
"Let's see it in more detail.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Starting the notebook server using the command line\n",
"\n",
"You can start the notebook server from the command line (Terminal on Mac/Linux, CMD prompt on Windows) by running the command: \n",
"\n",
"```bash\n",
" ipython notebook\n",
"```\n",
"![ip_dachboard](images/dashboard_files_tab.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Basic conceps\n",
"\n",
"* **Kernels**: Separate processes started by the notebook web application that runs users' code in a given language and returns output back to the notebook web application. \n",
"\n",
"* **Notebook documents**: Self-contained documents that contain a representation of all content visible in the notebook web application, including inputs and outputs of the computations, narrative text, equations and images. Each notebook document has its own kernel."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Cell types\n",
"\n",
"We have different types of cells. The type of a cell is selected from the dropdown menu or with a keyboard shortcut in command mode. We'll see `code` cells and `Markdown` cells. \n",
"\n",
"This is a **Markdown** cell itself and is used to add formatted text to your notebooks. You can use both [Markdown](https://en.wikipedia.org/wiki/Markdown) syntax and [LaTeX](https://en.wikipedia.org/wiki/LaTeX) syntax.\n",
"\n",
"You can include mathematical expressions both inline: $e^{i\\pi} + 1 = 0$ and displayed:\n",
"\n",
"$$e^x=\\sum_{i=0}^\\infty \\frac{1}{i!}x^i$$\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1.0, 4.0, 3.14]\n"
]
}
],
"source": [
"# This is a **Code cell** which allow us to input and run Python code\n",
"# Once the cell is run the corresponding output, if any, appears below it.\n",
"a = [1., 4., 3.14]\n",
"print (a)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Modal editor\n",
"\n",
"\n",
"The IPYthon Notebook has a modal user interface with two modes: \n",
"\n",
"* **edit** mode \n",
"\n",
"* **command** mode\n",
"\n",
"The keyboard does different things depending on which mode the Notebook is in.\n",
"\n",
" \n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Edit mode\n",
"\n",
"Edit mode is indicated by a green cell border and a prompt showing in the editor area:\n",
"\n",
"<img src=\"images/edit_mode.png\">\n",
"\n",
"When a cell is in edit mode, you can type into the cell, like a normal text editor.\n",
"\n",
"<div class=\"alert alert-success\">\n",
"Enter edit mode by pressing ENTER or using the mouse to click on a cell's editor area.\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"### Command mode\n",
"\n",
"Command mode is indicated by a grey cell border:\n",
"\n",
"<img src=\"images/command_mode.png\">\n",
"\n",
"When you are in command mode, you are able to edit the notebook as a whole, but **not type into individual cells**. Most importantly, in command mode, the keyboard is mapped to a set of shortcuts that let you perform notebook and cell actions efficiently.\n",
"\n",
"<div class=\"alert alert-success\">\n",
"Enter command mode by pressing ESC or using the mouse to click *outside* a cell's editor area.\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Running cells\n",
"\n",
"The keyboard shortcuts for running a cell, both in edit and command mode, are:\n",
"\n",
"* `Shift-Enter` runs the current cell and moves to the one below.\n",
"* `Alt-Enter` runs the current cell and inserts a new one below.\n",
"* `Ctrl-Enter` run the current cell and enters command mode in current cell.\n",
"\n",
"\n",
"<div class=\"alert alert-success\">\n",
"Press 'h' anytime in command mode for a keyboard shotcut list.\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Tab completion & help (edit mode)\n",
"\n",
"\n",
"### Tab completion\n",
"\n",
"Simply type in a code cell `object_name.<TAB>` to view the object’s attributes. Besides Python objects and keywords, tab completion also works on file and directory names.\n",
"\n",
"### Object help\n",
"\n",
"Type `object_name.<SHIFT+TAB>` and a tooltip with the object short help will open. \n",
"\n",
"Pressing `<TAB>` twice (`<SHIFT+TAB+TAB>`) the full object help will open. \n",
"\n",
"Doing it four times and the full object help will go into a new frame."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"\n",
"# Let's try!\n"
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3",
"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.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment