Source: src/idl_cvs/gamma_raise.pro

 NAME:
	GAMMA_RAISE

 PURPOSE:
	Apply gamma correction to an array, presumably an image.

 CATEGORY:
	Image Processing.

 CALLING SEQUENCE:
	newImage = GAMMA_RAISE(image, Gamma)

 INPUTS:
	Gamma:	The value of gamma correction.  A value of 1.0 indicates a
		linear ramp, i.e., no gamma correction.  Higher values of 
		gamma give more contrast.  Values less than 1.0 yield lower 
		contrast.

 KEYWORD PARAMETERS:

 OUTPUTS:
	A gamma-corrected image.

 RESTRICTIONS:
	None.

 PROCEDURE:
	The gamma correction is implemented as x^gamma.

 MODIFICATION HISTORY:
	Written 14-Jul-2008 by Bill Davis

Source: src/idl_cvs/gaussian.pro

 NAME:
       GAUSSIAN
 PURPOSE:
       Compute the 1-d Gaussian function and optionally the derivative
 CATEGORY:
       Math
 EXPLANATION:
       Compute the 1-D Gaussian function and optionally the derivative 
       at an array of points.

 CALLING SEQUENCE:
       y = gaussian( xi, parms,[ pderiv ])

 INPUTS:
       xi = array, independent variable of Gaussian function.

       parms = parameters of Gaussian, 2 or 3 element array:
               parms(0) = maximum value (factor) of Gaussian,
               parms(1) = mean value (center) of Gaussian,
               parms(2) = standard deviation (sigma) of Gaussian.
               (if parms has only 2 elements then sigma taken from common).

 OPTIONAL OUTPUT:
       pderiv = optional output of partial derivatives,
               computed only if parameter is present in call.

               pderiv(*,i) = partial derivative at all xi absisca values
               with respect to parms(i), i=0,1,2.

       Function returns array of Gaussian evaluated at xi.

 EXAMPLE:
       Evaulate a Gaussian centered at x=0, with sigma=1, and a peak value
       of 10 at the points 0.5 and 1.5.   Also compute the derivative

       IDL> f = gaussian( [0.5,1.5], [10,0,1], DERIV )
       ==> f= [8.825,3.25].   DERIV will be a 2 x 3 array containing the
       numerical derivative at the two points with respect to the 3 parameters.
 
 COMMON BLOCKS:
       common gaussian, sigma
 HISTORY:
       Written, Frank Varosi NASA/GSFC 1992.
       Converted to IDL V5.0   W. Landsman   September 1997

Source: src/idl_cvs/getcmodefit.pro

 NAME:
       getCmodEfit
 PURPOSE:
       Get efit data from CMOD for separatrix and limiter locations
 CATEGORY:
       CMOD
 CALLING SEQUENCE:
       IDL> 
 INPUTS:
       shot = CMOD shot number 
	
 KEYWORD PARAMETERS:
    Inputs:
	tree - MDSplus tree
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed
    Outputs:
	status - if odd, then success
 OUTPUTS:
       
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> getcmodefit, 1100824017, rbbbs=rbbbs, zbbbs=zbbbs, $
			nbbbs=nbbbs, efitTimes=efitTimes          ,/debug  
 NOTES:
 MODIFICATION HISTORY:
	29-Nov-2012 use connect_cmd
       21-Dec-2011 Written by Bill Davis, PPPL

Source: src/idl_cvs/getefit.pro

 NAME: 
     GETEFIT

 PURPOSE: 
    Procedure to get efit data from A0 and G0 file or from MDSPLUS.  This
    can be used as a front end to the usual reada and readg.  It prints
    out a message if the efit data does not occur for the desired value
    of DELTIME.  It does not return any data unless time window
    requirements are met.
    
 CATEGORY:
       EFIT

 CALLING SEQUENCE: 
    getefit, shot, time, aaa, ggg [,DELTIME=DELTIME] $
              [,ERR=ERR] [,MODE=MODE] [,runID=runID]

 INPUTS: 
     shot    shot number
     time    shot time (sec)

 KEYWORDS: 
      DELTIME - maximum allowable time (sec) for the data to deviate from
        	time.  If two values [t0,t1] are input, the time window is from
        	(time - t0) to (time + t1), otherwise, the time window is from
        	(time - t0) to (time + t0).
      ERR - set to 0 for successful return of efit data; a non-zero
            value means there was a problem getting the efit data
      MODE - read a mode parameter, file or mdsplus
      runID - choose EFIT01 (JT snap file) or EFIT02 (MSE snap file) from
              MDSPlus efit data. Default is EFIT01, the non-MSE automatic
              control room EFIT

 OUTPUTS: 
      aaa     structure from reada routine holds data from A0 file
      ggg     structure from readg routine holds data from G0 file
      err     error code returned from reada ok if err=0

 RESTRICTIONS:
     User can specify source of data as MDSPLUS or a file in the current
     directory, or in a directory given by the environment variable
     MY_EFIT_DIR.

 PROCEDURE: 

 CODE TYPE: modeling, analysis, control

 CODE SUBJECT:  operation, edge, rf, transport, equilibrium, other

 EASE OF USE: can be used with existing documentation

 OPERATING SYSTEMS:  UNIX of all flavors

 EXTERNAL CALLS:  READA, READG

 TO TEST: IDL> getefit, 138000, 0.2, aaa, ggg

	   IDL> getefit, 141010, runID='LRDFIT06', 0.2, aaa, ggg

 MODIFICATION HISTORY:
     Created by Gary D. Porter
     1998.10.20:     Allow for data from a file or MDSPLus by G.D. Porter
     1998.11.03:     Change DELTIME check to allow for 2 values by R.A. Jong
     1999.04.01:     Added runID and removed BLESSED optional keywords
     1999.05.06;     Reset aaa.error=1 when our err parameter=1
     2000.01.03;     Change check on aaa.time and ggg.time to accept data if
                     both are in the acceptable time range, when not equal
     2000.10.19;     Do not cd to MY_EFIT_DIR and send message if mode=MDSPLUS
     2001.10.16;     Fix missing time_range flag in readg call (RAJ)
     06-Aug-2010 [BD] adapted for NSTX for Jose Boedo (note EFIT times on NSTX are
		       in seconds, rather than milliseconds)
     27-nov-2012 [BD] added aaa.shot and ggg.shot tags when getting LRDfit trees.

Source: src/idl_cvs/getfiletime.pro

 NAME:
       getfiletime
 PURPOSE:
       return creation date and time of a file
	(not sure atime and ctime are right, for files from a PC)
 CATEGORY:
       Dates, files
 CALLING SEQUENCE:
       IDL> times = getfiletime(files=files)
 INPUT KEYWORDS:
       files - string array of filenames, needed unless list used
       list - alternate way: filename containing a list of files
       dir - if present, is prepended to filenames before finding
       
 KEYWORD PARAMETERS:
	print - if present, will print results
	atime - access time in seconds since 1 January 1970 UTC
	ctime - creation time in seconds since 1 January 1970 UTC 
	mtime - modification time in seconds since 1 January 1970 UTC
 OUTPUTS:
       times - string array of creation date and times of files, 
		e.g., 
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	% /bin/ls -1 * > list.txt
	idl
	IDL> times = getfiletime( list='list.txt',/print )
	camerasbig Tue Oct  2 11:35:37 2007
	cpp Fri Nov  9 16:28:02 2007
	dothis.csh Tue Oct  2 11:33:37 2007
	...
 NOTES:
 MODIFICATION HISTORY:
	03-Mar-2009 added atime, ctime & mtime keywords
       16-Apr-2008 Written by Bill Davis, PPPL

Source: src/idl_cvs/getimage.pro

 NAME:
       GETIMAGE

 PURPOSE:
       The purpose of this function is to allow the user to open either
       regular or XDR binary image files of two or three dimensions.

 CATEGORY:
       Image Processing, Widgets, File I/O

 CALLING SEQUENCE:
       image = GETIMAGE(filename)

 INPUTS:
       filename: The name of the file to open for reading.

 KEYWORD PARAMETERS:

       CANCEL: An output variable that can be set to a named variable.
       The value of the return variable will be 1 if the user clicked
       the "Cancel" button or if there was a problem reading the file.

       DIRECTORY: The name of the directory the file is located in. By
       default the program looks in the "training" directory under the
       main IDL directory, if one exists. Otherwise, it defaults to the
       current directory.

       FRAMES: The 3rd dimension of a 3D data set. Defaults to 0.

       HEADER: The size of any header information in the file in BYTES.
       Default is 0.

       PARENT: The group leader for this widget program. The PARENT is
       required if GETIMAGE is called from another widget program.

       XDR: Set this keyword if the binary file is of XDR type.

       XOFFSET: This is the X offset of the program on the display. The
       program will be placed approximately in the middle of the display
       by default.

       XSIZE: The size of the 1st dimension of the data.

       YOFFSET: This is the Y offset of the program on the display. The
       program will be placed approximately in the middle of the display
       by default.

       YSIZE: The size of the 2nd dimension of the data.

 COMMON BLOCKS:
       None.

 SIDE EFFECTS:
       A "CANCEL" operation is indicated by a 0 return value.
       Any error in reading the file results in a 0 return value.

 RESTRICTIONS:
       None.

 EXAMPLE:
       To load the image "galaxy.dat" in the $IDL/examples/data
       directory, type:

       image = GETIMAGE('galaxy.dat', DIRECTORY=!DIR + '/examples/data', $
          XSIZE=256, YSIZE=256, Cancel=cancelled, Parent=event.top)
       IF NOT cancelled THEN TV, image

 MODIFICATION HISTORY:
       Written by: David Fanning, 3 February 96.
       Fixed bug that prevented reading INTEGER data. 19 Dec 96.
       Modifed program for IDL 5 MODAL operation. 19 Oct 97.
       Added CANCEL keyword. 27 Oct 97. DWF.
       Fixed CANCLE keyword spelling. Sigh... 29 JUN 98. DWF.

Source: src/idl_cvs/getmdslabel.pro

 NAME:  
	getMDSlabel
 PURPOSE: 
	return a label for an MDSplus signal. If there is a :LABEL sub-node,
	use that string, else if there is a :COMMENT sub-node, use that, else
	return the MDSplus signal name.
 CATEGORY:
       MDSplus
 CALLING SEQUENCE:
	IDL> (the tree has to be opened)
       IDL> label=getMDSlabel( signal, textNode=textNode, FOUNDTDI=foundTDI, $
                      status=status, /quiet, /fullPath )
 INPUTS:
       signal - mdsplus signal or tag name (shot must be opened)
 OUTPUT:
       label - contents of :LABEL substring, if found. Otherwise the
		signal name is returned (just the last two elements, unless
		/fullPath set)
 KEYWORD PARAMETERS:
    Optional Inputs:
	quiet - just passed to mdsvalue
	fullPath - if set, return fullpath if no :LABEL subnode found
    Optional Outputs:
	textNode - 1 returned if a text node
	FOUNDTDI - 1 returned if TDI in node 
	status - if odd, successfull
 NOTES:
       The relevant MDSplus tree must be open for this routine to work.
 MODIFICATION HISTORY:
	01-Jun-01 Also look for :COMMENTS sub-node. 
	11-Mar-01 if no :LABEL node, look for :COMMENT node
       15-Feb-01 Written by Bill Davis, PPPL

Source: src/idl_cvs/getnextfile.pro

 NAME:
       getNextFile
 PURPOSE:
 	get next file in a directory, defaulting to alphabetic search
 CATEGORY:
       Files
 CALLING SEQUENCE:
       IDL> nextFile = getNextFile( inFile )
 INPUTS:
       input = filename with or without directory prefix
 KEYWORD PARAMETERS:
	numeric - if set will try to sort files numerically, so *_9.ext will
		   come before *_10.ext 
	back - if set will go back one in list
 OUTPUTS:
       nextFile               			out
 EXAMPLE:
	IDL> infile='/p/camdata/fastsoftxray/NSTX_119761/Frame_287.tif'
	IDL> nextFile = GetNextFile( inFile)

	IDL> infile='/p/camdata/fast_camera/shot000119681/NSTX000119681_35.tif'
	IDL> print, GetNextFile( inFile, /numeric)
 NOTES:
   	finds all files of the form AAAAAA_*.ext (if no "_" in file, just
	return next in alphabetical order)
 MODIFICATION HISTORY:
	29-Jun-2006 added back keyword
       20-Apr-2006 Written by Bill Davis, PPPL

Source: src/idl_cvs/getpos.pro

 NAME:
       getpos
 PURPOSE:
       Get the values for the POSITION keyword after a plot
 CATEGORY:
       Plotting
 CALLING SEQUENCE:
       IDL> pos = getpos()
 INPUTS:
       
 KEYWORD PARAMETERS:
    Inputs:
	window - window wanted
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed
 OUTPUTS:
       pos = position returned 
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> plot, indgen(100)
	IDL> pos = getpos( )
 NOTES:
 MODIFICATION HISTORY:
       20-Mar-2013 Written by Bill Davis, PPPL

