View on GitHub

Better Analysis Workflow with [I]Python

@BaBar Collaboration Meeting Jan 2013
Thursday 31st Jan 2013 8:30am-12:30pm(1 day AFTER Collaboration Meeting)
by Piti Ongmongkolkul and Chih-hsiang Cheng

Download this project as a .zip file Download this project as a tar.gz file


Python is a very expressive language which means you type less to do more. We have been using Python for our analysis for more than a year. Interactive environment provided by IPython couples with matplotlib allows us to make beautiful plots with quick turnaround. Analysis Tools can take full advantage Python's introspection capability. This enables us to think less about how to get the tools to do what we want and focus more on the analysis. In this tutorial we will be covering how to perform various analysis procedures typically done after skimming process with IPython. Take a look at our advertisement slides for why we think IPython will make life easier.

Location and Time

Somewhere at SLAC. There will be 2 sessions. The tutorial session will be on the day AFTER the collaboration meeting. So make sure you book your flight for an extra day (leaving on Thursday afternoon or Friday).


Set Up Your Laptop

Using Virtual Machine (Recommended. Any OS.)

Big download but very easy install. This way you don't really have to mess with your system and you can throw it away afterward if you don't like it. [Show]


I did this on a freshly installed 12.04. [Show]


Please report if it works or not. I do not have a clean mac to try out.[Show]

Test it out

After you have setup your computer. You can test it out.
  1. Download our entire tutorial project.[ zip| tar.gz]. Or
    git clone git://
    from your terminal.
    • If you have cloned it before but want to get the latest version, go to the directory
      cd ~/babar_python_tutorial/, then
      git pull
  2. cd to ~/babar_python_tutorial/notebooks directory.
  3. You should be able to type
    ipython notebook --pylab=inline --script
    and a browser should pop up. You will be using this a lot. I alias mine to
    alias ipylabnb='ipython notebook --pylab=inline --script'
    The --script will save .py file along side with the notebook file.
  4. You will see 5 notebook choices. You should be able to play with any of those. To go through each cell, just press Shift+Enter.