Source: src/idl_cvs/datatype.pro

 NAME:
       DATATYPE
 PURPOSE:
       Datatype of variable as a string (3 char or spelled out).
 CATEGORY:
	Programming
 CALLING SEQUENCE:
       typ = datatype(var, [flag])
 INPUTS:
       var = variable to examine.         in
       flag = output format flag (def=0). in
 KEYWORD PARAMETERS:
       Keywords:
         /DESCRIPTOR returns a descriptor for the given variable.
           If the variable is a scalar the value is returned as
           a string.  If it is an array a description is return
           just like the HELP command gives.  Ex:
           datatype(fltarr(2,3,5),/desc) gives
             FLTARR(2,3,5)  (flag always defaults to 3 for /DESC).
 OUTPUTS:
       typ = datatype string or number.   out
          flag=0    flag=1      flag=2    flag=3     flag=4
          UND       Undefined   0         UND	      UND
          BYT       Byte        1         BYT	      BIT(8)
          INT       Integer     2         INT	      SMALLINT
          LON       Long        3         LON	      INTEGER
          FLO       Float       4         FLT	      FLOAT
          DOU       Double      5         DBL	      Double
          COM       Complex     6         COMPLEX    COMPLEX
          STR       String      7         STR	      CHARACTER
          STC       Structure   8         STC	      STC
          DCO       DComplex    9         DCOMPLEX   DCOMPLEX
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
       Written by R. Sterner, 24 Oct, 1985.
       Johns Hopkins University Applied Physics Laboratory.
       RES 29 June, 1988 --- added spelled out TYPE.
       R. Sterner, 13 Dec 1990 --- Added strings and structures.
       R. Sterner, 19 Jun, 1991 --- Added format 3.
       R. Sterner, 18 Mar, 1993 --- Added /DESCRIPTOR.
       R. Sterner, 1995 Jul 24 --- Added DCOMPLEX for data type 9.
   23-Jun-2009 BD added Unit, Long54, Ulong64.
   28-FEB-2011 BD Added flag=4 for types used by SQL

 Copyright (C) 1985, Johns Hopkins University/Applied Physics Laboratory
 This software may be used, copied, or redistributed as long as it is not
 sold and this copyright notice is reproduced on each copy made.  This
 routine is provided as is without any express or implied warranties
 whatsoever.  Other limitations apply as described in the file disclaimer.txt.

Source: src/idl_cvs/date2jd.pro

 NAME:
       DATE2JD
 PURPOSE:
       Convert a date string to Julian Day number.
 CATEGORY:
	Dates
 CALLING SEQUENCE:
       jd = date2jd(date)
 INPUTS:
       date = date string, e.g., '6/17/1951', '1951/6/17', or 19510617    
 KEYWORD PARAMETERS:
 OUTPUTS:
       jd = Returned Julian Day number.   out
 COMMON BLOCKS:
 NOTES:
       Note: date must contain month as a name of 3 or more leeters.
 MODIFICATION HISTORY:
	18-Aug-2009 return 0 if date blank
	12-Feb-2008 handle input date of form 19510617 (yyymmdd)
	27-Nov-2006 Handle date of form 2006/4/28 [Bill Davis, PPPL]
       R. Sterner, 1996 Sep 15

 Copyright (C) 1996, Johns Hopkins University/Applied Physics Laboratory
 This software may be used, copied, or redistributed as long as it is not
 sold and this copyright notice is reproduced on each copy made.  This
 routine is provided as is without any express or implied warranties
 whatsoever.  Other limitations apply as described in the file disclaimer.txt.

Source: src/idl_cvs/date2ymd.pro

 NAME:
       DATE2YMD
 PURPOSE:
       Date text string to the numbers year, month, day.
 CATEGORY:
	Dates
 CALLING SEQUENCE:
       date2ymd,date,y,m,d, dateString=dateString
 INPUTS:
       date = date string.             in
 KEYWORD PARAMETERS:
	dateString - (OPTIONAL OUTPUT) of form yyyymmdd (e.g., 20030613)
 OUTPUTS:
       y = year number.                out
       m = month number.               out
       d = day number.         out
 COMMON BLOCKS:
 NOTES:
       Notes: The format of the date is flexible except that the
         month must be month name.
         Dashes, commas, periods, or slashes are allowed.
         Some examples: 23 sep, 1985     sep 23 1985   1985 Sep 23
         23/SEP/85   23-SEP-1985   85-SEP-23   23 September, 1985.
         Doesn't check if month day is valid. Doesn't
         change year number (like 86 does not change to 1986).
         Dates may have only 2 numeric values, year and day. If
         both year & day values are < 31 then day is assumed first.
         systime() can be handled: date2ymd,systime(),y,m,d
         For invalid dates y, m and d are all set to -1.
 MODIFICATION HISTORY:
   29-Jul-2011 handle strings like 7/25/2011-04:46:0-6.538
   12-Feb-2008 handle input date of form 19510617 (yyymmdd)
   17-Apr-2006 - added keyword longDate for return of 20051014.
   14-Oct-2005 - fix to allow dates like 10/14/2005
   13-Jun-2003 - added keyword output of composite string of form
   		    yyyymmdd (e.g., 20030613)
   R. Sterner, 1994 Mar 29 --- Modified to handle arrays.
   RES 18 Sep, 1989 --- converted to SUN.
   25-Nov-1986 --- changed to REPCHR.
   Written by R. Sterner, 29 Oct, 1985.
   Johns Hopkins University Applied Physics Laboratory.

 Copyright (C) 1985, Johns Hopkins University/Applied Physics Laboratory
 This software may be used, copied, or redistributed as long as it is not
 sold and this copyright notice is reproduced on each copy made.  This
 routine is provided as is without any express or implied warranties
 whatsoever.  Other limitations apply as described in the file disclaimer.txt.

Source: src/idl_cvs/db_columns.pro

 NAME:
	db_columns

  PURPOSE:
	list database tables and columns in which the column name 
	contains a string.

  CATEGORY:
	Database

  USE: 
       IDL> info = db_columns( wildCard='te')
    or IDL> info = db_columns( 'te', /print)

  KEYWORDS:
	wildCard - string to match 
		  (do not include *'s or other wildcard strings)
	dataBase - database to search. Defaults to nstxlogs.
	print	 - if set, will print tables and columns fitting criteria

  WRITTEN Oct-2002 by Bill Davis

Source: src/idl_cvs/db_list.pro

 NAME:
       db_list
 PURPOSE:
       List info from an NSTX Database Table; especially to be displayed
	in output from a Web Tool database, like 
	http://nstx.pppl.gov/nstx/Software/WebTools/searchefitdb.html.
	Searches from a database will be MUCH faster than from MDSplus trees.
 CATEGORY:
       Database, NSTX, Web Tools
 CALLING SEQUENCE:
       IDL> db_list, shot1=shot1, shot2=shot2, runID=runID,  $
		rundate=rundate, username=username,  $
		str1=str1, str2=str2, str3=str3, logical1=logical1, logical2=logical2, $
		database=database, include=include, outFile=outFile
 INPUTS:
	(none required)
 KEYWORD PARAMETERS:
   (all optional)
       shot1 - beginning shot, e.g., 120200
	shot2 - ending shot (if missing, will just search 100 shots before shot1) 
	database - database to query; defaults to 'NSTXLOGS'
	table - table in database to query; defaults to 'EFIT02'
	outFile - string (if not present, data listed to screen)
	_extra - contains all the (arbitrary) parameters for the query. 
		These must be the column names in the table; e.g., gapin1=gapin1
 		qualifiers ending with 1 or 2 are limits for that parameter
 		if value = '*', want to list parameter, but not include in qualifier
 OUTPUTS:
       data to screen or file, if specified. File can be displayed in the calling web page.
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> db_list, shot1=120200		
	IDL> db_list, rundate=20060426	; all shots from Apri. 25, 2006
	IDL> db_list, shot1=120200, shot2=120500, pnbi1=600000
 MODIFICATION HISTORY:
	20-Dec-2007  Written by Bill Davis, PPPL

Source: src/idl_cvs/decode_gray.pro

 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

Source: src/idl_cvs/decomposedcolor.pro

 NAME:
  DECOMPOSEDCOLOR

 PURPOSE:

   This function is used to determine, in a device independent way, if the 
   current graphics device is using color decomposition. The function returns
   a 1 if color decomposition is turned on, and a 0 if it is turned off. When
   color decomposition is turned on, we say the device is using a true-color
   display. If color decomposition is turned off, we say the device is using
   an indexed color display.

 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/

 CATEGORY:

   Colors

 CALLING SEQUENCE:

   result = DecomposedColor()

 RETURN VALUE:

   result:       A 1 if color decomposition is turned on. A 0 if color decomposition is turned off.

 ARGUMENTS:

  device:        The IDL graphics device whose color decomposition state you wish to know the
                 current value of. If undefined, the current graphics device is used.

 KEYWORDRS:

  DEPTH:          An output keyword that returns the depth of the graphics device. Normally,
                  either 8 for index color devices, with color decomposition turned off, or 24
                  for true-color devices with color decomposition turned on.

 EXAMPLE:

  IDL> Print, DecomposedColor()     ; Color decomposition state of current graphics device.
       1
  IDL> Print, DecomposedColor('PS') ; Color decomposition state of PostScript graphics device.
       0

 MODIFICATION HISTORY:

  Written by: David W. Fanning, May 24, 2009.
  Modified the way decomposition was obtained for PostScript devices IDL 7.1 and higher. 12 Dec 2010. DWF.
  Fixed a problem in the CASE statement with ELSE clause and added a NULL device segment. 4 Jan 2011. DWF.
  It now appears 24-bit PostScript support was added in IDL 7.1, although the Get_Decomposed keyword
      didn't work until IDL 7.1.1. 13 January 2011. DWF

Source: src/idl_cvs/delfromlist.pro

 NAME:
       delfromlist
 PURPOSE:
       delete ith element from a list
 CATEGORY:
	Strings, Lists
 CALLING SEQUENCE:
        newList = delfromlist( list, idel )
 INPUTS:
       list - string array      				in
	idel    - integer (starting at 0) of line not wanted   	in
		  idel may also be an array of indices.
 KEYWORD PARAMETERS:
 OUTPUTS:
	newList: string array without ith line
 EXAMPLE:
	IDL> list=['a','b','c','d']
	IDL> print,delfromlist(list,1)
	a c d
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
	09-Dec-02 Works when deletion index is an array
 	Written 03-Mar-99 by Bill Davis

Source: src/idl_cvs/dialog_input.pro

 NAME:
     DIALOG_INPUT

 PURPOSE:
     A modal (blocking) dialog widget to input a line of text.
     The dialog must be dismissed, by entering text and pressing the
     Return key, or by clicking on the 'Ok' or 'Cancel' button before
     execution of the calling program can continue.

 TYPE:
     FUNCTION

 CATEGORY:
     GUI, Input, WIDGETS

 CALLING SEQUENCE:
     result = DIALOG_INPUT (PROMPT)

 INPUTS:
     NONE

 KEYWORD PARAMETERS:

     PROMPT: Optional STRING or STRARR displayed on the widget.
         If the keyword NFIELDS is set, then PROMPT must be a
         STRARR of length NFIELDS.  If NFIELDS is not set, and PROMPT is
         a STRARR, each element of the array will appear on a separate line.

         If not supplied, default = 'Enter Text'

     TITLE: Window title [default = 'dialog_input']

     INITIAL: Initial value to show in the input area.  If PROMPT is 
              supplied, this must be a array of length FIELDS.

     XSIZE, YSIZE: The width and height of the dialog

     WIDTH: Set the width of the input field IN CHARACTERS.  

     NFIELDS: Show multiple input fields.  If PROMPT and/or INITIAL are
              supplied, they must be STRARR of length FIELDS.  
 
     CHECKBOX - prompt for optional check box
     BOXINIT - initial value of check box (Default=0)
     BOXOUT - if=1, then box was checked
     TOPLABEL - label above inputs

     FLOATING, INTEGER, LONG, DOUBLE - type of input
     DIALOG_PARENT: Set this keyword to the widget ID of a widget over
         which the message dialog should be positioned. When displayed,
         the DIALOG_INPUT dialog will be positioned over the specified
         widget. Dialogs are often related to a non-dialog widget tree.
         The ID of the widget in that tree to which the dialog is most
         closely related should be specified.

     RETURN_EVENTS:	
	Set this keyword to make cluster return an event when a
	 is pressed in a text field.  The default is
	not to return events.  

     OK: STRING label for the 'Ok' button (default = '  OK  ' )
     CANCEL: STRING label for the 'Cancel' button (default = 'Cancel')

 OUTPUTS:
     result: STRING or STRARR of input text, or '' if dialog is cancelled

 EXAMPLE:
     IDL> a=DIALOG_INPUT('enter val', CHECK='turn on', BOXOUT=box )

     IDL> a=DIALOG_INPUT(['x1:','y1:', 'x2:','y2:'], NFIELDS=4, TITLE='Box Overlay', $
			  INITIAL=[1,1,5,6],  $
			  checkBox='Show Box', boxOut=showBox, boxInit=1,  $
			  TOPLABEL='Enter lower left and upper right coords')

 SIDE EFFECTS:
     Creates a modal widget

 MODIFICATION HISTORY:
     24-Feb-2011 added Top Label & boxInit [BD]
     03-Feb-2011 added Check Box [BD]
     22-Jul-2009 added Alt button [BD]
     15-Jul-2009 added didCancel keyword
     01-Jun-06 default to return events [BD]
     12-Sep-04 improvement for prompt on just one entry 
		Allow for no cancel button [BD]
     02-Jul-01 Fixed bug for floating point values [BD]
     13-Sep-00 Added RETURN_EVENTS keyword [BD]
     03-Feb-00 Added FLOATING, INTEGER and LONG keywords [BD]

     v1.03: RSM, Aug 1998, Added WIDTH keyword to set the width of the 
            input field IN CHARACTERS.  Fixed layout bug when using NFIELDS.

     v1.02: RSM, May 1998, Non-backward compatible changes to allow multiple
            input fields.

     v1.01: RSM, Mar 1998, fixed error when used with a modal toplevel base.

     v1.0:  Written, Robert.Mallozzi@msfc.nasa.gov, July 1997.

Source: src/idl_cvs/dialog_menu.pro

 NAME:
     DIALOG_MENU

 PURPOSE:
     A modal (blocking) dialog widget to display a selectable menu.
     The dialog must be dismissed by selecting a menu item before
     execution of the calling program can continue.

 TYPE:
     FUNCTION

 CATEGORY:
     WIDGETS

 CALLING SEQUENCE:
     result = DIALOG_MENU (menu_items)

 INPUTS:
     menu_items: STRARR of menu items

 KEYWORD PARAMETERS:

     TITLE: The menu title.  Use STRARR for multi-line titles.

     XSIZE, YSIZE: x, y size of the widget.
     XPOSITION, YPOSITION: The position of the upper left corner of the
            dialog, relative to the upper left corner of the screen.

     SCROLL: Adds a scroll bar
     X_SCROLL_SIZE: Size of x scroll region, if /SCROLL is set
     Y_SCROLL_SIZE: Size of y scroll region, if /SCROLL is set

     DIALOG_PARENT: Set this keyword to the widget ID of a widget over
            which the message dialog should be positioned. When displayed,
            the DIALOG_MENU dialog will be positioned over the specified
            widget. Dialogs are often related to a non-dialog widget tree.
            The ID of the widget in that tree to which the dialog is most
            closely related should be specified.
          
            If this keyword is not specified, the default placement of the
            menu is the center of the screen (window manager dependent).

     INDEX: Optionally return the index of the selected item instead of
            the item's text.  The index of the first menu_item is zero.
    
     CANCEL: STRING label for the 'Cancel' button (default = 'Cancel')
 OUTPUTS:
     result: String of selected menu_item, or integer index if INDEX keyword
         is used, starting at index = 0

 COMMON BLOCKS:
     NONE

 SIDE EFFECTS:
     Creates a modal widget.

 RESTRICTIONS:
     None known.

 DEPENDENCIES:
     NONE

 EXAMPLES:
     result = DIALOG_MENU (['Item 1', 'Item 2', 'Item3'], $
         TITLE = 'Select an Item')

 MODIFICATION HISTORY:

     22-Jul-2009 added Alt button [BD]
     15-Jul-2009 added didCancel keyword
     06-Jul-2009 added Cancel button [BD]

     v1.04: RSM, May 1998
            Added XPOSITION, YPOSITION keywords.  Removed the UL, LL, UR, LR 
            keywords.  Changed WIDTH keyword to XSIZE, and added YSIZE 
            keyword.  These bring the widget in line with common IDL widget
            size and position keywords.  

            THESE CHANGES WILL BREAK OLD CODE THAT USED ANY OF THESE KEYWORDS!

     v1.03: RSM, Mar 1998
            If not using /SCROLL, removed the sub-base for the menu buttons 
            so that they span the full width of the top level base. 

     v1.02: RSM, Mar 1998
            Changed to return selected item's text, not index (index can
            now be returned with the INDEX keyword).
                
     v1.01: RSM, Mar 1998
            Fixed error when used with a modal toplevel base.

     v1.0:  Written, Robert.Mallozzi@msfc.nasa.gov, November 1997.

