Local IDL Routines

This page was created by a MODIFICATION of the IDL library routine mk_html_help. For more information on this routine, refer to this page or type:

     doc_library, 'mk_html_help'

at the IDL command line prompt.

List Last updated: Thu Sep 18 12:57:54 2008.

You may download a g-zipped tar file of all these files.


Routines by Category

[Alphabetical Listing of Routines]


Routine Descriptions


Category: 2-D Plotting

[List of Routines]


EFITPLUSCAMMDS

[Next Routine] [List of Routines]
 NAME:
 	efitpluscammds

 PURPOSE:
       Plot  Camera images along with EFIT field 
	lines, and also plot Ip, Pnb, and H-alpha (or another) signal vs. time.

 CATEGORY:
       2-D Plotting, Animation, NSTX, EFIT
 CALLING SEQUENCE:
	IDL> efitpluscammds, shot, timeRame=[time1,time2]
 INPUTS:
       shot = nstx shot number  
	If you want to use diverter camera data, it must be moved manually 
       to linux. Examples are
	at /p/nstxusr2/uppercam/114333 and /p/nstxusr2/divcam/114333.
	A .cih file must also be in each directory for the timing information
 KEYWORD PARAMETERS:
    Keywords:
	timeRame - 2-element array for animation; single value for one frame
		   (in SECONDS)
                  alternately, minMsec and maxMsec may be used.
	animate - if set to 0, will NOT make a movie in an IDL XINTERANIMATE window.
                 if a time range is specified, multiple images will be plotted
		  to the default IDL window.
	maxFrames - max # of frames over time range -- necessary if X-memory 
		    is limited (default is 2000).
	imSmooth - amount to median smooth images (default=0)
	nSmooth - amount to median smooth sigName (default=0)
	sigName - if set, will not show Fast Camera images, but this
		  signal vs. time (defaults to \passivespec::BAYC_DALF_HAIFA)
	sigT1 - starting time of signal vs. time plot. Defaults to timerange[0]
	sigT2 - ending time of signal vs. time plot. Defaults to timerange[1]
	sigTitle - if set, will be displayed above sigName plot,
		   else tries to get label from MDSplus
	EFITversion - EFIT version to use. Defaults to largest available.
	FCimgScale - can multiply by each frames's data to brigten images
 OUTPUTS:
       none

 EXAMPLES:
    for a quick demo that doesn't consume too many resources:
	   animate=1 uses X-interanimate VCR-like controls,
          animate=0 just redraws multiple plots to the same window
	IDL> efitpluscammds, 115431, animate=0, time=[.16,.17]
	IDL> efitpluscammds, 115431, animate=1, nskip=5,time=[.16,.20]
	IDL> efitpluscammds, 115431, time=[.18,.2], sigT1=.18,sigT2=.20, /verbose

    to make a series of .ppm files for use with another 
	IDL> efitpluscammds, 115431, pixmap=1, animate=0, ppmout=1, /verbose

	   To get a postscript frame printed:
	IDL>efitpluscammds,114333,time=0.01,thom=0,sigT1=.005,sigT2=.02,anim=0,/postscript

   if the FC images are too light, you can make them 4 times as bright:
	IDL> efitpluscammds, 112608, FCimgScale=4

   to get an animation with no more than 40 frames between 50 and 317 msec:
	IDL> efitpluscammds, shot, time=[0.05,0.317],max=40
 
 LIMITATIONS:
       MPEG movies created from widget are poor.
	Fast Camera data is expected to be in MDS -- only started April, 2005 
	When DISPLAY=1, all the frames requested are download to your
	X-server's memory. If you run out of this memory, you will see:
	   % WINDOW: Unable to create X windows pixmap (BadAlloc (insufficient resources
                    for operation)).
 NOTES:
 MODIFICATION HISTORY:
	21-Mar-2007 added camsig keyword to get other signal names
	30-Mar-2005 convert from fcdcmovies
	05-Aug-2004 Added two Hiroshima cameras
	23-Jul-04 added ExtendEFITtime keyword to continue animation after efit
	05-May-04 Adapted from EfitMovies for Fast Camera data plus x-y plots
	Original EFIT animation written by Dave Gates

(See src/idl_cvs/./src/idl_cvs/efitpluscammds.pro)


EFITPLUSCAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 	efitpluscam

 PURPOSE:
       Plot  Camera images along with EFIT field 
	lines, and also plot Ip, Pnb, and H-alpha (or another) signal vs. time.

 CATEGORY:
       2-D Plotting, Animation, NSTX, EFIT
 CALLING SEQUENCE:

    for a quick demo that doesn't consume too many resources:
	IDL> efitpluscam, 111877, animate=1, nskip=5,time=[.16,.20]

	IDL> efitpluscam, 111877, pixmap=1, animate=0, ppmout=1, /verbose, $
			tmpdisk='/p/nstxusr2/user/tmp/NEW'

	IDL> efitpluscam, 111877, pixmap=1, animate=0, ppmout=1, /verbose, $
			maxframes=5000
	IDL> efitpluscam, 111877, pixmap=1, animate=0, ppmout=1, /verbose, $
			time=[.3,.5], tmpdisk='/p/nstxusr2/tmp'
	IDL> efitpluscam, 111827, time=[.18,.2], sigT1=.18,sigT2=.20, /verbose
	IDL> efitpluscam, 111827, pixmap=1, animate=0, ppmout=1, /verbose

	IDL> efitpluscam, 114333,time=[.008,.012],thom=0, sigT1=.005,sigT2=.020

	   To get a postscript frame printed:
	IDL>efitpluscam,114333,time=0.01,thom=0,sigT1=.005,sigT2=.02,anim=0,/postscript

   if the FC images are too light, you can make them 4 times as bright:
	IDL> efitpluscam, 112608, FCimgScale=4

   to get an animation with no more than 40 frames between 50 and 317 msec:
	IDL> efitpluscam, shot, time=[0.05,0.317],max=40
 
 INPUTS:
       shot = nstx shot number  
	diverter camera data must be moved manually to linux. Examples are
	at /p/nstxusr2/uppercam/114333 and /p/nstxusr2/divcam/114333.
	A .cih file must also be in each directory for the timing information
 KEYWORD PARAMETERS:
    Keywords:
	time - 2-element array for animation; single value for one frame
	animate - if set to 0, will NOT make a movie in an IDL XINTERANIMATE window.
	maxFrames - max # of frames over time range -- necessary if X-memory
	imSmooth - amount to median smooth images (default=3)
		    is limited (default is 200).
	sigName - if set, will not show Fast Camera images, but this
		  signal vs. time (defaults to \passivespec::BAYC_DALF_HAIFA)
	sigT1 - starting time of signal vs. time plot
	sigT2 - ending time of signal vs. time plot
	sigTitle - if set, will be displayed above sigName plot,
		   else tries to get label from MDSplus
 OUTPUTS:
       none

 LIMITATIONS:
       MPEG movies created from widget are poor.
	All Fast Camera data is on VMS, but can be mounted from petrel084 to
	petrel092. Only what has been moved manually 
	is on Unix. 
 NOTES:

   you need to use /save to get Mpeg  quality=100 (but it's not clear there's
	any improvement in the Mpeg.

   to get tiff files from the fastcamera system into the right taurus directory:
	FTP them from the KODAK directory, or one of it's subdirectories, on VMS
 MODIFICATION HISTORY:
	30-Mar-2005 convert from fcdcmovies
	05-Aug-2004 Added two Hiroshima cameras
	23-Jul-04 added ExtendEFITtime keyword to continue animation after efit
	05-May-04 Adapted from EfitMovies for Fast Camera data plus x-y plots
	Original EFIT animation written by Dave Gates

(See src/idl_cvs/./src/idl_cvs/efitpluscam.pro)


SHADE_SURFRANGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       shade_surfrange
 PURPOSE:
       make SHADE_SURF plots with x & y ranges (correctly)
 CATEGORY:
	2-D Plotting
 CALLING SEQUENCE:
        shade_surfrange, f, x, y, XRANGE=xrange, YRANGE=yrange, _EXTRA =_extra
 INPUTS:
       f, x & y are just as for surf      in
 KEYWORD PARAMETERS 
	Input:
	  XRANGE - array containing min x & max x
	  YRANGE - array containing min y & max y
	  ZRANGE - array containing min y & max y
	  _EXTRA - standard idl EXTRA keyworrd
 OUTPUTS:
	none
 EXAMPLE:
	x=findgen(100)
	y=x 
	f=DIST(100)
	_EXTRA = { title: 'My Title', $		; pass any extra SHADE_SURF keywords here
	           xtitle: 'seconds', $
		   ax : 40  }
	shade_surfrange, f, x, y, xrange=[20,40], yrange=[50,70],  _EXTRA =_EXTRA
 COMMON BLOCKS:
 NOTES:
	If your are using color tables with reserved colors at the the top,
	e.g., if you use mk_color, you should first call:
	  IDL> dum=mk_color(n_nonfixed=ncolors)
	  IDL> set_shading, values=[0,ncolors-1]
 MODIFICATION HISTORY:
     09-Jul-02 Handle when yrange or xrange reversed (i.e., first > last)
     17-Aug-01 Handle correctly when !z.range set
     17-Oct-00 Written by Bill Davis

(See src/idl_cvs/./src/idl_cvs/shade_surfrange.pro)


SHOW3M

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	SHOW3m

 PURPOSE:
	Show a 2D array three ways in a display that combines SURFACE, 
	CONTOUR, and an image (color/gray scale pixels).

 CATEGORY:
	2-D Plotting, Graphics, Image Processing.

 CALLING SEQUENCE:
	SHOW3m, Image [, INTERP = Interp, SSCALE = Sscale]

 INPUTS:
	Image:	The 2-dimensional array to display.

 OPTIONAL INPUTS:
	X = a vector containing the X values of each column of Image.
		If omitted, columns have X values 0, 1, ..., Ncolumns-1.
	Y = a vector containing the Y values of each row of Image.
		If omitted, columns have Y values 0, 1, ..., Nrows-1.
 KEYWORD PARAMETERS:
	INTERP:	Set this keyword to use bilinear interpolation on the pixel 
		display.  This technique is slightly slower, but for small 
		images, it makes a better display.

	SSCALE:	Reduction scale for surface. The default is 1.  If this
		keyword is set to a value other than 1, the array size 
		is reduced by this factor for the surface display.  That is, 
		the number of points used to draw the wire-mesh surface is
		reduced.  If the array dimensions are not an integral multiple
		of SSCALE, the image is reduced to the next smaller multiple.
	E_CONTOUR: a structure containing additional keyword parameters
		that are passed to the CONTOUR procedure.  See the example
		below.
	E_SURFACE: a structure containing additional keyword parameters
		that are passed to the SURFACE procedure.  See the example
		below.
       TITLE: Top plot title
       XTITLE: x-axis title
       YTITLE: y-axis title
       FLOOR: if = 0, will not show color contours on floor
       CHARTHICK;  character thickness on color bar
       DRAWLINES: draw lines to indicate a region of interest
       DRAWBOX : draw box around region of interest
       BOXYMID: y-mid point of box, an line location (default=0.1)
       BOXXMID: x-mid point of box, an line location (default=1)
       BOXWIDTH: width of box (default=0.1)
       BAR: if = 0, will not draw color bar
       C_COLOR:   colors for contours
 OUTPUTS:
	No explicit outputs.

 EXAMPLE:
	IDL> gp, '/u/bdavis/MarthRedi/kineticballooning.txt'

 SIDE EFFECTS:
	A new plot is generated.

 RESTRICTIONS:
	The display gets too "busy" when displaying larger (say 50 by 50),
	images, especially if they are noisy.  It can be helpful to use
	the SSCALE keyword or the SMOOTH and/or REBIN functions to smooth the 
	surface plot.

	You might want to modify the calls to CONTOUR and SURFACE slightly
	to customize the display to your tastes, i.e., with different colors,
	skirts, linestyles, contour levels, etc.

 PROCEDURE:
	First, do a SURFACE with no data to establish the 3D to 2D scaling.
	Then convert the coordinates of the corner pixels of the array to
	2D.  Use POLYWARP to get the warping polynomial to warp the
	2D image into the area underneath the SURFACE plot.  Output the image,
	output the surface (with data) and then output the contour plot at
	the top (z=1).

 EXAMPLES:
	A = BESELJ(SHIFT(DIST(30,20), 15, 10)/2.,0)  ;Array for example
	SHOW3, A		;Show it with default display.
	SHOW3, A, SQRT(FINDGEN(30))  ;Make X axis proportional to sqrt
	SHOW3, A, E_CONTOUR={C_CHARSIZE:2, DONW:1} ;Label CONTOUR lines with
		double size characters, and include downhill tick marks.
	SHOW3, A, E_SURFACE={SKIRT:-1, ZRANGE:[-2,2]}  ;Draw a surface with
		a skirt and scale Z axis from -2 to 2.
 MODIFICATION HISTORY:
	DMS. Jan, 1988.
	Added fudges for PostScript, April, 1988.
	Fixed bug where contour plot was occasionally clipped. Dec, 1990.
	Added optional axis variables, and _EXTRA keywords for CONTOUR,
		and SURFACE.  Jan, 1996.
	DD.  Added code to ignore !ORDER for the TV of the image.  Mar 1997.
       SJL  Fixed bug from scaling with polywarp. July, 1998.
	DD.  Add better support for TrueColor devices.
	     Honor !P.BACKGROUND (rather than assuming black or white
            background).  Sept, 2000.
    	Feb/2005 hacked by Bill Davis for Martha Redi:
	     better scaling of bottom image. Added lines and a square to indicate region.
	     When bottom values are zero, make white (transparent). Add color bar.

(See src/idl_cvs/./src/idl_cvs/show3m.pro)


SURFRANGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       surfrange
 PURPOSE:
       make SURF plots with x & y ranges (correctly)
 CATEGORY:
	2-D Plotting
 CALLING SEQUENCE:
        surfrange, f, x, y, XRANGE=xrange, YRANGE=yrange, _EXTRA =_extra
 INPUTS:
       f, x & y are just as for surf      in
 KEYWORD PARAMETERS 
	Input:
	  XRANGE - array containing min x & max x
	  YRANGE - array containing min y & max y
	  ZRANGE - array containing min y & max y
	  _EXTRA - standard idl EXTRA keyworrd
 OUTPUTS:
	none
 EXAMPLE:
	x=findgen(100)
	y=x 
	f=DIST(100)
	_EXTRA = { title: 'My Title', $		; pass any extra SURF keywords here
	           xtitle: 'seconds', $
		   ax : 40  }
	surfrange, f, x, y, xrange=[20,40], yrange=[50,70],  _EXTRA =_EXTRA
 COMMON BLOCKS:
 NOTES:
	logic is still not perfect. See, e.g., 
	AUSER4:[BDAVIS.TEST.NDD]NDD3D.PRO for a working example of overlaying
	surface plot on a shaded surface plot with ranges set.
 MODIFICATION HISTORY:
     09-Jul-02 Handle when yrange or xrange reversed (i.e., first > last)
     17-Aug-01 Handle correctly when !z.range set
     17-Oct-00 Written by Bill Davis

(See src/idl_cvs/./src/idl_cvs/surfrange.pro)


TH_IMAGE_CONT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       TH_IMAGE_CONT
 PURPOSE:
       Plot contours of Images with both contour lines and colors
 CATEGORY:
	2-D Plotting
 USAGE:
******************** HIGH FREQUENCY RADAR DIVISION, SRL **********************
*************************** Ionospheric Effects ******************************
HELP
1 TH_IMAGE_CONT
	Overlays an image and a contour plot and optionally adds a scale bar.
	Based on the IDL USERLIB routine IMAGE_CONT. This routine supersedes 
	the USERLIB one, having far more functionality, yet capable of EXACTLY
	reproducing the effect of IMAGE_CONT. Scale bar appears on the 
	right-hand-side unless /NOBAR is set. NB: the scale bar is
	automatically created by a recursive call to this routine using the
	same colour and image parameters 

 Format:
	In its simplest form (allowing all parameters to default)

    IDL> TH_IMAGE_CONT, IMAGE

	or,

    IDL> TH_IMAGE_CONT, IMAGE, X, Y

	And in its most complex form, specifying ALL parameter

    IDL> TH_IMAGE_CONT, IMAGE, $
		ASPECT=aspect, $
		BADPTS=badpts,$
     		BAR_LABEL_LENGTH=bar_label_length, $
		BAR_RANGE=bar_range, $
		BAR_SEPARATION=bar_separation, $
		BAR_TICKLEN=bar_ticklen, $
		BAR_TICKNAME=bar_tickname, $
		BAR_TICKS=bar_ticks, $
		BAR_TICKV=bar_tickv,$
		BARSZ_CHARS=barsz_chars, $
		BOTTOMCOLOUR=bottomcolour,$
		C_COLORS=c_colors,$
		C_LINESTYLE=c_linestyle, $
		C_THICK=c_thick, $
		CONGRID=congrid, $
		CONT=cont, $
		CRANGE=crange, $
		CT=ct, $
		CUBIC=cubic, $
		DEBUG=debug, $
		EXACT=exact, $
		RAISE_PTITLE=raise_ptitle
		IMAGE_WINDOW=image_window, $
		INTERP=interp,$
		LEVELS=levels,$
		MAX_VALUE=max_value, $
		NLEVELS=nlevels, $
		NOBAR=nobar, $
		NOCONT=nocont, $
		NOERASE=noerase,$
		TOPCOLOUR=topcolour,$
		TSIZE=tsize, $
		WINDOW_SCALE=window_scale, $
		XRANGE=xrange, $
		YRANGE=yrange
 
2	IMAGE
		2-dimensional array to display as an image.

2	/ASPECT
		set to retain image's aspect ratio.  Assumes square
		pixels.  If /WINDOW_SCALE is set, the aspect ratio is retained.

2	BADPTS
		indices into IMAGE data which define the bad points.
		These will not be contoured

2 BAR_LABEL_LENGTH
     the space, in characters (default = 2), for the bar label
2	BAR_RANGE	
	 	set the range limits for the colour scale bar
		(same as CRANGE, defaults to autoscaling if
		 BAR_TICKV not set)

2	BAR_SEPARATION	
		the separation, in characters (default = 2), between the scale
		bar and the image. Note that the |y-ticklength| will be added
		to this value if y-ticklength < 0.
		Both the image and the colour bar need to fit 
		into the space allowed for the plot window, otherwise an
		informative message will be printed and unpredictable results
		may occur for the displayed image 

2	BAR_TICKS
		set the number of tick intervals for the labelling
		of the scale bar 
		(defaults to !z.ticks)

2	BAR_TICKV
		the values to label on the scale bar. If this is set
		then the scale bar will have AT LEAST this range
		(defaults to !z.tickv)

2	BAR_TICKNAME
		the labels to use on the scale bar 
		(defaults to !z.range)

2	BAR_TICKLEN
		the length of the ticks on the scale bar  in fractions of tick
		bar window, (defaults to !z.ticklen)

2	BARSZ_CHARS
		the size of the scale bar in characters (default = 2). 
		Both the image and the colour bar need to fit 
		into the space allowed for the plot window, otherwise an
		informative message will be printed and unpredictable results
		may occur for the displayed image. If the value of this
		keyword is <=0 then no bar will be displayed BUT the scaling
		and window size will be calculated as those a colour bar is to
		be used. This is useful when doing multiple plots per page
		where only some scale bars are not required but you want the
		plots to all be the same size. Set BARSZ_CHARS = -#chars to
		allow room for a bar of #chars size but not to put a scale bar
		on the plot. Then set BARSZ_CHARS = +#chars to plot the bar on
		alongside another plot, to end up with images of the same
		size. Useful in collaboration with the SIDES procedure (which
		will set flags for when the plot is on the Left,Right,Top and
		Bottom of the plot window).


2	BOTTOMCOLOUR
		Set this keyword to the colour index of the desired bottom
		colour (range from 0 to TOPCOLOUR-1).
		Note that the default value for this keyword is 1,
		which allows the colour of the image to
		be independent of the background and axes colours
		(!P.background and !P.color). If the user sets this keyword
		then allowance should be made for these colours as they are
		generally swapped for POSTSCRIPT and X-Window devices

2	/CONGRID 	
		if the image has to be resampled then use the USERLIB CONGRID
		routine 

2	/CONT 	
		only do the contouring (no image)

2	CRANGE	
		set the range limits for the colour scale bar
		(same as BAR_RANGE, defaults to autoscaling if
		 BAR_TICKV not set)

2	CT	
		load a color table (uses LOADCT via MK_COLOR)

2	/CUBIC	
		if the image has to be resampled AND interpolated then use the
		CUBIC interpolation rather than the bi-linear (see INTERP
		Keyword) 

2	/DEBUG	
		write out some inforamtion as it goes


2	/EXACT
 
		When set this will force the contour routine to fit to the
		exact positions relative to the image.
		When data is displayed as an image each datum is expanded out
		to fill a pixel of finite dimensions. The assignment of where
		the "data value" resides within this space is open to debate,
		but is most appropriately (to this author) assigned to the
		geometric centre of the pixel. Most defaults assign this
		position to be at the bottom left-hand corner of the
		pixel. Contour will fit to the 2-d plane assuming that the
		data value is associated with the bottom left-hand corner. To
		reconcile this with the notion of the value being in the
		middle of the pixel the contour call is made with the x/y
		values and ranges for the image adjusted (effectively by half
		a pixel in the x/y directions). This is the EXACT mapping. By
		default, the mapping will be the default contour one.

2	RAISE_PTITLE
		Raise the plot title by this many character units above the
		plot to allow room to put a label on the top x-axis. Default
		is raise by 1 char. If not called then the default y-position
		is 1 char unit above plot (allowing room for xticks, and
		scaled by !P.charsize)

2	IMAGE_WINDOW
		the position of the image window. Can be used to set
		!p.position so you can over-plot the image.
		(Only useful when the scale-bar has been used)

2	/INTERP 
		set to bi-linear interpolate if image is resampled.
		(see also the CUBIC keyword)

2	/NOBAR 
		dont put a scale bar on the right-hand-side

2	/NOCONT
		only do the imaging (no contours)

2	/NOERASE
		dont erase the previous plot
       /NOLOAD
		if set, do not load color table

2	TOPCOLOUR
		Set this keyword to the colour index of the desired bottom
		colour (range from BOTTOMCOLOUR+1 to !D.n_colors-1). Note that
		the default value for this keyword is !D.n_colors-2, which
		allows the colour of the image to be independent of the
		background and axes colours (!P.background and !P.color). If
		the user sets this keyword then allowance should be made for
		these colours as they are generally swapped for POSTSCRIPT and
		X-Window devices 

2	TSIZE	
		size of the plot title (default = 1)
 
2	/WINDOW_SCALE
		set to scale the window size to the image size,
		otherwise the image size is scaled to the window size.
		Ignored when outputting to devices with scalable pixels.

2	XRANGE
		will set the ranges for the x-axes labelling

2	YRANGE
		will set the ranges for the y-axes labelling

2	Contour
		most of the CONTOUR parameters are passed directly

2 Examples
 IDL>   th_image_cont, image

 IDL>	th_image_cont, image, /nocont, /nobar

 IDL>	!p.title = "!17 This is an example of what can be done"
 IDL>	!x.title = "X Title"	& !y.title = "Y Title"	& !z.title = "Z Title"
 IDL>	!x.ticklen = -0.02	& !y.ticklen = -0.02	& !z.ticklen = -0.02
 IDL>	!p.charsize = 1.5
 IDL>	levels = findgen(5)*2
 IDL>	image = findgen(20,20)/40.
 IDL>	th_image_cont, image, crange=[0,10], /follow, level=levels, $
			tsize=1.5*!p.charsize, bar_tickv=levels, c_char=1.5

2 Error_responses
 Returns to the calling procedure on an error

2 Limitations/Assumptions 
	The currently selected display is affected.
	If the device has scalable pixels then the image is written over
	the plot window.
	As with all TV style image displays, the axes range is independent of 
	the image, so it is up to the user the ensure correct labelling of the
	axes.
	NOTE: if the user aborts while this routine is processing then the 
	system variables (in particular !p.position) will have 
	been changed, causing subsequent plots to appear different. Issue the 
	command "resetplt,/all" to reset all the system variables back to the 
	startup state.

	NOTE: if x or y does not have a constant interval, the image will be
		wrong. Instead, use contour, /fill...
2 References 
 	See USERLIB IMAGE_CONT

2 Keywords
	Graphics images contours

2 MODIFICATIONS:
  -------------
  06-Jun-2006 several changes including adding x & ytickformat keywords
  06-Apr-2006 limit max dimension of interpolated postscript plots to 2000 pixels
  14-Mar-2006 added zrange keyword [BD]
  25-Oct-01 Made Contours work when /ASPECT set. Made Contours work when
	     XRANGE or YRANGE set.
  18-Apr-00 Made interpolated image align with data. /EXACT does not give
		  an exact representation. Warn if style=2
  06-Dec-99 Added another pixel to TV image size, so it fills the grid square
  23-Aug-99 Allow Contour, Z, X, Y format. Use MK_COLOR
  07-Jan-98 BD allow more space at the bottom and right-hand side for text
               (keyword BAR_LABEL_LENGTH added)
  07-Aug-97 Bill Davis- v. 2.24
                [1] added _extra call to main CONTOUR and removed
                    it from those making the bar.
 (more modifications in file)

(See src/idl_cvs/./src/idl_cvs/th_image_cont.pro)


VECTORSURF

[Previous Routine] [List of Routines]
 NAME:
       vectorsurf

 PURPOSE:
       Shows a fancy way to plot irregulary spaced data from x,y & z vectors.

 CATEGORY:
	2-D Plotting, Example

 CALLING SEQUENCE:
        vectorsurf, x, y, z

 INPUTS:
       tag - MDSplus tag or node name      in

 KEYWORD PARAMETERS 
    Input:
	DRAWXSIZE = drawXsize
	DRAWYSIZE = drawYsize
       BG_COLOR = bg_color

 OUTPUTS:
	none

  EXAMPLE:
     IDL> x=[4,6,1,7,1,8,5,2,4]
     IDL> y=[3,3,1,6,4,5,6,8,1]
     IDL> z=sqrt((x-3)^2+(y-2)^2)+randomn(seed)+2 
     IDL> vectorsurf, x, y, z

  MODIFICATION HISTORY:
       05-Sep-97 Written by Bill Davis
                 from IDL's d_mathstat.pro in the IDL 5.0 release
                 Written by:  DC, RSI,  1995

(See src/idl_cvs/./src/idl_cvs/vectorsurf.pro)


Category: Animation

[List of Routines]


ANIM2CINE

[Next Routine] [List of Routines]
 NAME:
    anim2cine

 PURPOSE:
    Create an mpeg or avi movie from two .cin files from Phantom 7 Cameras.
    The data can be color or monochrome

 CATEGORY:
    animation

 CALLING SEQUENCE:
    anim2cine, CineFile1, CineFile2, outFile=outfile, t1=t1, t2=t2
   or

 INPUTS:
	CineFile1 - cine file
	CineFile2 - 
	 - 
 OPTIONAL KEYWORD PARAMETERS:
	outFile - name of output MPEG file (will default to a nice name), or 
	prefix - what would precede _shot_t1_t2 (in msec) in the output filename
	t1 - start time of animation in seconds
	t2 - end time of animation in seconds
	VIEW - if set, just displays images, and does not make an mpeg
   	ndups - if given means repeat every image 'ndups' times
   	despeckle - if set call despeckle routine (slow, but less "intrusive" 
		    than median)
	nSmooth - number input to median smoothing routine
	topPixels -
	botPixels - 
	charsize - character size for plots. Default=2
	ctb - color table for non-color image 
	label1 - label on plot for CineFile1 (default='Monochrome')
	label2 -  label on plot for CineFile2 (default='Color')
	verbose - if set will print out info as it works
 OUTPUTS: 
	an MPEG file named by outFile keyword

 PROCEDURE:
   will assume Phantom 7 camera is the fastest
 EXAMPLE:

    anim2cine, '/p/nstxusr2/nstxphantom7/NSTX_130389.cin', $
		'/p/nstxusr2/miro/MIRO_130389.cin', $
		t1=0.02, t2=0.0300, /verbose                        , /debug

    anim2cine, shot=130370, t1=0.05, t2=0.58, /verbose, /view    , /debug

    anim2cine, '/p/nstxusr2/nstxphantom7/NSTX_130388.cin', $
		'/p/nstxusr2/phantom4/NSTX_130388.cin', $
		t1=0, t2=2, ctb=0, /verbose                    , /debug

    anim2cine, shot=130375, /nonGlobal, $
		t1=0, t2=2, ctb=0, /verbose                    , /debug

   mv files to /w/nstx.pppl.gov/htdocs/nstx/Software/Diagnostics/Miro for web viewing at
   http://nstx.pppl.gov/nstx/Software/Diagnostics/Miro/

 MODIFICATION HISTORY:
	16-Jul-2008 Use Z-buffer, even when viewing, for smoother displays
   15-Jul-2008 Written by Bill Davis

(See src/idl_cvs/./src/idl_cvs/anim2cine.pro)


ANIMXYPLOT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       animxyplot
 PURPOSE:
       Animate X-Y plot of a 2-D array
 CATEGORY:
       Animation
 CALLING SEQUENCE:
       IDL> animxyplot, data2d, x, time [, ....]
 INPUTS:
       data2d - 2 d array (1st dimension like x, 2nd like time)
	x - array for x-axis of x-yplot
	time
 KEYWORD PARAMETERS:
	(can have any keywords used in PLOT command -- will be passed on)
 	mpeg - if set, will create an mpeg of animation
	filename - name of mpeg file (default =  'plotanimation.mpg')
	rep - # number of times to repeat frames (to slow down mpeg) default=0
	t1 - time to start animation (indexes into time array) (default=start)
	t2 - time to end animation (default=end)
	xtitle -    
	ytitle -    
	xsize - xsize of window in pixels
	ysize - ysize of window in pixels 
	flip - if set, will flip mpeg image    
	timeTitle - appended to indication of time on plot (def='Sec.')
	pause - # of seconds to pause between plotted frames when creating
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed
 OUTPUTS:
       NONE; just the mpeg file, if specified
 EXAMPLE:
	nframes = 20
	nPts = 1000
	data2d = fltarr(npts, nframes)
	time = findgen(nFrames)/1000 +0.2
	x =findgen(npts)/npts*150 + 50
	for i=0,nframes-1 do data2d[0,i]=sin(x*5/max(x)+i/10.)*exp(1.-x/100-i/10.)
	animxyplot, data2d, x, time, xtitle='Radii', ytitle='Value', /mpeg
 NOTES:
 MODIFICATION HISTORY:
       18-Jan-2008 Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/animxyplot.pro)


