Showing posts with label science. Show all posts
Showing posts with label science. Show all posts

Friday, 4 November 2011

Making single eps file from latex figure

Journals, being the cash-strapped money-printing machines that they are, like to have submissions written in LaTeX, but only in the simplest LaTeX possible.

I like to use LaTeX as much as possible when annotating figures produced by other programs, as then the fonts in my document match those in my figures. This makes it sensible to compose figures within the LateX figure environment. A simple example which collects some sub-figures then labels them would be:

\begin{figure}
\begin{picture}(86,175)(0,0)
  \put(0,140){\includegraphics[width=86mm]{figures-a}}%
  \put(80,144){a}
  \put(0,75){\includegraphics[width=86mm]{figures-b}}%
  \put(80,78){b}
  \put(0,108){\includegraphics[width=86mm]{figures-c}}%
  \put(80,111){c}
\end{picture}
\caption{A multi-figure figure}
\label{f-FigureLabel}
\end{figure}

For final submission, journals like to have single eps files for each figure, so we need a way to make a single eps file from this. The trick is to use the preview and standalone environments. Create a file for the figure (e.g. fig-01.tex) with contents:

\documentclass{standalone}
\usepackage[dvips]{graphicx}
\usepackage[T1]{fontenc}
\usepackage[active,tightpage]{preview}

\begin{document}%
\begin{preview}%
%
\resizebox{86mm}{!}{%
% put \picture{} here
}%
%
\end{preview}%
\end{document}

do not include the \caption or \label, just the code for the figure itself.

Now run:

latex fig-01.tex --output-format=dvi
dvips -E -I 3c -o fig-01.eps fig-01.dvi

to produce a single eps file with cropped boundaries. This can then be included in the main document's figure directly.

Tuesday, 6 September 2011

Where to go in Antarctica?

Well, where to go if you can only go to Scott Base or McMurdo. Sounds obvious, right?

Maybe not... if you're a sun lover (and who isn't), you'll soak up slightly more rays at McMurdo than at Scott Base (assuming that you even go outside).

The following plot was generated by taking the sunshine energy arriving at Arrival Heights (just above McMurdo) and subtracting the sunshine energy arriving at Scott Base. Positive numbers (blue) correspond to McMurdo being sunnier, negative (green) mean SB was best. The red running line shows the 5 times exaggerated 7 day average of all years from 2000 to the present.


So, if you want to sunbathe, McMurdo's the place to pick, especially while the light is going or coming.

Friday, 11 March 2011

Sea ice breakup in McMurdo Sound, 2011

Our group installed an ice tethered profiler in the sea ice by Scott Base, close to where we spent much of the winter of 2009 working on the sea ice. If we'd been down there now, we'd have quite wet feet as the sea ice which had been in place since about 1998 has finally succumbed to a well-timed storm and has broken out. This is bad news for our ITP, as it has drifted to a position where the ocean depth is too shallow for the length of cable, so the poor unit is spending a lot of time acting as an anchor in the mud. Hopefully it will clear the coast and start working again...

Here are a series of satellite images taken around the time of the breakout, with the path of the ITP superimposed on them.


2011-02-20 (a big storm makes lots of waves, you can see the road from McMurdo to Pegasus as a white line near the profiler, with a tongue of water crossing it...)


2011-02-22 (the ice edge moves towards the profiler)


2011-02-23 (moved, stuck by the ice shelf)


2011-02-24



2011-02-25 (escapes from the ice shelf edge)


2011-03-03 (a few days later)

Thursday, 26 August 2010

Version Control for Scientists

So, here I am, working very hard, writing code, making figures, assembling presentations, writing papers, thinking about three different things at once, calibrating my data, recording observations and generally trying to do science. The result of three years' work will be three or four artifacts: a dataset of observations, a couple of papers with a definite view on what that means, and the rest of my thoughts bundled into a big book of a PhD.