Source: src/idl_cvs/displayfctiffs.pro

 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

Source: src/idl_cvs/domainname.pro

 NAME:
       domainName
 PURPOSE:
       Return TCP/IP domain name from Unix systems
 CATEGORY:
       Utility, OS-specific
 CALLING SEQUENCE:
       IDL> thisDomain = domainName()
 INPUTS:
       None 
 KEYWORD PARAMETERS:
 OUTPUTS:
       thisDomain = e.g., pppl or gat.com (depends on system setup)
 COMMON BLOCKS:
       NONE
 NOTES:
	This can take from 0.3-0.5 seconds the first time it is called.

	If called from VMS, will print a warning (once) and return
	some.vms.system as the domain name.
 MODIFICATION HISTORY:
	26-Sep-2007 Not working for Linux, so added code
       16-Apr-99 Written by Bill Davis, PPPL

Source: src/idl_cvs/drawcircle.pro

 NAME:
  	drawcircle

 PURPOSE:
  	draw a circle centered on [x0, y0]. 
  	YOU HAVE TO HAVE YOUR AXES ESTABLISHED BEFORE CALLING THIS.
  	Return out arrays for later drawing on a surface, too. These are in two
	parts, so you won't have a line down the middle when drawing.

 CATEGORY:
       2-D Plotting,

 CALLING SEQUENCE:
	IDL> (some plot command to estable coordinates)
	IDL> drawcircle, x0, y0, radius

  INPUTS:
	x0,y0 - origin of circle
	radius - radius of circle

  KEYWORDS:
    Inputs:
	color - 
	dashed - if set, will draw curve with dashed line
	angle1 - angle in radians to start drawing arc
	angle2 - angle in radians to stop drawing arc
	deg1 - angle in degrees to start drawing arc
	deg2 - angle in degrees to stop drawing arc
	bottom - draw arc in bottom of circle
    Outputs:
	outX1 - X1 output for other ploting
	outY1 - Y1  "
	outX2 - X2  "
	outY2 - Y2  "
	npts - # of points to use for drawing circle (all the way around)
		(default may be too coarse, so curve not smooth)
  EXAMPLE:
	IDL> x = findgen(100)  & y = x
	IDL> Right_Aspect, x, y, IN_POS=[.1,.1,.9,.9], POSITION=position
	IDL> plot, findgen(100), /nodata, POSITION=position
	IDL> drawcircle, 40, 60, 20
	IDL> drawcircle, 40, 60, 15, /dashed
	IDL> drawcircle, 40, 60, 15, deg1=-60,deg2=-30, /bot
  LIMITATIONS:
	angle1 & angle2 can't cross over 0 or !PI
	ANGLES NEED FIXING (determine where starting from)

  04-Feb-2010 - added angle1 & angle2 keywords (in radians), bottom and npts
  WRITTEN by Bill Davis

Source: src/idl_cvs/drawdiamond.pro

 NAME:
       drawdiamond
 PURPOSE:
  	draw a diamond in data coordinates
 CATEGORY:
	Graphics
 USAGE:
	IDL> drawdiamond, x, y, radius
 INPUTS:
       x - x of center 
	y - y of center
	radius - height of diamond
 KEYWORD PARAMETERS:
	color - color of diamond
	dashed - if set, linestyle is 4

 MODIFICATION HISTORY:
       22-mar-2012 Written by Bill Davis, PPPL

Source: src/idl_cvs/drawellipse.pro

 NAME:
  	drawellipse

 PURPOSE:
  	draw an ellipse centered on [x0, y0]. 
  	YOU HAVE TO HAVE YOUR AXES ESTABLISHED BEFORE CALLING THIS.

 CATEGORY:
       2-D Plotting

 CALLING SEQUENCE:
	IDL> (some plot command to estable coordinates)
	IDL> drawellipse, x0, y0, radius1, radius2, tilt=tilt

 INPUTS:
	x0,y0 - origin of circle/ellipse
	radius1 - Ellipse semi axis 1
	radius2 - Ellipse semi axis 2

 KEYWORDS:
    Inputs:
	tilt - Ellipse rotation angle (radians, unless /deg set)
	       Clockwise; zero is horizontal, to the left
	degrees - if set, tilt is in degrees
	convention - if set, zero is to the right, CCW is positive,
		     with 90 straight up and -90 down 
	color - an index into the color table, or 'red', 'blue', etc.
	dashed - if set, will draw curve with dashed line
	npts - # of pts used in drawing (will be made > 100)
    Outputs:
	xout - x pts in outline
	yout - y pts in outline
 EXAMPLE:
	IDL> x = findgen(100)  & y = x
	IDL> Right_Aspect, x, y, IN_POS=[.1,.1,.9,.9], POSITION=position
	IDL> plot, findgen(100), /nodata, POSITION=position
	IDL> drawellipse, 40, 60, 20, 10
	IDL> drawellipse, 40, 60, 15, 10, /dashed
	IDL> drawellipse, 40, 60, 15, 10, tilt=-1
	IDL> drawellipse, 40, 60, 15, 10, tilt=60, /deg
	IDL> drawellipse, 40, 60, 15, 10, tilt=30, /deg
	IDL> drawellipse, 40, 60, 15, 10, tilt=10, /deg
	IDL> drawellipse, 40, 60, 15, 10, tilt=-10, /deg
	IDL> drawellipse, 40, 60, 15, 10, tilt=60, /deg, /conv
	IDL> drawellipse, 40, 60, 15, 10, tilt=30, /deg, /conv
	IDL> drawellipse, 40, 60, 15, 10, tilt=10, /deg, /conv

	IDL> drawellipse, 40, 60, 15, 5, tilt=20, /deg, /con
	IDL> drawellipse, 40, 60, 15, 5, tilt=30, /deg, /con
	IDL> drawellipse, 40, 60, 15, 5, tilt=40, /deg, /con
	IDL> drawellipse, 40, 60, 15, 5, tilt=50, /deg, /con
	IDL> drawellipse, 40, 60, 15, 5, tilt=60, /deg, /con
	IDL> drawellipse, 40, 60, 15, 5, tilt=-10, /deg, /con
	IDL> drawellipse, 40, 60, 15, 5, tilt=-30, /deg, /con

    to get the points back:
	IDL> drawellipse, 40, 60, 15, 10, tilt=1, /noPlot, xout=xout, yout=yout

 LIMITATIONS:
 MODIFICATION HISTORY:
	15-Jan-2013 added "convention" keyword to have tilt angle be like Jr. High
	19-Sep-2012 used polyfill for filled ellipses
	12-Sep-2012 added thick and fill keywords (fill is faked)
	WRITTEN by Bill Davis, 30-Aug-2011

Source: src/idl_cvs/drawnstxinsides.pro

 NAME:
       drawnstxinsides
 PURPOSE:
       Provide a drawnstxinsides for IDL routines to be used by others
 CATEGORY:
       Utility
 CALLING SEQUENCE:
       IDL> drawnstxinsides, shot=shot
 INPUTS:
       none required 
 KEYWORD PARAMETERS:
    Inputs:
	shot - if set, insides will be drawn for the corresponding shot range
 OUTPUTS:
       none
 EXAMPLE:
      IDL> window, /free, xsize=300, ysize=600
      IDL> cs=mk_color(/load, table=13)
      IDL> tree = 'EFIT01'
      IDL> shot = 121048
      IDL> mdsopen, tree, shot
      IDL> zt =       mdsvalue('\'+tree+'::z')
      IDL> rt =       mdsvalue('\'+tree+'::r')
      IDL> r = rt(*,0) & z = zt(*,0)
      IDL> right_aspect, r, z, POSITION=position
      IDL> plot, r, z, POSITION=position, /nodata
      IDL> drawnstxinsides, shot=shot

    EASIER:
      window,/fr
      cs=mk_color(/load, table=13)
      r=[0,2.15]
      z=[-2.2,2.2]
      right_aspect, r, z, POSITION=position
      plot, r, z, POSITION=position, /nodata
      drawnstxinsides

     TO ZOOM IN ON LLD, FOR EXAMPLE:
 	drawnstxinsides, r=[0.3,1.1], z=[-2.0,-1.2]
 	drawnstxinsides, r=[0.4,1.0], z=[-1.8,-1.4],ystyle=1,xstyle=1

 MODIFICATION HISTORY
 --------------------
	26-May-2010 BD added keywords Z and Radius to allow clipping plot
	12-May-2010 BD added keyword antenna (default=1) to plot RF antenna
	23-Mar-2010 BD don't load colors or make window if Z buffer, so works with
			Web Tools.
  	15-Mar-2010 BD changed name so as not to conflict with original 
	01-Mar-2010 Add LLD; draw plot window if !d.window = -1
	17-Dec-2009 Add beam keyword (used in efitmovies.pro). Beam armor?
	Written by Bill Davis

Source: src/idl_cvs/drawrectangle.pro

 NAME:
       drawrectangle
 PURPOSE:
  	draw a rectangle in data coordinates
 CATEGORY:
	Graphics
 USAGE:
	IDL> drawrectangle, x1, y1, x2, y2
 INPUTS:
       text - text string to write to window
 KEYWORD PARAMETERS:
	dropshadow - if set, make a drop shadow of thick=3 text
	color - color of text
	dscolor - color of drop-shadow text (defaults to black or white)
	nPixels - # of pixels to drop shadow

 MODIFICATION HISTORY:
       25-Sep-2006 Written by Bill Davis, PPPL

Source: src/idl_cvs/dt_nicenumber.pro

 NAME:
 	dt_nicenumber

  PURPOSE:
 	Makes nice delta time numbers, by rounding to 3 significant digits
	Can be used if you want to know if you have a constant timebase.

 CATEGORY:
       Math, Graphics

 CALLING SEQUENCE:
        niceDts = dt_nicenumber( dts )

 INPUTS:
	dts - an array of numbers

 KEYWORD PARAMETERS:
    Optional Inputs:
	nSignificantDigits - number of significant digits to round to
				(defaults to 3)
    Optional Outputs:
       nDecimals - number of significant decimal places in returned value
  EXAMPLE:
	IDL> dt=[2.0003,2.15,.2003,.20009,22.0004,.250002,.5001,100000.1]
	IDL> print, dt_nicenumber(dt) 
	   2.00000    2.15000   0.200000   0.200000    22.0000   0.250000
	   0.500000    100000.

	IDL> print,  dt_nicenumber( -1.876e6 ) 
 NOTES:
	see nicenumber.pro to round to numbers like 1, 2, 2.5, 5, etc.,
	which might be time intervals for older digitizer rates.
  HISTORY:
	13-May-2011 fixed bug
	20-Apr-2011 handle arrays
	05-Nov-2008 corrected for numbers like -1.876e6
	26-Sep-2005 fixed nToShift for nums less than zero (like 0.0016)
	26-Jul-04 work OK for 0
  	03-Nov-00 Rewrote [BD]

Source: src/idl_cvs/edittable.pro

 NAME:
       EDITTABLE
 PURPOSE:
       Edit a structure with a table where the second item in the structure 
	is on/off. You can set all items (but the first) on, off, or to a specific value.
	If there are more rows than will fit on your screen, it will make new columns.
 CATEGORY:
       GUI, Editor, Structures
 CALLING SEQUENCE:
       IDL> newStruct= editTable( struct )
 INPUTS:
       struct = structure where all tags have same number of elements, and the second
		 one is for on/off
 KEYWORD PARAMETERS:
	nrows - defaults to scFrac  of screen
	noFields - if set, do not show fields, other than on/off
	labels - labels of columns, else use tagnames
	scFrac= fraction (roughly) of y length to use
	title - window title
	col1Title - title of first column, else use tagname
	fieldSz - size of all numeric fields (defaults to 12)
	verbose - if set, print some info
	debug - if set, stop in the middle
 OUTPUTS:
       newStruct = edited structure
 EXAMPLE:

    items = replicate( '\OPERATIONS::F_FLEVVL', 40 )
    nitems = n_elements( items )
    for i=0,nitems-1 do items[i]=items[i]+string(i,format='(i2.2)')

    onoffs = replicate( 1, nitems )
    errvals = replicate( 1.e6, nitems )
    more = errvals
    third =replicate( 1, nitems )
    forth=third

    struct = { items : items, onoffs : onoffs, errvals : errvals, more:more, $
 		third:third, forth:forth}

    s= edittable( struct, title='My Dets')

 MODIFICATION HISTORY:
	WRITTEN 19-Jan-2005 by Bill Davis for Jon Menard

Source: src/idl_cvs/efitmovies.pro

 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:
       EFIT, Animation, 2-D Plotting, NSTX, Thomson Scattering

 CALLING SEQUENCE:
   for a nice animated display of the latest shot, with a pick-list displayed for movies:
	IDL> efitmovies, /thom, /summary

   for a movie with a camera looking at the RF limiter and the RF power plotted:
	IDL> efitmovies, 'nstx_1_134625.cin', signame='\wf::prf', time=[.05,.45],  $
		         sigt1=0.1, sigt2=.3, maxframes=1000, $
			 /framesOut, QTmovie='NSTX_134625.mov', /verbose

   to see the strike point plot with EFIT:
	IDL> efitmovies,138000,signame='\EFIT02::RVSOUT',/nofc, sigTitle='Strike Point'

   to get a single frame (with camera image):
	IDL> shot=138000
	IDL> efitmovies, shot, time=0.2, /thom, signame='\wf::ip',  $
                        sigt1=0, sigt2=.4

   to get a single frame with just EFIT
	IDL> efitmovies, 136159,time=.2, /noFC

   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 (determined from dialog box) image on the left:
       IDL> efitmovies, 138000, time=.2, /pick

   to get an IDL Animation Widget, from which you can write an MPEG:
	IDL> efitmovies, 138000, 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], /noFC, $
			/signame, sigtitle='H-alpha',max=40

    to see limiter camera (with Lithium dropping):
	IDL> efitmovies, '/p/nstxcam/phantom4/NSTX_135060.cin', /thom, time=[.1,.2]

    to see miro camera (would use nstx_2*138000 in 2010):
	IDL> efitmovies, 'miro*135060', /thom, time=[.1,.12], /summary

    for the Open House:
	IDL> efitmovies, 'miro*135260', /thom,/summ, /noEfit, time=[.18, .55],  $
			maxFrames=400, /press, /fahren, /HMODE

    for full rotation, with just 3 contours outside of plasma:
	IDL> efitmovies, 136159,time=.2, /noFC, outlevels=3, /double, /pdf, /emailPsFile

    for zooming into plot for a single frame:
	IDL> efitmovies, 136159,time=.2, /noFC,xmin=.25,xmax=1.25,ymin=-2,ymax=-1

    to make a movie using jmovie:
	IDL> efitmovies, 138497, time=[.1,.5], /thom, /framesOut, /nofc, anim=0, $
			 QTmovie='NSTX_138000.mov'

   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:
	noEfit - if set, do not display EFIT contours
	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).
	nDecimalTime - # of decimals to display for time (if in seconds)
	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.
       Summary - if set will include a plot summary (Ip, Pinj, D-alpha, Wmhd)
	save - if set, create the MPEG file, but don't bring up the widget
	pick - if set, will let you pick from a menu when more than one Fast Camera
		file matches the specification of the first argument
	warning - if set to 0, will not pop dialog up for messages
 OUTPUTS:
       none

 LIMITATIONS:
       Some reds are green on printer.
 NOTES:
 MODIFICATION HISTORY:
	17-Aug-2010 added WARNING keyword so popping dialog windows can be surpressed
	10-Aug-2010 added option to make MPEGs from Eliots Java code that uses jpegs
	13-Jul-2010 fixed auto-save of mpeg files. Default name has whole time range.
		    Improved finding of camera files. Default to showing Fast Camera
		    when SIGNAMES set.
	01-Jul-2010 added group keyword, and pass to XIA so can be destroyed
		    by a calling program, like efitmovieloop.pro
	04-Jun-2010 many improvements when using frames from MDSplus; have interpolated
		    Thomson profiles extend to adjacent EFIT times before and after
	12-May-2010 added nLevels keyword for # of flux contours
	07-Apr-2010 added noEfit option for Masa
	02-Apr-2010 provided for color movies
	16-Mar-2010 fix for selecting file after no data found for input shot
	17-Dec-2009 made to work with Cine files. Include plot summaries.
	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

