Thomas' Plant-Related Blog

On plant science. Mostly.

Archive for the ‘Computers’ Category

Datat: Data tables for Python

leave a comment »

(A computery post today)

R is the up-and-coming thing for handling data. It’s a programming language, with a particular focus on statistics and graphs. For manipulating data before analysing it, however, I prefer Python. Code written in Python is (relatively) easy to read, and it can use a wide range of Python modules for all sorts of tasks, even for controlling R. But R has its strengths too, and one of them is the “data frame”, a table with columns of data that’s easy to use for statistics.

So, over the last few days, I’ve written Datat, a Python module for data tables. Although it’s quite different from R’s data frames, if you have the RPy2 module installed, a datat can be translated into a data frame. Using it works a bit like this:

from datat import Datat
temperaturerecords = Datat(["Date", "Min temp", "Max temp", "Notes"])
temperaturerecords.append({"Date":"9/10/11", "Min temp": 2.1, "Max temp": 13})
temperaturerecords.append({"Date":"10/10/11", "Min temp": -0.4,
                           "Notes":"Forgot some recordings"})
temp_rdataframe = temperaturerecords.translate_to_R()
temperaturerecords.save_csv("temp_records_Oct11.csv")

 

 

Advertisements

Written by Thomas Kluyver

30 October, 2010 at 12:29 am

Posted in Computers

Introducing ‘Pied Paper’

leave a comment »

If you’ve ever tried to read a journal paper on screen, you’ll know that it’s not always easy. With widescreen monitors now common, the text you’re trying to read ends up either as a long, narrow column surrounded by menus and sidebars, or spread out so wide that you can’t comfortably read the long lines. You could download a PDF, but since they’re designed to be printed, it’s often clumsy to read them on screen.

A scroll (the Torah)I wondered if we could lay a paper out to make better use of a large monitor. Using a relatively new feature in browsers, I’ve experimented with putting papers into multiple columns, continuing off the screen to the right, somewhat like an old fashioned scroll. The prototype got enough interest that I’ve (finally) made a tool to reformat papers ‘live’.

How to get it

If you’re using Firefox, you’ll need an add-on called Greasemonkey to run Pied Paper. Install it from here, then restart Firefox. Chrome (and possibly Opera) can use Pied Paper without this step. (It won’t work in Internet Explorer at all, I’m afraid)

Then get Pied Paper (click the install button on that page).

How to use it

Pied Paper currently works on:

When you load the full text (HTML) of a paper on one of those sites, Pied Paper will recognise it, and automatically reformat it. At present, if you want to go back to the original format, you’ll need to disable Pied Paper (in Firefox, use the Greasemonkey monkey icon in the bottom right), and reload.

Please don’t hesitate to let me know if you encounter any problems.

Notes

Although this is a tool that I hope you’ll find useful, it’s not exactly polished. Part of this is down to the script, and if people express interest in the idea, I’ll look at using more sophisticated tools to deal with it. Part of it is down to the browsers: multi-column support is quite new, and hopefully over the next couple of years, it will mature.

For a similar tool to remove clutter, without the unusual scroll-like layout, try Readability (a project I have nothing to do with).

Finally, if you read journal papers often, allow me to plug Refzap, a tool I made for quickly looking up citations.

Written by Thomas Kluyver

23 June, 2010 at 6:49 pm

Posted in Computers