Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Jupyter notebook Nature.ipynb
Introduction
Welcome! You have just launched a live example of an IPython Notebook. The notebook is an open-source, interactive computing environment that lets you combine live code, narrative text, mathematics, plots and rich media in one document. Notebook documents provide a complete reproducible record of a computation and its results and can be shared with colleagues (through, for example, email, web-hosting services such as GitHub, Dropbox, and nbviewer).
You can edit anything in this temporary demonstration notebook, including the text you are reading. To see it full-screen, click on the 'Expand' icon in the lower right corner of the frame around this notebook.
This notebook showcases some of IPython's capabilities for researchers.
This demonstration is hosted by Rackspace and is running on its bare metal offering, OnMetal. Try out these cloud services yourself through Rackspace's developer+ page.
Basic Python code and plotting
The box below (known as a code cell) contains the Python code to plot over the range . The blue comments preceded by #
explain what the code does.
To run the code:
Click on the cell to select it.
Press
SHIFT+ENTER
on your keyboard or press the play button ([removed]) in the toolbar above.
A full tutorial for using the notebook interface is available here.
Above, you should see a plot of .
You can edit this code and re-run it. For example, try replacing y = x**2
with y=np.sin(x)
. For a list of valid functions, see the NumPy Reference Manual. You can also update the plot title and axis labels.
Text in the plot as well as narrative text in the notebook can contain equations that are formatted using . To edit text written in , double click on the text or press ENTER
when the text is selected.
Interactive illustration of aliasing
Notebooks can also link code and data to user interfaces (such as sliders, checkboxes, dropdowns) that facilitate interactive exploration.
Aron Ahmadia (Coastal & Hydraulics Laboratory at the US Army Engineer Research and Development Center) and David Ketcheson (King Abdullah University of Science & Technology) created the following example to illustrate the perils of aliasing, which occurs when a rapidly-changing periodic signal is sampled too infrequently, and creates a false impression of the true frequency of the signal.
Ketcheson explains:
"As an undergraduate, I did some observational astronomy looking at variable stars. These are stars whose brightness oscillates, usually on a fairly regular basis. Many published results claim to measure how quickly the star's brightness oscillates - but actually report the oscillations at some multiple of the real answer, owing to insufficient observation and (as a result) aliasing."
This example shows how trying to reconstruct a simple sine wave signal from discrete measurements can fail. The sliders allow you to adjust the frequency of the underlying periodic sine wave signal (represented by frequency
), and also how often the signal is sampled (represented by grid_points
). Get it wrong, and a high-frequency sine wave is measured as a lower-frequency signal.
To see the effects of aliasing:
Run the next cell, then set the
grid_points
slider to13
.Move the
frequency
slider to values above10
.As the frequency increases, the measured signal (blue) has a lower frequency than the real one (red).
Counting galaxies in the Hubble deep field
The notebook can utilize powerful Python libraries that span everything from statistics and machine learning to signal and image processing. This example uses the image-processing library scikit-image to identify galaxies in an image of the sky provided by the Hubble Space Telescope using a blob feature detection algorithm (an approach known as the determinant of Hessian ).
After running the cell, you can play with the parameters of the detection algorithm to find galaxies of different sizes and prominences:
The
max_sigma
parameter determines the maximum size of the objects that will be identified.The
threshold
parameter can be reduced to detect less prominent objects.
Notebooks for academic publications
IPython notebooks are being distributed as supplementary materials in peer-reviewed academic publications to enable readers to reproduce the computational aspects of the work. Here are three prominent examples:
Gross, A. M. et al., Multi-tiered genomic analysis of head and neck cancer ties TP53 mutation to 3p loss, Nature Genet. 46, 939–943 (2014). (A GitHub repository with all the notebooks required to reproduce this analysis can be found here. The notebooks can be viewed directly here.
Ragan-Kelley, B. et al., Collaborative cloud-enabled tools allow rapid, reproducible biological insights, ISME 7, 461–464 (2013). Supplementary notebook
Ding, T. & Schloss, T. D. Dynamics and associations of microbial community types across the human body, Nature 509, 357–360 (2014). Supplementary notebook
A longer list of peer-reviewed publications that have supplementary notebooks can be found here.
Next steps
The IPython Project maintains a curated list of notebooks that provide examples of its use across a wide range of fields and topics. You can find these examples at this gallery.
Directions on how to install software to run the IPython notebook on your own computer can be found here.
It is also possible to run a notebook in the cloud, without installing the software, using the following services:
The notebook is being moved into a project called Jupyter, which aims to make the IPython software package more compatible with other languages, including Julia and R. Further information can be found on the IPython and Jupyter websites.
The IPython and Jupyter projects are sponsored by the Alfred P. Sloan Foundation, Rackspace, Google, Microsoft, the National Science Foundation and the Simons Foundation.
This demonstration was created with the help of: Kyle Kelley, Brian Granger, Fernando Perez, Matthias Bussonnier, Aron Ahmadia, David Ketcheson, Chris Ryan, Richard Van Noorden and Stéfan van der Walt.