Source: src/idl_cvs/error_message.pro

 NAME:
    ERROR_MESSAGE

 PURPOSE:

    The purpose of this function  is to have a device-independent
    error messaging function. The error message is reported
    to the user by using DIALOG_MESSAGE if widgets are
    supported and MESSAGE otherwise.

    In general, the ERROR_MESSAGE function is not called directly.
    Rather, it is used in a CATCH error handler. Errors are thrown
    to ERROR_MESSAGE with the MESSAGE command. A typical CATCH error
    handler is shown below.

       Catch, theError
       IF theError NE 0 THEN BEGIN
          Catch, /Cancel
          ok = Error_Message()
          RETURN
       ENDIF

    Error messages would get into the ERROR_MESSAGE function by
    throwing an error with the MESSAGE command, like this:

       IF test NE 1 THEN Message, 'The test failed.'

 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/

 CATEGORY:

    Utility.

 CALLING SEQUENCE:

    ok = Error_Message(the_Error_Message)

 INPUTS:

    the_Error_Message: This is a string argument containing the error
       message you want reported. If undefined, this variable is set
       to the string in the !Error_State.Msg system variable.

 KEYWORDS:

    ERROR: Set this keyword to cause Dialog_Message to use the ERROR
       reporting dialog. Note that a bug in IDL causes the ERROR dialog
       to be used whether this keyword is set to 0 or 1!

    INFORMATIONAL: Set this keyword to cause Dialog_Message to use the
       INFORMATION dialog instead of the WARNING dialog. Note that a bug
       in IDL causes the ERROR dialog to be used if this keyword is set to 0!

    TITLE: Set this keyword to the title of the DIALOG_MESSAGE window. By
       default the keyword is set to 'System Error' unless !ERROR_STATE.NAME
       equals "IDL_M_USER_ERR", in which case it is set to "Trapped Error'.

    TRACEBACK: Setting this keyword results in an error traceback
       being printed to standard output with the PRINT command. Set to
       1 (ON) by default. Use TRACEBACK=0 to turn this functionality off.

 OUTPUTS:

    Currently the only output from the function is the string "OK".

 RESTRICTIONS:

    The WARNING Dialog_Message dialog is used by default.

 EXAMPLE:

    To handle an undefined variable error:

    IF N_Elements(variable) EQ 0 THEN $
       ok = Error_Message('Variable is undefined')

 MODIFICATION HISTORY:

    Written by: David W. Fanning, 27 April 1999.
    Added the calling routine's name in the message and NoName keyword. 31 Jan 2000. DWF.
    Added _Extra keyword. 10 February 2000. DWF.
    Forgot to add _Extra everywhere. Fixed for MAIN errors. 8 AUG 2000. DWF.
    Adding call routine's name to Traceback Report. 8 AUG 2000. DWF.
    Added ERROR, INFORMATIONAL, and TITLE keywords. 19 SEP 2002. DWF.
    Removed the requirement that you use the NONAME keyword with the MESSAGE
      command when generating user-trapped errors. 19 SEP 2002. DWF.
    Added distinctions between trapped errors (errors generated with the
      MESSAGE command) and IDL system errors. Note that if you call ERROR_MESSAGE
      directly, then the state of the !ERROR_STATE.NAME variable is set
      to the *last* error generated. It is better to access ERROR_MESSAGE
      indirectly in a Catch error handler from the MESSAGE command. 19 SEP 2002. DWF.
    Change on 19 SEP 2002 to eliminate NONAME requirement did not apply to object methods.
      Fixed program to also handle messages from object methods. 30 JULY 2003. DWF.
    Removed obsolete STR_SEP and replaced with STRSPLIT. 27 Oct 2004. DWF.
    Made a traceback the default case without setting TRACEBACK keyword. 19 Nov 2004. DWF.
    Added check for window connection specifically for CRON jobs. 6 May 2008. DWF.