CINE2MPEG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    cine2mpeg

 PURPOSE:
    Create an mpeg movie from a .cin files from Phantom 7 Cameras.
    The data can be color or monochrome

 CATEGORY:
    animation

 CALLING SEQUENCE:
      cine2mpeg, CineFile1, outFile=outfile, t1=t1, t2=t2, ndups=ndups
   or
      cine2mpeg, shot=shot, t1=t1, t2=t2, /verbose

 INPUTS:
	CineFile1 - a cine filename
 OPTIONAL KEYWORD PARAMETERS:
	outFile - name of output MPEG file (will default to a nice name), or 
	prefix - what would precede _shot_t1_t2 (in msec) in the output filename
	t1 - start time of animation in seconds
	t2 - end time of animation in seconds
	VIEW - if set, just displays images, and does not make an mpeg
   	ndups - if given means repeat every image 'ndups' times
   	despeckle - if set call despeckle routine (slow, but less "intrusive" 
		    than median)
	nSmooth - number input to median smoothing routine
	topPixels -
	botPixels - 
	charsize - character size for plots. Default=2
	ctb - color table for non-color image 
	label1 - label on plot 
	verbose - if set will print out info as it works
 OUTPUTS: 
	an MPEG file named by outFile keyword

 PROCEDURE:
 EXAMPLE:

    cine2mpeg, '/p/nstxusr2/miro/MIRO_130389.cin', $
		t1=0.02, t2=0.0300, /verbose                        , /debug

    cine2mpeg, shot=130277, t1=0.100, t2=0.200, /verbose, /view    , /debug

    cine2mpeg, '/p/nstxusr2/phantom4/GDNex10usFps27000DC110maP1.98torr-1.cin', $
		outfile='Ne110us.mpg', t1=.0007, t2=0.0017, ndups=4, mag=3

   mv files to /w/nstx.pppl.gov/htdocs/nstx/Software/Diagnostics/Miro/GlobalMPEGs 
	for web viewing at
       http://nstx.pppl.gov/nstx/Software/Diagnostics/Miro/GlobalMPEGs

 MODIFICATION HISTORY:
	18-Sep-2008 mods to magnify keyword
	05-Aug-2008 Written by Bill Davis

(See src/idl_cvs/./src/idl_cvs/cine2mpeg.pro)


DISPLAYFCMDS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       displayfcmds

 PURPOSE:
	Animate Fast Camera images from MDSplus with the time overlayed

 CATEGORY:
       Animation

 CALLING SEQUENCE:

	IDL> displayfcmds, shot
 INPUTS:
       shot = nstx shot number  

 KEYWORD PARAMETERS:
    Keywords:
	minmsec - min time in msec to include
	maxmsec - max time in msec to include
	loop - number of times to loop through animation (default=1)
	pause - time in seconds to pause between frames (default=0)
	minToPlot - min value for bytscl of image
	maxToPlot - max value for bytscl of image
	skip - frames to skip between those displayed (default=0)
	magnify - magnification factor ( note that bigger movies are slower)
	charThick - 
	charsize -  
	debug -  
  	mpg - 
	xpos -
	ypos -
	mds - if set, look for data in MDS plus (little there as of Jul/04)
 OUTPUTS:
       none

 LIMITATIONS:
       MPEG movies created from widget are poor.
 EXAMPLE:
	IDL> displayfcmds,shot=113723,minms=140,maxms=170, loop=10, pause=.3
	IDL> displayfcmds, 127179, loop=10000L, minmsec=150, maxmsec=300, $
			   trig=0, mult=2

 MODIFICATION HISTORY:
	21-Feb-08 replaced openmdsshot with mdsopen
	05-MAR-07 Assume all shots in MDSplus
	10-Apr-06 more keywords. Be able to work from cameras2 tree
	16-Aug-05 added xpos and ypos keywords for use on wall [BD]
	31-May-05 Read timing module trigger time from MDSplu
	16-Mar-05 Only read in times within times requested
	29-Jul-04 access /v/kodak area from Unix
	22-Jul-04 Added mpg creation [DM]
      Written by Bill Davis, PPPLmax

(See src/idl_cvs/./src/idl_cvs/displayfcmds.pro)


DISPLAYFCTIFFS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       displayfctiffs

 PURPOSE:
	Animate Fast Camera images with the time overlayed

 CATEGORY:
       Animation

 CALLING SEQUENCE:

	IDL> displayfctiffs, shot
 INPUTS:
       shot = nstx shot number  

 KEYWORD PARAMETERS:
    Keywords:
	minmsec - min time in msec to include
	maxmsec - max time in msec to include
	loop - number of times to loop through animation (default=1)
	pause - time in seconds to pause between frames (default=0)
	minToPlot - min value for bytscl of image
	maxToPlot - max value for bytscl of image
	skip - frames to skip between those displayed (default=0)
	magnify - magnification factor ( note that bigger movies are slower)
	charThick - 
	charsize -  
	debug -  
  	mpg - 
	mds - if set, look for data in MDS plus (little there as of Jul/04)
 OUTPUTS:
       none

 LIMITATIONS:
       MPEG movies created from widget are poor.
 EXAMPLE:
	IDL> displayfctiffs,shot=113723,minms=140,maxms=170

 MODIFICATION HISTORY:
	16-Mar-05 Only read in times within times requested
	29-Jul-04 access /v/kodak area from Unix
	22-Jul-04 Added mpg creation [DM]
      Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/displayfctiffs.pro)


