initial port of analysis code to ipython notebook