Source: src/idl_cvs/eventspawn.pro

 NAME:
 	eventspawn
 PURPOSE:
       When a designated MDSplus event is detected, spawn an IDL procedure, 
	first killing any versions that are running.
 CATEGORY:
       MDSplus, Program Control
 CALLING SEQUENCE:
	IDL> eventspawn, event=event, procedure=procedure, server=server, $
                        immediate=immediate, display=display
 INPUTS:
       none required, but procedure is probably necessary
 KEYWORD PARAMETERS:
    Keywords:
	event - MDSplus event to wait for (default to NSTX_ACQ_DONE
	procedure - file to pass to idl batch command (default is batchmyidl.pro)
	ASCII - if set, will assume data block contains ascii representation of numbers
	server - MDSplus event server (default is europa.pppl.gov:8501)
	immediate - if set, execute procedure even before waiting for event
	display - X display to send IDL graphics to.
 OUTPUTS:
       none
 EXAMPLE:
	IDL> eventspawn, pro='/u/bdavis/RFcam/batchrfmovie', $
			event='RFcamera_loaded', display='nstxwindowspc:0', /immed
 LIMITATIONS:
	currently, no arguments can be passed to IDL command.
	only works on Unix/Linux.
 NOTES:
	see /u/bdavis/RFcam/batchtedmovie.pro as example of routine to call.
	shot numbers must be accessed in the calling programs via LASTSHOT()
	or an environmental variable.
 MODIFICATION HISTORY:
	09-Mar-2007 Added ASCII keyword which is needed on sflip PC
	15-Aug-2005 written by Bill Davis

Source: src/idl_cvs/execonevent.pro

 NAME:
       execonevent

 PURPOSE:
       Widget to spawn an executable (with shot as argument) when an 
	MDSplus event occurs. An IDL routine can also be spawned with shot as
	the only  argument, or any IDL command string executed.
	
 CATEGORY:
       Events, MDSplus

 CALLING SEQUENCE:
	IDL> execOnEvent, kickOffEvent='bdtest', executable='/u/bdavis/cvs/idl_cvs/echoarg.exe'
       IDL> execonevent, events=['NSTX_SOC', 'my_event' ]
	IDL> execonevent, emailTo=['vlad@pppl.gov, joeshmoe@pppl.gov'], $
		events=['NSTX_ACQ_DONE', 'CAM1_DONE',  $
			'CAM2_DONE','CAM3_DONE','CAM4_DONE' ]
    to get e-mail when really important events are missed, e.g., :
	IDL>  execonevent,add=['TS_RAW_READY','PHOENIXGO_P1','MPTS_FIT_DONE', $
			       'TFMON_ACQ_DONE'], emailTo='joeshmoe@pppl.gov'
 INPUTS:
       none.  
 KEYWORD PARAMETERS:
    (optional) 
	kickOffEvent - event at which to kick of executable
	executable - executable to spawn
	idljob - spawns subprocess, with current shot number as the only input
	cmd - IDL command string to execute (will wait until returns)
	TEST - if set, appends TEST to all events
       EVENTS_WANTED - Character array of events to watch for.
			defaults to ['NSTX_SOC', 'CAM1_DONE',
			'CAM2_DONE','CAM3_DONE','CAM4_DONE' ]
	EMAIL - email address for message if all events listed not set before next shot..
	NOCLEAR - if set, will not clear events when first event is recognized
	noBox - if set, will not create color box for events 
		(can conflict with plot windows spawned from cmd)
	PRINT - if set, will print messages when events are recognized
	TIME - if set, will display time-of-day when event was declared
	add_events - if set, will add these event(s) to the default
	BIG - if set, fonts are big
	WALL - if set, events of interest for display wall, and big font
       GROUP_LEADER - Group_Leader ID
 OUTPUTS:
       none.
 NOTES:
       The time of day will be printed for the first event, and the other times
       will be cleared. Then the time difference will be printed as mm:ss, 
       so :12 would mean it came 12 seconds after the first event. 
 TESTING
	IDL> execonevent, EVENTS_WANTED=['MY_TEST_EVENT_1','MY_TEST_event_2'], $
			/Shots
	   and from a VMS computer:  
	IDL> SetMDSShotEvent,'MY_TEST_EVENT_1', 999999

	IDL> execonevent, EVENTS='bdtest', cmd='print, "Hi Mom"', /verbose

 ROUTINES USED:
	MK_COLOR, usingXwindows, MDSEVENT
 EXAMPLE:
	  to automatically have MPTS plots come up on Display Wall:
	IDL> execonevent, EVENTS='MPTS_REFRESH', cmd='plot_mpts,shot=0,chrsz=1.5, xmargin=[7,3]'
 LIMITATION:
	Shot numbers are only returned  when running on VMS currently.
 NOTES:
	As the events are declared, the boxes turn color.
 	When the first event in the list is recognized, the other boxes are
	set to yellow (unless /noClear was set). Shot numbers declared with 
	the events may optionally be displayed.
       The status fields are initially the background color.
	A program calling this routine, might want to save !D.WINDOW 
	before the TV commands and restore it immediately afterwards.
 MODIFICATION HISTORY:
	15-Jun-2010 added cmd keyword [BD]
	01-Oct-2008 Removed MDSconnect
	06-Mar-2006 Written by Bill Davis, PPPL

Source: src/idl_cvs/factor.pro

 NAME:
       FACTOR
 PURPOSE:
       Find prime factors of a given number.
 CATEGORY:
	Math
 CALLING SEQUENCE:
     FACTOR, x, p, n
 INPUTS:
      x = Number to factor, scalar positive integer
 OUTPUT PARAMETERS:
      p = Array of prime numbers.    
      n = Count of each element of p. 
 INPUT KEYWORD PARAMETER: 
      /HELP - Display help documentation
 PROCEDURES USED:
      PRIME()
      Also see numfactors, print_fact in the JHUAPL Library
 MODIFICATION HISTORY:
       R. Sterner.  4 Oct, 1988.
       RES 25 Oct, 1990 --- converted to IDL V2.
       Johns Hopkins University Applied Physics Laboratory.

 Copyright (C) 1988, Johns Hopkins University/Applied Physics Laboratory
 This software may be used, copied, or redistributed as long as it is not
 sold and this copyright notice is reproduced on each copy made.  This
 routine is provided as is without any express or implied warranties
 whatsoever.  Other limitations apply as described in the file disclaimer.txt.
       Converted to IDL V5.0   W. Landsman   September 1997

Source: src/idl_cvs/fancy_title.pro

 NAME:
       fancy_title
 PURPOSE:
       write a title at top of screen, with option to use Hershey fonts
 CATEGORY:
       Plotting
 CALLING SEQUENCE:
       IDL> fancy_title, mytitle, ishot
 INPUTS:
       mytitle = whatever you want as the main plot title.  
       ishot = shot number.  
 KEYWORD PARAMETERS:
     Keywords:
       right - When set, print at right of screen (else center)
       fancy - if set, use Hershey fonts
       line - if set, drop the title down by this number of lines.
       bottom - if set, at bottom of screen (else top)
       yloc - location of text in pixels
       xloc - location of text in pixels
	nudgeup - fraction of a line to nudge up title in Y direction
       charcolor 
       charsize  
       charthick 
 OUTPUTS:
       none
 EXAMPLE:
	IDL> !Y.OMARGIN=[0,1]
	IDL> plot,indgen(100)
	IDL> fancy_title, 'This is my title', 100523 
 NOTES:
       You'll probably want a little more room at the top of your plots, e.g.
	IDL> !Y.OMARGIN=[0,1]
 MODIFICATION HISTORY:
	11-Jun-2010 added nudgeUp keyword
	19-Sep-2008 reduce font size if title won't fit on screen
	30-May-2007 Use charsize in positing shot #
       21-Sep-00 Written by Bill Davis, PPPL

Source: src/idl_cvs/fcdcmovies.pro

 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 $NSTXUSR/uppercam/114333 and $NSTXUSR/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

Source: src/idl_cvs/fcplayer.pro

 NAME:
       fcplayer
 PURPOSE:
       Also displays files from the Phantom or color Miro cameras (.cin 
	files) and optionally save frames as JPEG, png or TIFF files. 
	Allows recording of click locations on .cin files from a 
	Phantom 4 or 7 camera (for tracking dust, e.g.). Also trackes "blobs"
	from images of edge turbulence.
 CATEGORY:
       Image Processing, Animation, Fast Cameras
 CALLING SEQUENCE:
       IDL> fcplayer, filename
 INPUTS:
       filename - a .cin file 
		(or will pop dialog box)
	  Environmental/System variable FC_DATA_DIR will be used, if set, to look for
	  files containing the string in 'filename'
 KEYWORD PARAMETERS:
	AveT1 - start time in seconds to form average frame for normalizing
	AveT2 - end time in seconds to form average frame for normalizing
	bgFrame - the first frame of the background (default=0)
	box - if set, will try to handle two boxes that show up on one of Ricky's cameras
	ByteScale - if =0, will not byte scale image before displaying.
	camera - a number from 1-7, which will go into wildcard search for filename
		like 'nstx_5_'
	colorTable - default to IDL color table 3 (hot metal)
	drawXSize - the horizontal size in pixels of the image window
	gamma - gamma correction. (Default=1, which is no correction). 0.5 probably better 
		for Miro
	horizontal_flip - if set, flip images horizontally (desired for NSTX and CMOD shots)
	INTERP - if =1, pixels will be smoothed, rather than replicated
	loop - if set, will continue to loop over all times, or those in widget boxes.
	maxPlayMinutes - defaults to 60
	minXsize - minimum X size of window displaying image
	nBG - number of background frames. If=0 (the default) no background subtraction is done
	noCaption - do not put text on or above image
	pause - time to pause between frames when playing
	radius - 1/2 of square in pixels drawn around click point, setting the area to be 
		used for the maxval calculation.
       RotCCW - rotate image Counter-ClockWise (desired for NSTX shots)
	RotCW - rotate image ClockWise
	RotDegrees - rotate an arbitray # of degrees Clockwise
	saturation - As in HSV color representation, for color camera. Default is 0.3.
	startTime - start time in milliseconds
	shot - a number which will go into wildcard search for filename
		like '*123456.*'
	vertical_flip - if set, flip images vertically
	FrameOffset - if set, subtract this (like a baseline) from all pixels
	FrameAveMin - if set, make close-to-zero pixels this number, 
		      so when dividing into data, as in normalizing, result is near zero
			(if <= 0, then just one average frame will be used) 
	AveFrameSmooth - smoothing for the averaged frame(s)
	FrameAveDeltaMS - make frames used for normalizing an average of this many millisec
	verbose - if set, lots of information output listed
       debug - if set, will output even more and may stop at some spots
       GROUP_LEADER - Group_Leader ID
   Blob-related keywords:
       blobs - if set, will track blobs (and will set normalize=1, if not set)
	normalize - if set, will divide frames by the average frame
       saveBlobs - if set, will save blob info to a file (may be easier to run saveblobs.pro)
       BlobArrows - if set, will draw arrow from where blob was in the last frame 
			(if database available for shot and time range)
       history - if set, will draw plus signs of previous locations of blob
			(if database available for shot and time range)
       surface - show shaded surface plot of blobs in another window
       aveT1 - if tracking blobs, use this as start time in sec. for averaging frame (DEF=0)
       aveT2 - if tracking blobs, use this as ending time in sec. for averaging frame 
		(DEF=end of file)   
 OUTPUTS:
       none.
 COMMON BLOCKS:
       region_com
 ROUTINES USED:
	MK_COLOR, usingXwindows
 EXAMPLE:
	IDL> fcplayer	; you will be prompted for a .cin file

    or IDL> fcplayer,'nstx121048.cin',start=200
    or IDL> fcplayer,'MIRO_130376.cin',start=232
       IDL> fcplayer,file='~bdavis/France/Data/ball_against_wall_cam2.cine', $
			nsmooth=5, /gauss, nbg=1, /invert, /debug

    fcplayer, colorTable=3, /horiz, minXsize=256, normalize=0, $
          /RotCCW, /edge,   time=300,  $
          file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139442.cin', $
          avet1=.3, avet2=.302, /debug

   examples for Blob tracking:
    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139056.cin', $
	      aveT1=0.420, aveT2=0.430, /horiz, /RotCC,  $
	      colorTable=3, /blobs, minXsize=300  , FrameAveDeltaMS=0                                ,/debug

    fcplayer, file='/u/bdavis/Blobs/solt_012_3.5b.hdf', /horiz, /rotcw, ctb=3, minXsize=300,  $
    	       minNorm=0.001, aveT1=0.0, aveT2=1.e-5, FrameAveDeltaMS=0, /blobs  , /debug

    fcplayer, aveT1=0.0, aveT2=0.02, colorTable=3, /blobs, /horiz, minXsize=400, $
         file='/home/bdavis/shot_1091216028.cin'		; at MIT

    fcplayer, aveT1=0.0, aveT2=0.02, colorTable=3, /blobs, /horiz, minXsize=400, $
         file='/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216028.cin'

	(Myra:)
    fcplayer, aveT1=0.055, aveT2=0.0580, colorTable=3, /blobs, /horiz, minXsize=256, $
         file='/p/gpi/szweben/Phantom_Data/2010_data/1100120/shot_1100120025.cin'
    fcplayer, aveT1=0.06, aveT2=0.08, colorTable=3, /blobs, /horiz, minXsize=256, $
         file='/p/gpi/szweben/Phantom_Data/2010_data/1100824/shot_1100824017.cin'

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139432.cin', $
	      aveT1=0.268, aveT2=0.288, /horiz, /RotCC,  $
	      colorTable=3, /blobs, minXsize=300                                  ,/debug

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139442.cin', $
	      aveT1=0.310, aveT2=0.312, /horiz, /RotCC, colorTable=3, minXsize=300                            ,/debug

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139444.cin', $
	      aveT1=0.265, aveT2=0.275, /horiz, /RotCC,  $
	      colorTable=3, /blobs, minXsize=300  , FrameAveDeltaMS=0                                ,/debug

    fcplayer, $
       file='/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216030.cin', $
	colorTable=3, minXsize=256, /blobs, /horiz, aveT1=0., aveT2=0.02,    /debug

    fcplayer,colortable=3, minXsize=256, /blobs, /horiz, avet1=1.25, avet2=1.27, $
	file='/p/gpi/szweben/Phantom_Data/2010_data/1100803/shot_1100803008.cin'

    fcplayer, aveT1=0.0, aveT2=0.02, colorTable=3, /blobs, /horiz, minXsize=512, $
         file='/p/gpi/szweben/Phantom_Data/2011_data/1110114/shot_1110114026.cin'

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141751.cin', $
	      aveT1=0.2, aveT2=0.22, /horiz,  /RotCC,  $
	      colorTable=3, minXsize=256, /blobs,/debug

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141752.cin', $
	      aveT1=0.21, aveT2=0.23, /horiz, /RotCC,  $
	      colorTable=3, minXsize=256, /blobs

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138234.cin', $
	      aveT1=0.530, aveT2=0.550, /horiz, /RotCC, colorTable=3,   $
		minXsize=300, /blobs                           ,/debug

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138234.cin', $
	      aveT1=0.530, aveT2=0.540, /horiz, /RotCC,  $
	      colorTable=3,  minXsize=300, /blobs , FrameAveDeltaMS=0             ,/debug

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138128.cin', $
	      aveT1=0.280, aveT2=0.290, /horiz, /RotCC,  $
	      colorTable=3,  minXsize=300, /blobs , FrameAveDeltaMS=0                  ,/debug

    fcplayer,file='/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138114.cin', $
	      aveT1=0.225, aveT2=0.235, /horiz, /RotCC,  $
	      colorTable=3,  minXsize=300, /blobs , FrameAveDeltaMS=0                  ,/debug

    fcplayer,'/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138120.cin' , $	     
    	     avet1=0.219,avet2=0.229, colorTable=3, minXsize=256, /blobs, /horiz, $  
    	     /rotccw, starttim=.2						     

	NB shot, with 1MW during some FC timesL
    fcplayer,'/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_142220.cin' , $	     
    	     avet1=0.280,avet2=0.300, colorTable=3, minXsize=256, /blobs, /horiz, $  
    	     /rotccw, starttim=.29			     

	for looking at elliptical changes at 0.922:
    fcplayer, colorTable=3, /blobs, /horiz, minXsize=400, $
    	  file='/p/gpi/szweben/Phantom_Data/2011_data/1110114/shot_1110114032.cin'

       to look at X-pt camera from CMOD:
    fcplayer, aveT1=0.08, aveT2=0.09, colorTable=3, /blobs, /horiz, /RotCW, minXsize=400,  $
	   file='/p/gpi/szweben/Phantom2_Data/2012_shots/1120815/shot_1120815021.cine', $
          FrameAveMin=25, FrameAveDeltaMS=1, max2show=2

       to look at X-pt camera from CMOD via MDSplus (times are shot times):
    fcplayer, aveT1=1.044, aveT2=1.048, colorTable=3, /blobs, /horiz, /RotCW,  $
	   minXsize=400,  file='shot_1120224022.cine', $
          FrameAveMin=25, FrameAveDeltaMS=0, max2show=2 

	to look at mid-plane camera from CMOD via MDSplus
    fcplayer, aveT1=1.044, aveT2=1.045, colorTable=3, /blobs, /horiz,  $
	   minXsize=400,  file='shot_1120224022.cin', $	  ; no "e" on end for midplane
          FrameAveMin=25, FrameAveDeltaMS=0, max2show=2 
    shot = '1120815018'  &  t1=1.270  &  t2=1.274
       ; black part will be across top with /horiz and /RotCW
    fcplayer, aveT1=t1, aveT2=t2, colorTable=3, /blobs, /horiz, /RotCW,  $
	       minXsize=400,  file='shot_'+shot+'.cine', $	; .cine is X-pt cam
              FrameAveDeltaMS=0, FrameAveMin=25, max2show=2

       to look at corresponding mid-plane camera from CMOD:
    fcplayer, aveT1=t1, aveT2=t2, colorTable=3, /blobs, /horiz,   $
	       minXsize=400,  file='shot_'+shot+'.cin', $	; .cin is midplane cam
              FrameAveDeltaMS=0, FrameAveMin=25, max2show=2	; blacking good here?
    fcplayer, aveT1=1.086, aveT2=1.088, colorTable=3, /blobs, /horiz,  $
	   minXsize=400,  file='shot_1120224029.cin', $
          FrameAveMin=25, FrameAveDeltaMS=0, max2show=2 , minrise = 0.06

    fcplayer, aveT1=1.440, aveT2=1.443, colorTable=3, /blobs, /horiz,  $
	   minXsize=400,  file='shot_1120712028.cin', $
          FrameAveMin=25, FrameAveDeltaMS=0, max2show=2 , minrise = 0.06

    fcplayer, aveT1=1.440, aveT2=1.443, colorTable=3, /blobs, /horiz, /rotcw, $
	   minXsize=400,  file='shot_1120712028.cine', $
          FrameAveMin=25, FrameAveDeltaMS=0, max2show=2 , minrise = 0.06

    fcplayer, aveT1=1.086, aveT2=1.088, colorTable=3, /blobs, /horiz,  $
	   minXsize=400,  file='shot_1120224029.cine',   $		    ; RotDeg=51, $
          FrameAveMin=25, FrameAveDeltaMS=0, max2show=2, minrise = 0.06    fcplayer, aveT1=1.089, aveT2=1.091, colorTable=3, /blobs, /horiz, /rotcw,  $
	   minXsize=400,  file='shot_11202240.cine', $
          FrameAveMin=25, FrameAveDeltaMS=0, max2show=2  NOTES:
 MODIFICATION HISTORY:
	17-Jul-2013 made to work (again) with a single frame
	05-Mar-2013 added shot and camera keywords.
	29-Nov-2012 Replaced Save-as-GIF with png
	06-Oct-2012 allow surface plot axes to be in cm
	05-Oct-2012 added showNumbers keyword so text on images can be surpressed.
	13-Sep-2012 If CMOD files not in local directory, or the one specified, get from 
			MDSplus at MIT.
	05-Sep-2012 different smoothing parameter for Frame Averaging.  
		    Allow average frames to be for 1ms, or whatever. 
		    New keyword FrameOffset to be subtracted from each frame. 
		    Reinstated the printing of "rise" next to blobs.
	04-Sep-2012 read file for Average Intensity plot, if not in tree.
	27-Mar-2012 support for HDF files from simulations by Jim Myra.
	07-Mar-2012 In findblobs, check Chi Squared first, before tossing all 
			interior contours (fixed a bug where occaisional blobs missing).
       01-Mar-2012 decided not to smooth average frame. Changed median smoothing to regular
	23-Feb-2012 allow for not smoothing the average frame. Smooth average frame the
		    same as the setting for the data
	14-Dec-2011 added option to show separatrix (keyword edge); probably only makes
		    sense for GPI camera (#5) data
	07-Dec-2011 subtract background right after data read, so shouldn't rotate,
  		    flip, etc., background data
	26-Sep-2011 Anticipating loading of blob database will be done with loadblob.pro,
		    made the blobCriteria more reasonable. MinHt 1.1, MinArea 15, 
		    MinChiSq 5, minRise 0.05
	06-Sep-2011 reworked findblobs, so can plot surface within same window
	20-May-2011 fixed printer selection and aspect ration of prints
	07-Apr-2011 added NoCaption keyword for NOVA work.
	21-Jan-2011 use database of parent/child relations of blobs to draw arrows
		    Using point of maximum withing (smoothed) blob as center to track.
	04-Jan-2011 blob tracking and output file for Stewart Zweben
	22-Jul-2010 added Preview and Revert buttons to Image Enhancement widget.
	23-Jun-2010 desensitze widgets in slave window that would create new widget IDs
	14-Jun-2010 added rotate-image options
	10-Jun-2010 added Master Player feature to allow synced play of two different cameras
	08-Jun-2010 use amedian, so edges of images get filtered
	28-May-2010 fixed play range, and made jpeg saves a screen dump (so would
			use image enhancements.
	27-May-2010 can specify nBG and BGframe on command line.
	18-May-2010 fixed one pixel too many being displayed on zoom (so click points off a little)
	06-May-2010 Improved default dir for writing Click files, and don't destroy clicked
		    data if cancel out of writing.
	19-Apr-2010 combined background dialogs into one widget
	27-Jan-2010 remove /KEEP_ASPECT from TVIMAGE and draw at z=0 so Z Position is correct
	21-Jan-2010 set Val printed back to value of clicked point (for later reasonableness checking)
	11-Jan-2010 Added slider for saturation in "Image Enhancement" widget, and made default=0.3
	05-Jan-2010 Added display of X & Y positions
	21-Dec-2009 Added "Specify region to display" option
	10-Dec-2009 Added option to plot average intensity vs. time of RGB components
	01-Sep=2009 added /horizontal_flip and /vertical_flip and menu items.
	06-Jul-2009 Added menu option to search for movie files.
	24-Jun-2009 Added Write MPEG, and min/max values to show.
	15-Apr-2009 Added support for *.raww files, from new Photron camera
	10-Nov-2008 cleaned up incompatibility with tvimage. Added menu options for # of
		    background frames to subtract, start frame for background subtraction,
		    turn off/on byte scaling of image.
	04-Aug-2008 added Frame Time slider widget
	31-Jul-2008 Added imageproc option to Special menu & gamma setting to Edit menu.
		    Also added median smoothing option.
	16-Jul-2008 Can ungzip .gz files automatically
	14-Jul-2008 Added support for color images. Added GAMMA keyword.
	10-Jun-2008 Added XSectionW option. Changed default to no background subtraction
	15-May-2008 Added maxPlayMinutes, so movie won't run for ever (Default to 1 hour)
	12-May-2008 made advance and backup buttons more clear. Added noLoad keyword so
		    color palette loading can be surpressed.
	15-Feb-2008 Add options to save as JPEG, GIF & TIFF
	15-Mar-2007 add animation feature
	26-Oct-2006 added Advance-number-of-frames box
	19-Oct-2006 added BG subtraction and "box disquising"
       01-Jun-2006 Written by Bill Davis, PPPL

Source: src/idl_cvs/fctiffsvcr.pro

 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

Source: src/idl_cvs/fcvcr.pro

 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:
	sigName - MDSplus signal name of 3-D signal
	tree - MDSplus tree of signal (defaults to cameras2)
	bytescale - if set, will scale each frame to 0-255
	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)
	maxVal - maximum value to use when byte scaling
	minVal - minimum value to use when byte scaling
	camt0 - time of first frame (overrides what is in MDSplus)
	camdt - time between frames (overrides what is in MDSplus)
 OUTPUTS:
       calls XIA, from which you can save pictures of frames, or an mpeg file
 EXAMPLES:
	IDL> fcvcr, 138116, signal='\cameras2::top.edge_neutral.rawdata.data', mag=2
	IDL> fcvcr, 138178, signal='\cameras2::fastsoftxray:frames', ndecimals=5, mag=5
 LIMITATIONS:
 NOTES:
 MODIFICATION HISTORY:
	08-Jun-2010 use amedian, so edges of images get filtered
	03-Jun-2010 added handling of time outside of shot, and overrides
	02-Jun-2010 added keywords maxVal, minVal, bytescale (does all data at once)
	28-Mar-2008 written by Bill Davis

Source: src/idl_cvs/fdecomp.pro

 NAME:
	FDECOMP
 PURPOSE:
	Routine to decompose a file name for any operating system

 CATEGORY:
	Files, OS Specific, Strings
 CALLING SEQENCE:
	FDECOMP, filename, disk, dir, name, qual, version, [OSFamily = ]

 INPUT:
	filename - string file name, scalar

 OUTPUTS:
	All the output parameters are scalar strings
	disk - disk name, always '' on a Unix machine, scalar string
	dir - directory name, scalar string
	name - file name, scalar string
	qual - qualifier, set equal to the characters beyond the last "."
	version - version number, always '' on a non-VMS machine, scalar string

 OPTIONAL INPUT KEYWORD:
	OSFamily - one of the four scalar strings specifying the operating 
		system:  'vms','windows','MacOS' or 'unix'.    If not supplied,
		then OS_FAMILY() is used to determine the operating system.
 EXAMPLES:
	Consider the following file names 

	Unix:    file = '/rsi/idl40/avg.pro' 
	VMS:     file = '$1$dua5:[rsi.idl40]avg.pro;3
	Mac:     file = 'Macintosh HD:Programs:avg.pro'
	Windows: file =  'd:\rsi\idl40\avg.pro'
	
	then IDL> FDECOMP,  file, disk, dir, name, qual, version
	will return the following

		  Disk             Dir          Name        Qual     Version
	Unix:      ''            '/rsi/idl40/'  'avg'       'pro'       ''
	VMS:     '$1$dua5'       '[RSI.IDL40]'  'avg'       'pro'       '3'
	Mac:     'Macintosh HD'  ':Programs:'   'avg'       'pro'       ''
	Windows:    'd:'         \rsi\idl40\    'avg'       'pro'       ''

 NOTES:
	(1) All tokens are removed between
		1) name and qual  (i.e period is removed)
		2) qual and ver   (i.e. VMS semicolon is removed)
	(2) On VMS the filenames "MOTD" and "MOTD." are distinguished by the 
	    fact that qual = '' for the former and qual = ' ' for the latter.

 ROUTINES CALLED:
	Function GETTOK(), OS_FAMILY()
	Users with V4.0 or later can replace OS_FAMILY() with !VERSION.OS_FAMILY
 HISTORY
	version 1  D. Lindler  Oct 1986
	Include VMS DECNET machine name in disk    W. Landsman  HSTX  Feb. 94
	Converted to Mac IDL, I. Freedman HSTX March 1994

Source: src/idl_cvs/feature.pro