EFITMOVIES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 	efitmovies

 PURPOSE:
       Plot EFIT field lines, Thomson Scattering Density and Temperature 
	and, optionally, Fast Camera images. Instead of Fast Camera, can
	plot H-alpha (or another) signal vs. time.

 CATEGORY:
       Animation, EFIT, 2-D Plotting, NSTX, Thomson Scattering

 CALLING SEQUENCE:
   to get a single frame:
	IDL> shot=130000
	IDL> efitmovies, shot, time=0.2, /thom, signame='\wf::ip',  $
                        sigt1=0, sigt2=.4

   to get a single frame with flux surfaces on both sides:
       IDL> efitmovies, 121048, time=.2, /double

   to get a single frame with fast camera image on the left:
       IDL> efitmovies, 120200, time=.2

   to get an animation:
	IDL> efitmovies,120200,time=[0.05,0.317],/thom,max=40

   to get an animation with H-alpha time trace instead of Fast Camera images:
	IDL> efitmovies,107314,/thom, time=[.05,.5], $
			/signame,sigtitle='H-alpha',max=40

   to see what shots have fast camera data in the tree:
 	IDL> MDSnodeChanges,'\fc3d',shot1=119120,shot2=119230,tree='cameras',/after
 INPUTS:
       shot = nstx shot number  

 KEYWORD PARAMETERS:
    Keywords:
	ndups - number of times each frame of movie is duplicated (default=0)
	time - 2-element array for animation; single value for one frame
	thomson - if set, will plot Thomson Te and Ne below EFIT contours
	animate - if set to 0, will plot individual frames instead of movie.
	maxFrames - max # of frames over time range -- necessary if X-memory
		    is limited (default is 200).
	pixMap - if set, will not send each frame to the screen (faster)
 	double - plot efit color contours on both sides of center stack
	sigName - if set, will not show Fast Camera images, but this
		  signal vs. time (defaults to \passivespec::BAYC_DALF_HAIFA)
	sigT1 - starting time of signal vs. time plot
	sigT2 - ending time of signal vs. time plot
	sigTitle - if set, will be displayed above sigName plot,
		   else tries to get label from MDSplus
	overlayTe - overlay Thomson Te and Ne, instead of on left and right
	window - starting window number (default=0)
	efitVersion - the efit version to display. Defaults to the highest
			available less than 5.
	LRDfitVersion - the LRDfit version to display. If non-blank, will override
		        efitVersion keyword used.
 OUTPUTS:
       none

 LIMITATIONS:
       Some reds are green on printer.
 NOTES:
   to create an FLC animation out of ppm files:

       IDL> efitmovies,106892,/pixmap,time=[0.05,0.317],/thom,max=400,;
	alias ppm2fli '/u/bdavis/FTP/ppm2fli-2.1/ppm2fli'
	cd /tmp/idl2ppm.frames/
	/bin/ls -1 *.ppm > pics.list
	ppm2fli -g 600x600 -s 180 pics.list ~/public_html/movies/xsec106892.fli

     the -g parameter specifies the size
     -s is the "rate" (bigger is slower)

   to get tiff files from the fastcamera system into the right taurus directory:
	IDL> .run /u/bdavis/Anim/get_tifs
	IDL> get_tifs,  shot
 MODIFICATION HISTORY:
	02-May-06 added ndups keyword
  	26-Jan-06 No longer e-mail to 'USER' if username not specified. 
		  Tidy up screen message for postscript output
	27-Sep-2005 fix bug for sub-msec timing for single plots
	19-Aug-2005 improve selection of efit version
	17-Jul-2005 Assure black lines on plots
	03-Sep-04 Better logic for missing Thomson data.
	15-Apr-04 Fixed bug for full time with lots of frames
		  made default max frames 200.
	23-Oct-03 Use spline Te and Ne from Thomson
	23-Aug-03 Adds for efitflux.html
	23-May-03 Added keywords for Web Plotting
	01-May-03 Added /double keyword
       28-May-02 Added /signame keyword and overlayTe
	Original written by Dave Gates

(See src/idl_cvs/./src/idl_cvs/efitmovies.pro)


