Presentation is everything

This is a 3-color image of the reflection nebula Gy2-21 (located in the dark cloud L1165), made from J-, H-, and K-broadband images (blue, green, and red, respectively). Data reduction by Dawn Peterson.

program names, file names
variable names
prompts, commands, program code


Contents:

Showing off one image

Let's say that you have reduced a set of images such that you have a tessellated, flux-calibrated image that you want to show to the boss. It's a good idea to include in the image some information regarding the physical scale, the intensity scaling, orientation, etc. You may want to crop out a portion of your image which just shows the object of the observation -- this can be done using v. When displaying single images, I like to use the inverted Stern Special colormap, as it has a good dynamic range:
IDLprompt> loadct, 15 IDLprompt> revvid

In this example, the box from running v is somewhat small, with dimensions of 48x47, so I'll display it with a magnification of 8 in order to make it large enough to take up a fair chunk of the display window. The image is flux-calibrated, and I'll display it to scale the intensity between 0 and 7.5 mJy. I'll set the o keyword to put the image in north-up, east-left orientation (that's just the way it worked out for this particular observing run -- setting o won't always put the image in the proper orientation). And I'll set the sam keyword to smoothe out the image:
IDLprompt> v, imagebox, 8, min = 0, max = .0075, /sam, /c, /o
The result looks like this:

[Bare-bones image of
a planetary nebula]

Looks nice enough, but let's give the image a little more information. The ne_arrows procedure draws a compass on the display screen indicating north-up, east-left orientation. The parameters of this procedure allow the user to determine the position (in device coordinates) on the display window of the intersection of the two arrows, the length (in pixels) of each arrow, the thickness (in pixels) of the two arrows, and the size (in pixels) of the N and E compass labels. The following command puts the intersection of the arrows at display coordinates (100,400), makes each arrow 40 pixels long, makes the labels 20 pixels in size, and makes the arrows 3 pixels thick:
IDLprompt> ne_arrows, 100, 400, 40, charsize = 20, linethickness = 3
The plots procedure can be used to draw a line from point to point on the display. We'll use it to draw a line to indicate the spatial scale of the image. The platescale of this data happens to be 0.217 arcsec/pixel, and the magnification is 8, so 5 arcsec corresponds to
5 arcsec / 0.217 arcsec/pixel * 8 = 184 pixels
The following command will draw on the screen a 184-pixel-long, 3-pixel-wide line which extends from display coordinates (150,334) to (440,440):
IDLprompt> plots, 150 + [ 0 , 184 ], 440 + [ 0 , 0 ], thick = 3, /device

The scalebar procedure is used to draw an intensity scale bar. Its parameters determine the display coordinates of the lower-lefthand corner of the scale bar, the length (in pixels) of the bar, and what kind of (if any) labels are drawn at the ends of the bar (I usually don't let scalebar write any labels -- I do that myself: that's next):
IDLprompt> scalebar, 420, 150, /nolabels, scalelen = 200
This puts a 200-pixel-long vertical scale bar at the display coordinates (420,150) (that's the position of the bar's lower-left corner), and no labels are written by scalebar.

Finally, we'd like to add some text annotation to give meaning to the intensity and the spatial scalebars. First we should set the font to something readable -- this is done by some magic:
IDLprompt> !p.font = 1 IDLprompt> device, set_character_size = [20,20]
(This makes each text character written to the display have a size of 20 pixels x 20 pixels). Now we can run the xyouts procedure, which writes text to the display:
IDLprompt> xyouts, 150, 445, '5"', /device IDLprompt> xyouts, 427, 120, '0', /device IDLprompt> xyouts, 415, 370, '7.5', /device IDLprompt> xyouts, 380, 400, 'FD / mJy', /device
These will indicate that the spatial scale bar is drawn to a length corresponding to 5 arcsec on the sky and that the intensity scale corresponds to a stretch in flux density (FD) from 0 mJy to 7.5 mJy.

The result of these efforts looks like the following, and is suitable for saving via a screen capture (/applic/nir/bin/xv is good for this):

[Annotated image of
a planetary nebula]