see http://www.physics.emory.edu/~weeks/idl
   for more information

 NAME:
		Feature	
 PURPOSE:
		Finds and measures roughly circular 'features' within 
		an image.
 CATEGORY:
		Image Processing
 CALLING SEQUENCE:
		f = feature( image, diameter [, separation, masscut = masscut,
			min = min, iterate = iterate, /field, /quiet ] )
 INPUTS:
		image:	(nx,ny) array which presumably contains some
			features worth finding
		diameter: a parameter which should be a little greater than
			the diameter of the largest features in the image.
			Diameter MUST BE ODD valued.
		separation: an optional parameter which specifies the 
			minimum allowable separation between feature 
			centers. The default value is diameter+1.
		masscut:Setting this parameter saves runtime by reducing the
			runtime wasted on low mass 'noise' features.
		min: 	Set this optional parameter to the minimum allowed
			value for the peak brightness of a feature. Useful
			for limiting the number of spurious features in
			noisy images.
		field: 	Set this keyword if image is actually just one field
			of an interlaced (e.g. video) image. All the masks
			will then be constructed with a 2:1 aspect ratio.
		quiet:	Supress printing of informational messages.
		iterate: if the refined centroid position is too far from
			the initial estimate, iteratively recalc. the centroid
			using the last cetroid to position the mask.  This 
			can be useful for really noisy data, or data with
			flat (e.g. saturated) peaks.  Use with caution- it
			may 'climb' hills and give you multiple hits.
 OUTPUTS:
		f(0,*):	this contains the x centroid positions, in pixels.
		f(1,*): this contains the y centroid positions, in pixels. 
		f(2,*): this contains the integrated brightness of the 
			features.
		f(3,*): this contains the square of the radius of gyration
			of the features.
		f(4,*): this contains the eccentricity, which should be 
			zero for circularly symmetric features and order
			one for very elongated images.
 SIDE EFFECTS:
		Displays the number of features found on the screen.
 RESTRICTIONS:
		To work properly, the image must consist of bright, 
		circularly symmetric regions on a roughly zero-valued 
		background. To find dark features, the image should be 
		inverted and the background subtracted. If the image
		contains a large amount of high spatial frequency noise,
		performance will be improved by first filtering the image.
		BPASS will remove high spatial frequency noise, and 
		subtract the image background and thus provides a good 
		complement to using this program. Individual features 
		should NOT overlap.
 PROCEDURE:
		First, identify the positions of all the local maxima in
		the image ( defined in a circular neighborhood with diameter
		equal to 'diameter' ). Around each of these maxima, place a 
		circular mask, of diameter 'diameter', and calculate the x & y
		centroids, the total of all the pixel values, and the radius
		of gyration and the 'eccentricity' of the pixel values within
		that mask. If the initial local maximum is found to be more
		than 0.5 pixels from the centroid and iterate is set, the mask 
		is moved and the data are re-calculated. This is useful for 
		noisy data. If the restrictions above are adhered to, and the 
		features are more than about 5 pixels across, the resulting x 
		and y values will have errors of order 0.1 pixels for 
		reasonably noise free images.

 *********	       READ THE FOLLOWING IMPORTANT CAVEAT!        **********
		'feature' is capable of finding image features with sub-pixel
		accuracy, but only if used correctly- that is, if the 
		background is subtracted off properly and the centroid mask 
		is larger than the feature, so that clipping does not occur.
		It is an EXCELLENT idea when working with new data to plot
		a histogram of the x-positions mod 1, that is, of the
		fractional part of x in pixels.  If the resulting histogram
		is flat, then you're ok, if its strongly peaked, then you're
		doing something wrong- but probably still getting 'nearest
		pixel' accuracy.

		For a more quantitative treatment of sub-pixel position 
		resolution see: 
		J.C. Crocker and D.G. Grier, J. Colloid Interface Sci.
		*179*, 298 (1996).

 MODIFICATION HISTORY:
		This code is inspired by feature_stats2 written by
			David G. Grier, U of Chicago, 			 1992.
		Written by John C. Crocker, U of Chicago, optimizing 
			runtime and measurement error, 			10/93.
		Added field keyword, 		 			 4/94. 
		Added eccentricity parameter, 	 			 5/95.
		Added quiet keyword					12/95.
		Added iteration, fixed up the radius/diameter fiasco and
		did some debugging which improves non-centroid data.	 4/96.
		
	This code 'feature.pro' is copyright 1997, John C. Crocker and 
	David G. Grier.  It should be considered 'freeware'- and may be
	distributed freely in its original form when properly attributed.

Source: src/idl_cvs/file2struct.pro

 NAME:
	file2struct

 PURPOSE:
 	return a structure where elements are named with column headings, and 
	arrays are the columns

 CATEGORY:
       files

 CALLING SEQUENCE:
       IDL> struct = file2struct(filename)

 INPUTS:
       filename - file name with columns and, preferably, headings
	

 KEYWORDS:
	strip - if set, strip everything from column headings up to
		and including the first period
	FORMAT - scalar string containing a letter specifying an IDL type
		for each column of data to be read.  Allowed letters are 
		A - string data, B - byte, D - double precision, F- floating 
		point, I - integer, L - longword, and X - skip a column.
		(G & E equate to F)

		Columns without a specified format are assumed to be floating 
		point.  Examples of valid values of FMT are

	   'A,B,I'   ;First column to read as 6 character string, then 
	   	      1 column of byte data, 1 column integer data. 'V' for LONG64
	   'L,L,L,L'  ;Four columns will be read as longword arrays.
	   ' '        ;All columns are floating point

	If a FORMAT keyword string is not supplied, then all columns are 
	assumed to be floating point.

	SILENT - Normally, READCOL will display each line that it skips over.
		If SILENT is set and non-zero then these messages will be 
		suppressed.
	DEBUG - If this keyword is non-zero, then additional information is
		 printed as READCOL attempts to read and interpret the file.
	nSkip - Scalar specifying number of lines to skip at the top of file
		before reading.   Default is to start at the first line.
	        Headings for the columns (the last line skipped) will be the tags
		in the structures.
	COMMENT - skip if a line begins with this
	NUMLINE - Scalar specifying number of lines in the file to read.  
		Default is to read the entire file
	LINESSKIPPED - Ascii array of lines skipped
	TABDELIM - If set, then assume columns are delimitted by tabs
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed

 OUTPUTS:
	struct - structure containing the filename and a tag for each column

 EXAMPLES:
	IDL> struct = file2struct( '/u/bdavis/Blobs/readtest.txt', nskip=1, /strip, $
		FORMAT='I,F,F,F,F,F,I,F,F,F,I,F,I,F,F,F,F,F,I,F,F,F,F,F,F,F,F,F,F,F,F,F' )

	IDL> loadblobs,t1=0.18,t2=0.35, dbout='/u/bdavis/Blobs/blobs141751.txt', $
		 '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141751.cin'
	IDL> struct = file2struct( '/u/bdavis/Blobs/blobs141751.txt', nskip=3,  $
		FORMAT='I,F,F,F,F,F,I,F,F,F,I,F,I,F,F,F,F,F,I,F,F,F,F,F,F,F,F,F,F,F,F,F' )

 REVISION HISTORY:
   03-Jul-2012  take the last non-blank line at the top for the column 
   		 headings & tag names
   WRITTEN 02-May-2012 by Bill Davis for Ahmed Diallo