EFITPLUSRF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 	efitplusrf

 PURPOSE:
       Plot  Camera images along with EFIT field 
	lines, and also plot Ip, Pnb, and H-alpha (or another) signal vs. time.

 CATEGORY:
       Animation, 2-D Plotting, NSTX, EFIT, RF Heating

 CALLING SEQUENCE:
	IDL> efitplusrf, 115775,time=[.1,.2],xsize=300,ysize=250
	IDL> efitplusrf,115775,time=[.1,.2], cx1=115,cx2=440, cy1=20, cy2=300
	IDL> efitplusrf,115775,time=[.1,.2], cx1=115,cx2=440, cy1=20, cy2=300, $
		mindata=50, maxdata=270

	IDL> efitplusrf, 115651, cx1=85,cx2=375, cy1=0, cy2=260
	IDL> efitplusrf, 112117, pixmap=1, animate=0, ppmout=1, /verbose, /debug

	IDL> efitplusrf, 111827, time=[.18,.2], sigT1=.18,sigT2=.20, /verbose
	IDL> efitplusrf, 111827, pixmap=1, animate=0, ppmout=1, /verbose

	IDL> efitplusrf, 114333,time=[.008,.012],thom=0, sigT1=.005,sigT2=.020

	   To get a postscript frame printed:
	IDL>efitplusrf,114333,time=0.01,thom=0,sigT1=.005,sigT2=.02,anim=0,/postscript

   if the FC images are too light, you can make them 4 times as bright:
	IDL> efitplusrf, 112608, FCimgScale=4

   to get an animation with no more than 40 frames between 50 and 317 msec:
	IDL> efitplusrf, shot, time=[0.05,0.317],max=40
 
 INPUTS:
       shot = nstx shot number  
	diverter camera data must be moved manually to linux. Examples are
	at /p/nstxusr2/uppercam/114333 and /p/nstxusr2/divcam/114333.
	A .cih file must also be in each directory for the timing information
 KEYWORD PARAMETERS:
    Keywords:
	time - 2-element array for animation; single value for one frame
	animate - if set to 0, will NOT make a movie in an IDL XINTERANIMATE window.
	maxFrames - max # of frames over time range -- necessary if X-memory
	imSmooth - amount to median smooth images (default=3)
		    is limited (default is 200).
	sigName - if set, will not show Fast Camera images, but this
		  signal vs. time (defaults to \passivespec::BAYC_DALF_HAIFA)
	sigT1 - starting time of signal vs. time plot
	sigT2 - ending time of signal vs. time plot
	sigTitle - if set, will be displayed above sigName plot,
		   else tries to get label from MDSplus
	ndups - number of times each frame of movie is duplicated (default=0)
 OUTPUTS:
       none

 LIMITATIONS:
       MPEG movies created from widget are poor.
	All Fast Camera data is on VMS, but can be mounted from petrel084 to
	petrel092. Only what has been moved manually 
	is on Unix. 
 NOTES:

   you need to use /save to get Mpeg  quality=100 (but it's not clear there's
	any improvement in the Mpeg.

   to get tiff files from the fastcamera system into the right taurus directory:
	spc them from the KODAK directory, or one of it's subdirectories, on VMS
 MODIFICATION HISTORY:
	01-Mar-2007 removed flip of image, per Lane Roquemore 
  	13-Apr-2006 camera times off by 2 time steps. Add triggerTime keyword
	11-Aug-2005 Handle smaller xsize & ysize (not great, but can see)
	25-Jul-2005 Get Ip and Pnb from EFIT, if WF tree not there.
	30-Mar-2005 convert from fcdcmovies
	05-Aug-2004 Added two Hiroshima cameras
	23-Jul-04 added ExtendEFITtime keyword to continue animation after efit
	05-May-04 Adapted from EfitMovies for Fast Camera data plus x-y plots
	Original EFIT animation written by Dave Gates

(See src/idl_cvs/./src/idl_cvs/efitplusrf.pro)


FCDCMOVIES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 	fcdcmovies

 PURPOSE:
       Plot Fast Camera and Divertor Camera images along with EFIT field 
	lines, and, optionally, Thomson Scattering Density and Temperature. 
	You may also plot H-alpha (or another) signal vs. time.

 CATEGORY:
        Animation, NSTX, EFIT, Thomson Scattering

 CALLING SEQUENCE:

	IDL> fcdcmovies, 114333,time=[.008,.012],thom=0, sigT1=.005,sigT2=.020

	   To get a postscript frame printed:
	IDL>fcdcmovies,114333,time=0.01,thom=0,sigT1=.005,sigT2=.02,anim=0,/postscript

   if the FC images are too light, you can make them 4 times as bright:
	IDL> fcdcmovies, 112608, FCimgScale=4

   to get an animation with no more than 40 frames between 50 and 317 msec:
	IDL> fcdcmovies, shot, time=[0.05,0.317],max=40
 
 INPUTS:
       shot = nstx shot number  
	diverter camera data must be moved manually to linux. Examples are
	at /p/nstxusr2/uppercam/114333 and /p/nstxusr2/divcam/114333.
	A .cih file must also be in each directory for the timing information
 KEYWORD PARAMETERS:
    Keywords:
	half - if set, only show left half of fast camera image
	time - 2-element array for animation; single value for one frame
	thomson - if set to 0, will NOT plot Thomson Te and Ne below EFIT contours
	animate - if set to 0, will NOT make a movie in an IDL XINTERANIMATE window.
	maxFrames - max # of frames over time range -- necessary if X-memory
	imSmooth - amount to median smooth images (default=3)
		    is limited (default is 200).
	sigName - if set, will not show Fast Camera images, but this
		  signal vs. time (defaults to \passivespec::BAYC_DALF_HAIFA)
	sigT1 - starting time of signal vs. time plot
	sigT2 - ending time of signal vs. time plot
	sigTitle - if set, will be displayed above sigName plot,
		   else tries to get label from MDSplus
 OUTPUTS:
       none

 LIMITATIONS:
       MPEG movies created from widget are poor.
	All Fast Camera data is on VMS, but can be mounted from petrel084 to
	petrel092. Only what has been moved manually 
	is on Unix. 
 NOTES:

   you need to use /save to get Mpeg  quality=100 (but it's not clear there's
	any improvement in the Mpeg.

   to get tiff files from the fastcamera system into the right taurus directory:
	scp them from the KODAK directory, or one of it's subdirectories, on VMS

	Postscript files can be huge; may try making separate one with only Fast Camera image.

 MODIFICATION HISTORY:
       03-Sep-04 Fixed bug in times of Thomson when animating partial shot
	05-Aug-2004 Added two Hiroshima cameras
	23-Jul-04 added ExtendEFITtime keyword to continue animation after efit
	15-Jul-04 Make default to do animation and include Thomson data
	13-Jul-04 Made the default be to show whole fast camera image
	05-May-04 Adapted from EfitMovies for Fast Camera data plus x-y plots
	Original EFIT animation written by Dave Gates

(See src/idl_cvs/./src/idl_cvs/fcdcmovies.pro)


FCMOVIES

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 	fcmovies

 PURPOSE:
       Plot EFIT field lines, Thomson Scattering Density and Temperature 
	and Fast Camera images. Can also
	plot H-alpha (or another) signal vs. time.

 CATEGORY:
       Animation, NSTX, EFIT, Thomson Scattering

 CALLING SEQUENCE:
      good demo:
	DL> fcmovies, 120477

	IDL> fcmovies, 112606

   if the FC images are too light, you can scale them up:
	IDL> fcmovies, 112608, FCimgScale=4

   to get an animation:
	IDL> fcmovies, 107994,time=[0.05,0.317],max=40
 
	IDL> fcmovies, 113723,time=[.14,.3],thom=0, /pixmap
 INPUTS:
       shot = nstx shot number  

 KEYWORD PARAMETERS:
    Keywords:
	NREPS - number of frames to repeat when creating mpeg (1 means no dups)
	half - if set, only show left half of fast camera image
	time - 2-element array for animation; single value for one frame
	thomson - if set to 0, will NOT plot Thomson Te and Ne below EFIT contours
	animate - if set to 0, will NOT make a movie in an IDL XINTERANIMATE window.
	maxFrames - max # of frames over time range -- necessary if X-memory
		    is limited (default is 500).
	sigName - if set, will not show Fast Camera images, but this
		  signal vs. time (defaults to \passivespec::BAYC_DALF_HAIFA)
	sigT1 - starting time of signal vs. time plot
	sigT2 - ending time of signal vs. time plot
	sigTitle - if set, will be displayed above sigName plot,
		   else tries to get label from MDSplus
	FCimageScale - factor to multiply image frames by.
 OUTPUTS:
       none

 LIMITATIONS:
       MPEG movies created from widget are poor.
	All data is on VMS. Only what has been moved manually is on Unix.
 NOTES:

   !!!!! you need to use /save to get quality=100

 MODIFICATION HISTORY:
	02-May-06 added nreps keyword
	27-Apr-06 added FcFromMDS keyword, so could get from files, even
		  if data in MDSplus.
	16-Aug-05 be able to read from MDSplus and default to color table 3
	13-Sep-04 Handle missing waveforms. Assure that overlayed signals on 
		  same timebase. 
		  Added a kludy check for bug in some DALF timing (e.g., 114446) 
	03-Sep-04 Fixed bug in times of Thomson when animating partial shot
	23-Jul-04 added ExtendEFITtime keyword to continue animation after efit
	15-Jul-04 Make default to do animation and include Thomson data
	13-Jul-04 Made the default be to show whole fast camera image
	05-May-04 Adapted from EfitMovies for Fast Camera data plus x-y plots
	15-Apr-04 Fixed bug for full time with lots of frames
		  made default max frames 200.
	23-Oct-03 Use spline Te and Ne from Thomson
	23-Aug-03 Adds for efitflux.html
	23-May-03 Added keywords for Web Plotting
	01-May-03 Added /double keyword
       28-May-02 Added /signame keyword and overlayTe
	Original EFIT animation written by Dave Gates

(See src/idl_cvs/./src/idl_cvs/fcmovies.pro)


FCTIFFSVCR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       fctiffsvcr

 PURPOSE:
	animate Fast Camera tiffs with VCR-like controls.
	from the resulting widget, you may write an Mpeg file

 CATEGORY:
       Animation

 CALLING SEQUENCE:

	IDL> fctiffsvcr, shot
 INPUTS:
       shot = nstx shot number  (Optional - you can navigate for a shot)

 KEYWORD PARAMETERS:
    Keywords:
	minmsec - min time in msec to include
	maxmsec - max time in msec to include
	minToPlot - min value for bytscl of image
	maxToPlot - max value for bytscl of image
	skip - frames to skip between those displayed (default=0)
	magnify - magnification factor ( note that bigger movies are slower)
	InitPath - Initial Path of Fast Camera data
	rate - initial display rate
	verbose - if set, will print info as it progresses
	charThick - 
	charsize -  
	debug -  
	mds - if set, look for data in MDS plus (little there as of Jul/04)
 OUTPUTS:
       none

 LIMITATIONS:
  	as of 29-Jul-2004, FC data just available on NSTX Petrels,
	the VMS cluster.
       MPEG movies created from widget are poor.
 EXAMPLE:
	IDL> fctiffsvcr,shot=113723,minms=140,maxms=170
	IDL> fctiffsvcr, frame1=1000, skip=5, maxframes=100, $
		files='/p/camdata/dust/120325_TIFF/*.tif', mag=3, /debug

 MODIFICATION HISTORY:
      29-Jul-2004 Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/fctiffsvcr.pro)


FCVCR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 	fcvcr

 PURPOSE:
       Plot Fast Camera images with a VCR-like interface

 CATEGORY:
       Animation, Fast Camera

 CALLING SEQUENCE:

   to get an animation with a maximum of 40 frames (spaced with time selection):
	IDL> fcvcr, 128030, time=[0.05,0.317], max=40

   to see what shots have fast camera data in the tree:
 	IDL> MDSnodeChanges,'\fc3d', shot1=119120, shot2=119330, tree='cameras'
 INPUTS:
       shot = nstx shot number  

 KEYWORD PARAMETERS:
    Keywords:
	ndups - number of times each frame of movie is duplicated (default=0)
	time - 2-element array for animation; single value for one frame
	animate - if set to 0, will plot individual frames instead of movie.
	maxFrames - max # of frames over time range -- necessary if X-memory
		    is limited (default is 200).
	pixMap - if set, will not send each frame to the screen (faster)
 OUTPUTS:
       calls XIA, from which you can save pictures of frames, or an mpeg file
 LIMITATIONS:
 NOTES:
 MODIFICATION HISTORY:
	28-Mar-2008 written by Bill Davis

(See src/idl_cvs/./src/idl_cvs/fcvcr.pro)


MK_MPEG

[Previous Routine] [Next Routine] [List of Routines]
 NAME: 
    mk_mpeg

 PURPOSE: 
    Write a sequence of images from a 3-D array, or a series of tiff
    files, as an mpeg movie.

 CATEGORY: 
    animation

 CALLING SEQUENCE:
    mk_mpeg, 'movie.mpg' ,ims
	or
    mk_mpeg, 'movie.mpg', files=files

 INPUTS:
     ims: sequence of images as a 3D array with dimensions [sx, sy, nims]
          where sx = xsize of images
                sy = ysize of images
                nims = number of images

 OPTIONAL INPUTS:

 KEYWORD PARAMETERS:
	delafter:  if set delete temporary array after movie was created
                you should actually always do it otherwise you get
                problems with permissions on multiuser machines (since
                /tmp normally has the sticky bit set)
	rep:     if given means repeat every image 'rep' times
                (as a workaround to modify replay speed). i.e., if = 2, make 2 copies of
		 each frame.
	files:   file list. If just one value, needs to include a wild card
	justone: just plot D-alpha
	despeckle : if set call despeckle routine (slow, but less "intrusive" than median)
 OUTPUTS: None

 OPTIONAL OUTPUTS:

 COMMON BLOCKS:

 SIDE EFFECTS:
	creates some files in TMPDIR which are only removed when
	the delafter keyword is used

 RESTRICTIONS:
	depends on the program mpeg_encode from University of
	California, Berkeley, which must be installed in /usr/local/bin

 PROCEDURE:
	writes a parameter file based on the dimensions of the image
	array + the sequence of images in ppm format into a
	temporary directory; finally spawns mpeg_encode to build the
	movie

 EXAMPLE:
 	IDL> shot = 111840
 	IDL> f = findfile( '/p/nstxusr2/divcam/'+strtrim(shot,2)+'/*.tif')
 	IDL> mk_mpeg, strtrim(shot,2)+'_divcam'+'.mpg',files=f,shot=shot,/fliphoriz

 LIMITATIONS:
	mpeg_encode must be in your path (not currently on PPPL Linux)

 MODIFICATION HISTORY:
	22-Apr-04 lots of kludges to make nice movies of camera data
		  from Hiroshima University on NSTX. [BD]
	29-Apr-02 Modified write_mpeg to accept a filelist or wildcard spec [BD].
	Mon Nov 18 13:13:53 1996, Christian Soeller
	

	grabbed original from the net and made slight modifications

(See src/idl_cvs/./src/idl_cvs/mk_mpeg.pro)


MPEG_FROM_SCREEN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 	mpeg_from_screen

 PURPOSE:
       Example of creating a color Mpeg animation with text overlayed.
	Works on both 8-bit and 24-bit monitors. Can read from files, but those
	returning 24-bit data will not have the text overlaying option.

 CATEGORY:
       Animation

 CALLING SEQUENCE:
	IDL> mpeg_from_screen
    or
	IDL> mpeg_from_screen, data3d=data3D, mpeg_filename='mymovie.mpg'
    or
	IDL> mpeg_from_screen, ndups=5,  $
		files=['out1.jpg','out2.jpg','out3.jpg','out4.jpg','out5.jpg']
 INPUTS:
       none required 

 KEYWORD PARAMETERS:
    All optional inputs:
	data3D - optional 3-D array ( nx, ny, nFrames )
	nFrames - # of frames when using dummy data.
	files - a string array of filenames. 
		Can be of type 'jpg','tif','tif','bmp','jpeg,'png', or 'gif'
	mpeg_filename - output filename for mpeg movie
	ndups - number of times each frame of movie is duplicated (default=3)
	showFrame - if =0, will not show frame around image (irrelevant for rgb files)
	useScreen - if=0, don't bother using screen for output (i.e., no text to overlay)
			(irrelevant for rgb files)
	border - # of pixels around data (default=25)
	ctb - color table to use (default=39)
	charsize - character size (default=1.5)
	charthick - character thickness (default=2)
	pixMap - if = 0, will write and read each frame from screen (much slower)

 OUTPUTS:
       mpeg file

 MODIFICATION HISTORY:
	20-Oct-2004 Optionally operate off a list of files
	15-Oct-2004 Written by Bill Davis

(See src/idl_cvs/./src/idl_cvs/mpeg_from_screen.pro)


MPTSCAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       mptscam
 PURPOSE:
	Animate several plots, including MPTS variables
 CATEGORY:
	Animation, MPTS
 CALLING SEQUENCE:
       IDL>   mptscam, shot, xSize=xSize, ySize=ySize, sideSigs=sideSigs, $
              MAX_COLORS_TO_USE = max_colors_to_use, 	$
              noSides=noSides, colortable=colortable, $
	      mpegFile=mpegFile, rf=rf, nb=nb, pixMap=pixMap, $
	      gaps=gaps
 INPUTS:
	shot - NSTX shot # to display
 KEYWORD PARAMETERS:
    Optional Inputs:
	...
 OUTPUTS:
       can create mpegs
 EXAMPLE: for output example, see 
	http://nstx.pppl.gov/nstx/Software/Diagnostics/MPTS/mptsdata.html
 NOTES:
	This routine has not been tested for many combinations of signals

   To get frames from the fastcam PC, contact Bill Davis
 MODIFICATION HISTORY:
  	16-Nov-01 Fine tuned for xsize=600, ysize=400 (for publication)
        Written by Bill Davis

(See src/idl_cvs/./src/idl_cvs/mptscam.pro)


WRITE_MPEG

[Previous Routine] [Next Routine] [List of Routines]
+
 NAME: 
        WRITE_MPEG

 PURPOSE: 
        Write a sequence of images as an mpeg movie

 CATEGORY: 
	animation

 CALLING SEQUENCE:
        WRITE_MPEG,'movie.mpg',ims

 INPUTS:
     ims: sequence of images as a 3D array with dimensions [sx, sy, nims]
 	   where sx = xsize of images
 		 sy = ysize of images
 		 nims = number of images

 OPTIONAL INPUTS:

 KEYWORD PARAMETERS:
     delaft:   if set delete temporary array after movie was created
               you should actually always do it otherwise you get
               problems with permissions on multiuser machines (since
               /tmp normally has the sticky bit set)
     rep:      if given means repeat every image 'rep' times
               (as a workaround to modify replay speed)

 OUTPUTS: None
 OPTIONAL OUTPUTS:

 COMMON BLOCKS:

 SIDE EFFECTS:
      creates some files in TMPDIR which are only removed when
      the DELAFT keyword is used

 RESTRICTIONS:
     depends on the program mpeg_encode from University of
     California, Berkeley, which must be installed in /usr/local/bin

 PROCEDURE:
     writes a parameter file based on the dimensions of the image
     array + the sequence of images in ppm format into a
     temporary directory; finally spawns mpeg_encode to build the
     movie

 EXAMPLE:
    IDL> s=openmdsshot('efit',112800)
    IDL> data3d=mdsvalue('\efit01::psirz')
    IDL> write_mpeg, 'efit_112800.mpg', bytscl(congrid(data3d,65*8,65*8,128))
  or 
    IDL>write_mpeg,'test.mpg',reform([[dist(100)],[dist(100)],[dist(100)]],100,100,3)

 MODIFICATION HISTORY:
     15-Jul-04 warn if file not 3d [BD]
     Mon Nov 18 13:13:53 1996, Christian Soeller
     

     grabbed original from the net and made slight modifications

(See src/idl_cvs/./src/idl_cvs/write_mpeg.pro)


XEASYANIM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
 	XeasyAnim 

 PURPOSE:
       animate 3-D array and optionally make MPEG Movie

 CATEGORY:
       Animation, MPEG

 KEYWORDS:
	nreps - number of frames to repeat when creating mpeg (1 means no dups)
	xSize - 
	ySize - 
	rate -            
	MAX_COLORS_TO_USE  - 
	magnification - 
	xpos - 
	ypos - 
	colortable - color table for movie
	ctbFile - color table file (for personal color tables)
	noLoad - if set, do not load any color table 
	SCALEEACHFRAME - 
	bottom -  if set, then position window at bottom of screen
	despeckle - 
	XWIN - 
	YWIN - 
	STDEV_MULT
	ctbfile - color table file (for personal color tables)
 EXAMPLE:
	IDL> Array3D_In = REFORM(DIST(600,200),200,200,3)
	IDL> XEasyAnim, Array3D_In,  /bottom

    you may wish to the following:

	IDL> dum=MK_COLOR(N_NONFIXED=ncolors)
	IDL> Array3D = BYTSCL( Array3D, TOP=ncolors )
	IDL> XEasyAnim, Array3D
 Modifications:
	12-May-2008 added noLoad and ctbFile keywords
	02-Aug-2007 add gamma keyword [BD]
	02-May-06 added nreps keyword
	14-Apr-06 added xpos & ypos keywords
	06-Mar-02 Added printing, resizing of array, added despeckling [BD]

(See src/idl_cvs/./src/idl_cvs/xeasyanim.pro)


XIA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
		XIA

 PURPOSE:
	Display an animated sequence of images using X-windows Pixmaps.
	The speed and direction of the display can be adjusted using 
	the widget interface.

 CATEGORY:
	Animation, Image display, widgets.

 CALLING SEQUENCE:
	To initialize:
		XIA, SET = [Sizex, Sizey, Nframes]

	To load a single image:
		XIA, IMAGE = Image, FRAME = Frame_Index

	To load a single image that is already displayed in an existing window:
		XIA, FRAME = Frame_index, $
			WINDOW = [Window_Number [, X0, Y0, Sx, Sy]]
	(This technique is much faster than reading back from the window.)

	To display the animation after all the images have been loaded:
		XIA [, Rate] 

	To close and deallocate the pixmap/buffer (which also takes place
	automatically when the user presses the "Done With Animation"
	button or closes the window with the window manager):
		XIA, /CLOSE

 OPTIONAL INPUTS:
	Rate:	A value between 0 and 100 that represents the speed of the 
		animation as a percentage of the maximum display rate.
		The fastest animation is with a value of 100 and the slowest
		is with a value of 0.  The default animation rate is 100.  
		The animation must be initialized using the SET
		keyword before calling XIA with a rate value.

 KEYWORD PARAMETERS:
	BOTTOM: If set, window will be at bottom of screen or parent window
	CLOSE:	Set this keyword to delete the offscreen pixwins and Widget, 
		freeing storage.

	CYCLE: If set, cycle.  Normally, frames are displayed going either
		forward or backwards.  If CYCLE is set, reverse direction
		after the last frame in either direction is displayed.
		Provide this keyword with the SET keyword.

	FRAME:	The frame number when loading frames.  This keyword only has
		an effect when used in conjunction with the SET keyword.
		FRAME must be set to a number in the range 0 to Nframes-1.

	GROUP:	The widget ID of the widget that calls XIA.  When 
		this ID is specified, the death of the caller results in the 
		death of XIA.

	IMAGE:	A single image to be loaded at the animation position given 
		by FRAME.  The keyword parameter FRAME must also be specified.

	KEEP_PIXMAPS: If TRUE, XIA doesn't destroy the animation
		pixmaps when it is killed. Calling it again without
		going through the SET and LOAD steps will cause the same
		animation to play without the overhead of creating
		the pixmaps.
	BLOCK:  Set this keyword to have XMANAGER block when this
		application is registered.  By default the Xmanager
               keyword NO_BLOCK is set to 1 to provide access to the
               command line if active command 	line processing is available.
               Note that setting BLOCK for this application will cause
		all widget applications to block, not only this
		application.  For more information see the NO_BLOCK keyword
		to XMANAGER.
	ORDER:	Set this keyword to display images from the top down instead
		of the default bottom up.  This keyword is only used when 
		loading images.
       MODAL:  If set, then XIA runs in "modal" mode, meaning that
               all other widgets are blocked until the user quits
               XIA.
       MPEG_OPEN: Set this keyword to open an MPEG file.
       MPEG_FILENAME: Set this keyword equal to a string for the desired
               MPEG filename.  If not set, idl.mpg is used.
       MPEG_CLOSE: Set this keyword to write the MPEG file.
	NREPS - number of frames to repeat when creating mpeg (1 means no dups)
       SHOWLOAD:	Set this keyword (in conjunction with the SET keyword) to 
		display each frame and update the frame slider as frames are 
		loaded.

	SET:	This keyword initializes XIA.  SET should be equated
		to a 3-element integer vector containing the following 
		parameters:
		  Sizex, Sizey:	The width and height of the images to be 
				displayed, in pixels.

		  Nframes:	The number of frames in the animated sequence 
				(since XIA is an animation routine, 
				Nframes must be at least 2 frames).

	TITLE:	A string to be used as the title of the widget.  If this 
		keyword is not specified, the title is set to "XIA" 
		This keyword has an effect only when used in conjunction with
		the SET keyword).

	TRACK: If set, the frame slider tracks the current frame.  Default
		is not to track.  Provide this keyword with the SET keyword.

	WINDOW:	When this keyword is specified, an image is copied from an 
		existing window to the animation pixmap.  When using X 
		windows, this technique is much faster than reading
		from the display and then calling XIA with a 2D 
		array.

		The value of this parameter is either an IDL window
		number (in which case the entire window is copied),
		or a vector containing the window index and the rectangular 
		bounds of the area to be copied, for example:
		WINDOW = [Window_Number, X0, Y0, Sx, Sy]

      XOFFSET:	The horizontal offset, in pixels from the left of the frame, 
		of the image in the destination window.

      YOFFSET:	The vertical offset, in pixels from the bottom of the frame,
		of the image in the destination window.

 OUTPUTS:
	No explicit outputs.

 COMMON BLOCKS:
	XIA_COM: a private common block.

 SIDE EFFECTS:
	A pixmap and widget are created.

 RESTRICTIONS:
	Only a single copy of XIA can run at a time.

 PROCEDURE:
	When initialized, this procedure creates an approximately square
	pixmap or memory buffer, large enough to contain Nframes of
	the requested size.  Once the images are loaded, using the 
	IMAGE and FRAME keywords, they are displayed by copying the images 
	from the pixmap or buffer to the visible draw widget.

 EXAMPLE:
	Enter the following commands to open the file ABNORM.DAT (a series
	of images of a human heart) and animate the images it contains using
	XIA.  For a more detailed example of using XIA, 
	see the example in the "Using IDL Widgets" chapter of "IDL Basics".
	Read the images into the variable H by entering:

		OPENR, 1, FILEPATH('abnorm.dat', SUBDIR = 'examples/data')
		H = BYTARR(64, 64, 16)
		READU, 1, H
		CLOSE, 1
		H = REBIN(H, 128, 128, 16)

	Initailize XIA with the command:

		XIA, SET=[128, 128, 16], /SHOWLOAD
		
	Load the images into XIA and play the animation by entering:

		FOR I=0,15 DO XIA, FRAME = I, IMAGE = H[*,*,I]
		XIA

 MODIFICATION HISTORY:
	02-May-06 added nreps keyword
	14-Apr-06 added xpos & ypos, bottom & right keywords
	02-Aug-01 modified XInterAnimate to have printing [Bill Davis]

