This tutorial is organized as a set of examples with limited explanation. The most effective way for you to go through this tutorial is by running IDL in a separate window, and trying out the commands and programs as you read the tutorial. For maximum benefit, you should save copies of the programs in a personal directory, and experiment with changing them.
You need to know about How to Setup IDL at PPPL. This will tell you on which machines IDL is running, how to set up your environment, how to set your display, and how to find documentation.
Recall that IDL programs can be stopped using control-C. (Hold down the control key and hit the letter c). IDL can be aborted immediately using control-\. (All variables are lost and the state of open files will be uncertain).
pro demolegend ; demolegend.pro ; ; this file demonstrates the use of the Legend routine in multiplots !p.multi=[0,1,2] meanings = ['good stuff', 'better stuff', 'best stuff'] psyms = [-1,-2,-4] colors = [MK_COLOR('red'),MK_COLOR('yellow'),MK_COLOR('blue')] lines = [1,2,4] x=FINDGEN(11) FOR nplots=0,1 DO BEGIN PLOT,x,x^1.3,/nodata for i=0,2 do OPLOT, x, x^(1.1+(i/10.)), psym=psyms[i], $ color=colors[i], linestyle=lines[i] LEGEND, meanings, /right, /top, psym=psyms, $ color=colors, linestyle=lines ENDFOR !p.multi=[0,1,1] return endType the following at the IDL prompt
IDL> demolegendThis will execute the commands above (if the directory containing demolegend is in your IDL "path".)
As an excersize, try modifying the above code to place the legend on the left instead of on the right (use the /left keyword in the LEGEND call, rather than /right).
To examine the source of any user-written routines used in these examples, locate it with doc_library. If the author followed the IDL convention for documenting the source, you will also see that displayed. For example, to find out where mk_color.pro is located, type:
IDL> doc_library,'mk_color'(If you are at PPPL, or do not wish to use the locally-written routines, like mk_color, see http://NSTX.pppl.gov/nstx/Software/IDL/simplecolors.html for an easy way to plot with named colors in IDL.)
; plot_right.pro - plot with axis on right x=findgen(100) y=0.95*sin(x/5) !x.margin=[8, 9] ; plot with no right axis plot,x,y, ystyle=8, ytitle='_____ Sine Wave' newx = findgen(500)/5. newy = 1000.*SIN(newx/7 + 1)*exp(-1.* newx/100) PLOT, newx,newy, /noerase, xrange=!x.crange, line=2, ystyle=4, xstyle=1 ; make an axis on the right for the last plot AXIS, YAXIS=1, YRANGE=!y.crange, ytitle='----- Damped Wave'Type the following at the IDL prompt
IDL> @plot_rightYou should see something this:
(put this in your .cshrc or .bashrc file: module load nstx ) MDSOPEN, 'wf', 130000 signal = '\ip' f = MDSVALUE( signal ) time = MDSUNITS( signal, /TIME ) flabel = MDSUNITS( signal, /UNITS ) timelabel = MDSUNITS( signal, /TIME, /UNITS ) PLOT, time, f/1000., XTITLE = timelabel, YTITLE = 'milli'+flabelFor more examples of MDSplus access at PPPL, see http://NSTX.pppl.gov/nstx/Software/IDL/mdsaccess.html.
Some of the above "widgets" are buttons that you click on to initiate actions (like making a plot or sending the plot to the printer), others are fields you can type in (like signal) and the field containg the small rectangle on the right is a pull-down menu. You can rescale the plot by placing the mouse pointer over the plot, holding down the middle mouse button, dragging, and releasing. The x- and y-positions of the cross-hairs are shown in the small boxes at the bottom of the plot.
To find where this source for mdsw.pro is located on your computer, type:
IDL> doc_library,'mdsw'You should probably look at mdsw_noch.pro. It is simpler and illustrates most of the important concepts.
If you want to customize your own MDSplus plotting widget, the easiest way may be to copy all the routines from $NSTXUSR/util/misc/plotw on the PPPL Unix cluster, and adapt the "include" files to your purposes.
IDL> vectorsurfThis will execute the commands in the file vectorsurf.pro.
Some aspects of this routine are fairly complicated, but may be useful as it stands.
There is an excellent demo supplied with idl, which shows many of the advanced things IDL can do. Just type "demo" at the IDL prompt.
You may also want to look at the IDL supplied examples in /usr/local/rsi/idl/examples on Linux.
You should also visit these valuable IDL sites, especially the ones that let you search for IDL routines written by others (no such search exists for fusion, or PPPL-specific software, but it should -- some locally-written routines are described at http://nstx.pppl.gov/nstx/Software/Programming/idl_routines.html).