Source: src/idl_cvs/getscopenames.pro

 NAME:
       getScopeNames
 PURPOSE:
       return signal names and plot settings from an MDSplus Scope input file
 CATEGORY:
       MDSplus, SCOPE
 CALLING SEQUENCE:
	names = getScopeNames( fileName, titles=titles )
	names = getScopeNames()	; will get a dialog box
 INPUTS:
   Optional:
	filename - name of scope input filename (else will get a dialog box)
 RETURNED:
	names - Array of signal names, including TDI, (Y values)
	        if nothing found, will return a '-1'
 KEYWORDS:
   (All Optional) Returned:
	Titles - string array of the plot titles from the scope file, else y-name
	xMins - array of each plot's x-minimum from the scope file (else global, or 0)
	xMaxes - array of each plot's x-maximum from the scope file (else global, or 0)
	yMins - array of each plot's y-minimum from the scope file (else global, or 0)
	yMaxes - array of each plot's y-maximum from the scope file (else global, or 0)
	nCols - # of columns for plot
	nRows - (array) # of rows in each column for plot
   Optional inputs:
	stripTitles - if set, remove double quotes and everything after //
	noEqualSigns - if set, remove equal signs (=)
	addTrees - if set, add trees into signals
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed
 NOTES:
 LIMITATIONS:
	For jScope files, won't handle 2 signals on a single frame
 EXAMPLES:
	IDL> file = 'wfplus.scope'
	IDL> SigNames = GetScopeNames( file, titles=titles, yMins=yMins, yMaxes=yMaxes, $
	IDL>                         	xMins=xMins, xMaxes=xMaxes, xNames=xNames, $
	IDL> 				nRows=nRows, nCols=nCols, /addTrees )

	IDL> file = '/p/nstxusr/util/jscp/wfplus.jscp'
	IDL> file = '/p/nstxusr/util/jscp/EAST_Mag_probes.jscp'
	IDL> names = getScopeNames( file, TITLES=titles, yMins=yMins, yMaxes=yMaxes )

 MODIFICATION HISTORY:
	22-Apr-2010 made to work with jScope input files (ext .jscp) (and with files
		    with blank lines in header lines)
	23-Jun-2008 added nRows and nCols keywords.
	22-Mar-2006 revised xName logic when some there and some not.
	27-Jan-06 add xNames keyword for specied X values.
	19-Oct-01 if file not found, try other versions of name
	13-Sep-01 Added addTrees keyword
	17-Mar-01 default directory on Unix to /p/nstxusr/util/scopes/
	02-Mar-01 added x & y mins and maxes
	11-Jan-01 Written by Bill Davis

Source: src/idl_cvs/getsep.pro

 NAME:
  	getsep

 PURPOSE:
	Get the separtrix (last closed flux surface) R & Z values 
       from EFIT or LRDfit for a particular NSTX or CMOD shot. 
	Interpolate surfaces in time. Can also return R & Z
	of limiter interior. Also works for CMOD shots (tree
	opened elsewhere).

 CATEGORY:
       EFIT, 2-D Plotting, NSTX, CMOD

 CALLING SEQUENCE:
	IDL> getsep, shot, outTime, r_edge=r_edge, z_edge=z_edge,	$
		     xLim=xLim, zLim=zLim

 INPUTS:
       shot - shot number for MDSplus call
	outTimes - times desired in seconds 

 KEYWORD PARAMETERS:
    Optional Inputs:
	efitVersion - 1-6. Defaults to "Best Fit"
	LRDfitVersion - alternate to above
	BestFit - (DEFAULT) if set, will call bestFitAvail, which has preference
		 of LRDFIT04, any other LRDFIT, EFIT02, then highest EFIT.
	outer - if set will just return edge values > median value (default)
	inner  - if set will just return edge values <= median value
	noOpen - if set will not try to open a tree (assumes already open)
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed
    Returned:
	r_edge - r values of separatrix (edge) points
	z_edge - z values of separatrix points
	rLim - r values of limiter points
	zLim - z values of limiter points

  EXAMPLE:
		; get R & Z of separatrix for CMOD shot
	IDL> getsep, 1120224029, 1.08800,   $
		     r_edge=r_edge, z_edge=z_edge,   $
		     /debug

     to get get R & Z data and limiter location:
	IDL> getsep, 135036, .589, R_edge=R, Z_edge=Z,  $
		     rLim=rLim, zLim=zLim  MODIFICATION HISTORY:
  	WRITTEN Aug-2012 by Bill Davis for Stewart Zweben

Source: src/idl_cvs/gettok.pro

 NAME:
	GETTOK
                            
 PURPOSE:
	Function to retrieve the first part of the string
	until the character char is encountered.

 CATEGORY:
       Strings

 CALLING SEQUENCE:
	token = gettok( st, char )

 INPUT:
	char - character separating tokens, scalar string

 INPUT-OUTPUT:
	st - (scalar) string to get token from (on output token is removed)

 OUTPUT:
	token - scalar string value is returned 

 EXAMPLE:
	If ST is 'abc=999' then gettok(ST,'=') would return
	'abc' and ST would be left as '999' 

 HISTORY
	version 1  by D. Lindler APR,86
	Remove leading blanks    W. Landsman (from JKF)    Aug. 1991
   Add TABCHAR keyword, so token = gettok( st, '@', TABCHAR='@') will
		just treat tabs as delimiters.

Source: src/idl_cvs/getwrd.pro

 NAME:
       GETWRD
 PURPOSE:
       Return the n'th word from a text string.
 CATEGORY:
	Strings
 CALLING SEQUENCE:
       wrd = getwrd(txt, n, [m])
 INPUTS:
       txt = text string to extract from.         in
       n = word number to get (first = 0 = def).  in
       m = optional last word number to get.      in
 KEYWORD PARAMETERS:
       Keywords:
         LOCATION = l.  Return word n string location.
         DELIMITER = d. Set word delimiter (def = space & tab).
         /LAST means n is offset from last word.  So n=0 gives
           last word, n=-1 gives next to last, ...
           If n=-2 and m=0 then last 3 words are returned.
         /NOTRIM suppresses whitespace trimming on ends.
         NWORDS=n.  Returns number of words in string.
 OUTPUTS:
       wrd = returned word or words.              out
 COMMON BLOCKS:
       getwrd_com
 NOTES:
       Note: If a NULL string is given (txt="") then the last string
             given is used.  This saves finding the words again.
             If m > n wrd will be a string of words from word n to
             word m.  If no m is given wrd will be a single word.
             n<0 returns text starting at word abs(n) to string end
             If n is out of range then a null string is returned.
             See also nwrds.
 MODIFICATION HISTORY:
       Ray Sterner,  6 Jan, 1985.
       R. Sterner, Fall 1989 --- converted to SUN.
       R. Sterner, Jan 1990 --- added delimiter.
       R. Sterner, 18 Mar, 1990 --- added /LAST.
       R. Sterner, 31 Jan, 1991 --- added /NOTRIM.
       R. Sterner, 20 May, 1991 --- Added common and NULL string.
       R. Sterner, 13 Dec, 1992 --- Made tabs equivalent to spaces.
       R. Sterner,  4 Jan, 1993 --- Added NWORDS keyword.
       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/get_delim.pro

 NAME:
	get_delim
 PURPOSE:
	returns file delimiter that is appropriate to VMS,  UNIX or Windows
 CATEGORY:
	Programming
 CALLING SEQUENCE:
	delim=get_delim()
 INPUTS:
	none
 OUTPUTS:
       delim=':' if VMS, '\' if Windows, '/' otherwise
 PROCEDURE:
	checks !version.os system variable
 MODIFICATION HISTORY:
       Written DMZ (ARC) May 1992
       Modified DMZ(SAC) Sept 1997 - added Windows

Source: src/idl_cvs/get_nebar.pro

 NAME:
       get_nebar

  PURPOSE:
  	Get Ne Bar (line-averaged plasma density at the midplane) from
   	Multi-point Thomson Scattering data and EFIT gap data.

  CATEGORY:
       MDSplus, Density
 
  CALLING SEQUENCE:
	nebar = get_nebar( shot, time=time )
  INPUTS:
	shot1 = starting shot number to process
  KEYWORDS:
    (Optional)
	efit - #. Defaults to 2
	time - time base of output (sec). Probably on the MPTS timebase

  EXAMPLE:
	IDL> nebar = get_nebar( 138846, time=time )

  NOTES:
	This has not been verified by the MPTS Cognizant Physicist

  HISTORY:
	WRITTEN 23-Jul-2013, by Bill Davis for Stewart Zweben

Source: src/idl_cvs/get_text_input.pro

 NAME:
       get_text_input

 PURPOSE:
       Prompt the user for input with a question and
       return the text string typed by user.
       For X-windows the input is through a text widget, in the middle of 
       the screen, and the text widget waits until carriage return is entered.
       Otherwise input is in the terminal window, with a beep to alert user.

 CATEGORY:
       GUI, Input
 CALLING:
       text = get_text_input( question )

 INPUTS:
       question = string(s), prompt for input, default is null string.
               If an array is passed, each element is shown on its own line.

 KEYWORDS:
       DEFAULT_INPUT = optional string, setting the default response.

 OUTPUTS:
       Function returns the text string entered by user,
       with leading and trailing blanks removed.

 HISTORY:
       Written, Frank Varosi NASA/GSFC 1993.
       F.V.1997, question can be a string array, shown as multiple lines.

Source: src/idl_cvs/get_webplotsum.pro

 NAME:
 	get_webplotsum

 PURPOSE:
	Creates summary plots vs time with plasma current, D-alpha,
	injected power and stored energy (W-mhd).

 CATEGORY:
       Web
 CALLING SEQUENCE:
	IDL> image = get_webplotsum( ishot )
 INPUTS:
       shot = NSTX shot number 
	
 KEYWORD PARAMETERS:
    Inputs:
	(many)
 EXAMPLE:
   	image = get_webplotsum( ishot, tois=ftime[0:nActualTimes-1]/1000., $
   			     sig=signals, status=status )
   	if status then begin
   	   jfile = 'SHOTSUMMARY_'+strtrim( ishot, 2 )+'.jpeg'
   	   mk_jpeg, filename=dir+subDir+jfile, image=image
   	   PRINTF,LUN,''
   	endif

   	image = get_webplotsum( 127264, tois=[50,100,150,200,300]/1000.)
   	tv, image, true=1

 MODIFICATION HISTORY:
  	04-Mar-2008 call webplotsum to add W-mhd (stored energy) to plot
  	WRITTEN by Bill Davis, PPPL

Source: src/idl_cvs/good_ip.pro

 NAME:
       good_ip

 PURPOSE:
       Determine if plasma current (Ip) was good for a shot and, optionally
	declare an event.

 CATEGORY:
	MDSplus, Shot Number, Plasma Current

 CALLING SEQUENCE:
        nextShot = good_ip( shot )

 INPUTS:
       shot - shot number

 KEYWORD PARAMETERS:
    Inputs:
	goodValue - value required for tag for next good shot (default=30000 Amps)
	event     - if non-blank, will be declared if plasma current > goodValue
	Server 	  - MDS server (default is NSTX)
	TagToUse  - Tag to use for IP check (default to \OPERATIONS::CAL_IROGEVVUL1)
	IPforGood - alternate to goodValue (for compatibility with old routine)
	Verbose   - if set, print debugging information
    Returned:
	IpTime - time of good plasma current in seconds.
 OUTPUTS:
	1 or 0
 EXAMPLE:
	IDL> ipOK = good_ip( shot, goodValue = 100. )
 COMMON BLOCKS:
 NOTES:
 	if TagToUse not specified, will try to use in the following order:
	  1) \ENGINEERING::IP1UNC
	  2) \ENGINEERING::PPCC_IP1
	  3) \WF::IP
	if SigUnits from MDSplus begins with 'K' will mult. by 1000. If it 
	begins with an 'M' will mult. by 1000000.
 RESTRICTIONS:
 MODIFICATION HISTORY:
 	Written by Bill Davis March, 2006

Source: src/idl_cvs/gpicont.pro

 NAME:
        gpicont

 PURPOSE:
        plot GPI data (an average of a center strip vs. time) as a 
        color contour with the separatrix overlayed

 CATEGORY:
        Cameras, GPI, MDSplus, NSTX, edge

 CALLING SEQUENCE:
        IDL> gpicont, shot

 INPUT PARAMETERS:
        shot - MDSplus shot #

 KEYWORD PARAMETERS:
        t1 - start time (Def=0.3 s)
        t2 - end time (Def=0.9 s)     
        maxtimes - max number of points in time to plot (def=100000)
	     nTimes - the final number of times on the color contours
	     moreSmooth - after smoothing is done in the time dimension
			when reducing the # of times plotted, this 
			is used for the whole image (with edges handled)
        XSIZE - initial horizontal size of graphics window 
        YSIZE - initial vertical size of graphics window 
        charsize - size of characters on plot (Def=2)
        sep - if=0, will not show separatrix
	     jpeg - if set, will make a jpeg of a screen dump
	     ps - if set, will save a postscript file
	     pdf - if set and ps set, will save a pdf file
	     new - forces rereading and saving data, even if times have 
		    been done before
        verbose - if set, will print many informational messages
        debug - if set, debug output will be printed
               

 EXAMPLE:
   IDL> gpicont, 138844    

   IDL> gpicont, 138846, /new, t1=0.59, t2=0.67

   IDL> for i=138844, 138846 do gpicont, i, t1=0.59, t2=0.67, $
					/psout, /pdf

 MODIFICATION HISTORY:
	18-Sep-2013 from efit edge points was using nearest point
		    to the camera middle. Now interpolate edge values
		    using sepatmidgpi.
  	14-Aug-2013 Written by Bill Davis for Stewart Zweben.

