Support the Arctic Sea Ice Forum and Blog

Author Topic: IPython Notebook - Volume, Area, Extent, Thickness  (Read 6138 times)

anonymous

  • Guest
IPython Notebook - Volume, Area, Extent, Thickness
« on: March 25, 2013, 03:03:53 AM »
Many scientists choose Python as first language, because it is easy to read and and has a vast amount of scientific libraries. Also it is open source and runs for free on Linux, Windows, Apple and more. For me it was also natural to choose Python here, because http://www.arctic.io runs on Python, too.

What I especially like is only a few lines of code are needed to go from an URL of a data set to a plot. A flavour of Python is IPython which comes with batteries included and even plots right into the browser, if you go with IPython Notebooks. Which turns development into fun, since everything happens in one window - the browser.

Enough said, this is how it works:

Open this url: http://nbviewer.ipython.org/urls/dl.dropbox.com/u/354885/notebooks/Arctic-Sea-Ice-V1.0.ipynb and scroll down.

It is an IPython Notebook rendered as a web page, you see the code and the result, for example this plot showing volume, including anomaly and climatology:



or thickness derived from area:



The notebook has the code to download, prepare and plot area, extent and volume. I didn't get fancy with plot decoration, you'll see the minimum to understand the data.

Basically a notebook consists of different cells of different type. They either contain code, markdown or raw text. In interactive mode you add/change the code in a cell and press ctrl-enter to run the cell. All output appears then below the current cell. That way you'll get results extremely fast. Beginners enjoy the help function, you create an empty cell and type e.g. os? and press ctrl-enter and get the os module help. Tab completion is available too. Notebooks include plots, code, etc. all in one file, so sharing them is easy.

You'll get IPYthon here: http://ipython.org/install.html ,
here is nice notebook showing basic 2d/3d plotting: http://nbviewer.ipython.org/urls/raw.github.com/jrjohansson/scientific-python-lectures/master/Lecture-4-Matplotlib.ipynb ,
here a ever growing galery of excellent notebooks https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks
and if you want to see them all try this google search: https://encrypted.google.com/search?as_q=filetype%3Aipynb

If you resist to install IPython, there are two other options, register at https://www.wakari.io and work completely online at your own virtual machine (no cost so far) and http://picloud.com offers 20 notebook hours/month  for free including their number crunching cloud. The notebook above was made entirely at wakari.io, because the net connection is very fast.

I can answer basic question here or via PM - sorry nothing Windows or Apple specific. Currently I'm working on the ice mass balance buoys and the SMOS data set, expect more notebooks soon.

Edit: two more links: One of the IPython Notebook creators won the 2013 Free Software Foundation Award, the article gives some high level background info and Windows Azure offers them too. There is also a nice video tutorial on the page. The free trial at Azure lasts 90 days.





« Last Edit: March 25, 2013, 03:46:17 AM by arcticio »

gfwellman

  • New ice
  • Posts: 85
    • View Profile
  • Liked: 0
  • Likes Given: 0
Re: IPython Notebook - Volume, Area, Extent, Thickness
« Reply #1 on: March 25, 2013, 03:56:16 AM »
Very nice, Arcticio!

With that said
Quote
Many scientists choose Python as first language
Damn, I'm old.  Mine was Fortran77  :o

anonymous

  • Guest
Re: IPython Notebook - Volume, Area, Extent, Thickness
« Reply #2 on: March 25, 2013, 09:43:30 AM »
gfwellman, thanks. Fortran is still fastest language in applications like e.g. climate models. Check out this notebook: Using Fortran and C code with Python, some long forgotten neurons may fire.  :)

ivica

  • Grease ice
  • Posts: 943
  • Kelele
    • View Profile
  • Liked: 19
  • Likes Given: 0
Re: IPython Notebook - Volume, Area, Extent, Thickness
« Reply #3 on: March 25, 2013, 10:21:17 AM »
Thanks a***!
iPythons seems as handy tool to fast prototype something,
and more - as your nice & useful web-site shows.

anonymous

  • Guest
Re: IPython Notebook - Volume, Area, Extent, Thickness
« Reply #4 on: March 25, 2013, 11:05:30 AM »
ivica, the buzz word is "executable papers". The idea is to get scientists to deliver (and publish) not only the results, but also the process. I think, if not everybody is forced to start form scratch with his code, we'll get comparable results with less bugs faster.


Jim Hunt

  • Young ice
  • Posts: 4288
    • View Profile
    • The Arctic sea ice Great White Con
  • Liked: 273
  • Likes Given: 27
Re: IPython Notebook - Volume, Area, Extent, Thickness
« Reply #6 on: March 26, 2013, 11:44:05 AM »
Thanks for sharing this stuff Arctic.io. I have to agree with Ivica that "executable papers" are an excellent idea.

It also seems that I'm even older than GF. I taught myself Fortran from a book long before 1977. I started programming in machine language using the front panel switches on a computer we built for ourselves at school in the late 60s.
Reality is merely an illusion, albeit a very persistent one - Albert Einstein