Top Banner
IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger [email protected] [email protected] Helen Wills Neuroscience Instiute, U.C. Berkeley Physics, California Polytechnic State University, San Luis Obispo SIAM CSE 09, Miami March 5, 2009
30

IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger [email protected]

Jul 25, 2018

Download

Documents

phungbao
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPythonComponents for Interactive Scientific Computing

Fernando PérezBrian E. Granger

[email protected]

[email protected]

Helen Wills Neuroscience Instiute, U.C. BerkeleyPhysics, California Polytechnic State University, San Luis Obispo

SIAM CSE 09, MiamiMarch 5, 2009

Page 2: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 2 / 28

Page 3: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 2 / 28

Page 4: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 2 / 28

Page 5: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

SciComp

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 3 / 28

Page 6: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

SciComp Inherently exploratory

Scientific computingThe computer as a microscope

Problem’s definition evolves as we understand it.No ‘requirements’ to build an application against.Mathematica, Maple, Matlab, IDL, etc.

All have an interactive environment.

Applications Languages

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 4 / 28

Page 7: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

SciComp Python

Python?

Primitive interactive interpreter provided.

Very good introspection.

All entities can be inspected at runtime by the language itself.

Dynamic reloading of (most) code.

Builtin documentation for objects (docstrings).

Live and post-mortem interactive debugging.

Note: Applications can also be built (easier than in C/Fortran).

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 5 / 28

Page 8: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPython

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 6 / 28

Page 9: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPython

What is IPython?

1 A better Python shell: object introspection, system access, ‘magic’command system, . . .

2 An embeddable interpreter: mix batch and interactive work.

3 A flexible component: tweak to taste for your project.

4 An interactive component plug into GUIs, browsers, etc.

5 High level distributed/parallel computing: next talk.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 7 / 28

Page 10: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPython

Quick overview

HistoryStarted in late 2001, ‘just one afternoon’...It seems to have filled a need.Organic community uptake, mostly ‘spare time’.Messy code, good functionalityMany contributions from outsiders

ToolsProject hosting (site, wiki, mailing lists):http://ipython.scipy.org (courtesy of Enthought)Code hosting and bug tracking:http://launchpad.net/ipython (Canonical)Distributed Version control: Bazaar.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 8 / 28

Page 11: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPython

Status

Code structure (as of early 2009):

Language LOC ProportionPython 37323 99.07%

Lisp 262 0.70%Sh 51 0.14%

Objective C 37 0.10%

Data generated using David A. Wheeler’s ‘SLOCCount’

Mailing lists:

Users: ∼400 membersDevelopers:∼170 members

Available on all Linux distributions. We provide OS X andWindows installers.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 9 / 28

Page 12: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPython

Cast of Characters

Brian Granger - Physics, Cal State San Luis ObispoVille Vainio - CS, Tampere University of Technology, FinlandMin Ragan-Kelley - Applied science, UC BerkeleyGael Varoquaux - Neurospin (Orsay, France)Robert Kern - EnthoughtStefan van der Walt - Applied Math, U. Stellenbosch, South AfricaBarry Wark - Neuroscience, U. Washington.Jorgen Stenarson - SwedenOndrej Certik - Physics, U. Nevada RenoLaurent Dufrechou - FranceVivian De Smedt - BelgiumDarren Dale - Astronomy, CornellMany more I am forgetting...

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 10 / 28

Page 13: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Matlab-like interactive usageMatplotlib: high quality plotting. Scipy: numerical algorithms.

Page 14: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Multiple GUI systemsVTK with WxWidgets

Page 15: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPython

Components

Interactive app - terminalEmbeddable shell (dbg, exploration, control)Widget (Wx, GTK, Tk, Qt)Network-aware computational engine

Interactive distributed and parallel computingHigh-level interfaces for thisComplement, not replace MPI

Node for visual-programming driven HPC - IPVision

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 13 / 28

Page 16: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPython

IPython for distributed and parallel computing

Think of Python as ‘the CPU’.IPython abstracts them over the network.Use interactively or not.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 14 / 28

Page 17: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Vision: visual programmingMichel Sanner, Scripps Institute, La Jolla.

Page 18: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

VisionA generic framework for visual programming

Page 19: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPVision: distributed computingWith: Michel Sanner, Jose Unpingco, Ananth Devulapalli [Ohio SupercomputingCenter/OSU], Min Ragan-Kelley [UC Berkeley]

Page 20: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPVision

Easy access to distributed computing for non-expertsVision allows any python library to be accessed (after wrapping)Users get to use all their cores...

Page 21: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

IPython

Part of an ecosystemRapid flow of developments across open source projects

Matplotlib: interactive plotting and GUI support.

Numpy: sharing code for testing support.

Nose: automatic testing system

Sphinx: high quality documentation.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 19 / 28

Page 22: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Users

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 20 / 28

Page 23: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Sympy: symbolic computingOndrej Certik & team, U. Nevada Reno

Page 24: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

BCPy2000: Brain-Computer Interface systemsIntrospection of a multi-module real-time system

Figure credit: BCPy2000 team.

Page 25: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

NS-3 PyViz: discrete event simulationGTK widget inside the application

Figure credit: Gustavo Carneiro, NS-3 PyViz author.

Page 26: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

MayaVi 2: VTK for the rest of usWxWidgets embedded shell

Page 27: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

And the obligatory one: the iPhone

Figure credit: Josh Bloom, UC Berkeley Astronomy.

Page 28: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Others

Sage: open source mathematics

Customized IPython instance (command line).Input preprocessing to extend the language ‘on the fly’

Django, TurboGears, Zope: web frameworks.

PyRAF from the Hubble Telescope.

CASA from NRAO.

Ganga from CERN.

Amazon cloud: run your own IPython instances

as many as you want, without licensing restrictions...

More...

Page 29: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

Users

Wrapup

Interactive, exploratory workflows are natural in scientificcomputing

Python is a great language for this approach

IPython has many tools to support it

Use it in your projects...

let us know of problemsjoin in to make it betteropen source, by scientists, for scientists!

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 27 / 28

Page 30: IPythonipython.scipy.org/talks/0903_siamcse09_ipython_interact_fperez.pdf · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger Fernando.Perez@berkeley.edu

http://ipython.scipy.org

Thanks!Any questions?