Getting the most out of IPython Notebook

June 3, 2015

This week’s Swinburne Hacker Within (SHW) topic is iPython Notebooks. We will briefly go through the basics of launching a Notebook and how you can make them public. We will also look at some online examples. Experienced IPython Notebook users please come along and share your tips and tricks. You are most welcome to demo your own Notebooks.

Where & When

Advanced Manufacturing and Design Centre - Room 206. Wednesday 3rd June from 1:30 - 3pm.

About IPython Notebook

The IPython Notebook is an interactive computational environment, in which you can combine code execution, rich text, mathematics, plots and rich media. It aims to be an agile tool for both exploratory computation and data analysis, and provides a platform to support reproducible research, since all inputs and outputs may be stored in a one-to-one way in notebook documents. These notebooks are files which record all computations carried out and the results obtained in a literate way, including inputs, outputs, together with descriptive text and mathematics.

They are plain text files, which are thus easy to share with colleagues and place under version control. But, by using the JSON format, they can record all aspects of the computation, including embedding rich media output. The standard file extension for notebook documents is .ipynb. Examples of notebooks

###Features of the IPython Notebook app include:###

###Resources to help you get started###

###Setting up IPython and Notebook### * via Ureka (STScI) – You may need to install dependencies afterwards but it’s not that difficult. Ureka includes IRAF and PyRAF which is why I chose this route. I also didn’t want multiple Python installations clogging my laptop i.e. Anaconda. The Python 2.7.5 comes with Ureka and the notebook viewer is the original ‘IPython Notebook’. I keep my notebooks and relaated data in a separate /user/akarick/Notebook/ directory, and launch akarick>ipython notebook from there. * via Anaconda. Most people recommend this route because Anaconda will install everything. It will give you a more recent version, Python 3.4 and your notebook viewer will be ‘Jupyter’. This is what you would have installed if you attended the Unix/Python Software Carpentry workshop. * If you need help installing things (on MacOSX) feel free to ask me during any of the Hacker Within sessions (Astros - Vivek is your go-to guy for Linux and Windows laptops.)

##What we talked about##

After a bit of a rocky start (room booking/ITS issues - apologies folks) we launched straight into a somewhat haphazard discussion about who currently uses IPython Notebooks, why you might want to use the, the emerging culture of open data and reproducible science, and current issues faced by new users. We looked at a couple of examples of simple notebooks on the web. the first was an IPython Notebook I started on the Crisis Mapping in Nepal project (very much work in progress). The second example was this Evolution of Swarming notebook which you can downloaded along with data files. If you have new to IPython I recommend downloading this, launching and editing all the different cells.

Another great example is this Notebook that uses Plotly and CartoDB to visualise earthquake data.

Moving existing code/projects to IPython Notebook may be more effort than it’s worth, especially if you use multiple scripts in multiple languages (e.g. IDL + shell scripts + python), or if your datasets/analysis are really complex. IPython Notebook seems to be great for: describing how you analysed data or wrote your pipeline and sharing this with your collaborators, creating tutorials/teaching materials, supplementing public code with a comprehensive description, creating webpages that include html, text and code, or writing how-to-guides etc.

nbviewer is a really useful site for sharing notebooks and I’ve found some good tutorials on web-scraping (e.g. Mining the Social Web, 2nd Edition) and other programming languages.

Neil gave a short presentation with examples of his own Notebooks and talked about why he uses them, how they are organised, and showed us some really useful features including the ability to mix-and-match markdown, HTML and Latex math in essentially text paragraphs, sharing Notebooks using Gist (rather than nbviewer) and converting Notebooks to latex and HTML and PDF from the command line.

###More links### * multiple notebooks used to reproduce a paper analysis * Reproducible academic publications * A gallery of interesting IPython Notebooks * Convert IPython Notebook to ApJ or A&A article

Attended by:

Share

Discuss

comments powered by Disqus