Source: src/idl_cvs/gpimountain.pro

 NAME:
        gpimountain

 PURPOSE:
        plot GPI data (an average of a center strip vs. time) as a surface
        with the separatrix overlayed

 CATEGORY:
        3-D Plotting, MDSplus, NSTX, GPI, edge

 CALLING SEQUENCE:
        IDL> gpimountain, shot

 INPUT PARAMETERS:
        shot - MDSplus shot #

 KEYWORD PARAMETERS:
        t1 - start time (Def=0.3 s)
        t2 - end time (Def=0.9 s)     
        maxtimes - max number of points in time to plot (def=1000)
        az - degrees to rotate around Z axis (def=30)      
        ax - degrees to rotate around X axis (def=30)     
        XSIZE - initial horizontal size of graphics window 
        YSIZE - initial vertical size of graphics window 
        charsize - size of characters on plot (Def=2)
        sep - if=0, will not show separatrix
        nudge - amount to nudge separatrix line up, so shows above surface
                Def=30
        fence - height to draw top of fence where separatrix is.
	        Def=100. If=0, no fence will be drawn.   
        verbose - if set, will print many informational messages
        debug - if set, debug output will be printed
               
 LIMITATIONS:
        To show the separatrix on the surface, you have to find the right
        Z, which is hard without lots of interpolation. The work around is
        to nudge the Z values up so they will show above the surface even
        if it isn't quite right.

 EXAMPLE:
        IDL> gpimountain, 138844, az=50, ax=40, nudge=10, $
		           position=[.15,.1,.85,.85], nSmooth=5, nTimes=100	 

        IDL> gpimountain, 138846, az=50, ax=40, nudge=10, /new, $
		           position=[.15,.1,.85,.85], nSmooth=5, nTimes=1000	 

 MODIFICATION HISTORY:
  	 11-Jun-2013 Written by Bill Davis for Stewart Zweben.

Source: src/idl_cvs/greek.pro

 NAME:
	GREEK

 PURPOSE:
       This function returns the string needed to draw the specified
       greek character using either the vector graphics font no. 4,
       or PostScript font 9.

       If (!d.name eq 'PS') and (!p.font eq 0), then the PostScript
       font will be used.  Otherwise, the vector font will be used.

 CATEGORY:
	Programming

 CALLING SEQUENCE:
	Result = GREEK(Name)

 INPUTS:
       Name - String specifying the greek character name. Valid
              inputs are:

              alpha, beta, gamma, delta, epsilon, zeta, eta, theta
              iota, kappa, lambda, mu, nu, xi, omicron, pi, rho,
              sigma, tau, upsilon, phi, chi, psi, omega

              Alpha, Beta, Gamma, Delta, Epsilon, Zeta, Eta, Theta
              Iota, Kappa, Lambda, Mu, Nu, Xi, Omicron, Pi, Rho,
              Sigma, Tau, Upsilon, Phi, Chi, Psi, Omega

              Although not greek, the following characters are also
              valid (but will only work with the 'default' font !3):

              angstrom, Angstrom, degrees, plus_minus

 KEYWORDS:
       FORCE_PS - Set to use PostScript font, regardless of the value
                  of !d.name and !p.font.
       PLAIN - Set to just return Name in plain text.
       APPEND_FONT - Set to append the characters specifying a
                     'default' font: !3. That is, if this keyword is
                     set, then the command

                     Result=GREEK(theta,/APPEND_FONT)

                     will return the string

                     '!9q!3' for PostScript and '!4h!3' for vector
                     fonts.
 

 OUTPUTS:
       Result - The string containing the specified greek character.

 EXAMPLE:
	Result=GREEK(theta)
	
       In this case, Result='!9q' if !d.name is 'PS' and !p.font is
       0; otherwise, Result='!4h'

 MODIFICATION HISTORY:
 	David L. Windt, Bell Labs, September 1998.
       windt@bell-labs.com

Source: src/idl_cvs/gridplot.pro

 NAME: 
	gridplot

 PURPOSE: 
	Widget for plotting a grid of data from MDSplus or gadat 
	This is an interactive version of ShotLoop. 
 	If at GA, assume that access will be through gadat only.
	When a plot on the grid is clicked on, it is expanded into a
	separate window.

 CATEGORY:
       Plotting, MDSplus, Example, GA

 CALLING SEQUENCE: 
	IDL> gridplot
   or  IDL> gridplot,tmin=2000,tmax=2002, SigFileName='mysigs.txt'

 INPUTS:
       none required  
    FILES:
	lastshot.txt - if this file (or that specified by ShotFileName
			keyword) is found, will initilize shot number 
			to that read from the first line of this file.
			If this file can not be found in the directory from
			which you are running, or in the IDL_PATH,
			the initial shot number will be set to the current
			machine shot minus 3.
	mdsplussig.txt - if this file (or that specified by SigFileName
			keyword) is found, will read signalnames from it
 KEYWORD PARAMETERS:
      Optional Keywords:
	  nSmooth - smoothing parameter to use when plotting data
	  nRows   - # of rows of plots (default to 6)
	  nCols   - # of colomns of plots (default to # signals/nrows)
	  printer - printer to send plots to (else goes to the default printer)
	  tmin - default plotting minimum for x-axis. (MDS in sec; GA in msec)
	  tmax - default plotting maximum for x-axis.
	  ShotFileName - File for storint last shot processed
			 (default:  lastshot.txt)
	  SigFileName - Signal names in the file will be plotted 
		     when you click on "Plot All." The names
		     should be one per row (default='mdsplusssig.txt')
	  sizeofplot - (2-element Real Array) x & y size of graphics area on widget 
			(but you are forced to stay on the screen).
 OUTPUTS:
       none from routine
 COMMON BLOCKS:
       gp_SetupParams, gp_Info, gp_GridData, gp_widgetIDs
 EXAMPLE:
 MAJOR FUNCTIONS and PROCEDURES:
       PLOT: X-Y plotting.

 NOTES:
	PlotOne and PlotSomething
	are routines shared in common with ShotLoop.
 MODIFICATION HISTORY: Written by:  WMD, PPPL, April, 1999
                       for Hiro Takahashi work at General Atomics

Source: src/idl_cvs/h5dfromtext.pro

 NAME:
	h5dfromtext 

 PURPOSE:
	create a H5D file from a text file with columns of data

 CATEGORY:
       files

 CALLING SEQUENCE:
       IDL> h5dfromtext, in_filename=in_filename, out_filename=out_filename

 KEYWORD INPUTS:
       in_filename - file name with columns and, preferably, headings
	out_filename - name of H5D file to write (defaults to in_filename with .H5 ext)
	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.
	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:
	status 
	(file written)

 EXAMPLES:
	IDL> h5dfromtext, in_filename='/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'

 REVISION HISTORY:
  	WRITTEN 02-May-2012 by Bill Davis for Ahmed Diall0

Source: src/idl_cvs/highestefitrun.pro

 NAME:
       highestEfitRun
 PURPOSE:
 	find highest efit version run (in the MDSplus tree)
	Checks up to 5, and contigously after that
 CATEGORY:
       EFIT, MDSplus
 CALLING SEQUENCE:
       IDL> run = highestEfitRun(shot)
 INPUTS:
       shot = shot #  
 KEYWORD PARAMETERS:
	FITTYPE= fit type. Defaults to 'EFIT'. Works for 'LRDFIT', too.
	min2Check - will always check up to this number, and contigously
		    after that. E.g. if there is a EFIT05 and EFIT07, 
		    5 will be declared the highest unless this keyword
		    is 6 or higher.
	max2Check - will stop checking at this fit number
 OUTPUTS:
       integer # representing highest EFIT run in tree
 EXAMPLES:
	IDL> print,fitsrun(123001)
	       EFIT01 EFIT02 EFITRT
	IDL> print,highestefitrun(123001)
		2

	IDL> print,fitsrun(117707)
	EFIT01 EFIT02 EFIT03 EFIT06 EFITRT LRDFIT04 LRDFIT06
	IDL> print,highestefitrun(117707)
	       6
	IDL> print,highestefitrun(117707,FIT='LRDFIT')
	       6
 NOTES:
       When the routine is called with no parameters, or with the
	keyword hlp set, help information is printed.
 MODIFICATIONS:
	13-Apr-2010 added max2Check keyword
	29-Aug-2008 make min2check=20 for LRDfit
 	27-Aug-2007 check at least 5 runs. Add keyword for fit type and
			min2Check.
	Aug-2005 Written by Bill Davis

Source: src/idl_cvs/hours2time.pro

 NAME:
       hours2time
 PURPOSE:
 	Return time string like 23:59:05 from floating point hour value
 CATEGORY:
	Dates, times
 CALLING SEQUENCE:
       timeStr = hours2time( hours )
 INPUTS:
       hours - floating pt., from 0-23.9999
 KEYWORDS
    optional outputs:
	hours - integer hours
	minutes - integer minutes
	seconds - floating point seconds
 OUTPUT
	timeStr - string like 23:59:05.123, 03:01:59.777, etc.
 EXAMPLE: 

	IDL> print,hours2time( 3.333333 )
       03:19:59.999
 NOTES:
  	use rgatime2hr() to go the other way

 MODIFICATION HISTORY:
 	07-Jul-2011 WRITTEN by Bill Davis

Source: src/idl_cvs/idlv4_to_v5.pro

 NAME:
	IDLV4_TO_V5
 PURPOSE:
	Modify an IDL V4.0 (or earlier) procedure such that variables are 
	indexed using square brackets, as allowed (and suggested) 
	within IDL V5.0 and later

 CALLING SEQUENCE:
	IDLV4_TO_V5, infiles, outdir 

 INPUTS:
	infiles - scalar string specifying IDL procedure name(s), wild card 
		values allowed
	outdir - scalar string giving directory to contain output file.

 EXAMPLES:
	Convert the procedure curvefit.pro in the current directory to a
	IDL V5 version in the (Unix) idlv5 directory

	IDL> idlv4_to_v5,'curvefit.pro','idlv5/'

	Convert all the procedures in the current directory to IDL V5 versions
	in the /share/idlv5 directory

	IDL> idlv4_to_v5, '*.pro', '/share/idlv5/'

 METHOD:
	ISFUNCTION() is used to determine all the routine names in the file,
	and then ROUTINE_INFO() is used to determine the names of all variables
	in the procedure.    Each (non-commented) line is scanned for
	parentheses, and converted to square brackets if the token to the left
	of the left parenthesis matches a variable name.
 
 NOTES:
	(1) Only runs under IDL V5.0 (since it calls ROUTINE_INFO())
	(2) May possibly get confused by parenthesis within strings.
	(3) May get confused by IDL statements that extend over multiple lines
	    idlv4_to_v5 will supply a warning when it becomes confused by
	    unmatched parenthesis.
	(4) Do not include this procedure 'idlv4_to_v5' in the directory that 
	    you are trying to convert (since it will compile the procedure 
	    while executing it, and do a retall.)
	(5) Conversions cannot be performed unless specified procedure(s) 
	    already compile properly
	(6) Will not work on IDL main programs
	(7) May get confused by gaps between array name and parenthesis

 PROCEDURES CALLED:
	FDECOMP, MATCH, REMOVE, ISFUNCTION()
 REVISION HISTORY:
	Written  W. Landsman   Hughes STX     June 1997 
	Variable names can have numerals      August 1997
	Never change an intrinsic IDL function to square brackets, even if it
	is also a variable name.

Source: src/idl_cvs/ij2rz.pro

 NAME:
       ij2rz
 PURPOSE:
       Convert from fast GPI camera pixels at CMOD or NSTX to R & Z
 CATEGORY:
       Fast 2-D Cameras
 CALLING SEQUENCE:
       IDL> ij2rz, shot=shot, cam=cam, nx=nx, ny=ny,  $
		     Rvals=Rvals, Zvals=Zvals
 INPUTS:
	
 KEYWORD PARAMETERS:
    Inputs:
       shot - CMOD or NSTX shot number (default to 1120224029)
	cam - default to 1 for NSTX (only one), but 2 (X-pt) for CMOD
	nx - # of pixels in X (defaults to that of camera)
	ny - # of pixels in Y (defaults to that of camera)
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed
    Outputs:
	Rvals - 2-D array of R (major Radius) values in meters of pixel location 
		(at Gas Puff)
	Zvals - 2-D array of Z values (m) of pixel location (at Gas Puff)
 OUTPUTS:
 EXAMPLE:
	IDL> ij2rz, shot=1120224029, cam=1,  $  ; input
		    Rvals=Rvals, Zvals=Zvals	; returned
 NOTES:
	Unrotated images from NSTX are read as [80,64]. Since these need to
	to be rotated so up is up, default to ny=80. MODIFICATION HISTORY:
	25-Sep-2012 don't transpose R-Z values, so 80 pixels is in vertical direction
       27-Aug-2012 Written by Bill Davis, PPPL, for Stewart Zweben