Now, the data I collect is hopefully fixed. The ice was 1.25 meters thick. The voltage measured by my logger was 0.027 V, the temperature of the air was -25C. Once I've collected the data and entered it into a handy digital format it shouldn't change - I won't be able to collect it again. It's important then for this data to be well structured, to be annotated with how I collected it, and for it to be safely stored for ever. This means it must be backed up safely and in lots of places, and that any processing I do doesn't alter any of the raw data - all I can do is read it in for further processing.

That data needs to be processed though. Raw readings need to be turned into temperatures through some calibration code, calculations turn these temperatures into ice growth rates and heat fluxes, eventually I want an output of pictures of what this means, and hard numbers to compare with other people. I also want to be able to prove to someone that I arrived at these hard numbers through an honest method, and to be able to recreate any figures I make today at some point in the future.

I achieve this by using code to transform my data and to produce all figures, and can in principle do this directly from the raw data (usually I save intermediate stages of the calculations to save time, but I could make these again too). This means I can easily redo a figure if someone points out a mistake, or if it might tell a better story if coupled with other information, or if it just needs to have a different format because last time I put it in a presentation and this time it's going into a paper.

Now, it's all well and good having the code to make the figure today, but what if I modify or add to my code in the future? How can I know exactly what I did today, if I might have added something to my code for something else tomorrow? Partly we can avoid this being a problem by designing the code well, to always operate as it used to even as we improve it, (but that's a whole different story). Mostly we need to make sure we can somehow get back to older versions of the code we're using, or the paper we're writing. This is the only way we can prove to someone else exactly what we did to produce our final, polished and published paper.

I think it's essential for a scientist to be using a version control system, not because it offers a way to safely make and remove changes when developing code, but because it offers proof of our methods, even in the future. While I don't expect my work to generate the controversy of climategate, by using version control it should always be both possible and very easy to defend work I've done, even once I've moved on.

And how do I do this? I use mercurial with TortoiseHg and Kiln, for which there is a very good tutorial, but more adventurous people might like git with github which also fits the bill very nicely. As well as a fix of honesty, I get a easy way to backup my work, to recover deleted paragraphs I realise I liked after all, and a simple way to synchronize my work between three different computers and an online backup (thoughtfully provided by Kiln).

(This post was spurred on by an interesting discussion on the merits or not (I'm with not, if you didn't notice above) on version control of data at http://sunlightlabs.com/blog/2010/we-dont-need-a-github-for-data/.)


Thursday, 22 April 2010

Antarctic-Arctic see-saw

In recent years we've seen a large loss of sea ice in Arctic and a small increase in the Antarctic. This is a well established fact, but sometimes we are asked 'why don't they both decrease, if global warming is global?'. This is a reasonable question, and one explanation for this was found in an interesting analysis by Chylek et. al. in GRL, 'Twentieth century bipolar seesaw of the Arctic and Antarctic surface air temperatures': (http://www.agu.org/journals/gl/gl1008/2010GL042793/).

They show that over the 20th century when the Antarctic was a little warmer, the Arctic was a little cooler, and vice-versa, and explain this by suggesting that the Atlantic ocean couples the Antarctic and Arctic regions, with ocean currents sometimes sending warm water northwards away from the Antarctic (so cooling the Antarctic) through the equator and on to the Arctic (so warming the Arctic), and sometimes this not happening quite as much, making the Arctic a little cooler, and the Antarctic a little warmer.

This imposes a strong signal of warming and cooling on top of the signal from CO2 driven global warming, so we shouldn't be surprised if major changes driven by temperatures, such as the extent of summer sea ice cover, appear at one of the poles without showing up immediately at the other.

Tuesday, 6 April 2010

head hurty

While working away at some temperature data, I made my head sore. Not just because I'm trying to figure out what's going on, but because the graph comes out all head-hurty. Those blue lines are vertical, but they're not, yet they are! ouch.