Source: src/idl_cvs/fileonevent.pro

 NAME:
 	fileOnEvent
 PURPOSE:
       When a designated MDSplus event is detected, write a file containing a shot 
	number, first deleting existing file.
 CATEGORY:
       MDSplus, Program Control
 CALLING SEQUENCE:
	IDL> fileOnEvent, event=event, file=file, server=server,
 INPUTS:
       none required
 KEYWORD PARAMETERS:
    Keywords:
	event - MDSplus event to wait for (default to NSTX_ACQ_DONE
	server - MDSplus event server (default is europa.pppl.gov:8501)
	file - default to 'E:/pulse.ini'
 OUTPUTS:
       none
 EXAMPLE:
	IDL> fileOnEvent,  event='bdtest', file='bdfile.txt'

 LIMITATIONS:
 NOTES:
 MODIFICATION HISTORY:
	23-Aug-2010 written by Bill Davis for Doug Darrow

Source: src/idl_cvs/fileshotdate.pro

 NAME:
       fileshotdate
 PURPOSE:
       Print time and date of an NSTX shot, but get data from a file
 CATEGORY:
       Dates, MDSplus, Tree Status 
 CALLING SEQUENCE:
       IDL> date = fileshotdate( shot, time=time  )
 INPUTS:
       shot = MDSplus shot number
 KEYWORDS:
    optional output:
	time = time of shot, e.g., 12:25:02.00
 OUTPUT:
	date - e.g., '18-Mar-2010'
 EXAMPLE:
       IDL> date=fileshotdate(136942,time=time)
       IDL> print, date, ' ', time
       18-Mar-2010 13:51:00.00
 COMMON BLOCKS:
       fileshotdate_local
 NOTES:
 LIMITATIONS:
 MODIFICATION HISTORY:
	08-Jul-2013 converted from mdsshotdate by Bill Davis

Source: src/idl_cvs/filetime2dbtime.pro

 NAME:
       fileTime2dbTime
 PURPOSE:
 	Return times in filetimes format in database format 
 CATEGORY:
	Dates, times
 CALLING SEQUENCE:
       seconds = filetime2dbtime( time )
 INPUTS:
       time - string in military style  '11:04' or '23:59' (no double quotes!)
 KEYWORDS
	addminutes - minutes to add (can be negative, but cannot cross midnight)
 OUTPUT
	time - string with AM or PM after it (no space between). This is the
	       format SQL queries want.
 EXAMPLE: 

	IDL> print,filetime2dbtime( '6:08',addminutes=-10)
	5:58AM
	IDL> print,filetime2dbtime( '13:35')
	1:35PM

 MODIFICATION HISTORY:
 	WRITTEN by 27-Nov-2006 Bill Davis

Source: src/idl_cvs/filter_image.pro

 NAME:
       FILTER_IMAGE

 PURPOSE:
       Identical to MEDIAN or SMOOTH but handle edges and allow iterations.
 CATEGORY:
       Image Processing
 EXPLANATION:
       Computes the average and/or median of pixels in moving box,
       replacing center pixel with the computed average and/or median,
               (using the IDL smooth or median functions).
       The main reason for using this function is the option to
       also process the pixels at edges and corners of image, and,
       to apply iterative smoothing simulating convolution with Gaussian,
       and/or to convolve image with a Gaussian kernel.

 CALLING SEQUENCE:
       Result = filter_image( image, SMOOTH=box_width, /MEDIAN, /ALL )

 INPUT:
       image = 2-D array (matrix)

 OPTIONAL INPUT KEYWORDS:
       SMOOTH = scalar (odd) integer specifying the width of a square box 
               for moving average, in # pixels.
       /SMOOTH  means use box width = 3 pixels for smoothing.

       MEDIAN = scalar (odd) integer specifying the width of square moving 
               box for median filter, in # pixels.
       /MEDIAN  means use box width = 3 pixels for median filter.
   
       /ALL_PIXELS causes the edges of image to be filtered as well,
               accomplished by reflecting pixels adjacent to edges outward.

       /ITERATE means apply smooth(image,3) iteratively for a count of
               (box_width-1)/2 times (=radius), when box_width >= 5.
               This is equivalent to convolution with a Gaussian PSF
               of FWHM = 2 * sqrt( radius ) as radius gets large.
               Note that /ALL_PIXELS is automatically applied,
               giving better results in the iteration limit.
               (also, MEDIAN keyword is ignored when /ITER is specified).

       FWHM_GAUSSIAN = Full-width half-max of Gaussian to convolve with image. 
                       FWHM can be a single number (circular beam),
                       or 2 numbers giving axes of elliptical beam.

       /NO_FT_CONVOL causes the convolution to be computed directly,
               with IDL function convol.
               The default is to use FFT when factors of size are all LE 13.
               (note that external function convolve handles both cases)

 RESULT:
       Function returns the smoothed, median filtered, or convolved image.
       If both SMOOTH and MEDIAN are specified, median filter is applied first.

 EXAMPLES:
       To apply 3x3 moving median filter and
       then 3x3 moving average, both applied to all pixels:

               Result = filter_image( image, /SMOOTH, /MEDIAN, /ALL )

       To iteratively apply 3x3 moving average filter for 4 = (9-1)/2 times,
       thus approximating convolution with Gaussian of FWHM = 2*sqrt(4) = 4 :

               Result = filter_image( image, SMOOTH=9, /ITER )

       To convolve all pixels with Gaussian of FWHM = 3.7 x 5.2 pixels:

               Result = filter_image( image, FWHM=[3.7,5.2], /ALL )

 EXTERNAL CALLS:
       function psf_gaussian
       function convolve
       pro factor
       function prime          ;all these called only if FWHM is specified.

 PROCEDURE:
       If /ALL_PIXELS or /ITERATE keywords are set then
       create a larger image by reflecting the edges outward,
       then call the IDL median and/or smooth function on the larger image,
       and just return the central part (the orginal size image).
 HISTORY:
       Written, 1991, Frank Varosi, NASA/GSFC.
       FV, 1992, added /ITERATE option.
       FV, 1993, added FWHM_GAUSSIAN= option.
       Converted to IDL V5.0   W. Landsman   September 1997

Source: src/idl_cvs/findallchar.pro

 NAME:
	findAllChar

 PURPOSE:
	Find all appearances of a character in a scalar string

 CATEGORY:
	Strings

 CALLING SEQUENCE:
	positions = findAllChar( ST, CHAR )

 INPUTS:
	ST  - scalar String 
	CHAR- Character to find

 KEYWORDS
   Optional:
	nFound - # of occurences of CHAR
 EXAMPLE:
	IDL> a = "I call that 'fun'" 
	IDL> print, findAllChar(a, "'")
                12          16

 REVISIONS HISTORY
	Written Bill Davis, July, 2007

Source: src/idl_cvs/findcamfiles.pro

 NAME:
       findcamfiles
 PURPOSE:
       Find camera files in various directories Environmental/System
       variable FC_DATA_DIR will be used, if set, to  look for files
	containing the string in 'filename'  
 CATEGORY:
       Files
 CALLING SEQUENCE:
       IDL> paths = findcamfiles(shotstr)
 INPUTS:
       shotstr = anything, but usually a shot number.  If not present,
                  a dialog box will pop up.
 KEYWORD PARAMETERS:
        dirs - directories to search. If not set, the known NSTX camera  
                directories will be searched.
        defPath - path to find most recent "*.cin" file for default selection
        first - if set, will just return the first match (for speed)
        pick - if set, and more than one match found, will pop a dialog
                box for user to pick one.
        noPick - Do not offer dialog box, even if no file found
        CASE_SENSITIVE - if not set, search will be case insensitive.
        subDirectories - if NOT set, WILL search subdirectories
	 camera - optional input, if you want cameras with file names including "_n_" 
	 SANfaster - if file is on both /p/nstxcamera and /p/nstxcam, just 
		     offer /p/nstxcam
        verbose - if set, will print many informational messages
        debug - if set, debug output will be printed
 OUTPUTS:
       paths = paths of files matching input in directories searched
 EXAMPLE:
        IDL> print, findcamfiles( '*miro*134180' )
        IDL> print, findcamfiles( 142000 )
        IDL> print, findcamfiles( 'nstx_5_139442' )
 NOTES:
 	if file is on both /p/nstxcamera and /p/nstxcam, in 2010, /p/nstxcam 
	was much faster. if this is not true, set keyword SANfaster to 0.
 MODIFICATION HISTORY:
	27-Feb-2013 - don't modify camera input string
	20-Sep-2012  fixed bug when shotstr_in just a shot number 
  	10-Sep-2012 - Account for data to be read via MDSplus at MIT for CMOD.
		      if shot is > 9, no directory info included, and file not
		      if the current directory, then get from tree at MIT
        08-Dec-2011 added camera keyword
	 25-Jul-2011 don't overwrite shotstr input
	 08-Dec-2010 if file is on both /p/nstxcamera and /p/nstxcam, in 2010, 
		     /p/nstxcam was much faster, so just offer it.
        03-Nov-2010 mods for running on a PC or Mac.
        07-Oct-2010 fixed a bug finding old files, when search string not found in last dir
        16-Jul-2010 added ext keyword, and default to "cin*" so .txt files, etc. don't show
        19-Jan-2010 use getcamdirs() so list of NSTX dirs is in one place.
                    Assuming FILE_SEARCH will include subdirectories if 2 arguments used
                    (this didn't always work in some testing)
        14-Jan-2010 if no files in the default directory, back up a year and check
        06-Nov-2009 Default to case-insensitive searches.
        21-Jul-2009 added other areas (this will probably be pretty slow)
        06-Jul-2009 Written by Bill Davis, PPPL

Source: src/idl_cvs/finddisks.pro

 NAME:
       findDisks
 PURPOSE:
      return a list of disks shown in the df command on Linux
 CATEGORY:
       Utility
 CALLING SEQUENCE:
       IDL> opt = findDisks(dfcmd=dfcmd, nskip=nskip, Ignore=Ignore)
 INPUTS:
       none required 
 KEYWORD PARAMETERS:
	dfcmd - command to list disks. Default = 'df'
	nskip - number of lines to skip in df output, Default = 2
	Ignore - disks to ignore. Default to ''
	debug - if set, debug output will be printed
 OUTPUTS:
       opt = string array of disks
 EXAMPLE:
	IDL> print, findDisks( ignore=['/', '/dev/shm']  )
 NOTES:
       Only tested on Linux
 MODIFICATION HISTORY:
       19-Juln-2008 Written by Bill Davis, PPPL

Source: src/idl_cvs/findmdsnodes.pro

 NAME:
        FindMDSNodes
 PURPOSE:
      Search for MDSplus nodes or tags with a name containing a string
 CATEGORY:
       MDSplus, Search, Utiltiy
 CALLING SEQUENCE:
       IDL> paths = FindMDSNodes( nodeString, status=status )
 INPUTS:
       nodeString - string to search nodenames for
 KEYWORD PARAMETERS:
	nonNodeString - exclude nodes in returned array if this string found in name
	tags - if set, just look for nodes with tags, and search tagnames
	Scalars - if=0, then only return nodes with more than one data element
       JustText - if set, just look for Text nodes (no effect if /TAGS set)
	usage - if /TAGS not set, what GETNCI expects 
		(if used, overrides /JustText; DEFAULT: ANY)
	max2find - max # of nodes returned (DEFAULT=10000)
	status - success if true (odd number)
	debug - print some debugging info

  the tree may be opened before this routine is called, or you can specify:
	treeName - MDSplus tree. Default='NSTX' (unless embedded in nodeString)
	shot - MDSplus shot to search. Default=-1 (the model tree).
   returned:
	states - string array containing 'OFF' or 'ON'.
	isSignal - logical array where 1s indicate corresponding node is a signal
	COMPRESS_ON_PUT - logical array
	PARENT_STATE - logical array
	NUMERIC - logical array
	NO_WRITE_MODEL - logical array
	NO_WRITE_SHOT - logical array
 OUTPUTS:
	paths - paths satifying search criteria
 COMMON BLOCKS:
       none
 EXAMPLE:
	IDL> paths = FindMDSNodes( 'ip', status=status, tree='wf', shot=120200 )
	IDL> tags = FindMDSNodes('*', /tags, tree='lrdfit04', shot=117747)
   	    ; exclude some nodes:
	IDL> paths = FindMDSNodes( 'ip',non='formula', tree='wf', shot=120200 ) 
	IDL> paths = FindMDSNodes( 'ip',non=['formula','description'], tree='wf', shot=120200 ) 
    	IDL> p = FindMDSNodes( 'svd', tree='engineering', shot=142039)

 NOTES:
	if tree already open before FindMDSNodes is called, tree & shot need not be set.
	if no records are found in current tree, returns ['']
 LIMITATIONS:
	If connect to VMS, will not get tags from trees on Linux.
 MODIFICATION HISTORY:
	08-Mar-2013 with tree NSTX, must be too many returned when getting all, so use 
		    nodestring in filter.
	04-Oct-2012 try with more stars for searches like from engineering tree with
		    'svd'
	06-May-2010 never check more than 2000 nodes for being a signal (too slow)
	21-Apr-2010 added keyword max2find 
	20-Apr-2010 added keyword isSignal & checkSignals
	08-May-2009 If /tag set and no tree, use getenv('MACHINE'), and if empty, use
		    'nstx'.
       16-Mar-2009 add Sclars keyword
	02-Feb-2009 have to spawn MDSTCL and read it's commands from a file
		    for big results, like searching for '*' in operations.
	19-Jan-2009 don't return names that are blank or have spaces in them
	02-Dec-2008 added STATES keyword to return 'OFF' or 'ON'
	09-Jan-08 fintags.fun not on Linux, so don't use. 
		  nonNodeString can be an array of strings
	22-Nov-06 use MDSTCL for tags on Linux trees. Use mdsopen, instead of
		  openMDSshot, and only if tree not entered
	11-Nov-05 Added keywords for use with new treesearch web page.
	31-Jan-01 Written by Bill Davis, PPPL

Source: src/idl_cvs/findmdstime.pro

 NAME:
       findMDStime
 PURPOSE:
        find a time within an MDSplus shot, correspoding to
	 the time of Max Ip, time of Max W-tot, etc. 
	signals come from the EFIT tree when possible.
 CATEGORY:
       MDSplus
 CALLING SEQUENCE:
       IDL> time = findMDStime( /maxIp )
 INPUTS:
       shotListString - a string indicating shots, 
		e.g., 107694 108305 108330-108350
		 or   108100+20		
			(this returns shots 108100, 108101,...,108120)
       nshots - # of shots to search over (def=10)
 KEYWORD PARAMETERS:
	maxIp - if set, return time of Max Ip (less 3 msec)
	MaxNeutrons - if set, return time of Maximum Neutron production
	MaxBetaN - if set, return time of Beta Normal 
	MaxPTot - if set, return time of maximum heating power
	MaxWMHD - if set, return time of maximum Plasma Stored Energy
	MaxTAUMHD - if set, return time of maximum Energy confinement time
	MaxDENS - if set, return time of maximum Line Density
	shot - if set, will return value for this shot, else for opened shot
 OUTPUTS:
       time in seconds         			
 EXAMPLE:
	IDL> time = findMDStime( /maxIp )
 NOTES:
	if more than one time is found for the max, a median time will be
	returned.
 MODIFICATION HISTORY:
       14-Jun-02 Written by Bill Davis, PPPL

Source: src/idl_cvs/findpeaks.pro

 NAME:
       findpeaks
 PURPOSE:
       Find peaks in a data array. To be a peak a local maximum must have
	a 25% higher range than the first and last quarter of the peak range.
 CATEGORY:
       Data Analysis
 CALLING SEQUENCE:
	IDL> peaks = findpeaks( data )
 INPUTS:
	data - array 
 OUTPUTS:
	peaks - (up to "maxPeaks") values of peaks found. Returns 0 if no
		peaks found.
 KEYWORDS:
   Optional Input:
	maxPeaks - max # of peaks to search for
	AboveFrac - Fraction of peak height that peak must be above the 
		peak "tails" to be counted (default=0.25)
	NeighborhoodFrac - fraction of whole X range to be a neighborhood.
          	Range is initially divided up in these neighborhoods
		for determination of initial maxima.
	HowCloseToMax - if set, will not be considered a peak, if not within
		this fraction of maximum of whole data set.
	OnlyBig - if set will not count peaks 1/3 the size of the biggest peak
	Plot - if set, will plot data with vertical lines indicating which
		peaks qualified.
	Ordered - if set, returns peaks in order of highest first
   Optionally Returned via Keyword:
	indicesOfPeaks - array indices of peaks returned (=-1 if no peaks found)
	FWHM - full width at half max estimate, in indices
 EXAMPLE:
	IDL> data = mk_2peaks()
	IDL> peaks = findpeaks( data, /plot )

	IDL> peaks = findpeaks( data, indicesOfPeaks=indicesOfPeaks )
 COMMON BLOCKS:
       none
 NOTES:
	Maxima too close to the beginning and end of array are not counted.
       You may wish to do filtering or smoothing before passing data.
 LIMITATIONS:
	What constitutes a "peak" is subjective, so this won't fit all needs
 MODIFICATION HISTORY:
	05-Aug-2008 Added HowCloseToMax keyword & many mods for finding Lithium peaks
	08-May-2003 Written by Bill Davis, PPPL

Source: src/idl_cvs/findratz.pro

 NAME:
  	findRatZ

 PURPOSE:
       find the r of desired Z, but on the outer part of curve, if there
	is more than one point that would cross Z=desiredZ. Use spline 
	interpolation.

 CATEGORY:
       2-D Plotting, EFIT

 CALLING SEQUENCE:
	IDL> desiredR = findRatZ( r, z, desiredZ )

 INPUTS:
	r - radius of plasma edge, (can be an array)
	z - Z of plasma edge, (can be an array of same dimension as r)
	desiredZ - Z at which you want R value on the outer edge returned
		   can be

 KEYWORD PARAMETERS:
	inner - if set, will return the inner value rather than the outer
	plot - if set, will plot inputs and results
	test - if set, will restore test values for inputs
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed

  EXAMPLE:
	IDL> desiredR = findRatZ( r, z, desiredZ, /test, /debug, /plot )

  WRITTEN 18-Feb-2010 by Bill Davis

Source: src/idl_cvs/findvalidshots.pro

 NAME:
       findvalidshots
 PURPOSE:
	Search MDS Plus Trees for valid shot numbers with data in a 
	particular node
 
 CATEGORY:
       MDSplus, Utility
 CALLING SEQUENCE:
       IDL> findvalidshots ; This is interactive widget version
 or    IDL> findvalidshots, signal,beginshotnumber,endshotnumber
 
 INPUTS:
       none 
 KEYWORD PARAMETERS:
       none
 OUTPUTS:
       on screen: valid shot numbers in entered range               			
 COMMON BLOCKS:
       none
 EXAMPLE:  IDL>findvalidshots, '\passivespec::vs2.rawdata:spectra',104500,104515

 NOTES:
       
 MODIFICATION HISTORY:
	01-Oct-2008 Removed mdsconnect [BD]
       4-JAN-2001 Written by Dana Mastrovito, PPPL

Source: src/idl_cvs/find_common.pro

Project     : SOHO - CDS     
                   
 Name        : FIND_COMMON()
               
 Purpose     : Find which elements are common to the input vectors.
               
 Explanation : Returns the indices of the elements in second vector which
               are also present in the first vector.
               
 Use         : IDL> c = find_common(first, second)
    
 Inputs      : first  - vector to be searched
               second - search vector
               
 Opt. Inputs : None
               
 Outputs     : Function returns indices of elements in second vector which
               are common to first and second vectors
               
 Opt. Outputs: None
               
 Keywords    : None

 Calls       : FIND_DUP()

 Common      : None
               
 Restrictions: None
               
 Side effects: None
               
 Category    : Util
               
 Prev. Hist. : None

 Written     : C D Pike, RAL, 9-Nov-94
               
 Modified    : Make loop variable LONG.  CDP, 1-Oct-97

 Version     : Version 2, 1-Oct-97

Source: src/idl_cvs/find_font.pro

 NAME:
    FIND_FONT
 Purpose:
    Select a Unix hardware font for IDL graphics.
 Category:
    Utility, Fonts

 Usage:
    myfont = FIND_FONT( /courier, size=24 )
    WIDGET_CONTROL, default_font=myfont

 Input:
    None required.

 Optional Keywords:
    /HELVETICA    Select a Helvetica font (default)
    /TIMES        Select a Times font
    /PALATINO     Select a Palatino font
    /COURIER      Select a Courier font
    /BOLD         Select a bold font (default is no bold)
    /ITALIC       Select and italic font (default is no italics)
    SIZE          If set to a named variable, sets the font size (default=12)
    NAME          If set to a named variable, returns the font name selected

 Revised:
    04-Oct-02 Return a font, so can set in a widget program [BD]
    17-OCT-1997 Liam Gumley, CIMSS/SSEC
    		Created

 Example:
    myfont = FIND_FONT( /courier, size=24 )
    WIDGET_CONTROL, default_font=myfont

Source: src/idl_cvs/firstsigname.pro

 NAME:
       firstSigName
 PURPOSE:
       Return the first signal name in a TDI expression.
	Needed when you want the xaxis from a combination of signals.
 CATEGORY:
       MDSplus
 CALLING SEQUENCE:
	sig1 = firstSigName( TDIexpr )
 INPUTS:
   	TDIexpr - TDI expression. Can be just a signal name, or '(\ip1+\ip2)/2'
 RETURNED:
	sig1 - first signal name in TDI expr, e.g., '\ip1'
 KEYWORDS:
    Optional Outputs:
	FOUNDTDI - 1 returned if TDI in node
	DIMENSION - if root node is 2-D, but expression limits to 1.
	SECOND - the second signame name in the expression, if any (else '')
    Optional Inputs:
	DATA = if set, return everything from DATA to ']', if present, or
	       to ')'
 COMMON BLOCKS:
       none
 EXAMPLE:
 	IDL> print, firstSigName( '\engineering::ip1+\engineering::ip2' )
	   \engineering::ip1
 LIMITATIONS:
	probably won't return proper dimension when DATA() is within a TDI function, 
	like BCSMOOTH( data( \camera:image, 1) )
 MODIFICATION HISTORY:
	31-Aug-2007 added keyword SECOND
	19-Jun-2007 ONLY return dimension number from syntax like ",1" if 
		    MAXVAL, MINVAL or DATA (others can be included here).
	06-Apr-2007 Added data and dimension keywords 
  		    to handle style of maxval(\efit01::pisrz,1) and 
		    data(\efit01::pisrz)[10,*] )
	01-May-01 Written by Bill Davis

Source: src/idl_cvs/fitsrun.pro

 NAME:
       FITSRUN
 PURPOSE:
       Quickly tell which EFITs and LRDFITs exist for an MDSplus shot
 CATEGORY:
       MDSplus
 CALLING SEQUENCE:
       IDL> fits=fitsrun(shot)
 INPUTS:
       shot - NSTX shot number 
 KEYWORD PARAMETERS:
       maxefits= MAX efits to check 
       maxlrdfits - max lrdfits to check
       quiet - if set to 0, will tell you about each open
       realquiet - if set to 0, will tell you about failed opens
	needSig - a node that you need in the tree to use that tree
		DEFAULT='\CODE_VERSION'
 OUTPUTS:
       fits - string array like  ['EFIT01', 'EFIT03', 'LRDFIT04']
 EXAMPLE:
	IDL> print,fitsrun(117707, maxefits=5, maxlrdfits=5)
	EFIT01 EFIT02 EFIT03 EFIT04 EFIT05 LRDFIT04

	IDL> for i=122440,123244 do print, i,' ',fitsrun(i,loadfit='EFIT03')

	IDL> fits = fitsrun( 130000, run_by=user, /noLoad )

	IDL> fits = fitsrun( 129125, run_by=run_by, comments=comments, $
	                     code_version=code_version, date_run=date_run )
 NOTES:
       When the routine is called with no parameters, 
	help information is printed.
 MODIFICATION HISTORY:
	11-Dec-2012 don't let comments be integer (0)
	17-Aug-2010 added needSig keyword
  	22-Jun-2010 added comments, code_version, and date_run keywords [BD]
	02-Feb-2010 Added noLoad & run_by keywords
	25-May-2007 Just look in EFIT tree for all possible subtrees
	12-Apr-2007 Option to load fits into code_rundb database (for efitviewer)
       07-Mar-2006 Written by Bill Davis, PPPL

Source: src/idl_cvs/fluxcoords.pro

 NAME:
       fluxcoords
 PURPOSE:
       Return flux coordinates for input R values at a given Z
 CATEGORY:
       Physics, Plotting
 CALLING SEQUENCE:
       IDL> newXs = fluxcoords( shot=shot, time=time, Radius=Radius, z=z )
 INPUTS:
       (only keywords) 
 KEYWORD PARAMETERS:
   Inputs
     Required:
	shot - NSTX shot number
	time - time after T0, in seconds
	Radius - floating point array of major radii, in meters
     Optional:
	Z - Z value (above mid-plane) in meters (default = 0), scalar or dimensioned 
	    same as Radius.
	fit - E.g., 'EFIT01', EFIT02', 'LRDFIT04', etc. (defaults to 'EFIT01')
	psi_n - if set, will return on psi_n surfaces
	verbose - if set, will print many informational messages
   Outputs
	newXs - transformed input points to rho or psi_n, depending on keyword inputs
	status - if odd, then was successful
 OUTPUTS:
       opt = returned value                                    out
 COMMON BLOCKS:
       NONE
 EXAMPLE:
       IDL> Radius=findgen(10)/10.*.30+1.50
       IDL> newXs = fluxcoords( shot=121100, time=0.205, Radius=Radius, fit='EFIT01') 
       IDL> newXs = fluxcoords( shot=120440, time=0.206, Radius=Radius, z=0.5, fit='lrdfit09') 
 NOTES:
       Slow 1st time called for each new time. Especially slow for LRDFIT trees because 
	need to an MDSCONNECT to VMS, for some reason, for this to work.
       
 MODIFICATION HISTORY:
	01-Oct-2008 Removed mdsconnect [BD]
       22-Feb-2007 Written by Bill Davis, PPPL, using LOTS of code from Jon Menard

Source: src/idl_cvs/followcontour.pro

 NAME:
	followcontour 

 PURPOSE:
	Follow a contour line to find where it intersects a desired Y and
	return the X value. I.e., where the 2D input array has the same value as
	at specified coordinates. This is used to find the R value at Z=0 with
	the same Psi value as a specified point on the flux surface. So, it can
	be used for plotting things in relation to flux surfaces.
	
 CATEGORY:
       2-D Plotting, Normalized Psi

 CALLING SEQUENCE:
       IDL> xWant = followcontour( data2d [, x, y], xpt=xpt, ypt=ypt [, yWant=yWant])

 INPUTS:
	data2d - 2D array, e.g., flux values
	x - X values (defaults to indices)
	y - Y values (defaults to indices)	 
	xpt - X value at which to get flux (will linearly interpolate)
	ypt - Y value at which to get flux (will linearly interpolate)	 
	yWant - Y value at which to determine X with same flux value [Def=0]
     
 KEYWORD PARAMETERS:
	outer - if set will return largest value, else will return all
		(closed contours may intersect a constant Y line in two,
		 or more, locations)
	inner - if set will return smallest value, else will retrun all
	level - contour/value you want to follow (else determined by xpt & ypt)
	exact - if set will interpolate to get level, rather than use nearest data pt
	plot - if set will plot contours and input point and found point
	_extra - passed to the contour routine
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed

 OUTPUTS:
	xWant - X value where Y=yWant and data2D has same value as at [xpt,ypt]
		(finds the nearest point)

 EXAMPLE:
	IDL> restore, '/u/bdavis/contfollowtest.sav'
	IDL> xWant = followcontour( data2d, x, y, xpt=xpt, ypt=ypt, /plot )

		; where psiRZ, R, Z are from EFIT/LRDfit at a particular time:
	IDL> RatZ0 = followContour( psiRZ, R, Z, xpt=Rwant, ypt=Zwant, $
                                   yWant=0.0, /OUTER, /EXACT )
  19-Nov-2010 added SAME keyword for speed when looking up a lot of points
  WRITTEN 15-Feb-2010 by Bill Davis

Source: src/idl_cvs/foundsubtree.pro

 NAME:
       foundsubtree
 PURPOSE:
       determine if sub trees like efit05, lrdfit06, etc. exist
 CATEGORY:
       MDSplus
 CALLING SEQUENCE:
       IDL> found = foundSubTree( shot=shot, tree=tree, index=index)
 INPUTS:
       none but keywords 
 KEYWORD PARAMETERS:
	shot - MDSplus shot/pulse number
	tree - main fit tree, e.g., 'EFIT' or 'LRDFIT'
	index - "subtree" version number, 5 would get you 'EFIT05' or 'LRDFIT05'
	SERVER - MDS server (default is skylark.pppl.gov:8501 for NSTX)
    RETURNED:
	status - MDS status from open if failed, else from mdsvalue
 OUTPUTS:
       found - 1 if found, 0 if not found.
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> print, foundsubtree(shot=117449, tree='efit', index=2 )

 MODIFICATION HISTORY:
       26-Jun-2006 Written by Bill Davis, PPPL

Source: src/idl_cvs/fromidlseconds.pro

 NAME:
	fromidlseconds
       
 PURPOSE:
       Convert from IDL-syle time (output from SYSTIME(1),
	to form of '06/14/2004 11:04:52'
 CATEGORY:
	Dates
 CALLING SEQUENCE:
       date_time = fromIdlSeconds( secondsSince )
 INPUTS:
	secondsSince - seconds since 1/1/1970
 KEYWORD PARAMETERS:
	monthString - if set, return dateString as 1-Jan-1970
    optional output:
	datestr - just the date string
 OUTPUTS:
	date_time - string line  '06/14/2004 11:04:52' (no double quotes!)
       
 NOTES:

 EXAMPLE: 
	IDL> print,fromIdlSeconds(1129295443)
	10/14/2005 09:28:10

 MODIFICATION HISTORY:
 	WRITTEN 27-Mar-2009 by Bill Davis

Source: src/idl_cvs/fromidltime.pro

 NAME:
	fromidltime
       
 PURPOSE:
       Convert from IDL-syle time (output from SYSTIME(0),
	to form of '06/14/2004 11:04:52'
 CATEGORY:
	Dates
 CALLING SEQUENCE:
       date_time = fromidlTIME( idldatetime )
 INPUTS:
       idldatetime - like Fri Oct 14 09:28:10 2005 (DEFAULTS to now)
 KEYWORD PARAMETERS:
	monthString - if set, return dateString as 1-Jan-1970
    optional output:
	secondsSince - seconds since 1/1/1970
	datestr - just the date string
 OUTPUTS:
	date_time - string line  '06/14/2004 11:04:52' (no double quotes!)
       
 NOTES:

 EXAMPLE: 
	IDL> print,fromidltime('Fri Oct 14 09:28:10 2005')
	10/14/2005 09:28:10

 MODIFICATION HISTORY:

	12-Feb-2008 added secondsSince and monthString keywords
 	WRITTEN 14-Oct-2005 by Bill Davis

Source: src/idl_cvs/fsc_color.pro

 NAME:
       FSC_COLOR

 PURPOSE:

       The purpose of this function is to obtain drawing colors
       by name and in a device/decomposition independent way.
       The color names and values may be read in as a file, or 192 color
       names and values are supplied with the program. These colors were
       obtained from the file rgb.txt, found on most X-Window distributions,
       and from colors in the Brewer color tables (http://colorbrewer2.org/).
       Representative colors were chosen from across the color spectrum. To
       see a list of colors available, type:

          Print, FSC_Color(/Names), Format='(6A18)'
          
        If the color names '0', '1', '2', ..., '255' are used, they will
        correspond to the colors in the current color table in effect at
        the time the FSC_Color program is called.

 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

 CATEGORY:

       Graphics, Color Specification.

 CALLING SEQUENCE:

       color = FSC_Color(theColor, theColorIndex)

 NORMAL CALLING SEQUENCE FOR DEVICE-INDEPENDENT COLOR:

       If you write your graphics code *exactly* as it is written below, then
       the same code will work in all graphics devices I have tested.
       These include the PRINTER, PS, and Z devices, as well as X, WIN, and MAC.

       In practice, graphics code is seldom written like this. (For a variety of
       reasons, but laziness is high on the list.) So I have made the
       program reasonably tolerant of poor programming practices. I just
       point this out as a place you might return to before you write me
       a nice note saying my program "doesn't work". :-)

       axisColor = FSC_Color("Green", !D.Table_Size-2)
       backColor = FSC_Color("Charcoal", !D.Table_Size-3)
       dataColor = FSC_Color("Yellow", !D.Table_Size-4)
       thisDevice = !D.Name
       Set_Plot, 'toWhateverYourDeviceIsGoingToBe', /Copy
       Device, .... ; Whatever you need here to set things up properly.
       IF (!D.Flags AND 256) EQ 0 THEN $
         POLYFILL, [0,1,1,0,0], [0,0,1,1,0], /Normal, Color=backColor
       Plot, Findgen(11), Color=axisColor, Background=backColor, /NoData, $
          NoErase= ((!D.Flags AND 256) EQ 0)
       OPlot, Findgen(11), Color=dataColor
       Device, .... ; Whatever you need here to wrap things up properly.
       Set_Plot, thisDevice

 OPTIONAL INPUT PARAMETERS:

       theColor: A string with the "name" of the color. To see a list
           of the color names available set the NAMES keyword. This may
           also be a vector of color names. Colors available are these:

           Active            Almond     Antique White        Aquamarine             Beige            Bisque
             Black              Blue       Blue Violet             Brown         Burlywood        Cadet Blue
          Charcoal        Chartreuse         Chocolate             Coral   Cornflower Blue          Cornsilk
           Crimson              Cyan    Dark Goldenrod         Dark Gray        Dark Green        Dark Khaki
       Dark Orchid          Dark Red       Dark Salmon   Dark Slate Blue         Deep Pink       Dodger Blue
              Edge              Face         Firebrick      Forest Green             Frame              Gold
         Goldenrod              Gray             Green      Green Yellow         Highlight          Honeydew
          Hot Pink        Indian Red             Ivory             Khaki          Lavender        Lawn Green
       Light Coral        Light Cyan        Light Gray      Light Salmon   Light Sea Green      Light Yellow
        Lime Green             Linen           Magenta            Maroon       Medium Gray     Medium Orchid
          Moccasin              Navy             Olive        Olive Drab            Orange        Orange Red
            Orchid    Pale Goldenrod        Pale Green            Papaya              Peru              Pink
              Plum       Powder Blue            Purple               Red              Rose        Rosy Brown
        Royal Blue      Saddle Brown            Salmon       Sandy Brown         Sea Green          Seashell
          Selected            Shadow            Sienna          Sky Blue        Slate Blue        Slate Gray
              Snow      Spring Green        Steel Blue               Tan              Teal              Text
           Thistle            Tomato         Turquoise            Violet        Violet Red             Wheat
             White            Yellow

           The color OPPOSITE is used if this parameter is absent or a color name is mis-spelled. To see a list
           of the color names available in the program, type this:

              IDL> Print, FSC_Color(/Names), Format='(6A18)'

       theColorIndex: The color table index (or vector of indices the same length
           as the color name vector) where the specified color is loaded. The color table
           index parameter should always be used if you wish to obtain a color value in a
           color-decomposition-independent way in your code. See the NORMAL CALLING
           SEQUENCE for details. If theColor is a vector, and theColorIndex is a scalar,
           then the colors will be loaded starting at theColorIndex.

        When the BREWER keyword is set, you must use more arbitrary and less descriptive color
        names. To see a list of those names, use the command above with the BREWER keyword set,
        or call PICKCOLORNAME with the BREWER keyword set:

               IDL> Print, FSC_Color(/Names, /BREWER), Format='(8A10)'
               IDL> color = PickColorName(/BREWER)

         Here are the Brewer names:

       WT1       WT2       WT3       WT4       WT5       WT6       WT7       WT8
      TAN1      TAN2      TAN3      TAN4      TAN5      TAN6      TAN7      TAN8
      BLK1      BLK2      BLK3      BLK4      BLK5      BLK6      BLK7      BLK8
      GRN1      GRN2      GRN3      GRN4      GRN5      GRN6      GRN7      GRN8
      BLU1      BLU2      BLU3      BLU4      BLU5      BLU6      BLU7      BLU8
      ORG1      ORG2      ORG3      ORG4      ORG5      ORG6      ORG7      ORG8
      RED1      RED2      RED3      RED4      RED5      RED6      RED7      RED8
      PUR1      PUR2      PUR3      PUR4      PUR5      PUR6      PUR7      PUR8
      PBG1      PBG2      PBG3      PBG4      PBG5      PBG6      PBG7      PBG8
      YGB1      YGB2      YGB3      YGB4      YGB5      YGB6      YGB7      YGB8
      RYB1      RYB2      RYB3      RYB4      RYB5      RYB6      RYB7      RYB8
       TG1       TG2       TG3       TG4       TG5       TG6       TG7       TG8

       As of 3 July 2008, the Brewer names are also now available to the user without using 
       the BREWER keyword. If the BREWER keyword is used, *only* Brewer names are available.
       
       The color name "OPPOSITE" is also available. It chooses a color "opposite" to the 
       color of the pixel in the upper-right corner of the display, if a window is open.
       Otherwise, this color is "black" in PostScript and "white" everywhere else.
       
 RETURN VALUE:

       The value that is returned by FSC_Color depends upon the keywords
       used to call it, on the version of IDL you are using,and on the depth
       of the display device when the program is invoked. In general,
       the return value will be either a color index number where the specified
       color is loaded by the program, or a 24-bit color value that can be
       decomposed into the specified color on true-color systems. (Or a vector
       of such numbers.)

       If you are running IDL 5.2 or higher, the program will determine which
       return value to use, based on the color decomposition state at the time
       the program is called. If you are running a version of IDL before IDL 5.2,
       then the program will return the color index number. This behavior can
       be overruled in all versions of IDL by setting the DECOMPOSED keyword.
       If this keyword is 0, the program always returns a color index number. If
       the keyword is 1, the program always returns a 24-bit color value.

       If the TRIPLE keyword is set, the program always returns the color triple,
       no matter what the current decomposition state or the value of the DECOMPOSED
       keyword. Normally, the color triple is returned as a 1 by 3 column vector.
       This is appropriate for loading into a color index with TVLCT:

          IDL> TVLCT, FSC_Color('Yellow', /Triple), !P.Color

       But sometimes (e.g, in object graphics applications) you want the color
       returned as a row vector. In this case, you should set the ROW keyword
       as well as the TRIPLE keyword:

          viewobj= Obj_New('IDLgrView', Color=FSC_Color('charcoal', /Triple, /Row))

       If the ALLCOLORS keyword is used, then instead of a single value, modified
       as described above, then all the color values are returned in an array. In
       other words, the return value will be either an NCOLORS-element vector of color
       table index numbers, an NCOLORS-element vector of 24-bit color values, or
       an NCOLORS-by-3 array of color triples.

       If the NAMES keyword is set, the program returns a vector of
       color names known to the program.

       If the color index parameter is not used, and a 24-bit value is not being
       returned, then colorIndex is typically set to !D.Table_Size-1. However,
       this behavior is changed on 8-bit devices (e.g., the PostScript device,
       or the Z-graphics buffer) and on 24-bit devices that are *not* using
       decomposed color. On these devices, the colors are loaded at an
       offset of !D.Table_Size - ncolors - 2, and the color index parameter reflects
       the actual index of the color where it will be loaded. This makes it possible
       to use a formulation as below:

          Plot, data, Color=FSC_Color('Dodger Blue')

       on 24-bit displays *and* in PostScript output! Note that if you specify a color
       index (the safest thing to do), then it will always be honored.

 INPUT KEYWORD PARAMETERS:

       ALLCOLORS: Set this keyword to return indices, or 24-bit values, or color
              triples, for all the known colors, instead of for a single color.

       BREWER: Set this keyword if you wish to use the Brewer Colors, as defined
              in this reference:

              http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_intro.html
              
              As of 3 July 2008, the BREWER names are always available to the user, with or
              without this keyword. If the keyword is used, only BREWER names are available.

       DECOMPOSED: Set this keyword to 0 or 1 to force the return value to be
              a color table index or a 24-bit color value, respectively.

       CHECK_CONNECTION: If this keyword is set, the program will check to see if it can obtain
              a window connection before it tries to load system colors (which require one). If you
              think you might be using FSC_COLOR in a cron job, for example, you would want to set this
              keyword. If there is no window connection, the system colors are not available from the program.
              As of 18 October 2010, this keyword is no longer used, as system colors have been
              removed from the program.

       FILENAME: The string name of an ASCII file that can be opened to read in
              color values and color names. There should be one color per row
              in the file. Please be sure there are no blank lines in the file.
              The format of each row should be:

                  redValue  greenValue  blueValue  colorName

              Color values should be between 0 and 255. Any kind of white-space
              separation (blank characters, commas, or tabs) are allowed. The color
              name should be a string, but it should NOT be in quotes. A typical
              entry into the file would look like this:

                  255   255   0   Yellow

       NAMES: If this keyword is set, the return value of the function is
              a ncolors-element string array containing the names of the colors.
              These names would be appropriate, for example, in building
              a list widget with the names of the colors. If the NAMES
              keyword is set, the COLOR and INDEX parameters are ignored.

                 listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16)       NODISPLAY: Normally, FSC_COLOR loads "system" colors as part of its palette of colors.
              In order to do so, it has to create an IDL widget, which in turn has to make
              a connection to the windowing system. If your program is being run without a 
              window connection, then this program will fail. If you can live without the system 
              colors (and most people don't even know they are there, to tell you the truth), 
              then setting this keyword will keep them from being loaded, and you can run
              FSC_COLOR without a display. THIS KEYWORD NOW DEPRECIATED IN FAVOR OF CHECK_CONNECTION.
              As of 18 October 2010, this keyword is no longer used, as system colors have been
              removed from the program.

       ROW:   If this keyword is set, the return value of the function when the TRIPLE
              keyword is set is returned as a row vector, rather than as the default
              column vector. This is required, for example, when you are trying to
              use the return value to set the color for object graphics objects. This
              keyword is completely ignored, except when used in combination with the
              TRIPLE keyword.

       SELECTCOLOR: Set this keyword if you would like to select the color name with
              the PICKCOLORNAME program. Selecting this keyword automaticallys sets
              the INDEX positional parameter. If this keyword is used, any keywords
              appropriate for PICKCOLORNAME can also be used. If this keyword is used,
              the first positional parameter can be a color name that will appear in
              the SelectColor box.

       TRIPLE: Setting this keyword will force the return value of the function to
              *always* be a color triple, regardless of color decomposition state or
              visual depth of the machine. The value will be a three-element column
              vector unless the ROW keyword is also set.

       In addition, any keyword parameter appropriate for PICKCOLORNAME can be used.
       These include BOTTOM, COLUMNS, GROUP_LEADER, INDEX, and TITLE.

 OUTPUT KEYWORD PARAMETERS:

       CANCEL: This keyword is always set to 0, unless that SELECTCOLOR keyword is used.
              Then it will correspond to the value of the CANCEL output keyword in PICKCOLORNAME.

       COLORSTRUCTURE: This output keyword (if set to a named variable) will return a
              structure in which the fields will be the known color names (without spaces)
              and the values of the fields will be either color table index numbers or
              24-bit color values. If you have specified a vector of color names, then
              this will be a structure containing just those color names as fields.

       NCOLORS: The number of colors recognized by the program. It will be 104 by default.

 COMMON BLOCKS:
       None.

 SIDE EFFECTS:
       None.

 RESTRICTIONS:

   Required programs from the Coyote Library:

      http://www.dfanning.com/programs/error_message.pro
      http://www.dfanning.com/programs/pickcolorname.pro
      http://www.dfanning.com/programs/decomposedcolor.pro

 EXAMPLE:

       To get drawing colors in a device-decomposed independent way:

           axisColor = FSC_Color("Green", !D.Table_Size-2)
           backColor = FSC_Color("Charcoal", !D.Table_Size-3)
           dataColor = FSC_Color("Yellow", !D.Table_Size-4)
           Plot, Findgen(11), Color=axisColor, Background=backColor, /NoData
           OPlot, Findgen(11), Color=dataColor

       To set the viewport color in object graphics:

           theView = Obj_New('IDLgrView', Color=FSC_Color('Charcoal', /Triple))

       To change the viewport color later:

           theView->SetProperty, Color=FSC_Color('Antique White', /Triple)

       To load the drawing colors "red", "green", and "yellow" at indices 100-102, type this:

           IDL> TVLCT, FSC_Color(["red", "green", and "yellow"], /Triple), 100

 MODIFICATION HISTORY:

       Written by: David W. Fanning, 19 October 2000. Based on previous
          GetColor program.
       Fixed a problem with loading colors with TVLCT on a PRINTER device. 13 Mar 2001. DWF.
       Added the ROW keyword. 30 March 2001. DWF.
       Added the PICKCOLORNAME code to the file, since I keep forgetting to
          give it to people. 15 August 2001. DWF.
       Added ability to specify color names and indices as vectors. 5 Nov 2002. DWF.
       Fixed a problem with the TRIPLE keyword when specifying a vector of color names. 14 Feb 2003. DWF.
       Fixed a small problem with the starting index when specifying ALLCOLORS. 24 March 2003. DWF.
       Added system color names. 23 Jan 2004. DWF
       Added work-around for WHERE function "feature" when theColor is a one-element array. 22 July 2004. DWF.
       Added support for 8-bit graphics devices when color index is not specified. 25 August 2004. DWF.
       Fixed a small problem with creating color structure when ALLCOLORS keyword is set. 26 August 2004. DWF.
       Extended the color index fix for 8-bit graphics devices on 25 August 2004 to
         24-bit devices running with color decomposition OFF. I've concluded most of
         the people using IDL don't have any idea how color works, so I am trying to
         make it VERY simple, and yet still maintain the power of this program. So now,
         in general, for most simple plots, you don't have to use the colorindex parameter
         and you still have a very good chance of getting what you expect in a device-independent
         manner. Of course, it would be *nice* if you could use that 24-bit display you paid
         all that money for, but I understand your reluctance. :-)   11 October 2004. DWF.
       Have renamed the first positional parameter so that this variable doesn't change
         while the program is running. 7 December 2004. DWF.
       Fixed an error I introduced on 7 December 2004. Sigh... 7 January 2005. DWF.
       Added eight new colors. Total now of 104 colors. 11 August 2005. DWF.
       Modified GUI to display system colors and removed PickColorName code. 13 Dec 2005. DWF.
       Fixed a problem with colorIndex when SELECTCOLOR keyword was used. 13 Dec 2005. DWF.
       Fixed a problem with color name synonyms. 19 May 2006. DWF.
       The previous fix broke the ability to specify several colors at once. Fixed. 24 July 2006. DWF.
       Updated program to work with 24-bit Z-buffer in IDL 6.4. 11 June 2007. DWF
       Added the CRONJOB keyword. 07 Feb 2008. DWF.
       Changed the CRONJOB keyword to NODISPLAY to better reflect its purpose. 7 FEB 2008. DWF.
       Added the BREWER keyword to allow selection of Brewer Colors. 15 MAY 2008. DWF.
       Added the CHECK_CONNECTION keyword and depreciated the NODISPLAY keyword for cron jobs. 15 MAY 2008. DWF.
       Added the BREWER names to the program with or without the BREWER keyword set. 3 JULY 2008. DWF.
       If color names '0', '1', '2', ..., '255', are used, the colors are taken from the current
          color table in effect when the program is called. 23 March 2009. DWF.
       Added the ability to use 24-bit PostScript color, if available. 24 May 2009. DWF.
       Program relies on DecomposedColor() to determine decomposed state of PostScript device. 24 May 2009. DWF.
       Mis-spelled variable name prevented color structure from being returned by COLORSTRUCTURE keyword. 14 Oct 2009. DWF.
       The Z-buffer, after IDL 6.4, appears to be brain dead. It is *always* in DECOMPOSED=1
           mode, even when using an 8-bit graphics buffer. (Unless set manaually.) Now I set
           the decomposition mode in the program by looking at buffer depth, rather than
           the decomposition state, for the Z-buffer. 23 July 2010. DWF.
       Adding "system" colors to FSC_Color may have been the worst design decision I ever made.
            Since these require a window connection to determine, this decision has haunted
            me for years in the form of people wanting to use the software in places where
            there is no window connection. For example, in cron jobs. To accommodate legacy
            code, I need to *always* check for a connection. I am loath to do this because it
            means opening and closing a window, which is, relatively speaking, a slow process.
            I've made another attempt to solve this problem with this update and the
            corresponding update to the Coyote Library program CanConnect. CanConnect how
            creates the system variable !FSC_Display_Connection. If this system variable 
            exists, FSC_Color consults it to determine if there is a display connection. It
            it doesn't exist, it calls CanConnect. This way, a window has to be open only
            once in an IDL session to determine if a display connection can be made. 7 Oct 2010. DWF.
       I am tired of dealing with "system" colors. I've never used them, no one I know
            has ever used them, and they have given me nothing but headaches. I'm done
            with them. I'll leave the code here for awhile in case you use them, but
            I'm pretty sure I'm not putting them back in. 17 October 2010. DWF.
       Added a new color name "OPPOSITE". This is a color that is "opposite" of the pixel color
            in the upper right hand corner of the display, if a window is open and the pixel
            color can be determined. Otherwise, it is black in PostScript and white everywhere
            else. 19 Nov 2010. DWF.
       Made sure the ColorIndex that is returned is always an INTEGER. 24 Dec 2010. DWF.
       Changed the default "unknown" color from WHITE to OPPOSITE. 30 Dec 2010. DWF.
       TVLCT commands protected from NULL device. 4 Jan 2011. DWF.

Source: src/idl_cvs/fsc_colorbar.pro

 NAME:
   FSC_COLORBAR
   
      Note: The name of the routine has been changed from COLORBAR
      on 25 Sept 2010 to avoid conflicts with an IDL 8.0 routine of the
      same name. See the article "IDL 8 Name Conflicts" here:
       
           http://www.dfanning.com/ng_tips/idl8_name_conflicts.html

 PURPOSE:

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

 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/

 CATEGORY:

       Graphics, Widgets.

 CALLING SEQUENCE:

       FSC_COLORBAR

 INPUTS:

       None.

 KEYWORD PARAMETERS:

       ADDCMD:       Set this keyword to add the FSC_Colorbar command to the current FSC_Window
                     command list. 
               
       ANNOTATECOLOR: The name of the "annotation color" to use. The names are those for
                     FSC_COLOR, and using the keyword implies that FSC_COLOR is also in
                     your !PATH. If this keyword is used, the annotation color is loaded
                     *after* the color bar is displayed. The color will be represented
                     as theColor = FSC_COLOR(ANNOTATECOLOR). This keyword is provide
                     to maintain backward compatibility, but also to solve the problem of
                     an extra line in the color bar when this kind of syntax is used in
                     conjunction with the indexed (DEVICE, DECOMPOSED=0) model is used:

                          LoadCT, 33
                          TVImage, image
                          FSC_Colorbar, Color=FSC_Color('firebrick')

                     The proper syntax for device-independent color is like this:

                          LoadCT, 33
                          TVImage, image
                          FSC_Colorbar, AnnotateColor='firebrick', Color=255
                          
                    Set the Modification History note for 13 November 2010 for additional
                    information about default values.

       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 !P.Charsize.
       
       CLAMP:        A two-element array in data units. The color bar is clamped to these
                     two values. This is mostly of interest if you are "window-leveling"
                     an image. The clamp is set to the "window" of the color bar.
                     Normally, when you are doing this, you would like the colors outside
                     the "window" to be set to a neutral color. Use the NEUTRALINDEX keyword
                     to set the netural color index in the color bar. (See the Example section
                     for more information.

       COLOR:        The color index of the bar outline and characters. Default
                     is !P.Color. To display the color bar in a device indpendent
                     way, you should use the ANNOTATECOLOR keyword instead of this keyword.
                     If this keyword is a string color name, then ANNOTATECOLOR=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 '(I0)'.

       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.
       
       NEUTRALINDEX: This is the color index to use for color bar values outside the
                     clamping range when clamping the color bar with the CLAMP keyword.
                     If this keyword is absent, the highest color table value is used
                     for low range values and the lowest color table value is used
                     for high range values, in order to provide contrast with the
                     clamped region. See the Example section for more information.

       NODISPLAY:    FSC_COLORBAR uses FSC_COLOR to specify some of it colors. Normally, 
                     FSC_COLOR loads "system" colors as part of its palette of colors.
                     In order to do so, it has to create an IDL widget, which in turn 
                     has to make a connection to the windowing system. If your program 
                     is being run without a window connection, then this program will 
                     fail. If you can live without the system colors (and most people 
                     don't even know they are there, to tell you the truth), then setting 
                     this keyword will keep them from being loaded, and you can run
                     FSC_COLORBAR without a display. As of 19 Oct 2010, set to 1  by default.

       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.

       REVERSE:      Setting this keyword reverses the colors in the colorbar.

       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.
                     
       WINDOW:       Set this keyword if you want to add the FSC_Colorbar command to
                     the current FSC_Window application.

 COMMON BLOCKS:

       None.

 SIDE EFFECTS:

       Color bar is drawn in the current graphics window.

 RESTRICTIONS:

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

       Requires the FSC_COLOR program from the Coyote Library:

          http://www.dfanning.com/programs/fsc_color.pro

 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
       FSC_COLORBAR, NCOLORS=100, POSITION=[0.15, 0.85, 0.95, 0.90]
       
       Example using the CLAMP and NEUTRALINDEX keywords.
       
       LOADCT, 33, NCOLORS=254
       TVLCT, FSC_COLOR('gray', /TRIPLE), 255
       FSC_COLORBAR, NCOLORS=254, NEUTRALINDEX=255, RANGE=[0,1500], $
           DIVISIONS=8, CLAMP=[400, 800]

 MODIFICATION HISTORY:

       Written by: David W. Fanning, 10 JUNE 96.
       10/27/96: Added the ability to send output to PostScript. DWF
       11/4/96: Substantially rewritten to go to screen or PostScript
           file without having to know much about the PostScript device
           or even what the current graphics device is. DWF
       1/27/97: Added the RIGHT and TOP keywords. Also modified the
            way the TITLE keyword works. DWF
       7/15/97: Fixed a problem some machines have with plots that have
            no valid data range in them. DWF
       12/5/98: Fixed a problem in how the colorbar image is created that
            seemed to tickle a bug in some versions of IDL. DWF.
       1/12/99: Fixed a problem caused by RSI fixing a bug in IDL 5.2. Sigh... DWF.
       3/30/99: Modified a few of the defaults. DWF.
       3/30/99: Used NORMAL rather than DEVICE coords for positioning bar. DWF.
       3/30/99: Added the RANGE keyword. DWF.
       3/30/99: Added FONT keyword. DWF
       5/6/99: Many modifications to defaults. DWF.
       5/6/99: Removed PSCOLOR keyword. DWF.
       5/6/99: Improved error handling on position coordinates. DWF.
       5/6/99. Added MINOR keyword. DWF.
       5/6/99: Set Device, Decomposed=0 if necessary. DWF.
       2/9/99: Fixed a problem caused by setting BOTTOM keyword, but not NCOLORS. DWF.
       8/17/99. Fixed a problem with ambiguous MIN and MINOR keywords. DWF
       8/25/99. I think I *finally* got the BOTTOM/NCOLORS thing sorted out. :-( DWF.
       10/10/99. Modified the program so that current plot and map coordinates are
            saved and restored after the colorbar is drawn. DWF.
       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.
       9/29/05. Added REVERSE keywords, which does the *exact* same thing as
           INVERTCOLORS, but I can never remember the latter keyword name. DWF.
       1/2/07. Added ANNOTATECOLOR keyword. DWF.
       4/14/07. Changed the default FORMAT to I0. DWF.
       5/1/07. Unexpected consequence of default format change is colorbar annotations
           no longer match contour plot levels. Changed to explicit formating of
           colorbar axis labels before PLOT command. DWF.
       5/25/07. Previous change has unanticipated effect on color bars using
           logarithmic scaling, which is not really supported, but I have an
           article on my web page describing how to do it: http://www.dfanning.com/graphics_tips/logcb.html.
           Thus, I've fixed the program to accommodate log scaling, while still not OFFICIALLY
           supporting it. DWF.
       10/3/07. Method used to calculate TICKNAMES produces incorrect values in certain cases when
           the min and max range values are integers. Now force range values to be floats. DWF.
       10/17/07. Accidentaly use of INTERP keyword in CONGRID results in wrong bar values for
           low NCOLORS numbers when INVERTCOLORS or REVERSE keyword is used. Removed INTERP keyword. DWF.
       11/10/07. Finished fixing program to accommodate log scaling in ALL possible permutations. DWF.
       8 Feb 2008. Added CRONJOB keyword and decided to use month names when I write the date. DWF.
       8 Feb 2008. Renamed CRONJOB to NODISPLAY to better reflect its purpose. DWF.
      21 May 2008. Changed the default CHARSIZE to !P.CHARSIZE from 1.0. DWF.
      30 Oct 2008. Fixed a problem with the FONT keyword not being recognized in certain
            configurations.
      9 Nov 2009. Fixed typo in title of vertical colorbar. DWF.
      25 Sep 2010. Renamed FSC_Colorbar from Colorbar to avoid conflict with ITTVIS introduced
             colorbar.pro function in IDL 8.0. DWF.
      19 Oct 2010. Made changes so that axes titles are not picked up in _EXTRA and displayed
             on the color bar. Also changed all _EXTRA passes to _STRICT_EXTRA to report
             mis-spelled and/or inappropriate keywords. DWF.
      19 Oct 2010. Changed the default value of NODISPLAY keyword to 1, since FSC_Color
             no longer looks for system colors anyway. NODISPLAY is a depreciated keyword
             and does nothing if using the latest version of FSC_Color. DWF.
      13 Nov 2010. Samples the upper-right hand pixel on the display if it can. It this pixel is 
             "white" or the current device is PostScript, sets the ANNOTATECOLOR keyword
             to "black" if it of the COLOR keyword is not currently set to some other color. 
             If the pixel is "black" then ANNOTATECOLOR is set to "white". DWF.
      19 Nov 2010. Fixed a small problem when choosing an AnnnotateColor. DWF.
      29 Nov 2010. Added CLAMP and NEUTRALINDEX keywords, updated ability to set
             color model with SetDecomposedState command. DWF.
      1 Dec 2010. Set COLOR=1 and BITS_PER_PIXEL=8 in PostScript device. Tired of getting
             e-mails that "your damn colorbar doesn't work!". DWF.
      6 Dec 2010. I was always setting COLOR to ANNOTATECOLOR. I should only do that if
             COLOR is undefined. DWF.
      24 Jan 2011. Added WINDOW keyword. DWF.
      29 Jan 2011. Added ADDCMD keyword. DWF.

Source: src/idl_cvs/fullmdspath.pro

 NAME:
       fullMDSpath
 PURPOSE:
       Return an MDSplus path for a tag
 CATEGORY:
       MDSplus
 CALLING SEQUENCE:
       fullpath = fullMDSpath( tag, shot=shot )
 INPUTS:
       MDSplus tagname
 KEYWORD PARAMETERS:
	shot - if present, will open NSTX tree for this shot
 OUTPUTS:
	fullpaths - returns full pathnames of tags found
 EXAMPLE:
	IDL> mdsopen, 'edge', 129850
	IDL> print, fullMDSpath('\BE_H908_01')
       \EDGE::TOP.BEAP.RAWDATA:BE_H908_01

 NOTES:
       Only returns signals with data in them.
 LIMITATIONS:
	An MDSplus shot file must be open first.
 MODIFICATION HISTORY:
	17-Jun-2008 use tree in tagname, if present. Add tip, if not found.
	14-Mar-00 more efficient & added keywords [BD]
	20-Jan-00 Written by Bill Davis