Source: src/idl_cvs/imageproc.pro

 NAME:
       imageproc

  PURPOSE:
       Demonstrate a few of IDL's image processing features:
       Fourier filtering, pixel scaling, pixel distribution
       (histogram), edge enhancement, dilate & erode,
       convolution, and zooming.

  CATEGORY:
       Image Processing, 2-D Plotting

  CALLING SEQUENCE: 
	IDL> imageproc
 INPUTS:
       input = a 2-D image (optional, otherwise will pop dialog for tiff file

 KEYWORD PARAMETERS:
	NColors - # of colors to use
	Bottom - value to add to bytescaled image
	magnification - magnification factor desired for image
	INTERP - if magnification set, INTERP=1 will cause interpolation
	XSIZE - xsize of displayed image
	YSIZE - ysize of displayed image
  REFERENCE: IDL Reference Guide, IDL User's Guide

  NAMED STRUCTURES:
       none.

  COMMON BLOCS:
       none.

  MODIFICATION HISTORY:
	July, 2004 a few more additions [BD]
	23-Jan-00 Modified from RSI d_imageproc by Bill Davis.
	d_imageproc Written by:  DC, RSI,  1995

Source: src/idl_cvs/interp2d.pro

 NAME:
	interp2d

 PURPOSE:
	Perform bilinear 2d interpolation using the IDL intrinsic 
	interpolate procedure

 CATEGORY:
       Interpolation

 CALLING SEQUENCE:
       result = interp2d(A,x0,y0,x1,y1)
       result = interp2d(A,x0,y0,x1,y1,/grid)
       result = interp2d(A,x0,y0,x1,y1,/regular,/cubic)
       result = interp2d(A,x0,y0,x1,y1,missing=missing)

 INPUTS:
       A   = 2d array to interpolate
       x0  = Values that correspond to A(0,0), A(1,0), ...
       y0  = Values that correspond to A(0,0), A(0,1), ...
       x1  = New X values at which A should be interpolated
       y1  = New Y values at which A should be interpolated

 OPTIONAL INPUTS:
       nxny = [nx,ny] Vector of length 2 which specifies the size of
             the regular linearized grid produced with trigrid.  The
             default is nxny = [51,51].  If the size of A is much larger
             than 51 by 51, greater accuracy may be obtained by having
             nxny = [n_elements(A(*,0),n_elements(A(0,*))]

 OPTIONAL INPUT KEYWORDS:
       grid= If set, return an n_elements(X1) by n_elements(y1) grid
       missing = Value to points which have X1 gt max(X0) or X1 lt min(X0)
       	    and the same for Y1.
       quintic = If set, use smooth interpolation in call to trigrid
       regular = If set, do not call trigrid -- x0 and y0 must be linear.
       cubic	= If set, use cubic convolution
       extrapolate = If set, then extrapolate beyond boundary points
       bin = set to bin data prior to interpolation.
             (e.g. bin=2 interpolate every second pixel)

 Returned:
       result = a vector N_elements(X1) long 
          or, if /grid is set
       result = an array that is N_elements(X1) by N_elements(Y1)

 PROCEDURE:
   	First call the IDL intrinsic routines TRIANGULATE & TRIGRID to make
	sure that X0 and Y0 are linear (if /regular is not set).
   	Then call the IDL intrinsic INTERPOLATE to do bilinear interpolation.

 RESTRICTIONS:
   	X0 and Y0 must be linear functions.
   	A must be a 2-d array

 HISTORY:
    9-mar-94, J. R. Lemen LPARL, Written.
   20-Jan-95, JRL, Added the REGULAR & CUBIC keywords
   6-Sept-97, Zarro, GSFC, allowed for 2-d (X-Y) coordinate inputs
  22-Apri-99, Zarro, SM&A/GSFC - added /triangulate and made /regular
              the default (much faster).

Source: src/idl_cvs/interp2dfit.pro

 NAME:
 	interp2dfit 
 PURPOSE:
       fit irregularly-spaced x, y, & z points by fitting a 2-D surface 
	using SFIT,  and, using the returned coefficients, compute new
	values at other irregularly-spaced locations.
 CATEGORY:
       Interpolation
 CALLING SEQUENCE:
       IDL> zWant = interp2dfit( x, y, z, Xwant, Ywant, surfaceOut=surfaceOut )
 INPUTS:
       x, y, z - randomly-spaced points
	Xwant, Ywant - X & Y points at which to compute new points
 KEYWORD PARAMETERS:
    Inputs:
	degree - degree of polynomial passed to SFIT (default=6)
	plot - if set, will plot data and surfaces so you can see
		if fit is reasonable
	gtzero - if set, will force all values to be greater than 0
	NXout - # of X points to use for fitted surface, and in returned array
	NYout - # of Y points to use for fitted surface, and in returned array
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed
    Outputs:
	Zwant - (returned value) interpolated values at Xwant & Ywant
	KX - coeficients of polynomial fit, returned from SFIT.
       surfaceOut - 2-D grid to which irregular points were interpolated
  EXAMPLE:

	   ; get randomly-spaced x, y, & z values:
     IDL> restore,'/u/bdavis/cvs/idl_cvs/interp2dfiteg.sav'
     IDL> minx = MIN( x, MAX=maxx )
     IDL> miny = MIN( y, MAX=maxy )
     IDL> XWant = randomu(seed,200)*(maxX-minX) + minX  ; more points make smoother plots
     IDL> YWant = randomu(seed,200)*(maxY-minY) + minY
     IDL> Zwant = interp2dfit( x, y, z, Xwant, Ywant, /gtZero, /plot )

 NOTES:
       Polynomial fits can be way off beyond the edges of the data.
	(Probably should pass in as a parameter the 100 currently used
	 to make the interpolated surface)
 MODIFICATION HISTORY:
	22-Aug-2012 fix bug when plotting, but not returning regsurf
	15-May-2010 Use Xwant and Ywant for output array
 	WRITTEN 17-Jan-2010 by Bill Davis for Manny Manickam

Source: src/idl_cvs/interpedge.pro

 NAME:
  	interpEdge

 PURPOSE:
       Interpolate separatrix in time. From EFIT or LRDfit, find R
       and Z values of last closed flux surface (separatrix) for a
       particular NSTX or CMOD shot.  Can also return R & Z of limiter
       interior. Also works for CMOD shots (tree opened elsewhere).

 CATEGORY:
       EFIT, 2-D Plotting, NSTX, CMOD

 CALLING SEQUENCE:
	IDL> interpEdge, shot, outTime, r_edge=r_edge, z_edge=z_edge,	$
			 xLim=xLim, zLim=zLim,  $
			 /plot, /debug

 INPUTS:
       shot - shot number for MDSplus call
	outTimes - times desired in seconds 

 KEYWORD PARAMETERS:
    Optional Inputs:
	efitVersion - 1-6. Defaults to 2
	LRDfitVersion - alternate to above
	BestFit - (DEFAULT) if set, will call bestFitAvail, which has preference
		 of LRDFIT04, any other LRDFIT, EFIT02, then highest EFIT.
	outer - if set will just return edge values > median value
	inner  - if set will just return edge values <= median value
	noOpen - if set will not try to open a tree (assumes already open)
	plot - if set will plot data
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed
    Returned:
	r_edge - r values of edge points (in meters)
	z_edge - z values of edge points
	xLim - r values of limiter points
	zLim - z values of limiter points

  EXAMPLE:
	IDL> interpEdge, 130376, .2,   $
			 r_edge=r_edge, z_edge=z_edge,	$
			 /plot, /debug

     to get get R & Z data and limiter location:
	IDL> interpEdge, 135036, .589, R_edge=R, Z_edge=Z,  $
			 xLim=xLim, zLim=zLim

	IDL> interpEdge, 1120815021, 1.15, r_edge=Rsep, z_edge=Zsep, /outer, /plot

  IDL> interpEdge, 138846, .615,r_edge=Rsep,z_edge=Zsep,/outer,/plot, /deb

  MODIFICATION HISTORY:
  --------------------
  16-Sep-2013 always have noOpen=0 (bug somewhere)
  04-Mar-2013 don't stop if no radii found greater than average
  30-Aug-2012 add MDSconnect for CMOD; do not assume shot is open
  21-Aug-2012 fixed bug for CMOD
  05-Jan-2012 account for time being first dimension in r & z from CMOD EFITs
  21-Dec-2011 added CMOD support
  15-Dec-2011 added outer and inner keywords
  WRITTEN 12-Dec-2011 by Bill Davis

Source: src/idl_cvs/interpwf.pro

 NAME: 
	interpwf

  PURPOSE: 
	Interpolate MDS signal, or array, to 1 KHz.

  CATEGORY:
       Interpolation

  CALLING SEQUENCE:
	IDL> data1KHz = interpwf( inData, time=intime, OUTTIME=outTime)
	  or
	IDL> data1KHz = interpwf( sigName )
  INPUTS:
	inData - data array or MDSplus signal name
  KEYWORDS:
	intime - timebase of input. If not present will get dim_of(inData)
	dt - delta time desired of output. Default to 1.0e-3 (1 KHz)
	TSTART - start time desired. If not present, =0.0
	TSTOP - last output time desired. If not present = max(inTime)
     Returned
	outTime - timebase of desired output array.
  EXAMPLES:
    (works with just arrays, if time present:)
	IDL> data1KHz = interpwf(findgen(3000), time=findgen(3000)/(3000)*1.2, $
		                 OUTTIME=outTime)
	IDL> mdsopen, 'engineering', 130000 
	IDL> wf=interpwf( '\ip1', OUTTIME=outTime, $
				tStart=-0.5, tStop=1.5 )
	IDL> data=mdsvalue('\ip1')
	IDL> time=mdsvalue('dim_of(\ip1)')
	IDL> plot, time, data
	IDL> oplot, outTime, wf, color=colorsearch('red')
  LIMITATION:
	If a signal name is passed in, assume the tree is already open
  MODIFICATION HISTORY:
       13-Feb-2009 do everything in IDL
	27-Jun-2008 Convert to Linux
	06-Apr-06 made default endtime lesser of input and output time
       05-Jul-00 Written by Bill Davis, PPPL

Source: src/idl_cvs/int_defined.pro

 NAME:
       int_defined
 PURPOSE:
       see if a value is defined and is an integer
 CATEGORY:
	programming
 CALLING SEQUENCE:
        logical = INT_DEFINED( whatever )
 INPUTS:
       whatever - any IDL variable      in
 KEYWORD PARAMETERS 
	none
 OUTPUTS:
	logical - 1 if an integer, 0 if not (or if not defined)
 EXAMPLE:
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
     1999 Written by Bill Davis

Source: src/idl_cvs/isarray.pro

 NAME:
       ISARRAY
 PURPOSE:
       Tests if the argument is an array.
 CATEGORY:
	Programming
 CALLING SEQUENCE:
       flag = isarray(a)
 INPUTS:
       a = variable to test.                                in
 KEYWORD PARAMETERS:
 OUTPUTS:
       flag = test result: 0 if not array, else non-zero.   out
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
       R. Sterner  20 Mar, 1986.
       Checked for undefined variables.  RES 25 Aug, 1989.
       Johns Hopkins Applied Physics Lab.

 Copyright (C) 1986, 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/isfunction.pro

 NAME:
	ISFUNCTION()
 PURPOSE:
	Determine whether the IDL program(s) in a file are procedures or 
	functions.    Needed because the intrinisc RESOLVE_ROUTINE and 
	ROUTINE_INFO() procedures require the user to know beforehand whether 
	to supply the /IS_FUNCTION or /FUNCTION keywords.

 CALLING SEQUENCE:
	status = ISFUNCTION( filename, [ outnames, numlines]
 INPUT:
	filename = scalar string giving complete specification if file name
		(include .pro extension)

 OUTPUT:
	status - integer vector with number of elements equal to the number 
	of routines in the file.    Each status value consists of 0 or 1
	 1 - routine is an IDL function
	 0 - routine is an IDL procedure
	 If no valid IDL functions or procedures are found in the file, then
		ISFUNCTION() returns a scalar value of -1 

 OPTIONAL OUTPUTS:
	outnames - vector string, giving name of each IDL procedure or function
		in the file
	numlines - integer vector, giving the number of lines in each IDL
		procedure or function in the file
 PROCEDURE CALLS:
	FDECOMP
 REVISION HISTORY:
	Written, W. Landsman                  June, 1995

Source: src/idl_cvs/isnum.pro

 NAME:
       ISNUM
 VERSION:
       3.0
 PURPOSE:
       Checks whether the input is a number.
 CATEGORY:
       Programming.
 CALLING SEQUENCE:
       Result = ISNUM(X)
 INPUTS:
    X
       Arbitrary, doesn't even have to exist.
 OPTIONAL INPUT PARAMETERS:
       None.
 KEYWORD PARAMETERS:
    /DOUBLE
       Switch.  If set the result is 1 only if X is DOUBLE or DCOMPLEX.
    /COMPLEX
       Switch.  If set the result is 1 only if X is COMPLEX or DCOMPLEX.
    TYPE
       Optional output.  See below.
 OUTPUTS:
       Returns 1 if X is number, 0 otherwise.  Output type is byte.
 OPTIONAL OUTPUT PARAMETERS:
    TYPE
       The name of the variable to receive the numeric code of the type of X.
       Included for convenience to save an additional call to TYPE.
 COMMON BLOCKS:
       None.
 SIDE EFFECTS:
       None.
 RESTRICTIONS:
       None.
 PROCEDURE:
       Straightforward.  Using TYPE from MIDL.
 MODIFICATION HISTORY:
	19-Jul-2009 added U types [Bill Davis]
       Created 15-JUN-1995 by Mati Meron.
       Modified 5-MAY-1996 by Mati Meron.  Added keywords DOUBLE, COMPLEX and
       TYPE.

Source: src/idl_cvs/isnumber.pro

 NAME:
       ISNUMBER
 PURPOSE:
       Determine if a text string is a valid number.
 CATEGORY:
 CALLING SEQUENCE:
       i = isnumber(txt, [x])
 INPUTS:
       txt = text string to test.                      in
 KEYWORD PARAMETERS:
 OUTPUTS:
       x = optionaly returned numeric value if valid.  out
       i = test flag:                                  out
           0: not a number.
           1: txt is a long integer.
           2: txt is a float.
           -1: first word of txt is a long integer.
           -2: first word of txt is a float.
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
	28-Feb-2011 don't call a character when has a minus sign [BD]
	15-Feb-2008 don't consider date string, like 02/15/2008, a number [BD]
	29-Oct-2007 return 0 if input not defined [BD]
	01-Dec-2006 handle structures (treat as not a number) [Bill Davis]
       Richard Garrett, 14 June, 1992 --- fixed bug in returned float value.
       R. Sterner, 12 Mar, 1990 --- upgraded.
       R. Sterner.  15 Oct, 1986.
       Johns Hopkins Applied Physics Lab.

 Copyright (C) 1986, 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/isotime.pro

 NAME:
       ISOtime
 PURPOSE:
       Return time in ISO 8601 standard, assuming US East Coast. 
	(handles Daylight Savings time)
 CATEGORY:
       Dates
 CALLING SEQUENCE:
       IDL> timeStr = ISOtime( DateTime )
 INPUTS:
        DateTime - like "06/14/2004 11:04:52"
 KEYWORD PARAMETERS:
       Keywords:
 OUTPUTS:
       timeStr - like 2004-06-14T11:04:52.0-4:00
 COMMON BLOCKS:
       NONE
 EXAMPLE:
   IDL> print,isotime('06/14/2004 11:04:52')
	2004-06-14T11:04:52.0-4:00
 NOTES:
   The ISO standard includes the adjustment to Grenwich Mean Time, so
   you need to know whether Daylight Savings time is in affect.
   This includes routines to find last and first Sunday of a month.
   Assumes no fractions of seconds.
 MODIFICATION HISTORY:
       WRITTEN 19-Jan-2005 by Bill Davis, PPPL

Source: src/idl_cvs/jd2date.pro

 NAME:
       JD2DATE
 PURPOSE:
       Convert a Julian Day number to a date string.
 CATEGORY:
	dates
 CALLING SEQUENCE:
       date = jd2date(jd)
 INPUTS:
       jd = Julian Day number.       in
 KEYWORD PARAMETERS:
       Keywords:
         FORMAT = format string.  Allows output date to be customized.
            The following substitutions take place in the format string:
         Y$ = 4 digit year.
         y$ = 2 digit year.
         N$ = full month name.
         n$ = 3 letter month name.
         m$ = 2 digit month number.
         d$ = day of month number.
         0d$ = day of month number as a 2 digit number.
         W$ = full weekday name.
         w$ = 3 letter week day name.
 OUTPUTS:
       date = returned date string.  out
 COMMON BLOCKS:
 NOTES:
       Notes:
         The default format string is 'd$-n$-Y$' giving 24-Sep-1989
         Example: FORMAT='w$ N$ d$, Y$' would give 'Mon 
 MODIFICATION HISTORY:
	17-Aug-2009 added $m option so can get dates like 17-8-2009.
       R. Sterner, 27 Feb, 1991

 Copyright (C) 1991, 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/jd2ymd.pro

 NAME:
       JD2YMD
 PURPOSE:
       Find year, month, day from julian day number.
 CATEGORY:
	Dates
 CALLING SEQUENCE:
       jd2ymd, jd, y, m, d, dateString=dateString
 INPUTS:
       jd = Julian day number (like 2447000).     in
 KEYWORD PARAMETERS:
	dateString - (OPTIONAL OUTPUT) of form yyyymmdd (e.g., 20030613)
 OUTPUTS:
       y = year (like 1987).                      out
       m = month number (like 7).                 out
       d = day of month (like 23).                out
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
	12-Feb-2008 added dateString optional output keyword
       Theo Brauers, 21 Sep, 1997 long loop index i
       R. Sterner, 30 Apr, 1993 --- cleaned up and allowed arrays.
       R. Sterner.  21 Aug, 1986.
       Johns Hopkins Applied Physics Lab.

 Copyright (C) 1986, 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/keybrdanim.pro

 NAME:
       keybrdanim
 PURPOSE:
       Animate frames of plots with keyboard controls.
	Plot commands can be passed into the routine.
	By default a vertical dashed red line shows the time.

       Keyboard controls over animation:
          'H': See this Help
          'P' or : Toggle Pause
          'C': Continue
          'F': Faster
          'S': Slower
          'R' or '>' or : move forward 1 frame
          'L' or '<' or : move backward 1 frame
          'J' or : Jump forward 10 frames
          'B' or : move backward 10 frames
          'M':  Mouse-click time desired
          'Q':  to quit
 CATEGORY:
       Plotting
 CALLING SEQUENCE:
       IDL> keybrdanim, x, y
 INPUTS:
       x - abscissa array for plotting
	y - ordinate array for plotting
 KEYWORD PARAMETERS:
    Inputs:
	plotCmd - a string array to execute. To have something indexed by the loop
		  variable, use iFr.
	          Defaults to:
	 		["PLOT, x, y, _extra=_extra", $
	 	 	 "OPLOT, [x[ifr], x[ifr]], !y.crange, line=2, color=cs.red"]
	nframes - # of points to plot. Defaults to # of points in X
	plotCmd - a string array of plot commands. Defaults to 
	xsize - horizontal size of plot window, Default = 640
	ysize - vertical size of plot window, Default = 480     
	pauseInit - Initial time to pause between frames. Default = 0.2
	loops - # of times to loop through the animation. Default = 10
	load - if set, will call mk_color to load colors. Default = 1.
	verbose - if set, will print many informational messages
	debug - if set, debug output will be printed

       any other keywords will be passed to the PLOT command via the _extra keyword.
 OUTPUTS:
       none (just plot window)
 EXAMPLE:
	IDL> cmd =["PLOT, x, y, xtitle='Sec',  title='plot title'",  $
	  	   "OPLOT, [x[ifr], x[ifr]], !y.crange, line=2, color=colorsearch('red')", $
		   "xyouts, .12, 0.92, 'Shot 999999', /norm, charsize=2"]
	IDL> keybrdanim, x, y, plotCmd=cmd
 NOTES:
	The Z-buffer is used for plotting and then results copied to plot window for
	for smooth animations.
 MODIFICATION HISTORY:
   19-Jul-2010 Written by Bill Davis

Source: src/idl_cvs/labeleveryothertick.pro

 NAME:
 	labeleveryothertick

  PURPOSE:
 	Only label every other major tic mark.
 	The format of the numbers is customized.

 CATEGORY:
       Plotting, Graphics
  EXAMPLE 1 - Make a dummy plot call so can determine Tick Max:
	IDL> COMMON betterticklabels_common, yticklabels
	IDL> plot, y, ytick_get=yticklabels, ytickname=replicate(' ',30)
	IDL> AXIS, YAXIS=1, YRANGE=!y.crange, ytickformat='labeleveryothertick'
	IDL> dum = TEMPORARY(yticklabels)	; so doesn't affect later calls

  EXAMPLE 2 - Just take what you get (still pretty good):
	IDL> plot, y, ytickformat='labeleveryothertick'

  HISTORY:
	09-Oct-00 Written by Bill Davis

Source: src/idl_cvs/labelfit.pro

 NAME:
	labelfit

 PURPOSE:
	determine character size to make a label fit in a space

 CATEGORY:
	Strings

 CALLING SEQUENCE:
	IDL> newCharSize= labelfit( label, width=width )

 INPUTS:
	width - pixels to fit label into
	charsize - starting charactersize (max) Default=3
	minsize - minimum character size allowed
	pad - # of blank characters to allow around string (default=2)

 RETURNED:
	shortLabel - if charsize needs to be less than minsize to fit 
		     everything, make a short label that fits

 EXAMPLES:
	IDL> print, labelfit('Hi mom', width=40, charsize=20 )
	      5.80002
	IDL> label = 'abcdefghijklmnopqrstuvwxyz'
	IDL> print, labelfit(label, width=400 )
	      1.65000
	IDL> print, labelfit(label, width=400, minsize=2, shortLabel=shortLabel )
             2.00000
	IDL> help,shortlabel
	SHORTLABEL      STRING    = '...jklmnopqrstuvwxyz'

 MODIFICATION HISTORY:
	15-Sep-2011 Written by Bill Davis, PPPL

Source: src/idl_cvs/lastmdsshot.pro

 NAME:
       LastMDSshot
 PURPOSE:
       get the last (current) MDS shot
 CATEGORY:
	MDSplus
 CALLING SEQUENCE:
       currentShot = LastMDSshot()
 INPUTS:
       none
 KEYWORD PARAMETERS:
	SERVER - MDS server (default is NSTX)
	MACHINE - machine (default is NSTX)
 OUTPUTS:
	currentShot - current shot number
 EXAMPLE:
 COMMON BLOCKS:
 NOTES:
 MODIFICATION HISTORY:
 	25-Feb-99 BD added way to get current shot from either VMS or UNIX
		default to NSTX
 	11-Dec-98 BD added MDSplus access for shotnumber, if on VMS at PPPL
 	01-Dec-98 BD use fas_dir and Mk_Filename for filename lookup
 	5/14/98 changing USER directory to BE1 etc [PR]

Source: src/idl_cvs/leafname.pro

 NAME:
       LeafName
 PURPOSE:
       Return leaf name from MDSplus pathname(s)
 CATEGORY:
       MDSplus
 CALLING SEQUENCE:
       IDL> leaf = leafname(mdspath)
 INPUTS:
       mdspath - MDSplus path string.  
 OUTPUTS:
       leaf - MDSplus leaf node string (last signal in multi-signal TDI)
 KEYWORDS:
	Delim - delimiter (default is ':')
	Tree  - returns tree of input (last signal in multi-signal TDI),
		or environmental variable 'MACHINE' if Signal Math TDI used
		on signals from more than one tree
	AllTrees - all trees in input path
	Prefix - returns everything before the leafname
	nParts - # of parts to return, counting from the end (default=1, 
			max of 2)
	BRACKETSTR - (1st) square bracket clause, as in an array subscript
 COMMON BLOCKS:
       NONE
 EXAMPLE:
       IDL> print,leafname('\JMENARD_DAY1::TOP.FLUX_LOOP.FLUX:FFLPF1BL')
		FFLPF1BL
       IDL> print,leafname('\wf::ip')
		ip
	IDL> print,leafname('TOP.FLUXLOOP.FLUX.CALIBRATION',delim='.')
		CALIBRATION
 NOTE: 
	for multi-signal TDI, will return the leaf name of last signal, as well as the
	last tree.
 MODIFICATION HISTORY:
	23-Nov-2010 fixed bug introduced 15-Oct with defaulting to '::' delimiter
	15-Oct-2010 fixed bug using 2-char delimiter
	30-Sep-2010 set delimiter to '::' and don't return '-1' in allTrees
	26-Oct-07 Ignore square bracket clauses (but return in keyword BRACKETSTR)
	16-Aug-07 return last tree for multi-line TDI
	06-Aug-07 fix bug where no backslash in name
	11-Jul-07 return all tree names in ALLTREES keyword. 
		  If sigadd, sigmult, etc., used with more than one tree, 
		  return 'NSTX' in TREE keyword
	
	11-Jan-01 Remove comma and anything after, and ')' if TDI
	28-Nov-00 Don't return tree name with '\'
       23-Jul-99 Written by Bill Davis, PPPL

Source: src/idl_cvs/legend.pro

 NAME:
       LEGEND
 PURPOSE:
       Create an annotation legend for a plot.
 EXPLANATION:
       This procedure makes a legend for a plot.  The legend can contain
       a mixture of symbols, linestyles, Hershey characters (vectorfont),
       and filled polygons (usersym).  A test procedure, legendtest.pro,
       shows legend's capabilities.  Placement of the legend is controlled
       with keywords like /right, /top, and /center or by using a position
       keyword for exact placement (position=[x,y]) or via mouse (/position).
 CALLING SEQUENCE:
       LEGEND [,items][,keyword options]
 EXAMPLES:
       The call:
               legend,['Plus sign','Asterisk','Period'],psym=[1,2,3]
         produces:
               -----------------
               |               |
               |  + Plus sign  |
               |  * Asterisk   |
               |  . Period     |
               |               |
               -----------------
         Each symbol is drawn with a plots command, so they look OK.
         Other examples are given in optional output keywords.

       lines = indgen(6)                       ; for line styles
       items = 'linestyle '+strtrim(lines,2)   ; annotations
       legend,items,linestyle=lines            ; vertical legend---upper left
       items = ['Plus sign','Asterisk','Period']
       sym = [1,2,3]
       legend,items,psym=sym                   ; ditto except using symbols
       legend,items,psym=sym,/horizontal       ; horizontal format
       legend,items,psym=sym,box=0             ; sans border
       legend,items,psym=sym,delimiter='='     ; embed '=' betw psym & text
       legend,items,psym=sym,margin=2          ; 2-character margin
       legend,items,psym=sym,position=[x,y]    ; upper left in data coords
       legend,items,psym=sym,pos=[x,y],/norm   ; upper left in normal coords
       legend,items,psym=sym,pos=[x,y],/device ; upper left in device coords
       legend,items,psym=sym,/position         ; interactive position
       legend,items,psym=sym,/right            ; at upper right
       legend,items,psym=sym,/bottom           ; at lower left
       legend,items,psym=sym,/center           ; approximately near center
       legend,items,psym=sym,number=2          ; plot two symbols, not one
       legend,items,/fill,psym=[8,8,8],colors=[10,20,30]; 3 filled squares
 INPUTS:
       items = text for the items in the legend, a string array.
               For example, items = ['diamond','asterisk','square'].
               You can omit items if you don't want any text labels.
 OPTIONAL INPUT KEYWORDS:

       linestyle = array of linestyle numbers  If linestyle[i] < 0, then omit
               ith symbol or line to allow a multi-line entry.
       psym = array of plot symbol numbers.  If psym[i] is negative, then a
               line connects pts for ith item.  If psym[i] = 8, then the
               procedure usersym is called with vertices define in the
               keyword usersym.   If psym[i] = 88, then use the previously
               defined user symbol
       vectorfont = vector-drawn characters for the sym/line column, e.g.,
               ['!9B!3','!9C!3','!9D!3'] produces an open square, a checkmark,
               and a partial derivative, which might have accompanying items
               ['BOX','CHECK','PARTIAL DERIVATIVE'].
               There is no check that !p.font is set properly, e.g., -1 for
               X and 0 for PostScript.  This can produce an error, e.g., use
               !20 with PostScript and !p.font=0, but allows use of Hershey
               *AND* PostScript fonts together.
       N. B.: Choose any of linestyle, psym, and/or vectorfont.  If none is
               present, only the text is output.  If more than one
               is present, all need the same number of elements, and normal
               plot behaviour occurs.
               By default, if psym is positive, you get one point so there is
               no connecting line.  If vectorfont[i] = '',
               then plots is called to make a symbol or a line, but if
               vectorfont[i] is a non-null string, then xyouts is called.
       /help = flag to print header
       /horizontal = flag to make the legend horizontal
       /vertical = flag to make the legend vertical (D=vertical)
       box = flag to include/omit box around the legend (D=include)
       clear = flag to clear the box area before drawing the legend
       delimiter = embedded character(s) between symbol and text (D=none)
       colors = array of colors for plot symbols/lines (D=!P.color)
       textcolors = array of colors for text (D=!P.color)
       margin = margin around text measured in characters and lines
       spacing = line spacing (D=bit more than character height)
       pspacing = psym spacing (D=3 characters)
       charsize = just like !p.charsize for plot labels
       charthick = just like !p.charthick for plot labels
       thick = array of line thickness numbers, if used, then linestyle
               must also be specified
	box_color=color for the box       
	position = data coordinates of the /top (D) /left (D) of the legend
       normal = use normal coordinates for position, not data
       device = use device coordinates for position, not data
       number = number of plot symbols to plot or length of line (D=1)
       usersym = 2-D array of vertices, cf. usersym in IDL manual. (D=square)
       /fill = flag to fill the usersym
       /left = flag to place legend snug against left side of plot window (D)
       /right = flag to place legend snug against right side of plot window
               If /right,pos=[x,y], then x is position of RHS and text
               runs right-to-left.
       /top = flag to place legend snug against top of plot window (D)
       /bottom = flag to place legend snug against bottom of plot window
               /top,pos=[x,y] and /bottom,pos=[x,y] produce same positions.

       If LINESTYLE, PSYM, VECTORFONT, THICK, COLORS, or TEXTCOLORS are
       supplied as scalars, then the scalar value is set for every line or
       symbol in the legend.
 Outputs:
       legend to current plot device
 OPTIONAL OUTPUT KEYWORDS:
       corners = 4-element array, like !p.position, of the normalized
         coords for the box (even if box=0): [llx,lly,urx,ury].
         Useful for multi-column or multi-line legends, for example,
         to make a 2-column legend, you might do the following:
           c1_items = ['diamond','asterisk','square']
           c1_psym = [4,2,6]
           c2_items = ['solid','dashed','dotted']
           c2_line = [0,2,1]
           legend,c1_items,psym=c1_psym,corners=c1,box=0
           legend,c2_items,line=c2_line,corners=c2,box=0,pos=[c1(2),c1(3)]
           c = [c1(0)c2(2),c1(3)>c2(3)]
           plots,[c(0),c(0),c(2),c(2),c(0)],[c(1),c(3),c(3),c(1),c(1)],/norm
         Useful also to place the legend.  Here's an automatic way to place
         the legend in the lower right corner.  The difficulty is that the
         legend's width is unknown until it is plotted.  In this example,
         the legend is plotted twice: the first time in the upper left, the
         second time in the lower right.
           legend,['1','22','333','4444'],linestyle=indgen(4),corners=corners
                       ; BOGUS LEGEND---FIRST TIME TO REPORT CORNERS
           xydims = [corners(2)-corners(0),corners(3)-corners(1)]
                       ; SAVE WIDTH AND HEIGHT
           chdim=[!d.x_ch_size/float(!d.x_size),!d.y_ch_size/float(!d.y_size)]
                       ; DIMENSIONS OF ONE CHARACTER IN NORMALIZED COORDS
           pos = [!x.window(1)-chdim(0)-xydims(0) $
                       ,!y.window(0)+chdim(1)+xydims(1)]
                       ; CALCULATE POSITION FOR LOWER RIGHT
           plot,findgen(10)    ; SIMPLE PLOT; YOU DO WHATEVER YOU WANT HERE.
           legend,['1','22','333','4444'],linestyle=indgen(4),pos=pos
                       ; REDO THE LEGEND IN LOWER RIGHT CORNER
         You can modify the pos calculation to place the legend where you
         want.  For example to place it in the upper right:
           pos = [!x.window(1)-chdim(0)-xydims(0),!y.window(1)-xydims(1)]
 Common blocks:
       none
 Procedure:
       If keyword help is set, call doc_library to print header.
       See notes in the code.  Much of the code deals with placement of the
       legend.  The main problem with placement is not being
       able to sense the length of a string before it is output.  Some crude
       approximations are used for centering.
 Restrictions:
       Here are some things that aren't implemented.
       - An orientation keyword would allow lines at angles in the legend.
       - An array of usersyms would be nice---simple change.
       - An order option to interchange symbols and text might be nice.
       - Somebody might like double boxes, e.g., with box = 2.
       - Another feature might be a continuous bar with ticks and text.
       - There are no guards to avoid writing outside the plot area.
       - There is no provision for multi-line text, e.g., '1st line!c2nd line'
         Sensing !c would be easy, but !c isn't implemented for PostScript.
         A better way might be to simply output the 2nd line as another item
         but without any accompanying symbol or linestyle.  A flag to omit
         the symbol and linestyle is linestyle[i] = -1.
       - There is no ability to make a title line containing any of titles
         for the legend, for the symbols, or for the text.
 Side Effects:
 Modification history:
	10-Aug-07 add debug keyword. Don't die if more lines than labels. [BD]
	01-Mar-99 squeeze legend closer to top [Bill Davis]
       write, 24-25 Aug 92, F K Knight (knight@ll.mit.edu)
       allow omission of items or omission of both psym and linestyle, add
         corners keyword to facilitate multi-column legends, improve place-
         ment of symbols and text, add guards for unequal size, 26 Aug 92, FKK
       add linestyle[i]=-1 to suppress a single symbol/line, 27 Aug 92, FKK
       add keyword vectorfont to allow characters in the sym/line column,
         28 Aug 92, FKK
       add /top, /bottom, /left, /right keywords for automatic placement at
         the four corners of the plot window.  The /right keyword forces
         right-to-left printing of menu. 18 Jun 93, FKK
       change default position to data coords and add normal, data, and
         device keywords, 17 Jan 94, FKK
       add /center keyword for positioning, but it is not precise because
         text string lengths cannot be known in advance, 17 Jan 94, FKK
       add interactive positioning with /position keyword, 17 Jan 94, FKK
       allow a legend with just text, no plotting symbols.  This helps in
         simply describing a plot or writing assumptions done, 4 Feb 94, FKK
       added thick, symsize, and clear keyword Feb 96, W. Landsman HSTX
               David Seed, HR Wallingford, d.seed@hrwallingford.co.uk
       allow scalar specification of keywords, Mar 96, W. Landsman HSTX
       added charthick keyword, June 96, W. Landsman HSTX
		DM, allow choosing of color for box

Source: src/idl_cvs/linesout.pro

 NAME:
       linesout
 PURPOSE:
 	Write lines out to an X window. Works like xyouts, but uses
	line #'s (from the top) and /right if you want to right justify text.  
 CATEGORY:
       Plotting, Strings
 CALLING SEQUENCE:
       IDL> linesout, text, line=line
 INPUTS:
       text - text string to write to window
 KEYWORD PARAMETERS:
	line - line # location, starting with 1 at the top (default=1)
	right - if set, text will be right-justified, rather than left
	center - if set, will center line (default to left justify).
	charsize - character size of text (default to !p.charsize or 1)
	dropshadow - if set, make a drop shadow of thick=3 text
	thickDropShadow - thickness of drop shadow (default to 1, or 2 if /highlight)
	color - color of text
	dscolor - color of drop-shadow text (defaults to black or white)
	bottom - if set, write lines from bottom, instead of top.
 OUTPUTS:
       none
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> !p.color=mk_color('black')
	IDL> !p.backround=mk_color('white')
	IDL> plot,indgen(11)
	IDL> linesout, 'Hi Mom', line=2, /right, /dropshadow, charsize=2, $
			color=mk_color('black'), dscolor=mk_color('red')
 NOTES:
 MODIFICATION HISTORY:
	24-Oct-2006 added bottom, xpos, ypos, thickDropShadow, & highlight keyword
       25-Aug-2005 Written by Bill Davis, PPPL

Source: src/idl_cvs/lint.pro

 NAME:
       LINT
 PURPOSE:
       Find the intersection of two lines in the XY plane.
 CATEGORY:
 CALLING SEQUENCE:
       lint, a, b, c, d, i1, i2
 INPUTS:
       a, b = Points on line 1.          in
       c, d = Points on line 2.          in
 KEYWORD PARAMETERS:
       Keywords:
         FLAG=f  Returned flag:
           0 means no intersections (lines parallel).
           1 means one intersection.
           2 means all points intersect (lines coincide).
         /COND print condition number for linear system.
 OUTPUTS:
       i1, i2 = Returned intersection.   out
         Both i1 and i2 should be the same.
 COMMON BLOCKS:
 NOTES:
       Notes: Each point has the form [x,y].
 MODIFICATION HISTORY:
       R. Sterner, 1998 Feb 4

 Copyright (C) 1998, 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/linterp.pro

 NAME:   
       LINTERP  
 PURPOSE: 
       Linearly interpolate tabulated 1-d data from one grid to a new one.
 EXPLANATION:
       The results of LINTERP are numerically equivalent to the RSI
       INTERPOL() function, but note the followign:
         (1) LINTERP is a procedure rather than a function
         (2) INTERPOL() extrapolates beyond the end points whereas LINTERP
             truncates to the endpoints (or use the MISSING keyword)
         (3) LINTERP (unlike INTERPOL) uses the intrinsic INTERPOLATE function
                 and thus may have a speed advantage

       Use QUADTERP for quadratic interpolation.

 CALLING SEQUENCE:
       LINTERP, Xtab, Ytab, Xint, Yint, [MISSING =, /NoInterp ]   

 INPUT PARAMETERS: 
       Xtab - Vector containing the current independent variable grid.
               Must be monotonic increasing or decreasing
       Ytab - Vector containing the current dependent variable values at 
               the XTAB grid points.
       Xint - Scalar or vector containing the new independent variable grid 
               points for which interpolated value(s) of the dependent 
               variable are sought.

 OUTPUT PARAMETERS:
       Yint  - Scalar or vector with the interpolated value(s) of the 
               dependent variable at the XINT grid points.
               YINT is double precision if XTAB or YTAB are double,
               otherwise YINT is REAL*4

 OPTIONAL INPUT KEYWORD:
       MISSING - Scalar specifying YINT value(s) to be assigned, when Xint
               value(s) are outside of the range of Xtab.     Default is to
               truncate the out of range YINT value(s) to the nearest value 
               of YTAB.   See the help for the INTERPOLATE function.
       /NoINTERP - If supplied then LINTERP returns the YTAB value(s) 
               associated with the closest XTAB value(s)rather than 
               interpolating.

 EXAMPLE:
       To linearly interpolate from a spectrum wavelength-flux pair
       WAVE, FLUX to another wavelength grid defined as:
       WGRID = [1540., 1541., 1542., 1543., 1544, 1545.]
   
       IDL>  LINTERP, WAVE, FLUX, WGRID, FGRID  

       FGRID will be a 6 element vector containing the values of FLUX 
       linearly interpolated onto the WGRID wavelength scale

 PROCEDURE: 
       Uses TABINV to calculate the effective index of the values
       in Xint in the table Xtab.  The resulting index is used
       with the intrinsic INTERPOLATE function to find the corresponding 
       Yint value in Ytab.  Unless the MISSING keyword is supplied, out
       of range Yint values are truncated to the nearest value of Ytab.

 PROCEDURES CALLED:
       TABINV, ZPARCHECK
 MODIFICATION HISTORY:
       Adapted from the IUE RDAF,  W. Landsman      October, 1988
       Modified to use the new INTERPOLATE function        June, 1992
       Modified to always return REAL*4             October, 1992
       Added MISSING keyword                        August, 1993
       Converted to IDL V5.0   W. Landsman   September 1997
       Added NoInterp keyword  W. Landsman      July 1999

Source: src/idl_cvs/listfromperl.pro

 NAME:
      listFromPerl
 PURPOSE:
       Called from a Perl Script to list MDSplus data from a Web Page
 CATEGORY:
       WebTools, MDSplus
 MODIFICATION HISTORY:
       14-Jul-04 added parseShotInput for handling inputs

Source: src/idl_cvs/listshots.pro

 NAME:
       ListShots
 PURPOSE:
	List shot numbers with signal over/under a certain amount
 CATEGORY:
       MDSplus
 CALLING SEQUENCE:
       IDL> listshots, shot, nshots,  signal=signal, warningLevel=warningLevel
 INPUTS:
       shot - if an interger: beginning shot # to search for 
		if an array of integers, use as a shot list (ignore nshots)
       nshots - # of shots to search over (def=10)
 KEYWORD PARAMETERS:
    Optional Inputs:
	comparator - 'GT' (default) or 'LT' for cutoff and warning
	cutoff - value under which value will be ignored
	outFile - outFile for output
	nSmooth - # for median smoothing before using signal (default=0)
	noScreen - if set, do not echo output to screen
	server - MDSplus server, default='EUROPA.PPPL.GOV:8501'
	signal - mdsplus signal name
	skip - shots to skip while looping through list
	warningLevel - warn if greater than than this value
    Optional Returned:
	count - number of shots satisfying criteria
 OUTPUTS:
       just to screen and/or file           			
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> listshots, 102915, 10,  signal='\WF::IP', warn=1.0
 NOTES:
       tree should be in signal name
 MODIFICATION HISTORY:
	17-Apr-2008 Made > 0 not return zero values
	04-May-2006 changed openMDSshot to mdsopen
	03-Mar-04 a little bullet proofing
	23-May-01 Written by Bill Davis, PPPL

Source: src/idl_cvs/list_printer_unix.pro

 NAME: 
	LIST_PRINTER_UNIX

 PURPOSE: 
	LIST available printers from lpstat -a

 CATEGORY: 
	Printing, Unix

 SYNTAX: 
	IDL> printers=list_printer_unix(desc)

 EXAMPLES: 
	(see example in mk_pdmenu)

 INPUTS: None

 OUTPUTS: 
	PRINTERS - printer que names

    Opt. Outputs: 
	DESC - description of each printer (doesn't work for printcap.lprng)

 KEYWORDS: 
	printcap - the  printcap file to query (INPUT)
	ERR - error messages (OUTPUT)

 COMMON: 
	LIST_PRINTER_UNIX - contains last reading of printcap file

 Restrictions: 
	Unix only.

 History     
		22-Feb-2012 use "lpstat-a" for discovering printers
 		12-May-2005 Made to work for Red Hat Enterprise Linux
			where names end with colon [BD]
		13-Jan-2003 added printcap.lprng to file search and remove
			blank printer names. If file=printcap.lprng, also
			look for printer names as first character of line. [Bill Davis]

		Version 1,  8-Aug-1995, D M Zarro . Written
               Version 2,  1 July 1996, S.V.H.Haugan (UiO)
                       Added PSLASER/PSCOLOR/PSCOLOR2 environmentals check.
               1-Nov-2000, Kim Tolbert - Previously only worked for unix machines with
                       /etc/printcap file for printers (DEC, ?). Added check
                       for /etc/printers.conf (Sun) also.
               18-Dec-2001, Kim Tolbert.  Some unix (linux) allows pipe symbol (|) in
                       lp definition (like :lp=|/usr/share/printconf/jetdirectprint:\)
                       so have to look for names in lines with | but no colon in first column.
                       Also, names can be in lines with |, or lines with : (if not in
                       first column), so append result of both kinds of search instead of
                       doing one or the other.
                       Also, eliminate all comment lines first

Source: src/idl_cvs/loadblobs.pro

 NAME:
   loadblobs

 PURPOSE:
	calls many routines used for loading blob tracking info into a 
	database and making plots and output files

 CATEGORY:
	blobs

 CALLING SEQUENCE:
       IDL> loadblobs, filename

 INPUTS:
       filename - a .cin or .hdf file containing plasma images
	
 KEYWORD PARAMETERS:
	filename - cine file to analyze
	outfilename - output of text with blob info (default formed from inputs)
	t1 - start time desired in terms of times in .cin file (in sec)
	t2 - end time desired in terms of times in .cin file (in sec)
       aveT1 - start for averaging frame (DEF=t1) if normalize=1
       aveT2 - ending time for averaging frame (DEF=t2)   
	horiz - if=0, do not flip frames horizontally
	RotCCW - if set, will rotate frame Counter-clockwise (after horizontal flip)
		default for NSTX, but not for CMOD
	BlobCriteria - structure for blob criteria, like min normalized height, etc.
	normalize - normalize images (divide by average frame) before looking for 
		blobs.
	deleteFirst - if = 0, will NOT first delete the existing database table.
	dbOut - if=0, will not write to an SQL database
	outDBfile - if set, will write database info to this filename, rather than db
       table - if not set, will write to table SH+
	database - if not set, will write to database 'BLOBS'
	nSmooth - amount to smooth image before looking for blobs
	GaussSmooth - if set, will do "gaussian" smoothing (sort of a double smooth)
		      instead of boxcar smoothing
	velSmooth - amount to smooth velocity tracks before putting into database
	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
	AveFrameSmooth - smoothing for the averaged frame(s)
	verbose - if set, lots of information output listed
	debug - if set, will output even more and may stop at some spots

 NOTES:
      see CheckBlobVel.txt for validation case
   
 EXAMPLES:

   ; NB scan
 loadblobs, T1=0.500, T2=0.510, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139481.cin' 

 loadblobs, T1=0.500, T2=0.510, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139482.cin' 

 loadblobs, T1=0.500, T2=0.510, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139483.cin' 

   ; Li scan
 loadblobs, T1=0.580, T2=0.590, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141319.cin' 

 loadblobs, T1=0.580, T2=0.590, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141326.cin' 

 loadblobs, T1=0.530, T2=0.540, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141320.cin' 

 loadblobs, T1=0.530, T2=0.540, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141324.cin' 

 loadblobs, T1=0.530, T2=0.540, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141322.cin' 

 loadblobs, T1=0.480, T2=0.490, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141307.cin' 

    ; two CMOD cameras for same shot 
	(when data retrieved from MDSplus at MIT, times are shot times):

 loadblobs, T1=1.089, T2=1.091, /verb,  table='SH1120224030x',   $	; cam near X-pt
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120224030x_blobs_1116-1118ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, $
       'shot_1120224030.cine'

 loadblobs, T1=1.089, T2=1.091, /verb,  table='SH1120224030m',   $	; cam near mid-plane
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120224030m_blobs_1116-1118ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, $
       'shot_1120224030.cin'  shot='1120224009'  &  t1=0.701    &  t2=t1+0.005
  shot='1120224015'  &  t1=0.801    &  t2=t1+0.004
  shot='1120224022'  &  t1=1.044    &  t2=t1+0.004	; 
  shot='1120224023'  &  t1=1.113    &  t2=t1+0.003
  shot='1120224024'  &  t1=1.130    &  t2=t1+0.005
  shot='1120224027'  &  t1=1.144    &  t2=t1+0.004

  shot='1120712026'  &  t1=1.144    &  t2=t1+0.004
  shot='1120712027'  &  t1=1.144    &  t2=t1+0.004
  shot='1120712028'  &  t1=1.144    &  t2=t1+0.005	; 
  shot='1120712029'  &  t1=1.144    &  t2=t1+0.003

  shot='1120815018'  &  t1=1.270    &  t2=t1+0.004
  shot='1120815021'  &  t1=1.190    &  t2=t1+0.003
  shot='1120815030'  &  t1=1.260    &  t2=t1+0.004
  shot='1120815034'  &  t1=1.150    &  t2=t1+0.003

 st1 = strtrim( string(t1*1000,format='(I4.4)'), 2)
 st2 = strtrim( string(t2*1000,format='(I4.4)'), 2)
 loadblobs, T1=t1, T2=t2, table='SH'+shot+'x',   $	; cam near X-pt
       /horiz, /RotCW, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_'+shot+'x_blobs_'+st1+'-'+st2+'ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, FrameAveDeltaMS=0, $
       'shot_'+shot+'.cine', /verb

 loadblobs, T1=t1, T2=t2, table='SH'+shot+'m',   $	; cam near midplane
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_'+shot+'m_blobs_'+st1+'-'+st2+'ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, FrameAveDeltaMS=0, $
       'shot_'+shot+'.cin', /verb	; midplane camera file does not end in e    ; for fake blobs covering whole center of image:
 ; and tilts
 .r getfakeblobs
 loadblobs, T1=0.080, T2=0.080+.002, /verb,  table='FakeShotXall',   $
       nSmooth=3, /GaussSmooth, outFile='shot_1120815021FakeX_blobs_80-80ms.txt',  $
       norm=0,  horiz=0,  minHt=3, velSmooth=0,  $
       '/p/gpi/szweben/Phantom2_Data/2012_shots/1120815/shot_1120815021.cine'

 loadblobs, T1=0.080, T2=0.080+.0055, /verb,  table='FakeShotM',   $
       nSmooth=3, /GaussSmooth, outFile='shot_1120815021FakeM_blobs_80-80ms.txt',  $
       norm=0,  horiz=0,  minHt=3, velSmooth=0,  $
       '/p/gpi/szweben/Phantom_Data/2012_data/1120815/shot_1120815021.cin'

 loadblobs, T1=0.080, T2=0.080+.0055, /verb,  table='FakeShotXT',   $
       nSmooth=3, /GaussSmooth, outFile='shot_1120815021FakeXT_blobs_80-80ms.txt',  $
       norm=0,  horiz=0,  minHt=3, velSmooth=0, $
       '/p/gpi/szweben/Phantom2_Data/2012_shots/1120815/shot_1120815021.cine'

 loadblobs, T1=0.080, T2=0.080+.0055, /verb,  table='FakeShotXT30',   $
       nSmooth=3, /GaussSmooth, outFile='shot_1120815021FakeXT30_blobs_80-80ms.txt',  $
       norm=0,  horiz=0,  minHt=3, velSmooth=0, $
       '/p/gpi/szweben/Phantom2_Data/2012_shots/1120815/shot_1120815021.cine'
    ; two CMOD cameras for same shot:

 loadblobs, T1=1.086, T2=1.088, /verb,  table='SH1120224029x',   $	; cam near X-pt
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120224029x_blobs_1086-1088ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, $
       'shot_1120224029.cine'

 loadblobs, T1=1.086, T2=1.088, /verb,  table='SH1120224029m',   $	; cam near X-pt
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120224029m_blobs_1086-1088ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, $
       'shot_1120224029.cin'
    ; two CMOD cameras for same shot 
	(stewarts Movie is from 1.116-1.118, but stuff starts happening at 1.117):

 loadblobs, T1=1.115, T2=1.117, /verb,  table='SH1120224022x',   $	; cam near X-pt
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120224022x_blobs_1116-1118ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, $
       'shot_1120224022.cine'

 loadblobs, T1=1.115, T2=1.117, /verb,  table='SH1120224022m',   $	; cam near X-pt
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120224022m_blobs_1116-1118ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, $
       'shot_1120224022.cin'
 loadblobs, T1=0.080, T2=0.090, /verb,  table='SH1120815021xN',   $	; cam near X-pt
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120815021xN_blobs_80-90ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, $
       '/p/gpi/szweben/Phantom2_Data/2012_shots/1120815/shot_1120815021.cine'

 loadblobs, T1=0.080, T2=0.090, /verb, table='SH1120815021mN',    $	; midplane cam
       /horiz, minHt=0.33, minRise=0.04, Chi=5, velSmooth=0,  $
       nSmooth=3, /GaussSmooth, outFile='shot_1120815021mN_blobs_80-90ms.txt', $
       AveFrameSmooth=0, FrameAveMin=25, FrameOffset=25, $
      '/p/gpi/szweben/Phantom_Data/2012_data/1120815/shot_1120815021.cin' loadblobs, T1=0.080, T2=0.090, /verb,  table='SH1120224022xN',   $	; cam near X-pt
       /horiz, minHt=0.5, minRise=0.06, Chi=5,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120224022x_blobs_80-90ms.txt',  $
       AveFrameSmooth=0, FrameAveMin=25, $
       '/p/gpi/szweben/Phantom2_Data/2012_shots/1120224/shot_1120224022.cine'

 loadblobs, T1=0.080, T2=0.090, /verb, table='SH1120224022mN',    $	; midplane cam
       /horiz, minHt=0.33, minRise=0.04, Chi=5, velSmooth=0,  $
       nSmooth=3, /GaussSmooth, outFile='shot_1120224022m_blobs_80-90ms.txt', $
       AveFrameSmooth=0, FrameAveMin=25, FrameOffset=25, $
      '/p/gpi/szweben/Phantom_Data/2012_data/1120224/shot_1120224022.cin'    ; two CMOD cameras for same shot -- try without normalization
 loadblobs, T1=0.020, T2=0.040, /verb,  table='SH1120815021x',   $	; cam near X-pt
       /horiz, minHt=20, norm=0, minRise=4, Chi=8,  velSmooth=0, $
       nSmooth=3, /GaussSmooth, outFile='shot_1120815021x_blobs_20-40ms.txt',  $
       '/p/gpi/szweben/Phantom2_Data/2012_shots/1120815/shot_1120815021.cine'

 loadblobs, T1=0.020, T2=0.040, /verb, table='SH1120815021m',    $
       /horiz, minHt=20, norm=0, minRise=4, Chi=8, velSmooth=0,  $
       nSmooth=3, /GaussSmooth, outFile='shot_1120815021m_blobs_20-40ms.txt', $
   '/p/gpi/szweben/Phantom_Data/2012_data/1120815/shot_1120815021.cin'

   ; try that shot with normal params
 loadblobs, T1=0.020, T2=0.040, /verb, table='SH1120815021',    $
       /horiz, outFile='shot_1120815021_blobs_20-40ms.txt', $
   '/p/gpi/szweben/Phantom_Data/2012_data/1120815/shot_1120815021.cin'

   ; defaults work pretty well when normalizing:

 loadblobs, T1=0, T2=0.020, /verb,    $
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216017.cin'
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216018.cin'
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216019.cin'
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216023.cin'
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216025.cin'
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216026.cin'
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216028.cin'
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216029.cin'
    '/p/gpi/szweben/Phantom_Data/2009_Phantom_data/1091216/shot_1091216030.cin'
   
 loadblobs, T1=0.050, T2=0.070, /verb,   $
    '/p/gpi/szweben/Phantom_Data/2010_data/1100120/shot_1100120025.cin'
    '/p/gpi/szweben/Phantom_Data/2010_data/1100120/shot_1100120026.cin'
    '/p/gpi/szweben/Phantom_Data/2010_data/1100120/shot_1100120027.cin'
   
 loadblobs, T1=0.050, T2=0.070, /verb,   $
    '/p/gpi/szweben/Phantom_Data/2010_data/1100803/shot_1100803005.cin'
    '/p/gpi/szweben/Phantom_Data/2010_data/1100803/shot_1100803008.cin'
    '/p/gpi/szweben/Phantom_Data/2010_data/1100803/shot_1100803011.cin'
    '/p/gpi/szweben/Phantom_Data/2010_data/1100803/shot_1100803015.cin'

 loadblobs, T1=0.060, T2=0.080, /verb,   $
    '/p/gpi/szweben/Phantom_Data/2010_data/1100824/shot_1100824017.cin'
    '/p/gpi/szweben/Phantom_Data/2010_data/1100824/shot_1100824019.cin'
    '/p/gpi/szweben/Phantom_Data/2010_data/1100824/shot_1100824021.cin'
   
 loadblobs, T1=0, T2=0.020, /verb,   $
    '/p/gpi/szweben/Phantom_Data/2011_data/1110114/shot_1110114023.cin'
    '/p/gpi/szweben/Phantom_Data/2011_data/1110114/shot_1110114026.cin'
    '/p/gpi/szweben/Phantom_Data/2011_data/1110114/shot_1110114027.cin'
   
 loadblobs, T1=0.017, T2=0.027, /verb,   $
    '/p/gpi/szweben/Phantom_Data/2011_data/1110114/shot_1110114032.cin'

	For Matt:
 loadblobs, T1=0.24, T2=0.27, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_142000.cin' 

 loadblobs, T1=0.219, T2=0.229, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138120.cin' 

 loadblobs, T1=0.225, T2=0.235, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138114.cin' 

 ; APS NB
 loadblobs, T1=0.280, T2=0.300, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138119.cin' 

 loadblobs, T1=0.290, T2=0.300, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138128.cin' 

 loadblobs, T1=0.280, T2=0.300, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_142220.cin' 

 loadblobs, T1=0.530, T2=0.550, /verb, FrameAveDeltaMS=0, table='SH138234z',  $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_138234.cin' 

 loadblobs, T1=0.268, T2=0.288, /verb, table='SH139432',  $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139432.cin' 

 loadblobs, T1=0.258, T2=0.278, /verb, table='SH139444',  $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_139444.cin' 

 loadblobs, T1=0.200, T2=0.220, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141751.cin'

 loadblobs, T1=0.210, T2=0.230, /verb,   $
    '/p/nstxcam-archive/Phantom710-9205/2010/nstx_5_141752.cin'    , /deb

 loadblobs, T1=0.021, T2=0.031, /verb, '/p/nstxcam/CMOD/shot_1120223031.cin'    , /deb

    to load a file, but not a database:
 loadblobs, '/u/bdavis/Blobs/solt_012_3.5b.hdf', shot=99901203, dbout=0, $
		outDBfile='solt_012_3.5b.txt', normalize=0, minHt=0.01, minRise=0.01

  27-Feb-2012 added smoothing options, since default in findblobs now=0

 MODIFICATION HISTORY:
	12-Nov-2012 made default GaussSmooth=1, to be consistent with FCplayer.
	17-May-2012 several updates to pass parameters to saveblobs for file output
	WRITTEN by Bill Davis, PPPL, for Stewart Zweben

Source: src/idl_cvs/load_fc.pro

 NAME:
       load_fc
 PURPOSE:
       Load summary Waveforms for Phantom Fast Cameras into MDSplus.
 PROCEDURE:
 CATEGORY:
       Fast Cameras, MDSplus
 CALLING SEQUENCE:
	load_fc, shot1, shot2, path=['/p/nstxusr/miro/2009','/p/nstxcam/miro/2009'], $
			       prefix='Miro'
	load_fc, shot1, shot2, path='/p/nstxusr/miro/2008',prefix='Miro'
 INPUTS:
	shot1 = starting shot number to process
	shot2 = (Optional) last shot number to process
 KEYWORDS:
    (Optional)
	test  - doesn't write to MDSplus
	EventDone - if there, will declare this event when all of one shot done
	noDeclare - if set, will declare NO events.
 COMMON BLOCKS:
       NONE
 NOTES:
       YOU NEED PRIVILEGES to write to the MDSplus tree. On skylark:

	IDL> addSigNodes, shot1, shot2, tree='CAMERAS', $
		nodes=['\aveintensity', '\maxintensity', '\ave_r','\ave_g','\ave_b' ], $
		tags =['\aveint', '\maxint','\ave_r','\ave_g','\ave_b']
	    (probably better to do the above in TCL procedure
 LIMITATIONS:
 MODIFICATION HISTORY:
  	09-Mar-2007 WRITTEN by Bill Davis

Source: src/idl_cvs/load_nebar.pro

 NAME:
       load_nebar

 PURPOSE:
       Load Ne-bar Waveform into MDSplus.

 CATEGORY:
       MDSplus, Density 

 CALLING SEQUENCE:
       load_nebar, shot1, shot2

 INPUTS:
	shot1 = starting shot number to process
	shot2 = (Optional) last shot number to process

 KEYWORDS:
    (Optional)
	test  - doesn't write to MDSplus
	wfTree - name of MDSplus tree to write to (defalut='WF')

 NOTES:
       YOU NEED PRIVILEGES to write to the MDSplus tree.

 LIMITATIONS:
	Divide by zeroes, etc. will cause a message like:
	    % Program caused arithmetic error: Floating illegal operand

 MODIFICATION HISTORY:
	WRITTEN 23-Jul-2013, by Bill Davis for Stewart Zweben

Source: src/idl_cvs/logbook_list.pro

 NAME:
       logbook_list
 PURPOSE:
       List info from the NSTX logbook (to a screen or file)
 CATEGORY:
       Database, NSTX
 CALLING SEQUENCE:
       IDL> logbook_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 shot1) 
	runID - Typically the XP #, e.g., 5
	rundate - run date (YYYYMMDD), e.g., 20060426
	username - computer username of person who made the entry, e.g. 'KAYE'
	str1, str2, str3 - strings that must be in the comments for a shot to be included
	logical1, logical2, 'AND' or 'OR' between str1, 2, & 3
	include - if NOT=0 and USERNAME specified then include any entries satisfying 
		other criteria for which TOPIC='PHS OPS' or 'SESSION LEADER'
	database - defaults to 'NSTXLOGS'
	break - if set, lines longer than 72 characters will be broken at an earlier space
	outFile - string (if not present, data listed to screen)
 OUTPUTS:
	data to screen or file, if specified
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> logbook_list, shot1=120200		
	IDL> logbook_list, rundate=20060426	; all shots from Apri. 25, 2006
	IDL> logbook_list, shot1=120200, shot2=130000, username='PAUL'
 MODIFICATION HISTORY:
	07-Apr-2009  made response better when nothing found
	29-Nov-2007  Had to change supersep to wrap long lines
	28-Nov-2007  Written by Bill Davis, PPPL (some code from Josh Stillerman)

Source: src/idl_cvs/logbook_list_plus.pro

 NAME:
       logbook_list_plus
 PURPOSE:
       List info from the NSTX logbook (to a screen or file)
 CATEGORY:
       Database, NSTX
 CALLING SEQUENCE:
       IDL> logbook_list_plus, shot1=shot1, shot2=shot2, XP=XP,  $
		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 shot1) 
	XP - Typically the XP #, e.g., 5
	rundate - run date (YYYYMMDD), e.g., 20060426
	username - computer username of person who made the entry, e.g. 'KAYE'
	str1, str2, str3 - strings that must be in the comments for a shot to be included
	logical1, logical2, 'AND' or 'OR' between str1, 2, & 3
	include - if NOT=0 and USERNAME specified then include any entries satisfying 
		other criteria for which TOPIC='PHS OPS' or 'SESSION LEADER'
	database - defaults to 'NSTXLOGS'
	break - if set, lines longer than 72 characters will be broken at an earlier space
	outFile - string (if not present, data listed to screen)
	xsize - horizontal size of plot summary 
	ysize - vertical size of plot summary 
 OUTPUTS:
	data to screen or file, if specified
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> logbook_list_plus, shot1=120200		
	IDL> logbook_list_plus, rundate=20060426	; all shots from April 25, 2006
	IDL> logbook_list_plus, shot1=120200, shot2=130000, username='PAUL'
	IDL> logbook_list_plus, shot1=120200, /verb, /debug, outfile='temp.html'
 MODIFICATION HISTORY:
	09-Aug-2013  don't set shot # if blank, but rundate specified.
	11-Jul-2012  make work if just username specified (didn't use %) and allow strings
		     of shot numbers.
	24-Aug-2010  included 'RF' as default entries.
	26-Jul-2010  addes for having checkboxes for topics on weblogplus.html
	15-Jul-2010  made lightning fast by searching subdirectories like 138000s for plot
		     summary files. See mkandmv.pro to make these directories and move files.
	08-Apr-2010  allow pre-existing jpegs to be in subdirectories
	08-Dec-2009  added keywords charsize, xsize, ysize
	14-Jul-2009  Return error if no entries found
	25-Jul-2008  Removed RunID keyword, and added XP [BD]
	10-Jul-2008  Added "order by shot" to query, so all shots shown
	29-Nov-2007  Had to change supersep to wrap long lines
	28-Nov-2007  Written by Bill Davis, PPPL (some code from Josh Stillerman)

Source: src/idl_cvs/logbook_options.pro

 NAME:
       logbook_options (copied from logbook_options)
 PURPOSE:
       List info from the NSTX logbook (to a screen or file)
 CATEGORY:
       Database, NSTX
 CALLING SEQUENCE:
       IDL> logbook_options, shot1=shot1, shot2=shot2, XP=XP,  $
		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 shot1) 
	XP - Typically the XP #, e.g., 5
	rundate - run date (YYYYMMDD), e.g., 20060426
	username - computer username of person who made the entry, e.g. 'KAYE'
	str1, str2, str3 - strings that must be in the comments for a shot to be included
	logical1, logical2, 'AND' or 'OR' between str1, 2, & 3
	include - if NOT=0 and USERNAME specified then include any entries satisfying 
		other criteria for which TOPIC='PHS OPS' or 'SESSION LEADER'
	database - defaults to 'NSTXLOGS'
	break - if set, lines longer than 72 characters will be broken at an earlier space
	outFile - string (if not present, data listed to screen)
	xsize - horizontal size of plot summary 
	ysize - vertical size of plot summary 
 OUTPUTS:
	data to screen or file, if specified
 COMMON BLOCKS:
       NONE
 EXAMPLE:
	IDL> logbook_options, shot1=120200		
	IDL> logbook_options, rundate=20060426	; all shots from April 25, 2006
	IDL> logbook_options, shot1=120200, shot2=130000, username='PAUL'
	IDL> logbook_options, shot1=120200, /verb, /debug, outfile='temp.html'
 MODIFICATION HISTORY:
	24-Aug-2010  included 'RF' as default entries.
	26-Jul-2010  addes for having checkboxes for topics on weblogplus.html
	15-Jul-2010  made lightning fast by searching subdirectories like 138000s for plot
		     summary files. See mkandmv.pro to make these directories and move files.
	08-Apr-2010  allow pre-existing jpegs to be in subdirectories
	08-Dec-2009  added keywords charsize, xsize, ysize
	14-Jul-2009  Return error if no entries found
	25-Jul-2008  Removed RunID keyword, and added XP [BD]
	10-Jul-2008  Added "order by shot" to query, so all shots shown
	29-Nov-2007  Had to change supersep to wrap long lines
	28-Nov-2007  Written by Bill Davis, PPPL (some code from Josh Stillerman)

Source: src/idl_cvs/long64date2str.pro

 NAME:
       long64date2str
 PURPOSE:
 	Return date from a 64-bit longword, like 1112308040, as returned
	from file_info, in a more conventional format.
 CATEGORY:
	Dates
 CALLING SEQUENCE:
       dateString = long64date2str( long64date )
 INPUTS:
       long64date returned from file_info, e.g., 1112308040
 RETURNED:
       dateString - conventional date string, e.g. 02/18/2006
 KEYWORDS
	delim - (string) delimeter used for output (Default is /)
	twoDigitsForYear - if set, year will be last two digits of year
	filetime - time of day of file, e.g. 14:32:59
	year - year of file
	month - numerical month of file
	day - numerical day of file
 EXAMPLES: 

	IDL> print,long64date2str( 1112308040 )
	03/31/2005

	IDL> print,long64date2str( 1112308040, /twoDigitsForYear )
	03/31/05

 MODIFICATION HISTORY:
 	WRITTEN 3-Jan-2007 by Bill Davis

Source: src/idl_cvs/longdate2str.pro

 NAME:
       longdate2str
 PURPOSE:
 	Return date from a longword, like 20060218, in a more conventional 
	format
 CATEGORY:
	Dates
 CALLING SEQUENCE:
       dateString = longdate2str( longDate )
 INPUTS:
       date in form yyyymmdd, e.g., 20060218
 RETURNED:
       dateString - conventional date string, e.g. 02/18/2006
 KEYWORDS
	delim - (string) delimeter used for output (Default is /)
	twoDigitsForYear - if set, year will be last two digits of year
 EXAMPLES: 

	IDL> print,longdate2str( 20060218 )
	02/18/2006

	IDL> print,longdate2str( 19951229, /twoDigitsForYear )
	12/29/95

 MODIFICATION HISTORY:
 	WRITTEN by 1-May-2006 Bill Davis