from IPython.display import YouTubeVideo
YouTubeVideo('nRHBdkxVn48')
[...] Today, I want to introduce you to the IPython Notebook and in particuliar describe how the notebook is emerging as an important tool for Data Science.
If you have a bunch of data, the first thing you'll notice it that data is useless on its own. To be usefull, you need to leverage the data to tell a story.
In the process of telling that story, there are many different things that are coming into play :
The IPython Notebook is an open source web-based interactive computing environment for python and other languages that helps you tell stories using data.
As its core, the notebook is designed for writing and running code. For that, you can use the full power of python and its many libraries or even collate other languages such as R (Author Note: or ferret) but in addition to that, the notebook allows you to build shareable documents that combine that
In other words everything that is part of the story you are telling. [...]
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0.0, 5.0, 0.01)
s = np.sin(3*np.pi*t)
plt.plot(t, s, linewidth=4.0, color='b')
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
plt.savefig("test.png")
plt.show()
The IPython Notebook is an open source (BSD) tool for telling stories with code and data that are:
To start the notebook, type
$ ipython notebook
or with the option --notebook-dir to specify that your directory of notebooks is ~/IPy_Notebooks
$ ipython notebook --notebook-dir=~/IPy_Notebooks
You can also load IPython Notebooks that other people have created, saved as IPython Notebook files (File extension .ipynb.) Try downloading and opening some notebook files from http://nbviewer.ipython.org/github/Unidata/unidata-python-workshop/tree/master/ or http://nbviewer.ipython.org/.
After you download the Notebook file, move it into your IPython Notebook working directory and then choose File -> Open in Notebook to open it.
That Notebook contains some additional code, and some suggestions for changes you can make by going back and editing the existing files. Take a few moments to play with the Notebook - rerun the cells, edit the cells to change them, don't be afraid to break things!
You can also load a pre-existing Python file into an IPython Notebook cell by typing
%load "myprogram.py"
Into a cell and running it. This loads up a new cell containing the contents of myprogram.py.
Test this feature out by loading one of the scripts you wrote during the recap session. You may have to specify the full path to the script file, depending on the directory IPython Notebook started up from.
There is one other useful built-in tool for working with Python files:
%run "myprogram.py"
This will run myprogram.py and load the output into a Notebook cell.
We try to make writing code pleasant:
Not just Python code though! Though cell magics (%%
) the Notebook supports running code in other languages:
%%bash
echo "Hello bash world"
Hello bash world
You can enter latex directly with the %%latex cell magic:
%%latex
\begin{aligned}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{aligned}
You can do the same with R or octave.
Esc/Enter
: Mode Switchj/k
: Move up/downShift-Enter
: Run and go downAlt-Enter
: Run and make newControl-Enter
: Run in placea/b
: Insert cell above/belowx
: cut cellr
: rawm
: markdowny
: python code-
: Continue a slideThen type ipython nbconvert Presentation.ipynb --to slides
Then just type: ipython notebook
Read more at http://www.onlamp.com/pub/a/onlamp/excerpt/ssh_11/index1.html
*From your local machine to obelixN (LSCE)*
to get the python from the shared anaconda distribution
*From your local machine to curie (TGCC)*
Forwarding ssh port has been forbidden since 10/02/2015
*From your local machine to ciclad-ng (IPSL)*
Beware not sharing the same port number, indicated above as 70xx. Please visit and update http://wiki.ipsl.jussieu.fr/IGCMG/Outils/IPython_Notebook with an available port number.
Now, you should be able to work directly on the remote file system from the browser of your local machine (NOT the remote cluster or marchine) by opening http://localhost:70xx
Remember that ressources from cluster machines are shared among many users. So please shutdown notebooks that are not used anymore (press the red button to do so) and shutdown the notebook server when finish your work (press twice CTRL+C in the console you launch the server). The notebook server has an autosave system and you will certainly find back your notebook in the state you let it.
When ready to publish:
You can also use gitHub and structure all your notebooks in a repository as https://github.com/PBrockmann/IPy_Notebooks and browsable from http://nbviewer.ipython.org/github/PBrockmann/IPy_Notebooks
from IPython.display import YouTubeVideo
YouTubeVideo('XkXXpaVpNSc')
An article from Nature that describes the IPython notebook in a study on Workflow software Platforms
http://www.nature.com/naturejobs/2014/140327/pdf/nj7493-523a.pdf
Original workflow
Now workflow
The IPython Notebook provides an open source environment and foundation for telling stories with code and data.
It puts the fun back into working with code and data
It is finally all about a documented and reproductible workflow that brings you a fluid transition between:
Official website
A good introduction
Lectures organized by Unidata team
The ferret extension for pyferret
Must have python packages
Promising packages
Collection of notebooks
Please contact me Patrick.Brockmann@lsce.ipsl.fr