If you will be running idl on kepler, but displaying its output on another unix or linux machine you must allow idl to display its output on the local machine you are sitting in front of. There are TWO steps in this process.
You also need to set up the proper environment for idl. On kepler type:
source /h1/steinr/idl_5.5/bin/idl_setupOn my MAC I put in my .tcshrc file
source /Applications/idl/bin/idl_setup
Start IDL by typing (in the window on kepler):
idlA gui interface is also available. To start the gui interface type the following at the prompt:
idlde
The Command Line is a single IDL prompt where you can enter IDL commands. If you click the right mouse button while positioning over the Command Line, a popup menu appears displaying the command history, with a default of 10 entries and a maximum of 100 entries. IDL is an interpreted language and commands are executed immediately at the command line. To see the IDL Command Line in action, enter the following in the Command Line at the prompt and press Enter:
print, 'Hello World'Output from IDL is displayed in the Output Log window, which appears by default. Notice the command and the result of our print command in the Output Log.
The other windows of the IDL Development Environment are either obvious
or will be covered in later sections.
You can run a simple idl demo by typing at the prompt IDL>
.r /h1/steinr/idl_5.5/lib/testdemoThe instructions for the demo are in /h1/steinr/idl_5.5/lib/testdemo.demo The source code for the demo can be found in
demo.
When you install your own idl, the simple demo is run from $IDL_DIR/lib/testdemo and the widget demo is run by just typing demo.
When you run idl you need to set your preferences, in particular the path to your own individual procedures. In idlde, select preferences from the file menu, then select paths, and add them (one at a time). In idl, and a unix environment, set the environment variable IDL_PATH, e.g. on kepler
setenv IDL_PATH \+/h1/stein/Idl:\+$IDL_DIR/lib:\+$IDL_DIR/exampleson my MAC
setenv IDL_PATH \+/Users/Research/Idl:\+$IDL_DIR/lib:\+$IDL_DIR/examplesThe escaped + sign tells idl to include all the subdirectories in the path.
Idl_pathIDL can keep a record of everything you do in a journal file. This is aTH good idea so you can look back and see what you actually did and note how it worked. Start the journal file by typing at the prompt IDL>
journalThis will create a journal file in the directory where you started idl with a name idlsave.pro. You can use a procedure we have written called journ to create a jorunal file named yymmdd.hrmm.jou, e.g 011019.1739.jou.
To quit the current IDL session and return to the operating system,
type the following at the Command Line:
exitIn the IDL Development Environment select File -> Exit.
First, we'll plot a simple graph using a sine function. Use the FINDGEN function here to specify the dimensions of the array. The FINDGEN function returns a single-precision, floating-point array, with the specified dimension, where each element of the array is set to the value of its one-dimensional subscript. We also use a constant in creating this data (!pi). The character (!) is used to indicate constant pre-defined values.
1. First, create a value for the X axis:x=2*!pi/100*findgen(100)2. Now, use PLOT to visualize the array:plot,sin(x)
Now use OPLOT to plot the new information over the existing plot:
1. Plot at twice the frequency:The results are shown in the following figure.oplot,sin(2*x)2. Plot at three times the frequency:oplot,sin(3*x)
2. Create a LIVE plotThe result is shown in the following figure:live_plot,plot_ascii.Temp1,plot_ascii.Temp2, $ name={data:['Temp1','Temp2']}
First, view the array MARBELLS_BINARY.A as a three-dimensional, wire-mesh surface. Use the CONGRID procedure initially to resample the data set so that the mesh can be displayed at a size visible to the human eye.maroon_bells=read_binary('/usr/local/rsi/idl_5.4/idl_5.4/examples/data/surface.dat',$
data_dims=[350,450],data_type=2,endian='little')
1. Here resample the array size to 35 by 45, or one tenth its original size. To do this enter:a=congrid(maroon_bells,35,45)2. Now we are ready to visualize the mesh using the SURFACE command:surface,a
3. View the array from a different angle by entering the following command:surface,a, ax=70, az=25
1. First, load one of the pre-defined IDL color tables by entering:loadct, 32. To view the light-source shaded surface, shown in the following, simply enter the command:shade_surf,a
3. To look at the array from another angle, enlarge the label text, and add a title. Again, keywords are used to control certain features of the shaded surface plot. The AX and AZ keywords control the viewing angle, just as they did with the SURFACE command. The CHARSIZE keyword controls the size of plotted text. The TITLE keyword was used to add the title Shaded Surface Representation.shade_surf,a,ax=45,az=20,charsize=1.5, $
title='Shaded Surface Representation'
4. You can create a different kind of shaded surface, where the shading information is provided by the elevation of each point. Now different shading colors on the plot correspond to different elevations (the BYTSCL function scales the data values into the range of bytes). You could also specify a different array for the shading colors.shade_surf,a,shade=bytscl(a)
5. You can plot a wire-frame surface of the Maroon Bells (mountains) right over the existing plot. The XSTYLE, YSTYLE, and ZSTYLE keywords are used to select different styles of axis. Here, SURFACE is set to not draw the X, Y, and Z axis because they were already drawn by the SHADE_SURF command. The /NOERASE keyword allows the SURFACE plot to be drawn over the existing SHADE_SURF plot. Enter the following:surface,a,xstyle=4,ystyle=4,zstyle=4,/noerase
1. Set the array size back to its original 350 by 450 size by entering:a=maroon_bells2. Plot the contour:contour,a
That command was very simple, but the resulting plot was not as informative as it could be.
3. Create a customized CONTOUR plot with more elevations and labels by entering:contour,a,nlevels=8,c_labels=[0,1]
By using the NLEVELS keyword, CONTOUR was told to plot eight equally-spaced elevation levels. The C_LABELS keyword specifies which contour levels should be labeled. By default, every other contour is labeled. C_LABELS allows you to override this default and explicitly specify the levels to label.
4. Similarly, you can create a filled contour plot where each contour level is filled with a different color (or shade of gray) by setting the FILL keyword. To do this, enter:contour,a,nlevels=8,/fill
5. To outline the resulting contours, make another call to CONTOUR and set the OVERPLOT keyword to keep the previous plot from being erased. You can add tickmarks that indicate the slope of the contours (the tickmarks point in the downhill direction) by setting the DOWNHILL keyword:contour,a,nlevels=8,/overplot,/downhill
6. CONTOUR plots can be rendered from a three-dimensional perspective. First, set up the default 3-D viewing angle by entering:surfr7. By using the T3D keyword in the next call to CONTOUR, the contours will be drawn as seen from a 3-D perspective. Enter:contour,a,nlevels=8,/t3d
1. Create a plot that shows a two-dimensional array as an image, wire-frame surface, and contour simultaneously.show3,a
1. Here, to visualize a surface representation, enter the following:live_surface,a
1. Enter the following at the IDL Command Line:You can view an image in IDL with two different routines. The TV procedure writes an array to the display as an image without scaling. Enter the commands below at the IDL Command Line.nyny=read_tiff('/usr/local/rsi/idl_5.4/idl_5.4/examples/data/image.tif')
2. Display the image:tv,nyny
2. Enter WDELETE at the Command Line to dismiss the graphics window.wdelete3. The TVSCL procedure displays the image with the color values scaled to use the whole color table. Display the scaled image:tvscl,nyny
4. Enter WDELETE at the Command Line to dismiss the graphics window.
The REBIN function in IDL makes it easy to resize a vector or array to new dimensions. The supplied dimensions must be proportionate (that is, integral multiples or factors) to the dimensions of the original image. Since our original image array here is 768 by 512, well need to decide the correct dimensions of our new resized image. If we want to resize the image to half the original size then simply take half of the arrays original dimensions.wdelete
5. Create a new image with new dimensions using the REBIN function:
newimage=rebin(nyny,384,256)
6. Now display the image:
tv,newimage
7. Enter WDELETE at the Command Line to dismiss the graphics window.
IDL automatically creates a window for displayed graphics if one does not already exist. You can use the WINDOW command to create new windows with custom sizes.wdelete
8. To display Manhattan in a larger graphics window, enter:
window,0,xsize=800,ysize=600
9. Then enter:
tv,nyny
10. Enter WDELETE at the Command Line to dismiss the graphics window.
The WINDOW command above creates a new version of window number 0 that is 800 pixels wide (specified with the XSIZE keyword) and 500 pixels tall (specified with the YSIZE keyword).wdelete
Try loading some of the pre-defined IDL color tables to make this image more visible. While the graphics window is visible, type xloadct at the IDL Command Input Line. The XLOADCT widget application appears. Select a color table from the field; the window will reflect the color scheme. Click Done to accept a color table. When you are finished looking at the effects of different tables, click on the first color table in the field, B-W Linear, and click Done to load the original black and white color table.
Sections of an Image
Sections of images can be easily displayed by using subarrays.
1. Erase the current display, create a new array that contains Manhattan and display it by entering:erase2. Then enter:
e=nyny[100:300, 150:250]tv,e
3. Enter WDELETE at the Command Line to dismiss the graphics window.wdelete
Rotating an Image
Simple rotation in multiples of 90 degrees can be accomplished with the ROTATE function.
4. Rotate the image by 90 degrees, as shown below, by entering:r=rotate(e,1)5. Now enter to display:tvscl,r
The second parameter of ROTATE is an integer from 1 to 8 that specifies which one of the eight possible combinations of rotation and axis reversal to use.
1. Use the PROFILES routine with the rotated image that you just displayed by entering the following:profiles,r
A new window for displaying the profiles appears. Move the cursor in
the window containing the image r to display the profiles of different
rows andcolumns.
2. Click the left mouse button while the cursor is in the image window to switch between displaying row and column profiles.3. Click the right mouse button while the cursor is in the image window to exit the PROFILES routine.
1. Enter:live_image,nyny
You can click once on the image and then drag the cursor across the image to read the image values.
You may also double-click on the image to display a properties dialog.
The set of buttons in the upper left corner of the image window allows
you to print, undo the last operation, redo the last undone operation,
copy, draw a line, draw a rectangle, or add text. The LIVE_IMAGE window
may also be resized using the mouse.
1. Enter:
heart=read_binary('/usr/local/rsi/idl_5.4/idl_5.4/examples/data/abnorm.dat',$
data_dims=[64,64,16],data_type=1)
2. Load an appropriate color table:
loadct, 3
3. Display the first slice of our 3-D array:
The asterisks (*) in the first two element positions tell IDL to use all of the elements in those positions. Hence, the TV procedure displays a 64 by 64 byte image. The image is rather small.tv,heart[*, *, 0]
4. Now resize each image in the array with bi-linear interpolation by entering:
h=rebin(heart,320,320,16)
5. Then display:
Each image in H is 5 times its previous size. Now a simple FOR statement can be used to animate the images. (A more robust and convenient animation routine, XINTERANIMATE, is described next.)tv,h[*, *, 0]
6. To animate, enter:
for i=0,15 do tvscl,h[*,*,i]
IDL displays the 16 images in the array H sequentially. To repeat the animation, press the up arrow key to recall the command and press enter.
7. Dismiss the window:
wdelete
1. Create a new array to hold the heartbeat data:
s now holds 32 byte by 32 byte versions of the heartbeat images. SURFACE plots are often more legible when made from a resized version of the dataset with fewer data points in it.s=rebin(heart,32,32,16)
2. Display the first image in s, as a wire-mesh surface by entering:
surface,s[*,*,0]
Now create a whole series of SURFACE plots, one for each image in the original dataset.
3. To do this, first create a three-dimensional array to hold all of the images by entering:
The variable frames will hold sixteen, 300 by 300 byte images.frames=bytarr(300,300,16)
4. Now create a 300 by 300 pixel window in which to display the images:
The next command will draw each frame of the animation. A SURFACE plot is drawn in the window and then the TVRD function is used to read the image from the plotting window into the frames array. The FOR loop is used to increment the array indices. The lines which follow are actually a single IDL command. The dollar sign ($) works as a continuation character in IDL and the ampersand (&) allows multiple commands in the same line.window,1,title='IDL Animation',xsize=300,ysize=300
5. Enter:
You should see a series of SURFACE plots being drawn in the animation window, as shown in below. The ZRANGE keyword is used to keep theheight axis the same for each plot.for i=0,15 do begin surface,s[*,*,i],zrange=[0,250]$
& frames[0,0,i]=tvrd()&end
6. Now display the new images in series by entering:
for i=0,15 do tv,frames[*,*,i]
1. Save the first frame of the S dataset in the variable A to simplify the next set of commands:
a=s[*,*,0]
2. Create a window in which to display your surface:
window,0,xsize=300,ysize=300
3. Display a as a wire-mesh surface:
Setting the XSTYLE, YSTYLE, and ZSTYLE keywords equal to 4 turns axis drawing off. Usually, IDL automatically scales the axes of plots to best display all of the data points sent to the plotting routine. However, for this sequence of images, it is best if each SURFACE plot is drawn with the same size axes. The SCALE3 procedure can be used to control various aspects of the three-dimensional transformation used to display plots.surface,a,xstyle=4,ystyle=4,zstyle=4
4. Force the X and Y axis ranges to run from 0 to 32 and the Z axis range to run from 0 to 250:
scale3,xrange=[0,31],yrange=[0,31],zrange=[0,250]
5. Set up the XINTERANIMATE routine to hold 40, 300 by 300 byte images:
xinteranimate,set=[300,300,40],/showload
6. Generate each frame of the animation and store it for the XINTERANIMATE routine. Once a 3-D transformation has been established, most IDL plotting routines can be made to use it by including the T3D keyword. The [XYZ]STYLE keywords are shortened to [XYZ]ST:
for i=0,39 do begin scale3,az= -i * 9 & surface,a, $7. Play images back as an animation after all the images have been saved in the XINTERANIMATE routine:
/t3d,xstyle=4,ystyle=4,zstyle=4 & xinteranimate,$
frame=i,win=0 & end
xinteranimate
The XINTERANIMATE window should appear, as shown above. Tape recorderstyle controls can be used to play the animation forward, play it backward, or stop. Individual frames can also be selected by moving the Animation Frame slider. TheOptions menu controls the style and direction of image playback. Click on End Animation when you are ready to return to the IDL Command Line.
1. Delete both window 0 and window 1 by entering:
wdelete, 0
wdelete, 1