21 Apr 2014 #python

IPython extension to toggle dark code cells

Update 25 August 2014: As described in this newer post, this is now part of the ipython-extensions repository.

Sometimes it’s more pleasant to read light text on a dark background, particularly when dealing with code. However, depending on ambient lighting, it can be necessary to switch back to dark text on a light background on short notice.

To make this possible, I created a simple extension for the IPython notebook (version 2.0 and above). It adds a button to the toolbar that toggles between a light (default) and dark display mode for code cells in the notebook, with an optional keyboard shortcut.

Read more...

13 Apr 2014 #python

Mapping the world's nuclear power plants

This post demonstrates the use of Python to map the world's nuclear power plants. First, we procure data on plants currently operational or under construction. Then, we make some back of the envelope calculations on how many plants would power the world's current electricity demand.

For this latter part, we use GeoPandas, a very interesting development for Python-based geospatial analysis, building on modules such as Fiona and Shapely to add geospatial functionality on top of one of the workhorses of scientific Python, pandas. From the GeoPandas website:

Read more...

7 Apr 2013 #python

Doing a minor version update for homebrew-installed Python

I install Python with homebrew (on OS X) and manage my packages with virtualenv. I was interested in whether updating from Python 2.7.3 to 2.7.4 would cause my virtualenvs to break. It did, but fixing them turned out to be very simple:

  1. First, of course, $ brew upgrade python; brew cleanup python, which installed Python 2.7.4 and then removed 2.7.3.

  2. According to this post, re-running virtualenv suffices to update the paths inside a virtualenv (the installed packages remain, and you shouldn’t need to re-install or recompile anything after a minor version update):

    Read more...

19 Mar 2013

The discovery of sustainability

There are several events in the twentieth century commonly thought of as key milestones in developing a shared environmental consciousness. The first views of our planet from space (in particular the famous “blue marble” photo taken by Apollo 17 astronauts in 1972) and the publication of Rachel Carson’s Silent Spring a decade earlier are such milestones. So is the idea of sustainable development, as formulated by the Brundtland Commission:

“Sustainable development is development that meets the needs of the present without compromising the ability of future generations to meet their own needs.”

Read more...

23 Feb 2013

Linking DOIs on Scopus Preview

I use Scopus RSS feeds via my institutional Scopus access. Unfortunately, if I save links from a feed on the go I get redirected to a ‘Scopus Preview’ page when I later open the link in my browser. This preview offers no direct way to get the full paper, and no outbound links. Seizing the opportunity to experiment with making a jQuery-based user script, I threw together some simple code to add a DOI resolver link to the preview page:

Read more...