(See src/idl_cvs/./src/idl_cvs/xia.pro)


XYANIM

[Previous Routine] [List of Routines]
 NAME:
       xyanim
 PURPOSE:
	Animate a series of X-Y plots.
       Makes an animation in a XINTERANIMATE window. An MPEG file
	can then be saved, or the movie can be played with VCR-like 
	controls
 CATEGORY:
       Animation
 CALLING SEQUENCE:
       IDL> xyanim, Radii, YvsT, times, xSize=xSize, ySize=ySize
 INPUTS:
       Radii - 1-D array of Radii (for example)
       YvsT  - 2-D array of Independent axis vs. time
	times - times for which an x-y plot will be made (defaults to 1/frame)
 KEYWORD PARAMETERS:
       Keywords:
	  xSize - x size of resulting output frame (default=400)
	  ySize - y size of resulting output frame (default=xSize)
 OUTPUTS:
       just the XinterAnimate window. MPEGs can be made from that widget.
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	See /u/bdavis/cvs/idl_cvs/testxyanim.pro 
 MODIFICATION HISTORY:
       12-Jun-01 Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/xyanim.pro)


Category: Bits

[List of Routines]


BITS

[Next Routine] [List of Routines]
 NAME:
       bits
 PURPOSE:
       Given a byte or integer, return a vector of 8 or 16 values
       which are the binary representation of the value.
 CATEGORY:
       bits, hardware
 INPUT:
       invalue - The byte or integer value to check
 OUTPUT:
       bitarr  - The 8-element array with values set
                 if the bit is set
 EXAMPLE:
	IDL> BITS, invalue, BITARR
 HISTORY:
       Written 1988 by M.Morrison
       13-Nov-92 (MDM) - Modified to allow integer*2 values
                         and to allow an array of values.
        7-Apr-94 (MDM) - Allow integer*4 values
       15-Aug-94 (MDM) - Corrected error from 7-Apr-94 mod which
                         did not allow an array of inputs

(See src/idl_cvs/./src/idl_cvs/bits.pro)


BTEST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    BTEST       

 PURPOSE:
    To test bit N in FIX(X)

 CATEGORY:
    Bits, Hardware

 CALLING SEQUENCE:
    YesNo = btest( X, N )

 PARAMETERS:  
    Inputs:
    	X      (REQ) (I) (0 1) (I  F)
           	X is the variable to be tested
   
    	N      (REQ) (I) (0) (I)
           	The bit of X to be tested
     Returned:
    	YESNO  (REQ) (O) (0 1) (I)
           	The result of the test. 1(true) if bit N is set, 0(false)
           	otherwise.

 EXAMPLES:

        YESNO = btest( !X.STYLE, 4 )
        IF YESNO THEN PRINT,'X-axis suppressed' $
                 ELSE PRINT,'Draw X-axis'

        To find points in NEWSIPS which are outside calibrated region:
        YESNO = btest( ABS(NU),1 )             ; look for nu flag = -2
        IND = WHERE (YESNO EQ 0)            ; keep points where yesno = 0
        PLOT,W(IND),F(IND)                  ; plot calibrated points
        
 NOTES:

     Note that negative integers are stored in twos complement form.
     Therefore, the left-most bits are ON rather than OFF as they are for 
     positive numbers. Input the absolute value of X is negative numbers 
     to avoid this problem. 

     This procedure can be used to check the values of complex
     IDL system variables such as ![XYZ].STYLE.

 PROCEDURE:

     Checks whether (FIX(X) OR (NOT 2^N)) = -1 to set the output
     flag YESNO.

 MODIFICATION HISTORY:
	26-Oct-99 Convert from btest to make a function (like FORTRAN)
     Mar  6 1983 RJP GSFC initial program
     Aug 24 1987 RWT GSFC add PARCHECK
     Mar  7 1988 CAG GSFC all VAX RDAF-style prolog
     Jul 13 1990 RWT GSFC Sun mods: use examples pertinent to SUN IDL
                 and add listing of procedure call statement
     Jun 19 1991 PJL GSFC cleaned up; tested on SUN and VAX; updated prolog
     Mar  8 1993 RWT GSFC modify to allow X & YESNO to be vectors and 
                 add documentation about negative numbers.

(See src/idl_cvs/./src/idl_cvs/btest.pro)


DECODE_GRAY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DECODE_GRAY
 PURPOSE:
  	Convert a gray-code value to an integer
 CATEGORY:
       Bits, CAMAC, Hardware, Stepper Motor Control
 CALLING SEQUENCE:
       IDL> int = DECODE_GRAY(grayCode)
 INPUTS:
       grayCode = number in gray code.  
 KEYWORD PARAMETERS:
     Optional Input:
	  NBits - # of bits to decode; defaults to 8
 OUTPUTS:
       int = returned integer                 			out
 COMMON BLOCKS:
       NONE
 EXAMPLES:
	IDL> print,DECODE_GRAY(1)
	       1
	IDL> print,DECODE_GRAY(2)
	       3
	IDL> print,DECODE_GRAY(255)
	     170
	IDL> print,DECODE_GRAY(255+512)
	     170
	IDL> print,DECODE_GRAY(255+512,nbits=16)
	     853
 NOTES:
	This can probably be sped up considerably.
 MODIFICATION HISTORY:
       26-Oct-99 Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/decode_gray.pro)


