28 July 2011

Raster Graphics in R

As reported in P. Murrell, “Raster Images in R Graphics,” The R Journal, vol. 3, no. 1, pp. 48-54, Jun. 2011 (available online), the facilities for producing raster plots in R have improved dramatically.

I tried this out with a correlation matrix for one of my research projects. Here is the resulting image:

Quite nice and colourful. I originally plotted this using something like
> palette = rainbow(256) > image(x, col = palette)
But the new functions do not have a facility to directly specify a colour palette. You can feed them an matrix of colours though... So the solution is to transform the raw matrix into a colour matrix. So, assuming that the raw data consists of values between 0 and 1, you could do the following:
> y = matrix((rainbow(256))[c(x) * 255 + 1], ncol = ncol(x), nrow = nrow(x), byrow = TRUE) > grid.raster(y)
You need to do a little extra work to get the axes.

26 July 2011

Long Working Hours

A recent medical article (M. Kivimäki, G.D. Batty, M. Hamer, J.E. Ferrie, J. Vahtera, M. Virtanen, M.G. Marmot, A. Singh-Manoux, and M.J. Shipley, “Using additional information on working hours to predict coronary heart disease: a cohort study.,” Annals of Internal Medicine, vol. 154, Apr. 2011, pp. 457-63.) concludes that
Long working hours are associated with increased risk for coronary heart disease.
Not terribly surprising. Long working hours → more stress → heart disease. But limiting your work hours is sometimes easier in principle than practice. Sure there are some jobs where at the end of the day you can shut down your computer (or lay down your broom/stethoscope/AK47), turn off the lights and head home. Then there are others where you just cannot avoid hanging around until the late hours (computer jocks tend to specialise in these). Then there are the more insidious jobs, where you are nominally not working but at some level there is always some work related activity going on. I regularly wake up to take a leak in the middle of the night and find myself standing there thinking about one problem or another. Don't misunderstand me: I engage in this midnight piddle pondering because I enjoy what I do. But these are hours which are pretty hard to log on a timesheet. And I hate to think that they are hurting my health.

So, if you are working too long and too hard, what signs should you look out for? Here are some I found in an article in Discovery Magazine:
  1. dizziness, aches and pains, racing heart, tinnitus, unexplained weight gain/loss, difficulty sleeping;
  2. constant worry, difficulty making decisions, forgetfulness, poor concentration, lack of creativity, no sense of humour;
  3. anger, anxiety, depression, mood swings, irritability, loneliness, negative thoughts;
  4. compulsive eating, critical attitude, explosive actions, social withdrawal, alchohol or drug abuse.
Disturbingly, I can tick off a whole whack of those. Should I be worried? Or can running offset the damage?

Table Markers

Got these together for the table settings at the wedding reception. All selected from our epic trip to Norway. Good times.

21 July 2011

Einstein/Monroe Hybrid

This is pretty cool. Up close it is Einstein, but from a distance it morphs into Marilyn Monroe.

12 July 2011

Space Physics Overview

Today was my turn to lecture at the Antarctic Science Winter School. Now everyone else has been presenting flashy PowerPoint talks. I thought I would do something a little different. So I started off by seeing if I could sumarise a whole lot of the interesting material on just a single A4 page. This is what I came up with:

It doesn't cover everything, but it does cover a lot. The next challenge was how to present all of this material, filling in all of the facts that were not on the above outline... in just 45 minutes. And without using a computer or projector. This is where things got challenging. From the Sun to the Solar Wind to the Magnetosphere is a pretty simple linear progression, so that went well. But once you get inside the Magnetosphere there is no clear ordering. What to talk about first? And so many of the topics are deeply interlinked. So I stumbled along, just trying to inject as many interesting facts as possible. I think that it went okay. At least the students all stayed awake. And considering that only 2 of the 15 students were actually physicists (the rest were biologists or geomorphs), that was no small thing!