I’ve had trouble getting the IDL contour procedure to give me exactly what I want when both printing to the screen and the postscript device. I think I’ve finally figured it out, with a lot of help from the website of David Fanning. If this seems too basic for you, or you don’t have any desire to use IDL, then you may quit reading now.
I’ve decided to release the code, in the hopes that it may help someone else. This is free software, you may do with it as you wish.
CONTOUR_ON_MAP.PRO
This should work on Windows, Mac, and Linux machines, but has only been tested on one particular flavor of Linux. It has also only been tested on one version of IDL. The code can be broken down into the following sections:
default variables: set the default variables so if the user specifies only the minimum information a usable plot is still made
setting device: postscript or the screen
set_map: use the built-in IDL procedure
configure levels: Those first three steps are fairly straightforward. The difficulty is in setting the contours correctly. Let’s say I want a contour plot with 5 equally spaced contours. IDL has a keyword in its CONTOUR procedure for this: NLEVELS. However, this keyword does not always produce the desired amount of contours. IDL uses as a suggestion for the amount of contours to display. Therefore, I force it to have the number of levels that the user specifies.
contour: Call the IDL CONTOUR procedure.
colorbar: The COLORBAR procedure (courtesy D. Fanning) seems to be device dependent… although the documentation says it is device independent. That’s probably because I don’t fully understand the workings of how IDL does its color thing. Therefore, the calling of the colorbar procedure, needs to depend upon which device is being written to.
cleanup: Yeah! We’re all done. Let’s see what it looks like.
I’ve been working with 500mb geopotential height data lately. I’ve also been doing principle components analysis a lot. Therefore, I did the PCA of the last ~50 years of winter geopotential height anomalies. (No need to understand this, from this point on, it’s just pretty pictures.) As you can see, it’s simple to create contours on the map of different projections.
Orthographic Projection:
Mercator Projection:
Sinusoidal Interrupted Mollweide Projection:
It only took 3 commands at the IDL prompt to produce the 3 plots above (1 for each). Easy. 