MK_BITARRAY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       mk_bitarray
 PURPOSE:
       Create an array of 1's & 0's corresponding to input bits set
	(works for negative numbers, too, unlike similar routines)
 CATEGORY:
       Bits
 CALLING SEQUENCE:
       IDL> array= mk_bitarray( input )
       IDL> array= mk_bitarray( input, nbits=5 )
 INPUTS:
       input = whatever; might be something like !X.STYLE  
 KEYWORD PARAMETERS:
	NBITS=nbits - length of returned array (default to input type)
	PRINT - if set, will print bits in groups of fours.
 OUTPUTS:
       Byte array containing 1's and 0's               	out
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> print,mk_bitarray(3, nbits=8)
	   1   1   0   0   0   0   0   0
	IDL> dum = mk_bitarray( 1025, /print )'
	 1 0 0 0   0 0 0 0   0 0 1 0   0 0 0 0
 LIMITATION:
	Only works on a scalar.
 MODIFICATION HISTORY:
	05-Jun-00 default nbits to input type. add print keyword.
       30-Mar-99 Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/mk_bitarray.pro)


SHOWBITS

[Previous Routine] [List of Routines]
  NAME:
       showbits
  PURPOSE:
       Given a byte or integer, return a vector of 8 or 16 values
       which are the binary representation of the value.
  CATEGORY:             
	Bits, Hardware
  USAGE:
	bitarr = SHOWBITS( invalue, /print )
  INPUT:
       invalue - The byte or integer value to check
  OUTPUT:
       bitarr  - The 8-element array with values set
                 if the bit is set
  KEYWORDS:
    (Optional)
	NtoShow - # of bits to show
  HISTORY:
	29-Oct-99 Converted to Function by Bill Davis, ntoshow added
       Written 1988 by M.Morrison
       13-Nov-92 (MDM) - Modified to allow integer*2 values
                         and to allow an array of values.
        7-Apr-94 (MDM) - Allow integer*4 values
       15-Aug-94 (MDM) - Corrected error from 7-Apr-94 mod which
                         did not allow an array of inputs
  LIMITATIONS:
	Only works for non-negative, fixed-point numbers

(See src/idl_cvs/./src/idl_cvs/showbits.pro)


Category: Colors

[List of Routines]


BETTERRAINBOW

[Next Routine] [List of Routines]
 NAME:
       betterrainbow
 PURPOSE:
       Loads a rainbow color palette with 6 evenly-spaced (roughly) colors
 CATEGORY:
      Colors,  Graphics
 CALLING SEQUENCE:
       IDL> betterrainbow
 INPUTS:
       NONE  
 KEYWORD PARAMETERS:
    Optional Keywords:
	BAR - if set, will draw a color bar on plot
	nColors - # of colors to load (Defaults to !D.TABLE_SIZE)
	lessRed - if set, rainbow will have a smaller red region
	WhiteBottom - if set, there will be a white region at the bottom
	topColor - can be an index or 'white' or 'black'
	botColor - can be an index or 'white' or 'black'
	linePlots - if set, top color will be black and bottom color will be white
	noYellow - if set, don't have yellow (because doesn't show up well on white)
 OUTPUTS:
       NONE (color table changed)
 LIMITATIONS:
	always starts at the bottom of color palette.
 MODIFICATION HISTORY:
	18-Jun-2008 added NoYellow keyword
	02-Aug-2007 fix bug for /lineplot and ncolors<256; 
		    if /linePlots keyword set, reset !p.color & !p.background
	30-Apr-2007 added linePlots keyword
	26-May-2006 added ncolors and whiteBottom keywords
	14-Feb-2005 add topColor and botColor keywords
       15-Jul-02 Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/betterrainbow.pro)


COLORBAR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	COLORBAR

 PURPOSE:
       The purpose of this routine is to add a color bar to the current
       graphics window.

 CATEGORY:
      Colors,  Graphics

 CALLING SEQUENCE:
       COLORBAR

 INPUTS:
       None.

 KEYWORD PARAMETERS:
       BOTTOM:       The lowest color index of the colors to be loaded in
                     the bar.
       CHARSIZE:     The character size of the color bar annotations. Default is 1.0.
       COLOR:        The color index of the bar outline and characters. Default
                     is !P.Color..
       DIVISIONS:     The number of divisions to divide the bar into. There will
                     be (divisions + 1) annotations. The default is 6.
       FONT:         Sets the font of the annotation. Hershey: -1, Hardware:0, True-Type: 1.
       FORMAT:       The format of the bar annotations. Default is '(I5)'.
       INVERTCOLORS: Setting this keyword inverts the colors in the color bar.
       MAXRANGE:     The maximum data value for the bar annotation. Default is
                     NCOLORS.
       MINRANGE:     The minimum data value for the bar annotation. Default is 0.
       MINOR:        The number of minor tick divisions. Default is 2.
       NCOLORS:      This is the number of colors in the color bar.
       POSITION:     A four-element array of normalized coordinates in the same
                     form as the POSITION keyword on a plot. Default is
                     [0.88, 0.10, 0.95, 0.90] for a vertical bar and
                     [0.10, 0.88, 0.90, 0.95] for a horizontal bar.
       RANGE:        A two-element vector of the form [min, max]. Provides an
                     alternative way of setting the MINRANGE and MAXRANGE keywords.
       RIGHT:        This puts the labels on the right-hand side of a vertical
                     color bar. It applies only to vertical color bars.
       TICKNAMES:    A string array of names or values for the tick marks.
       TITLE:        This is title for the color bar. The default is to have
                     no title.
       TOP:          This puts the labels on top of the bar rather than under it.
                     The keyword only applies if a horizontal color bar is rendered.
       VERTICAL:     Setting this keyword give a vertical color bar. The default
                     is a horizontal color bar.

 COMMON BLOCKS:
       None.

 SIDE EFFECTS:
       Color bar is drawn in the current graphics window.

 RESTRICTIONS:
       The number of colors available on the display device (not the
       PostScript device) is used unless the NCOLORS keyword is used.

 EXAMPLE:
       To display a horizontal color bar above a contour plot, type:

       LOADCT, 5, NCOLORS=100
       CONTOUR, DIST(31,41), POSITION=[0.15, 0.15, 0.95, 0.75], $
          C_COLORS=INDGEN(25)*4, NLEVELS=25
       COLORBAR, NCOLORS=100, POSITION=[0.15, 0.85, 0.95, 0.90]

 MODIFICATION HISTORY:

       Written by: David W. Fanning, 10 JUNE 96.
       [...]
       3/18/00. Moved a block of code to prevent a problem with color decomposition. DWF.
       4/28/00. Made !P.Font default value for FONT keyword. DWF.
       9/26/00. Made the code more general for scalable pixel devices. DWF.
       1/16/01. Added INVERTCOLORS keyword. DWF.
       5/11/04. Added TICKNAME keyword. DWF.
 AUTHOR:

   FANNING SOFTWARE CONSULTING
   David Fanning, Ph.D.
   1645 Sheely Drive
   Fort Collins, CO 80526 USA
   Phone: 970-221-0438
   E-mail: davidf@dfanning.com
   Coyote's Guide to IDL Programming: http://www.dfanning.com/

(See src/idl_cvs/./src/idl_cvs/colorbar.pro)


COLORSEARCH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       colorSearch

 PURPOSE:
       Return color index (or closest available) from the color name.

 CATEGORY:
      Colors,  Graphics

 CALLING SEQUENCE:
	index = colorSearch( colorName )

 INPUT:
       colorName: A string with the name of the color. 'WHITE','BLACK','YELLOW',
		'RED','GREEN','BLUE','MAGENTA','YELLOW','ORANGE', 'PURPLE', 
		'DARKGREEN','LTBLUE', or 'GREY'

       (colorName is NOT case sensitive)

	Synonyms are handled as follows:
         'GREY' = 'GRAY'
         'DARKGRAY' = 'GRAY'
         'CHARCOAL' = 'GRAY'
         'AQUAMARINE' = 'GREEN'
         'SKYBLUE' = 'LTBLUE'
         'LT_BLUE' = 'LTBLUE'
         'CYAN' = 'LTBLUE'
         'DKBLUE' = 'BLUE'
         'DARKBLUE' = 'BLUE'
         'DK_BLUE' = 'BLUE'
         'VIOLET' = 'MAGENTA'

    or, if colorName = 
          'FOREGROUND' then simply return, !p.color
          'BACKGROUND' then simply return, !p.background

 KEYWORD PARAMETERS:
	INIT - if set, will load color table 39 (rainbow with Black and white),
	       and !p.color will be set to black, and !p.background to white.
	       *** NOTE that the SET_PLOT command can change !p.color and !p.background.
 	debug - if set, will print informational messages
	quiet - if set, will not warn if color found is not close to that asked for
	status - if = 1, then color was found, else 0

 RESTRICTIONS:
	If match is not found it will return the index of the "closest" table location, and
	status=0, and, if /quiet is not set, it will print a warning.
	

       Note that the SET_PLOT command (from IDL Help):
          "sets the default color !P.COLOR to the maximum color index minus one or, 
	    in the case of devices with white backgrounds, such as PostScript, to 0 (black)."
	After calling SET_PLOT,'X' or SET_PLOT,'Z' you will have to re-call a=colorSearch( /init )
	to return to plotting black lines on a white background.
 EXAMPLES:
	plot, indgen(10), color=colorSearch( /init )
	oplot, indgen(10)/2, color=colorSearch('red')
 
 MODIFICATION HISTORY:
	26-Jan-2007 Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/colorsearch.pro)