Incidentally, the coordinates used for the various components of the above annotations were determined by trial and error. The only loose end is the current state of the font in IDL -- we altered it to produce the large text for the annotations. We can restore the environment to a default state with a call to the envres procedure:
IDLprompt> envres


Showing off two images

Sometimes you want to be able to simultaneously look at two images of an object, (eg., two images at two different wavelengths). For example, the following two images of AFGL 2688 (at 2122 nm and at 3290 nm), both of which have the same size, magnification, and registration, are very different in appearance:

[Image of
a planetary nebula] [Image of
a planetary nebula]

It would be useful to somehow represent both images in a single graphical thingy.

In this example, we're going to display the 2122 nm data as a grayscale image (as in the above left image) with contours from the 3290 nm data superposed. The first step is to display the 2122 nm image, which in this case is a 101x101 array, so we'll display it with a magnification factor of 5, and with an appropriate set of display parameters:
IDLprompt> v, im2122, 5, min = 0.5, max = 3, /c, /sam
Now we'll make a call to the contour procedure. We'll want the 3290 nm data (im3290) to be magnified as im2122 was, so we'll use the pos keyword to tell IDL to draw the contours in a box which stretches from (0,0) to (504,504) (the size of a 101x101 array magnified 5 times). Using the ticklen, xstyle, ystyle, and device, keywords as follows ensures that the plot conforms to the device coordinates specified by the pos keyword and that no tickmarks are drawn around the edges of the plot. We'll set the color keyword to 0 for black contours, and we'll use the levels keyword to indicate that we want contours drawn around the pixels which (in im3290) have values greater than 0.75, 1.25, and 1.75. Finally, setting noerase tells IDL to draw the contours over whatever is already on the display (im2122, in this case) without erasing the display:
IDLprompt> contour, im3290, ticklen=0, /device, xstyle=1, ystyle=1, $ IDLprompt> pos=[0,0,504,504], levels=[0.75,1.25,1.75], /noerase, color=0
The result is shown below:

At this point you could also run a series of commands from the previous section to annotate the image.


Showing off three images

Making a three-color image is arguably the best (and perhaps the only practical) way of simultaneously displaying three different images. For example, let's say that we wanted to display the following three images of the reflection nebula GY 221 (J-, H-, and K-broadband images, from left to right below):

[Image of
a reflection nebula] [Image of
a reflection nebula] [Image of
a reflection nebula]

What we'll do is to use each of the above images as an intensity plane in an RGB image, and we'll generate a TIFF-format RGB image. Convention is to use the longest-wavelength (K, here) image for red, the middle wavelength (H) for green, and the shortest wavelength (J) for blue.

For this to work properly, the three images all need to have the same dimensions, the same magnification, and the same dimensions. We'll further assume that the three images are called K_red, H_green, J_blue. These are 2-D images, NOT impacks.

Next we need to determine viewing parameters for each individual image. This is done simply enough by using v to find the set of min and max keyword values that best display each image. Let's say that we find min=0 and max=3x10-5 to work well for K_red and H_green, and that min=-1x10-6 and max=5x10-5 work well for J_blue. We then edit the file ~/idlpro/twrc.txt to look like the following:

min, max values for red plane:
0 3e-5
min, max values for green plane:
0 3e-5
min, max values for blue plane:
-1e-6 5e-6

To actually make the TIFF image, we run the tiffwriter procedure, giving it the three planes and the name we want the created TIFF file to have:
IDLprompt> tiffwriter, '3color.tiff', red=K_red, green=H_green, blue=J_blue, /o
Setting the o keyword is a good idea, because IDL puts pixel (0,0) in the lower-left corner, while most image viewers put pixel (0,0) in the upper-left corner. Setting o imposes an up-down inversion, so that the TIFF image (written to 3color.tiff in the current IDL directory) will look like it does on the IDL display. The result is seen below:

[Image of
a reflection nebula]

You can also use tiffwriter to make two-color images (or even a one-color image) by supplying image planes to only two (one) of the red, green, and blue keywords. See tiffwriter's documentation for details.


Carl Welch