MK_COLOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       mk_color

 PURPOSE:
       Create color tables with 12 fixed colors at the top. These colors
	can be referenced by name.

 CATEGORY:
      Colors,  Graphics

 CALLING SEQUENCE:
	index = mk_color( color )
	index = mk_color( color, TABLE=5, MAX_COLORS_TO_USE = 128 )
 OPTIONAL INPUTS:
       COLOR: A string with the name of the color. 'WHITE','BLACK','YELLOW',
                 'RED','GREEN','BLUE','MAGENTA','LTBLUE', and (if device
		   supports more than 8 colors) 'GREY' are allowed.
	       Alternately, COLOR may be an integer from 0 - 8.
              If the COLOR input is anything else, or not present, an index
	          for yellow is returned.
 KEYWORD PARAMETERS:
	LOAD:	If set, return a structure containing all 8 colors.
		e.g. IDL> c=MK_COLOR(/load)
		     IDL> plot,x,y,color=c.red
       MAX_COLORS_TO_USE: The maximum number of colors to use for all of
		IDL . The default
		is 64 so IDL doesn't grab all the colors on a 256-color
		monitor. If an IDL window, or a call to LOADCT, was made
		before the first call to mk_color, the number of colors
	        will already have been allocated.
	TABLE: The number of the pre-defined color table to load, from 0 to 40.
	       The same as for LOADCT. The default is 0.
	FILE:  If present, will load color table from this file.
	        These colors will be squeezed into the number of
		colors used for the palette (N_NONFIXED colors).
	N_NONFIXED (returned) number of colors other than the nine fixed ones.
		e.g., MAX_COLORS_TO_USE-12.
	SILENT: If this keyword is set, the Color Table message is suppressed.
	SEARCH - if set, will do a least squares fit to color table to find
		 closest index to color -- good if color table was set outside
	  	 of mk_color
	GAcolors - if set create a color table with colors beginning at zero, 
		   in the same order as GA color_setup routine.
 COMMON BLOCKS:
       mk_color_local

 SIDE EFFECTS:
       Limits the maximum number of colors for this IDL session.
	(The default is 64 colors).
 RESTRICTIONS:
	Reserving the right number of colors only works if this is called
	before any IDL window is drawn, and before LOADCT is called.

	Good Luck if you try and run with 24-bit color.

	If a device allows less than 12 colors (like Tek), the colors beyond
	the number allowed will not be available.
 EXAMPLES:
    Simply:
	plot,indgen(100),color=mk_color('red'),background=mk_color('white')
    or:
	plot,[0,1],[0,10]-1
	for i=0,8 do oplot,[i,i],color=mk_color(i)	; to see all colors
    x-y overlays:
	PLOT,INDGEN(100),/NODATA, COLOR=MK_COLOR('blue')	; axes in blue
	PLOT,INDGEN(100), COLOR=MK_COLOR('red')			; data in red
	OPLOT,INDGEN(100)/2, COLOR=MK_COLOR('yellow')		; overlay yellow

    Using color contours AND x-y plots:
	array_2D = DIST(150)	; generate a test array
	yellow_index = mk_color( TABLE=5, MAX_COLORS_TO_USE = 128, $
		N_NONFIXED = n_nonfixed)
	WINDOW,  XSIZE=400, YSIZE=250				; make wide window
	TV, BYTSCL( array_2D, TOP = n_nonfixed-1 ), 25, 50  	; plot scaled 2-D image
	PLOT, HISTOGRAM(array_2D), COLOR=mk_color('LtBlue'),  $	; lt. blue axes
	   POSITION=[0.55, 0.15, 0.95, 0.95], /NOERASE, /NODATA
	OPLOT, HISTOGRAM(array_2D) > 10, COLOR=mk_color('Magenta')	; data in magenta
	whatever = mk_color(TABLE=39)	; change colors of contours, but not lines
 NOTES:
	Tek Colors are 0=black, 1=white, 2=red, 3=green, 4=blue,
		5=cyan, 6=magenta, 7=yellow, 8=orange.
 MODIFICATION HISTORY:
	24-May-04   moved creation of X-window when Z-buffer the device
		    (necessary when mk_color first called with PS or Z.)
	22-Apr-2004 fixed bug when Z-buffer set on first call.
	14-Nov-03 - fixed new bug for Tek colors.
	13-Mar-03 - if requested color not found, try to find black (instead of yellow)
		    if ask for 'FOREGROUND' or 'BACKGROUND' return !p values.
		    GAcolor Keyword for doing colors like GA (same order and position)
	20-Aug-02 - set !p.color & !p.background to previous colors (closest
		    r,g,b value), when called the first time, or when changing
		    color tables.  Add FILE keyword
	07-Mar-02 - Change !d.n_colors to !d.table_size
	08-May-01 - When in Tek, make !p.color=black (was going to index 15)
	23-Apr-01 - added three more colors (orange, purple, darkgreen)
	26-Jan-01 - limit structure returned to !d.n_colors (e.g., when=2).
	28-Sep-00 - Added bottom keyword (passes straight through to loadct)
	24-Jan-00 - If color found at multiple indices, return highest valid one
	02-Jan-00 - Both /LOAD and individual colors return valid indices in
		    24-bit mode.
	05-Oct-99 - BD Synonyms & Structure return as in new D. Fanning routine.
	09-Jun-99 - BD If desired color not found, return index of nearest color.
 	11-May-99 - BD make return valid values for 24-bit (decomposed) color
	28-Jan-99 - BD handle device with less than 9 colors.
	14-Dec-98 - BD allow COLOR input to be an integer from 0-8.
		        Return index of 0 when color not found in table.
	04-Dec-98 - Bill Davis changed GETCOLORS to load color table, return color
			index, etc.  Colors were added.
       GETCOLORS Written by: David Fanning, 10 February 96.

(See src/idl_cvs/./src/idl_cvs/mk_color.pro)


STRETCHSTEPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       stretchsteps

 PURPOSE:
       stretch parts of the color tables into steps.

 CATEGORY:
       Colors, Image processing

 CALLING SEQUENCE:
       stretchsteps, Low, High, steps=n [, /CHOP]

 INPUTS:
       Low:    The lowest pixel value to use.  If this parameter is omitted,
               0 is assumed.  Appropriate values range from 0 to the number 
               of available colors-1.

       High:   The highest pixel value to use.  If this parameter is omitted,
               the number of colors-1 is assumed.  Appropriate values range 
               from 0 to the number of available colors-1.

 OPTIONAL INPUTS:
       Gamma:  Gamma correction factor.  If this value is omitted, 1.0 is 
               assumed.  Gamma correction works by raising the color indices
               to the Gamma power, assuming they are scaled into the range 
               0 to 1.
       steps:  number of steps/colors of the resulting color table (default=16)
 KEYWORD PARAMETERS:
       CHOP:   If this keyword is set, color values above the upper threshold
               are set to color index 0.  Normally, values above the upper 
               threshold are set to the maximum color index.

 OUTPUTS:
       No explicit outputs.

 COMMON BLOCKS:
       COLORS: The common block that contains R, G, and B color
               tables loaded by LOADCT, HSV, HLS and others.

 SIDE EFFECTS:
       Image display color tables are loaded.

 RESTRICTIONS:
       Common block COLORS must be loaded before calling stretchsteps.

 PROCEDURE:
       New R, G, and B vectors are created by linearly interpolating
       the vectors in the common block from Low to High.  Vectors in the 
       common block are not changed.

       If NO parameters are supplied, the original color tables are
       restored.

 EXAMPLE:
       Load the STD GAMMA-II color table by entering:

               LOADCT, 5

       Create and display and image by entering:

               TVSCL, DIST(300)

       Now adjust the color table with stretchsteps.  Make the entire color table
       fit in the range 0 to 70 by entering:

               stretchsteps, 0, 70

       Notice that pixel values above 70 are now colored white.  Restore the
       original color table by entering:

               stretchsteps

 MODIFICATION HISTORY:
	26-May-2006 Fixed green & blue switch & get color table rather than
		relying on common block [BD]
	18-Dec-2002 Modified RSI STRETCH.PRO [BD]
       DMS, RSI, Dec, 1983.
       DMS, April, 1987.       Changed common.
       DMS, October, 1987.     For unix.
       DMS, RSI, Nov., 1990.   Added GAMMA parameter.

(See src/idl_cvs/./src/idl_cvs/stretchsteps.pro)


WHITEOUT

[Previous Routine] [List of Routines]
 NAME:
       whiteout
 PURPOSE:
 	white-out a portion of the color table 
	-- defaults to the 5 lowest locs.
 CATEGORY:
      Colors,  Graphics
 CALLING SEQUENCE:
       IDL> whiteout
 INPUTS:
       NONE  
 KEYWORD PARAMETERS:
    Optional Keywords:
	loc - index within color table to start whiting out (Default=0)
	nlocs - number of locations to whiteout (Default=5
 OUTPUTS:
       NONE (color table changed)
 LIMITATIONS:
	Reloading color table will undo this.
 MODIFICATION HISTORY:
	May-2006 Written by Bill Davis, PPPL

(See src/idl_cvs/./src/idl_cvs/whiteout.pro)


Category: Compound widgets

[List of Routines]


CW_BGROUP3_6

[Next Routine] [List of Routines]
 NAME:
	CW_BGROUP3_6

 PURPOSE:
	CW_BGROUP3_6 is a compound widget that simplifies creating
	a base of buttons. It handles the details of creating the
	proper base (standard, exclusive, or non-exclusive) and filling
	in the desired buttons. Events for the individual buttons are
	handled transparently, and a CW_BGROUP3_6 event returned. This
	event can return any one of the following:
		- The Index of the button within the base.
		- The widget ID of the button.
		- The name of the button.
		- An arbitrary value taken from an array of User values.

 CATEGORY:
	Compound widgets.

 CALLING SEQUENCE:
		Widget = CW_BGROUP3_6(Parent, Names)

	To get or set the value of a CW_BGROUP3_6, use the GET_VALUE and
	SET_VALUE keywords to WIDGET_CONTROL. The value of a CW_BGROUP3_6
	is:

		-----------------------------------------------
		Type		Value
		-----------------------------------------------
		normal		None
		exclusive   	Index of currently set button
		non-exclusive	Vector indicating the position
				of each button (1-set, 0-unset)
		-----------------------------------------------


 INPUTS:
       Parent:		The ID of the parent widget.
	Names:		A string array, containing one string per button,
			giving the name of each button.

 KEYWORD PARAMETERS:

	BUTTON_UVALUE:	An array of user values to be associated with
			each button and returned in the event structure.
	COLUMN:		Buttons will be arranged in the number of columns
			specified by this keyword.
	EVENT_FUNCT:	The name of an optional user-supplied event function 
			for buttons. This function is called with the return
			value structure whenever a button is pressed, and 
			follows the conventions for user-written event
			functions.
	EXCLUSIVE:	Buttons will be placed in an exclusive base, with
			only one button allowed to be selected at a time.
	FONT:		The name of the font to be used for the button
			titles. If this keyword is not specified, the default
			font is used.
	FRAME:		Specifies the width of the frame to be drawn around
			the base.
	IDS:		A named variable into which the button IDs will be
			stored, as a longword vector.
	LABEL_LEFT:	Creates a text label to the left of the buttons.
	LABEL_TOP:	Creates a text label above the buttons.
	MAP:		If set, the base will be mapped when the widget
			is realized (the default).
	NONEXCLUSIVE:	Buttons will be placed in an non-exclusive base.
			The buttons will be independent.
	NO_RELEASE:	If set, button release events will not be returned.
	RETURN_ID:	If set, the VALUE field of returned events will be
			the widget ID of the button.
	RETURN_INDEX:	If set, the VALUE field of returned events will be
			the zero-based index of the button within the base.
			THIS IS THE DEFAULT.
	RETURN_NAME:	If set, the VALUE field of returned events will be
			the name of the button within the base.
	ROW:		Buttons will be arranged in the number of rows
			specified by this keyword.
	SCROLL:		If set, the base will include scroll bars to allow
			viewing a large base through a smaller viewport.
	SET_VALUE:	The initial value of the buttons. This is equivalent
			to the later statement:

			WIDGET_CONTROL, widget, set_value=value

	SPACE:		The space, in pixels, to be left around the edges
			of a row or column major base. This keyword is
			ignored if EXCLUSIVE or NONEXCLUSIVE are specified.
	UVALUE:		The user value to be associated with the widget.
	XOFFSET:	The X offset of the widget relative to its parent.
	XPAD:		The horizontal space, in pixels, between children
			of a row or column major base. Ignored if EXCLUSIVE
			or NONEXCLUSIVE are specified.
	XSIZE:		The width of the base. 
	X_SCROLL_SIZE:	The width of the viewport if SCROLL is specified.
	YOFFSET:	The Y offset of the widget relative to its parent.
	YPAD:		The vertical space, in pixels, between children of
			a row or column major base. Ignored if EXCLUSIVE
			or NONEXCLUSIVE are specified.
	YSIZE:		The height of the base. 
	Y_SCROLL_SIZE:	The height of the viewport if SCROLL is specified.

 OUTPUTS:
       The ID of the created widget is returned.

 SIDE EFFECTS:
	This widget generates event structures with the following definition:

		event = { ID:0L, TOP:0L, HANDLER:0L, SELECT:0, VALUE:0 }

	The SELECT field is passed through from the button event. VALUE is
	either the INDEX, ID, NAME, or BUTTON_UVALUE of the button,
	depending on how the widget was created.

 RESTRICTIONS:
	Only buttons with textual names are handled by this widget.
	Bitmaps are not understood.

 MODIFICATION HISTORY:
	15 June 1992, AB
	7 April 1993, AB, Removed state caching.

(See src/idl_cvs/./src/idl_cvs/cw_bgroup3_6.pro)


CW_PDLIST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	CW_PDList

 PURPOSE:
	CW_PDList is a compound widget that simplifies creating
	pulldown menus. It has a simpler interface than the XPDMENU
	procedure, which it is intended to replace. Events for the
	individual buttons are handled transparently, and a CW_PDList
	event returned. This event can return any one of the following:
               - The Index of the button within the base.
               - The widget ID of the button.
               - The name of the button.
		- The fully qualified name of the button. This allows
		  different sub-menus to contain buttons with the same
		  name in an unambiguous way.


 CATEGORY:
	Compound widgets.

 CALLING SEQUENCE:
	widget = CW_PDList(Parent, Desc)

 INPUTS:
       Parent:	The ID of the parent widget.
	Desc:	An array of strings or structures.  Each element contains
		a menu description with two fields, a flag field, and
		the name of the item.  If a structure, each element
		is defined as follows:
			{ CW_PDList_S, flags:0, name:'' }

		The name tag gives the name of button. The flags
		field is a two-bit bitmask th