This page was created by the IDL library routine mk_html_help2.

Last modified: Thu Sep 27 14:05:48 2007.


Directory Listing of Routines


Routine Descriptions

APPEND_ARRAY

[Next Routine] [List of Routines]
PROCEDURE: append_array, a0, a1
PURPOSE:
   Append an array to another array.  Can also copy an array into a
   subset of another.
INPUT:
   a0:   Array to modify.
   a1:   Array to append to, or copy into, a0.
KEYWORDS:
   index:    Index of a0 at which to append or copy a1.  If index is
     greater than the number of elements of a0, then
     a0 is enlarged to append a1. Returns the index of the first
     element of a0 past the section copied from a1.
   done: If set, make a0 equal to the first index elements of a0.
CREATED BY:    Davin Larson
LAST MODIFIED: @(#)append_array.pro    1.6 98/08/13

(See ssl_general/misc/append_array.pro)


ARRAY_CROSS

[Previous Routine] [Next Routine] [List of Routines]
 FUNCTION array_cross(l1,l2)
 Purpose:
    returns a 2*n array, where n = n_elements(l1)*n_elements(l2)
    each pair is a combination of l1 and l2
    the total list represents all possible pairings of l1 and l2

 Written by Patrick Cruce

 $LastChangedBy: kenb-mac $
 $LastChangedDate: 2007-06-25 17:53:45 -0700 (Mon, 25 Jun 2007) $
 $LastChangedRevision: 870 $
 $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/tags/tdas_2_02/misc/array_cross.pro $

(See ssl_general/misc/array_cross.pro)


AVERAGE_STR

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:	average_str(data, res)
PURPOSE:
	Average data in res second time segments.
INPUTS:
	DATA:	array of structures.  One element of structure must be TIME.
	RES:	resolution in seconds.
KEYWORDS:
	NAN:	If set, treat the IEEE NAN value as missing data.
CREATED BY:	Davin Larson
LAST MODIFIED:	%W% %E%

(See ssl_general/misc/average_str.pro)


BYTESCALE

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:  bytescale(array)
PURPOSE:   Takes an array or image and scales it to bytes
INPUT:     array of numeric values.
KEYWORDS:
   RANGE:  Two element vector specifying the range of array to be used.
        Defaults to the min and max values in the array.
   ZERO:   Forces range(0) to zero
   TOP:    Maximum byte value  (default is !d.table_size-2)
   BOTTOM: Minimum byte value  (default is 1)
   MIN_VALUE: autoranging ignores all numbers below this value
   MAX_VALUE: autoranging ignores all numbers above this value
   MISSING:  Byte value for missing data. (values outside of MIN_VALUE,
     MAX_VALUE range)  If the value is less than 0 then !p.background is used.
   LOG:    sets logrithmic scaling

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)bytescale.pro	1.22 02/04/17

(See ssl_general/misc/bytescale.pro)


CART_TO_SPHERE

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:  cart_to_sphere, x, y, z,  r, theta, phi
PURPOSE:
            transform from cartesian to spherical coordinates
INPUTS:     x, y, z          (array or scalor)
OUTPUTS:    r, theta, phi    (same as x,y,z)
KEYWORDS:   ph_0_360:   if positive, 0<=phi<=360, if zero, -180<=phi<=180,
                        ***if negative, best guess phi range returned***
            ph_hist:   a two element array of max and min values for phi.
                        eg: if ph_0_360 is not set, and ph_hist=[-220,220]
                            then if d(phi)/dt is positive near 180, then
                            phi => phi+360 when phi passes the 180/-180
                            discontinuity until phi reaches 220.
            CO_LATITUDE:  If set theta will be in co-latitude. (0<=theta<=180)
            MIN_VALUE:
            MAX_VALUE:
CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)cart_to_sphere.pro	1.13 02/04/17

NOTES:
   -90 < theta < 90   (latitude not co-lat)

(See ssl_general/misc/cart_to_sphere.pro)


CDF_FILE_NAMES

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION: cdf_file_names
PURPOSE:
   Returns an array of filenames within a timerange.
USAGE:
   files=cdf_file_names(FORMAT,trange=trange,/verbose)
INPUT:
   FORMAT is a string that will be interpreted as one of two things:
     CASE 1:  
        e.g.    FORMAT = '/home/wind/dat/wi/3dp/k0/????/wi_k0_3dp*.cdf'
        if FORMAT contains * or ? then filenames are returned that match that
        pattern and for which YYYYMMDD falls within the specified timerange.
        for example:  
        (UNIX only)
     CASE 2:
        e.g.    FORMAT = 'fa_k0_ees_files'
        The name of an indexfile that associates filenames with start and 
        end times. If his file is not found, then the environment variable 
        getenv('CDF_INDEX_DIR') is prepended and searched for.
        See "make_cdf_index" for information on producing this file.
     SPECIAL NOTE:
        If strupcase(FORMAT) is the name of an environment varible. Then
        the value of that environment variable is used instead.
KEYWORDS:
     TRANGE: 
        Two element array specifying the time range for which data files should
        be returned.  If not provided then "timerange" is called to provide
        the time range.  See also "timespan".
     NFILES:
        Named variable that returns the number of files found.
     VERBOSE:
        Set to print some useful info.
     FILEINFO:  OBSOLETE!
        Set to a named variable that will return a table of file info.
NOTES:
     UNIX only!

(See ssl_general/misc/cdf_file_names.pro)


COLORS_COM

[Previous Routine] [Next Routine] [List of Routines]
COMMON BLOCK  colors_com
WARNING!  Don't rely on this file to remain stable!
USE "get_colors" to get color information.
SEE ALSO:
  "get_colors","bytescale","loadct2"
CREATED BY: Davin Larson
File:      96/08/30
Version:   1.2
Last Mod:  colors_com.pro

(See ssl_general/misc/colors_com.pro)


DAY_TO_YEAR_DOY

[Previous Routine] [Next Routine] [List of Routines]
NAME:
   day_to_year_doy
PURPOSE:
   determines year and day of year given day since 0000 AD
USAGE:
   day_to_year_doy,daynum,year,doy
INPUT:
   daynum:   (long int)  day since 0 AD
OUTPUT:
   year:     year         (0 <= year <= 14699 AD)
   doy:      day of year  (1 <= doy  <=  366) 
NOTES:
  This procedure is reasonably fast, it works on arrays and works from
  0 AD to 14699 AD

CREATED BY:	Davin Larson  Oct 1996
FILE:  day_to_year_doy.pro
VERSION:  1.2
LAST MODIFICATION:  97/01/27

(See ssl_general/misc/day_to_year_doy.pro)


DIMEN

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:   dimen(x)
PURPOSE:
  Returns the dimensions of an array as an array of integers.
INPUT:  matrix
RETURNS:  vector of dimensions of matrix.
   If the input is undefined then 0 is returned.
   if the input is a scaler then 1 is returned.

SEE ALSO:  "dimen", "data_type", "dimen1", "dimen2"

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)dimen.pro	1.6 96/12/16

(See ssl_general/misc/dimen.pro)


DIMEN1

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:   dimen1
INPUT:  matrix
RETURNS:  scaler int:  size of first dimension  (1 if dimension doesn't exist)

CREATED BY:	Davin Larson
LAST MODIFICATION;	@(#)dimen1.pro	1.3 95/08/24

(See ssl_general/misc/dimen1.pro)


DIMEN2

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:   dimen2
INPUT:  matrix
RETURNS:  scaler int:  size of second dimension  (1 if dimension doesn't exist)

CREATED BY:	Davin Larson
LAST MODIFICATION;	@(#)dimen2.pro	1.3 95/08/24

(See ssl_general/misc/dimen2.pro)


DIMEN_SHIFT

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:  dimen_shift(x,shift)
NAME:
  dimen_shift
PURPOSE:
  Rotate dimensions of a multidimensional array.
  This function is very similar to transpose but works on multi-dimensional
  arrays to shift the dimensions around.
  It has no effect on scalars and one dimensional arrays.
INPUT:
  x   multi-dimensional array of any type
  shift:  1 or -1  direction of shift.
CREATED BY: Davin Larson
LAST MODIFICATION:	@(#)dimen_shift.pro	1.4 98/07/09
 

(See ssl_general/misc/dimen_shift.pro)


DIVIDE_DATA

[Previous Routine] [Next Routine] [List of Routines]

PROCEDURE:	divide_data

PURPOSE:

  Divides successive channels of SST data by powers of 'factor', to

  separate the traces. Also, optionally, multiplies data by an overall factor,

  'conv_factor', to convert units.



INPUT:		in_name (string), the name of the input TPLOT variable
			structure.
               out_name (string), the name of the output TPLOT variable
			structure.

KEYWORDS:      factor (float), by which fluxes in successive channels are

               	divided.
		conv_factor (optional float), by which fluxes in all channels
			are multiplied.


CREATED BY:	Ted Freeman

FILE:  divide_data.pro

LAST MODIFIED:  @(#)divide_data.pro	1.2 99/09/01



NOTES:	  "LOAD_3DP_DATA" and "GET_SPEC" must be called first.

(See ssl_general/misc/divide_data.pro)


DOY_TO_MONTH_DATE

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:
  doy_to_month_date, year, doy, month, date
NAME:
  doy_to_month_date
PURPOSE:
 Determines month and date given the year and day of year.
 fast, vector oriented routine that returns the month and date given year and 
 day of year (1<=doy<=366)

CREATED BY:	Davin Larson  Oct 1996
FILE:  doy_to_month_date.pro
VERSION:  1.2
LAST MODIFICATION:  97/01/27

(See ssl_general/misc/doy_to_month_date.pro)


DPWRSPC

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 dpwrspc
PURPOSE:
    Called with times time and data quantity, dpwrspc returns a dps
    spectrum at frequencies fdps. A Hanning window is applied to
    the input data, and its power is divided out of the returned
    spectrum. A straight line is subtracted from the data to
    reduce spurius power due to sawtooth behavior of a background.
    UNITS ARE (UNITS)^2 WHERE UNITS ARE THE UNITS OF time. fdps is in Hz.
    THUS THE OUTPUT REPRESENTS THE MEAN SQUARED AMPLITUDE OF THE SIGNAL
       AT EACH SPECIFIC FREQUENCY. THE TOTAL (SUM) POWER UNDER THE CURVE IS
       EQUAL TO THE MEAN (OVER TIME) POWER OF THE OSCILLATION IN TIME DOMAIN.
    NOTE: IF KEYWORD notperhz IS SET, THEN POWER IS IN UNITS OF NT^2 ELSE
                              IT IS IN UNITS OF NT^2/HZ
CALLING SEQUENCE:
 dpwrspc, time, quantity, tdps, fdps, dps, nboxpoints = nboxpoints, $
          nshiftpoints = nshiftpoints, bin = bin, tbegin = tbegin,$
          tend = tend, noline = noline, nohanning = nohanning, $
          notperhz = notperhz
INPUT:
 time = the time array
 quantity = the function for which you want to obtain a power
            spectrum
OUTPUT:
 tps = the time array for the dynamic power spectrum
 fdps = the frequency array (units =1/time units)
 dps = the power spectrum, (units of quantity)^2/frequency_units
KEYWORDS:
 nboxpoints = the number of points to use for the hanning window, the
              default is 256
 nshiftpoints = the default is 128
 bin = a binsize for binning of the data, the default is 3
 tbegin = a start time, the default is time[0] 
 tend = an end time, the default is time[n_elements(time)-1]
 noline = if set, no straight line is subtracted
 nohanning = if set, then no hanning window is applied to the input
 notperhz = if set, the output units are simply the square of the
            input units 

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/dpwrspc.pro)


EXTRACT_TAGS

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:  extract_tags, newstruct, oldstruct
PURPOSE: takes the named tag elements from oldstruct and puts them into
   newstruct.  This procedure is very useful for creating a structure that
   can be passed onto the PLOT or OPLOT subroutines using the _EXTRA keyword.
   If no tag keywords are included then all tag elements of oldstruct are
   added to newstruct.  The mode keyword PRESERVE is used to prevent the
   overwritting of an existing keyword.
INPUTS:
  newstruct:  new structure to be created or added to.
  oldstruct:  old structure from which elements are extracted.
KEYWORDS:  Only one of the following should be given:;
 (TAG KEYWORDS)
  TAGS:  array of strings.  (tag names) to be taken from oldstruct and put in
      newstruct
  EXCEPT: array of strings.  Tag names not to be copied from old to new.
  OPLOT:  (flag)  If set, then TAGS is set to an array of valid keywords
     for the OPLOT subroutine.
  PLOT:   (flag)  If set, then TAGS is set to an array of valid keywords
     for the PLOT subroutine.
  CONTOUR: (flag) If set, then TAGS is set to an array of valid keywords
     for the CONTOUR procedure.   (might not be complete)
If no KEYWORDS are set then all elements of oldstruct are put into newstruct
  (MODE KEYWORDS)
  PRESERVE: (flag) Prevents the overwritting of an existing, non-null keyword.
     Adds tags to newstruct that were not already there, or if they were there
     and their values were either "" or 0.
CREATED BY:	Davin Larson
FILE:  extract_tags.pro
VERSION  1.21
LAST MODIFICATION: 02/04/17

(See ssl_general/misc/extract_tags.pro)


FILE_HTTP_COPY[1]

[Previous Routine] [Next Routine] [List of Routines]
 The documentation is not yet correct.
 NAME:
    file_http_copy

 PURPOSE:
    Use the IDL SOCKET procedure to get files from http servers

 EXPLANATION:
     FILE_HTTP_COPY can access http servers - even from behind a firewall -
     and perform simple downloads. Currently,
     Requires IDL V5.4 or later on Unix or Windows, V5.6 on
     Macintosh

 CALLING SEQUENCE:
      FILE_HTTP_COPY,url,serverdir=serverdir,localdir=localdir,pathname=pathname

 INPUTS:
      URL - scalar string giving a fully qualified url of the form
          'http://server.eso.org/path/file.html'.
 KEYWORDS:


 Examples:
   ;Download most recent version of this file to current directory:
   FILE_HTTP_COPY,'http://themis.ssl.berkeley.edu/data/themis/socware/bleeding_edge/idl/ssl_general/misc/file_http_copy.pro'

 OPTIONAL INPUT KEYWORD PARAMETERS:
       PATHNAME = pathname   ; pathname is the filename to be created.
                If the directory does not exist then it will be created.
                If PATHNAME does not exist then the original filename is used
                and placed in the current directory.

       /SILENT - If set, the information error messages are suppressed

 RESTRICTIONS:

     PROXY: If you are behind a firewall and have to access the net through a
         Web proxy,  set the environment variable 'http_proxy' to point to
         your proxy server and port, e.g.
         'setenv http_proxy=http://web-proxy.mpia-hd.mpg.de:3128'

               The URL *MUST* begin with "http://".

 PROCEDURE:
     Open a socket to the webserver and download the header.

 EXAMPLE:
      IDL> FILE_HTTP_COPY,'http://themis.ssl.berkeley.edu/themisdata/thg/l1/asi/whit/2006/thg_l1_asf_whit_2006010103_v01.cdf'
      IDL> PRINTDAT, file_info('thg_l1_asf_whit_2006010103_v01.cdf')
      or


 MINIMUM IDL VERSION:
     V5.4  (uses SOCKET)
 MODIFICATION HISTORY:
   Original version:  WEBGET()
     Written by M. Feldt, Heidelberg, Oct 2001 <mfeldt@mpia.de>
     Use /swap_if_little_endian keyword to SOCKET  W. Landsman August 2002
     Less restrictive search on Content-Type   W. Landsman   April 2003
     Modified to work with FIRST image server-  A. Barth, Nov 2006
   FILE_HTTP_COPY:   New version created by D Larson:  March 2007.
     Very heavily modified:

 $LastChangedBy: pcruce $
 $LastChangedDate: 2007-07-23 14:18:44 -0700 (Mon, 23 Jul 2007) $
 $LastChangedRevision: 1221 $
 $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/tags/tdas_2_02/misc/file_http_copy.pro $

(See ssl_general/misc/file_http_copy.pro)


FILE_HTTP_COPY[2]

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION extract_html_links(filename,count)
PURPOSE:  returns relative links within an html file
INPUT:  filename: (string) valid filename
OUTPUT:  count:  number of links found

(See ssl_general/misc/file_http_copy.pro)


FILE_RETRIEVE

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION file_retrieve(pathnames,local_data_dir=local_data_dir)
Keywords:
    local_data_dir:  local data directory;  'must end with a '/'
    remote_data_dir:  remote data directory:  'must end with a  '/'

$LastChangedBy: kenb-mac $
$LastChangedDate: 2007-07-09 10:37:13 -0700 (Mon, 09 Jul 2007) $
$LastChangedRevision: 1034 $
$URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/tags/tdas_2_02/misc/file_retrieve.pro $

(See ssl_general/misc/file_retrieve.pro)


FIND_CONST_INTERVALS

[Previous Routine] [Next Routine] [List of Routines]
	Procedure: FIND_CONST_INTERVALS

	Purpose:  Find intervals within the input array where the data are constant to some tollerance,
		and return the begin and end indices into the original array for those intervals.

	Calling Sequence:
		x = [ 1, 1, 3, 3, 4, 1, 1, 1, 1]
		ctol = 0.01
		find_const_intervals, x, nint=nint, ibeg=ibeg, iend=iend, ctol=ctol

	Arguements:
		X, ARRAY or any type; will be cast to FLOAT for comparison.
		NINT, LONG, number of intervals of constantcy found in X.
		IBEG, IEND, LONG[ nint], arrays of array indices to the begin and end of each constant interval.
		CTOL, FLOAT, tollerance for constancy of data; ABS(dX) lt CTOL for data to be "constant".

	Notes:
		None.

 $LastChangedBy: pcruce $
 $LastChangedDate: 2007-06-27 13:16:28 -0700 (Wed, 27 Jun 2007) $
 $LastChangedRevision: 904 $
 $URL $

(See ssl_general/misc/find_const_intervals.pro)


FIND_STR_ELEMENT

[Previous Routine] [Next Routine] [List of Routines]
 **** OBSOLETE!!! Please use "str_element"instead! ***

FUNCTION:  find_str_element
PURPOSE:  find an element within a structure
 Input:
   struct,  generic structure
   name,    string  (tag name)
 Purpose:
   Returns index of structure tag.
   Returns -1 if not found
   Returns -2 if struct is not a structure
KEYWORDS:
  If VALUE is set to a named variable then  the value of that element is
   returned in it.

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)find_str_element.pro	1.6 95/10/06

(See ssl_general/misc/find_str_element.pro)


FNAME_TO_TIME

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:	fname_to_time, fname, time
PURPOSE:
	To translate the name of a standard WIND data file into the starting
	time of the data.
INPUT:
	fname: filename (string) to be translated
	time: variable in which to return time (double)

CREATED BY:	Peter Schroeder
LAST MODIFICATION:	%W% %E%

(See ssl_general/misc/fname_to_time.pro)


GET_COLORS

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:    get_colors
PURPOSE:   returns a structure containing color pixel values
INPUT:    none
KEYWORDS:
   NOCOLOR:  forces all colors to !d.table_size-1.

Written by: Davin Larson    96-01-31
FILE: get_colors.pro
VERSION:  1.2
LAST MODIFICATION: 99/04/07

(See ssl_general/misc/get_colors.pro)


GET_FILE_NAMES

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:  get_file_names,  fnames
PURPOSE:  
   Gets an array of filenames within a time range
INPUT:
   fnames:  named variable in which the output array of filenames is placed.
KEYWORDS:
   TIME_RANGE: Two element vector (double or string) specifying the time range.
     If time range is not set, then "GET_TIMESPAN" will be called
     to get a time range.
   MASTERFILE: Use this keyword to pass in one of the following:
	1) Name of a masterfile that contains times and associated 
	     	filenames.  The file should have the format:
yyyy-mm-dd/hh:mm:ss   yyyy-mm-dd/hh:mm:ss   fullpathfilename
     		with one line for each file.
	     (Hint: for CDF files, the masterfile can be created using the 
	     UNIX program 'kpdfile' or the IDL procedure "MAKE_CDF_INDEX".)
	2) Full path/file names with wildcard characters to search for
		relevant files.  Input should be in the form:
		/path/xxx* for files of form /path/xxx_date.
	3) The name of a previously defined environment variable containing
		data in the form of 1 or 2 above.
   ROOT_DIR:   Optional root_directory of the masterfile.  This will properly
      manage operating system dependancies.

CREATED BY:	Davin Larson
MODIFIED BY:	Peter Schroeder
VERSION:	1.26 00/10/04 get_file_names.pro
 

(See ssl_general/misc/get_file_names.pro)


GET_FILE_NAMES_IND

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:  get_file_names_ind,  fnames
PURPOSE:  
   Gets an array of filenames within a masterfile within a time range
INPUT:
   fnames:  named variable in which the output array of filenames is placed.
KEYWORDS:
   TIME_RANGE: Two element vector (double or string) specifying the time range.
     If time range is not set, then "GET_TIMESPAN" will be called
     to get a time range.
   MASTERFILE: Name of a masterfile that contains times and associated 
     filenames.  The file should have the format:
yyyy-mm-dd/hh:mm:ss   yyyy-mm-dd/hh:mm:ss   fullpathfilename
     with one line for each file.
     (Hint: for CDF files, the masterfile can be created using the 
     UNIX program 'kpdfile' or the IDL procedure "MAKE_CDF_INDEX".)
   ROOT_DIR:   Optional root_directory of the masterfile.  This will properly
      manage operating system dependancies.
   NO_DUPLICATES:  (N;  integer)
      when set the first N characters of file names are compared and only
      the highest version is returned.

CREATED BY:	Davin Larson
VERSION:	@(#)get_file_names_ind.pro	1.1 97/06/23
 

(See ssl_general/misc/get_file_names_ind.pro)


INTERP

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:   interp(y,x,u)
PURPOSE:
  Linearly Interpolates vectors with an irregular grid.
  INTERP is functionally the same as INTERPOL, however it is typically 
  much faster for most applications.
USAGE:
  result = interp(y,x,u)
INPUTS:
       Y:      The input vector can be any type except string.

       X:      The absicissae values for Y.  This vector must have same # of
               elements as Y.  The values MUST be monotonically ascending 
               or descending.

       U:      The absicissae values for the result.  The result will have 
               the same number of elements as U.  U does not need to be 
               monotonic.
KEYWORDS:  
  NO_CHECK_MONOTONIC:   set this keyword to skip the check for monotonic data.
  INDEX:  Set to named variable to return the index of the closest x less than u. 
      (same dimensons as u)
  NO_EXTRAPOLATE:  Set this keyword to prevent extrapolation.
  INTERP_THRESHOLD:  Set to minimum allowed gap size.

CREATED BY:	Davin Larson  4-30-96
FILE:  interp.pro
VERSION:  1.15
LAST MODIFICATION:  02/04/17

(See ssl_general/misc/interp.pro)


MAKEGIF

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:  makegif, filename
NAME:
  makegif
PURPOSE:
  Creates a GIF file from the currently displayed image.
PARAMETERS:
  filename   filename of gif file to create.  Defaults to 'plot'. Note:
             extension '.gif' is added automatically
KEYWORDS:
  ct         Index of color table to load.  Note: will have global
             consequences!
  multiple   Write multiple gifs to a single file. Subsequent calls to
             makegif with same filename argument will append to the file.
             Use /close to close.
  close      close the gif file.  Useful when writing multiple gifs to
             a single file.  Does not write any image to the file.
  no_expose  Don't print index of current window.

Restrictions:
  Current device should have readable pixels (ie. 'x' or 'z')

Created by:  Davin Larson
FILE:  makegif.pro
VERSION:  1.11
LAST MODIFICATION:  02/11/06

(See ssl_general/misc/makegif.pro)


MAKEPNG

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:  makepng, filename
NAME:
  makepng
PURPOSE:
  Creates a PNG file from the currently displayed image.
PARAMETERS:
  filename   filename of png file to create.  Defaults to 'plot'. Note:
             extension '.png' is added automatically
KEYWORDS:
  ct         Index of color table to load.  Note: will have global
             consequences!
  multiple   Does nothing.
  close      Does nothing.
  no_expose  Don't print index of current window.
  mkdir      If set, make the parent directory/directories of the
             file specified by filename.

Restrictions:
  Current device should have readable pixels (ie. 'x' or 'z')

Created by:  Davin Larson
FILE:  makepng.pro
VERSION:  1.11
LAST MODIFICATION:  02/11/06

(See ssl_general/misc/makepng.pro)


MAKEPS.PRO

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 makeps.pro
PURPOSE:
 A simple function to reliably and consistently do postscript export
 Right now it will export whatever your last tplot command was(ie
 current plot)
CALLING SEQUENCE:
 makeps
 -or-
 makeps,'filename'
INPUT:
 a filename or nothing
OUTPUT:
 a postscript file to the specified location
 errors, grays out all buttons while processing

NOTES: Will append a .ps to your filename whether you like it or not
       TODO: add an argument to accept a list of variables

$LastChangedBy: pcruce $
$LastChangedDate: 2007-07-26 12:10:35 -0700 (Thu, 26 Jul 2007) $
$LastChangedRevision: 1238 $
$URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/tags/tdas_2_02/misc/makeps.pro $

(See ssl_general/misc/makeps.pro)


MINMAX

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:   minmax,array
PURPOSE:  returns a two element array of min, max values
INPUT:  array
KEYWORDS:
  MAX_VALUE:  ignore all numbers greater than this value
  MIN_VALUE:  ignore all numbers less than this value
  POSITIVE:   forces MINVALUE to 0

CREATED BY:    Davin Larson
LAST MODIFICATION:     @(#)minmax.pro	1.2 02/04/17

(See ssl_general/misc/minmax.pro)


MK_HTML_HELP2

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

 PURPOSE:
       Creates a html document from a list of IDL procedures.
	Given a list of IDL procedure files (.PRO), VMS text library 
       files (.TLB), or directories that contain such files, this procedure 
       generates a file in the HTML format that contains the documentation 
       for those routines that contain a DOC_LIBRARY style documentation 
       template.  The output file is compatible with World Wide Web browsers.
       This version is enhanced over the routine supplied by IDL, It will
       also cross reference, print the purpose, and add links to the source
       code.

 CATEGORY:
	Help, documentation.

 CALLING SEQUENCE:
	MK_HTML_HELP, Sources, Outfile

 INPUTS:
     Sources:  A string or string array containing the name(s) of the
		.pro or .tlb files (or the names of directories containing 
               such files) for which help is desired.  If a source file is 
               a VMS text library, it must include the .TLB file extension.  
               If a source file is an IDL procedure, it must include the .PRO
               file extension.  All other source files are assumed to be
               directories.  If not provided, searches down directory tree
		from current directory for files.

     Outfile:	The name of the output file which will be generated without
		HTML extension.

     If no inputs are given: All directories in the current directory tree
               are used with the exception of: directories named: 'obsolete'
               or 'SCCS.'  (UNIX only)

 KEYWORDS:
     TITLE:	If present, a string which supplies the name that
		should appear as the Document Title for the help.
     FILENAME: Alternative method of specifying Outfile (see above)
     VERBOSE:	Normally, MK_HTML_HELP does its work silently.
		Setting this keyword to a non-zero value causes the procedure
		to issue informational messages that indicate what it
		is currently doing. !QUIET must be 0 for these messages
               to appear.
     STRICT:   If this keyword is set to a non-zero value, MK_HTML_HELP will 
               adhere strictly to the HTML format by scanning the 
               the document headers for characters that are reserved in 
               HTML (",&,").  These are then converted to the appropriate 
               HTML syntax in the output file. By default, this keyword
               is set to zero (to allow for faster processing).
     CROSSLINK:If this keyword is set MK_HTML_HELP will create a cross
               reference between library files.
     CLTURBO:  If this keyword is set to a single character string, then the 
               cross reference procedure will only cross reference lines that
               contain the character given in CLTURBO.  This greatly increases
               the speed of the routine.  By default the double quote (") is 
               used
     PRINT_PURPOSE:  If this keyword is set then the first line after PURPOSE:
               is printed in the output file.
     MASTLIST:	If set, create master list only.  Do not create subdirectory
		file listings.

 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	A help file with the name given by the Outfile argument is
	created.

 RESTRICTIONS:
	The following rules must be followed in formatting the .pro
	files that are to be searched.
		(a) The first line of the documentation block contains
		    only the characters ";+", starting in column 1.
               (b) There must be a line which contains the string "NAME:",
                   which is immediately followed by a line containing the
                   name of the procedure or function being described in
                   that documentation block.  If this NAME field is not
                   present, the name of the source file will be used.
		(c) The last line of the documentation block contains
		    only the characters ";-", starting in column 1.
		(d) Every other line in the documentation block contains
		    a ";" in column 1.

       Note that a single .pro file can contain multiple procedures and/or
       functions, each with their own documentation blocks. If it is desired
       to have "invisible" routines in a file, i.e. routines which are only
       for internal use and should not appear in the help file, simply leave
       out the ";+" and ";-" lines in the documentation block for those
       routines.

	No reformatting of the documentation is done.

 MODIFICATION HISTORY:
       July 5, 1995, DD, RSI. Original version.
       July 13, 1995, Mark Rivers, University of Chicago. Added support for
               multiple source directories and multiple documentation
               headers per .pro file.
       July 17, 1995, DD, RSI. Added code to alphabetize the subjects;
               At the end of each description block in the HTML file,
               added a reference to the source .pro file.
       July 18, 1995, DD, RSI. Added STRICT keyword to handle angle brackets.
       July 19, 1995, DD, RSI. Updated STRICT to handle & and ".
               Changed calling sequence to accept .pro filenames, .tlb
               text librarie names, and/or directory names.
               Added code to set default subject to name of file if NAME
               field is not present in the doc header.
       September, 1995, D. Larson. SSL Berkeley. Added crosslink, print_purpose
               clturbo.
       October 4, 1995, D. Larson. SSL Berkeley. Added link to source file.
       October 3, 1996, F. Marcoline. SSL Berkeley.  Added Alphabet Jumpline.
       October 10, 1996, D. Larson. Added Listing by Directory.
       
FILE:  mk_html_help2.pro
VERSION 1.26
LAST MODIFICATION: 99/04/22

(See ssl_general/misc/mk_html_help2.pro)


NDIMEN

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION: ndimen
PURPOSE:
  Returns the number of dimensions in an array.
INPUT:  array
RETURNS number of dimensions  (0 for scalers,-1 for undefined)

SEE ALSO:  "dimen", "data_type"

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)ndimen.pro	1.6 97/03/10

(See ssl_general/misc/ndimen.pro)


NN

[Previous Routine] [Next Routine] [List of Routines]
NAME:                  nn
PURPOSE:               Find the index of the data point(s) nearest to the specified time(s)
                       
CALLING SEQUENCE:      ind=nn(data,time)
INPUTS:                data:  a data structure, a tplot variable name/index,
                          or a time array
                       time:  (double) seconds from 1970-01-01, scalar or array
                              if not present, "ctime" is called to get time(s)
OPTIONAL INPUTS:       none
KEYWORD PARAMETERS:    x, y, & v:  set to named keywords to return the values
			of the x, y, & v arrays, if applicable
			
OUTPUTS:               a long scalar index or long array of indicies
                       on failure, returns: -2 if bad inputs, 
                                            -1 if nearest neighbor not found
EXAMPLE:               ctime,times,npoints=2
                       inds=nn('Np',times)
                       get_data,'Np',data=dens & get_data,'Tp',data=temp
                       plot,dens.y(inds(0):inds(1)),temp(inds(0):inds(1))
LAST MODIFICATION:     @(#)nn.pro	1.8 02/04/17
CREATED BY:            Frank Marcoline

(See ssl_general/misc/nn.pro)


OPLOT_ERR

[Previous Routine] [Next Routine] [List of Routines]
 PROCEDURE:
	oplot_err, x, low, high
 PURPOSE:
	Plot error bars over a previously drawn plot.

(See ssl_general/misc/oplot_err.pro)


PCLOSE

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:   pclose
INPUT:  none
PURPOSE: Close postscript file opened with popen, and change device back to 
  default.
  If common block string 'printer_name' is set, then file is sent to that
  printer.
SEE ALSO: 	"print_options"
		"popen"

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)pclose.pro	1.10 99/02/18

(See ssl_general/misc/pclose.pro)


PLOT_POSITIONS

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:   plot_positions
PURPOSE:
  Procedure that will compute plot positions for multiple plots per page.
Created by Davin Larson

(See ssl_general/misc/plot_positions.pro)


POPEN

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE: popen, filename
PURPOSE: 
  Change plot device to postscript.
INPUT:    optional;  if:
  string   :  string used as filename,  '.ps' extension is added automatically
  integer X:  filename set to 'plotX.ps'.  value of x is incremented by 1.
  none:       filename set to 'plot.ps'
KEYWORDS: See print_options for info.
  COPY:    pass COPY keyword to set_plot
  INTERP:  pass INTERP keyword to set_plot  (default is to have interp off)

SEE ALSO:	"pclose",
		"print_options",
		"popen_com"

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)popen.pro	1.21 98/06/23

(See ssl_general/misc/popen.pro)


POPEN_COM

[Previous Routine] [Next Routine] [List of Routines]
COMMON BLOCK:	popen_com
PURPOSE:	Common block for print routines

SEE ALSO:	"popen","pclose",
		"print_options"

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)popen_com.pro	1.10 97/12/05

(See ssl_general/misc/popen_com.pro)


PRINTDAT

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE: printdat,[x]
PURPOSE:
   Displays information and contents of a data variable. (Very similar to HELP procedure but much more verbose.)
   This routine is most useful for displaying contents of complex
   data structures.
   If printdat is called without arguments then information on all variables
   within the calling routine are displayed.
   POINTER occurences are recursively displayed as well. (only non-null pointers are listed)

Keywords:
   FULL     Set this keyword to display full variable output.
   NAMES = string:  Optional list of variables to display (Same as for HELP)
   WIDTH:   Width of screen (Default is 120).
   MAX:     Maximum number of array elements to print.  (default is 30)
   NSTRMAX  Maximum number of structure elements to print. (default is 3)
   NPTRMAX  Maximum number of structure elements to print. (default is 5)
   OUTPUT=string :  named variable in which the output is dumped.
   VARNAME=string : [optional] name of variable to be displayed. (useful if input is an expression instead of a variable)
   RECURSEMAX = integer :  Maximum number of levels to dive into. (Useful for limiting the output for heavily nested structures or pointers)

Written by Davin Larson, May 1997.

 $LastChangedBy: davin-win $
 $LastChangedDate: 2007-06-08 06:46:50 -0700 (Fri, 08 Jun 2007) $
 $LastChangedRevision: 766 $
 $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/tags/tdas_2_02/misc/printdat.pro $

(See ssl_general/misc/printdat.pro)


PRINT_OPTIONS

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE: print_options
PURPOSE:  controls postscript printing options
KEYWORDS:
  PORT:   print pages in portrait format (default)
  LAND:   print pages in landscape format 
  BW:     Use black and white mode  (untested)
  COLOR:  Use Color postscript (default)
FUTURE OPTIONS:
  Ecapsulated postscript format
  changing plotting area

SEE ALSO:	"popen","pclose"

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)print_options.pro	1.16 97/05/30

(See ssl_general/misc/print_options.pro)


PTRACE

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION: PTRACE()
PURPOSE: Returns a string that provides the current program location.
KEYWORDS:
    OPTION:  The value of the option is retained in a common block
           OPTION=0  : returns null string
           OPTION=1  : returns highest level routine name.
           OPTION=2  : returns highest level routine name (indented).
           OPTION=3  : returns all levels

Usage: Generally useful for debugging code and following code execution.
Example:
  if keyword_set(verbose) then  print,ptrace(),'X=',x

Written:  Jan 2007,  D. Larson

(See ssl_general/misc/ptrace.pro)


PTR_EXTRACT

[Previous Routine] [Next Routine] [List of Routines]
NAME: ptr_extract
Function: ptrs = ptr_extract(p,EXCEPT=EXCEPT)
Purpose:
   Recursively searches the input (of any type) and returns an array of all
   pointers found.
   This is useful for freeing pointers contained within some complicated
   structure heirachy or pointer list.
   if no pointers are found then a scaler null pointer is returned.
   This routine ignores object pointers!
Keywords:
   EXCEPTPTRS = an array of pointers that should not be included in the output.
Created by Davin Larson. May 2002.

(See ssl_general/misc/ptr_extract.pro)


PWRSPC

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 pwrspc
PURPOSE:
    Called with times time and data quantity, PWRSPC returns a power
    spectrum power at frequencies freq. A Hanning window is applied to
    the input data, and its power is divided out of the returned
    spectrum. A straight line is subtracted from the data to
    reduce spurius power due to sawtooth behavior of a background.
    UNITS ARE (UNITS)^2 WHERE UNITS ARE THE UNITS OF quantity. freq
    is in 1/timeunits.
    THUS THE OUTPUT REPRESENTS THE MEAN SQUARED AMPLITUDE OF THE SIGNAL
       AT EACH SPECIFIC FREQUENCY. THE TOTAL (SUM) POWER UNDER THE CURVE IS
       EQUAL TO THE MEAN (OVER TIME) POWER OF THE OSCILLATION IN TIME DOMAIN.
    NOTE: IF KEYWORD notperhz IS SET, THEN POWER IS IN UNITS^2. If notset
           power is (as normal) in UNITS^2/Hz.
CALLING SEQUENCE:
 pwrspc, time, quantity, freq, power, noline = noline, $
         nohanning = nohanning, bin = bin, notperhz = notperhz
INPUT:
 time = the time array
 quantity = the function for which you want to obtain a power
            spectrum
OUTPUT:
 freq = the frequency array (units =1/time units)
 power = the power spectrum, (units of quantity)^2/frequency_units
KEYWORDS:
 noline = if set, no straight line is subtracted
 nohanning = if set, then no hanning window is applied to the input
 bin = a binsize for binning of the data, the default is 3
 notperhz = if set, the output units are simply the square of the
            input units 

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/pwrspc.pro)


SETBP

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:  setbp, module
    This procedure will set BREAKPOINTS at all lines within a program module
    file that contain the string:  ";bp"
    A conditional break point is set with  ;bpif  condition statement

Input:  module (string)
Purpose:   This is a DEBUGGING tool that is used to set breakpoints.
Keywords:
    /FUNCTION  Set this keyword if module is a function.

 Author:  Davin Larson 2007

(See ssl_general/misc/setbp.pro)


SHARE_COLORS

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:
  share_colors
PURPOSE:
  Procedure that allows multiple IDL sessions to share the same color table.
  The procedure should be called in each session before any 
  windows are created.
USAGE:
  Typically this procedure will be put in a startup routine. such as: 
  share_colors,first=f
  if f then loadct,39   

KEYWORDS:
  FIRST Named variable that will be set to 1 if this is the
      first session, and set to 0 otherwise.
SIDE EFFECTS:
  Creates a temporary file with the name 'idl_cmap:NAME' on the users home
  directory where NAME is the name of the display machine.
  This file is deleted upon exiting IDL.
  The procedure is only useful on UNIX for users with a common home directory.

(See ssl_general/misc/share_colors.pro)


SSL_SET_COMPLEMENT

[Previous Routine] [Next Routine] [List of Routines]
Purpose: Calculates the complement of l2 - l1
          (ie set difference)

Arguments: l1 subset,l2 superset
          

Notes: empty set is -1L
       all inputs must be empty set or arrays
       all outputs will be empty set or arrays
       Arrays must be of homogenous type

(See ssl_general/misc/ssl_set_complement.pro)


SSL_SET_INTERSECTION

[Previous Routine] [Next Routine] [List of Routines]
Purpose: Performs an intersection of two sets
Parameters: l1,l2 sets(arrays) for which the intersection is
calculated

Returns: -1L on empty set, otherwise intersection of the two sets

Notes: empty set is -1L
       all inputs must be empty set or arrays
       all outputs will be empty set or arrays
       Arrays must be of homogenous type

(See ssl_general/misc/ssl_set_intersection.pro)


SSL_SET_UNION

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION ssl_set_union(set1,set2)

Purpose: returns the union of two sets


Notes: empty set is -1L
       all inputs must be empty set or arrays
       all outputs will be empty set or arrays
       Arrays must be of homogenous type

(See ssl_general/misc/ssl_set_union.pro)


STR2TIME

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION str2time(string, informat=string)
 INPUT: scaler string.
 Returns seconds since 1970 given virtually any input string.
 (Assumes the string is GMT)
 The order of Year, Month, Date, hour, min, second is provided by INFORMAT
 INFORMAT should be a 6 character string:  "YMDhms"  specifies Year/Mon/Date-hour:minute:second
 examples:      time = str2time(systime(),informat='MDhmsY')
                time = str2time('tue, 04 jul 2006 19:00:04 gmt',informat='DMYhms')

(See ssl_general/misc/str2time.pro)


STRFILTER

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:
  res =  strfilter(stringarray,searchstring)
PURPOSE:
  Returns the subset of stringarray that matchs searchstring
  '*' will match all (non-null) strings
  ''  will match only the null string
  Output can be modified with keywords
  NOTE: this routine is very similar to the STRMATCH routine introduced in IDL 5.3
     it has some enhancements that make it useful.
     (i.e.: filterstring can also be an array)
INPUT:
  stringarray:  An array of strings to be filtered
  searchstring: A string that may contain wildcard characters ("*")
           (If searchstring is an array then results are OR'd together)
RETURN VALUE:
  Either:
     Array of matching strings.
  or:
     Array of string indices.
  or:
     Byte array with same dimension as input string.
  Depends upon keyword setting (See below)

KEYWORDS:
  FOLD_CASE: if set then CASE is ignored.   (only IDL 5.3 and later)
  STRING: if set then the matching strings are returned.  (default)
  INDEX:  if set then the indices are returned.
  BYTES:  if set then a byte array is returned with same dimension as input string array (similar to STRMATCH).
  NEGATE: pass only strings that do NOT match.
  COUNT:  A named variable that will contain the number of matched strings.
Limitations:
  This function still needs modification to accept the '?' character
  July 2000;  modified to use the IDL strmatch function so that '?' is accepted for versions > 5.4
EXAMPLE:
  Print,strfilter(findfile('*'),'*.pro',/negate) ; print all files that do NOT end in .pro
AUTHOR:
  Davin Larson,  Space Sciences Lab, Berkeley; Feb, 1999
VERSION:  01/10/08

(See ssl_general/misc/strfilter.pro)


STRIPPATH

[Previous Routine] [Next Routine] [List of Routines]
 FUNCTION:
        STRIPPATH

 DESCRIPTION:

       Function that strips off any directory components from a full
       file path, and returns the file name and directory components
       seperately in the structure:
               {file_cmp_str,file_name:'file',dir_name:'dir'}
       This is only implemented for UNIX at this time.

 USAGE (SAMPLE CODE FRAGMENT):
 
   ; find file component of /usr/lib/sendmail.cf
       stripped_file = STRIPPATH('/usr/lib/sendmail.cf')
 
  The variable stripped_file would contain:

       stripped_file.file_name = 'sendmail.cf'
       stripped_file.dir_name  = '/usr/lib/'


 REVISION HISTORY:

   $LastChangedBy: kenb-mac $
   $LastChangedDate: 2006-12-15 08:13:48 -0800 (Fri, 15 Dec 2006) $
   $LastChangedRevision: 97 $
   $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/tags/tdas_2_02/misc/strippath.pro $
       Originally written by Jonathan M. Loran,  University of 
       California at Berkeley, Space Sciences Lab.   Oct. '92
   Updated to use IDL 6.0 features for cross-platform usability.

(See ssl_general/misc/strippath.pro)


STRUCT2ASCII

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 struct2ascii
PURPOSE:
 given an IDL structure, print it out, if a logical unit is supplied,
 print to that unit, else print to the screen, called recursively for
 nested structures. Note that there is no formatting, numerical
 values are printed out in whatever the default output format is.
 Objects are not handled correctly here at all -- pointers eventually
 will be.
CALLING SEQUENCE:
 struct2ascii, structure, lun=lun
INPUT:
 structure =  a structure
OUTPUT:
 None, the structure is printed to the given unit
KEYWORDS:
 lun = a logical unit numnber for output, the default is to print to
       the screen.
HISTORY:
 23-apr-2007, jmm, jimm@ssl.berkeley.edu

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/struct2ascii.pro)


STRUCT2ASCII_READ

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 struct2ascii_read
PURPOSE:
 Reads a structure from a file created using the struct2ascii
 procedure, calls itself recursively for nested structures
CALLING SEQUENCE:
 struct2ascii_read, lun, structure
INPUT:
 lun = a logical unit for input
OUTPUT:
 structure =  a structure
HISTORY:
 23-apr-2007, jmm, jimm@ssl.berkeley.edu

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/struct2ascii_read.pro)


STRUCT_VALUE

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION: struct_value(struc,name,default=default,index=index)
PURPOSE:  Returns the value of a structure element.
   Function equivalent to the procedure: "STR_ELEMENT"
   if "name" is an array then a new structure is returned with only the named values.
Author:  Davin Larson, 2006

(See ssl_general/misc/struct_value.pro)


STR_ELEMENT

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:  str_element, struct,  tagname, value
PURPOSE:
 Find (or add) an element of a structure.
 This procedure will not
 Input:
   struct,  generic structure
   tagname,    string  (tag name)
 Output:
   value,  Named variable in which value of the structure element is returned.
 Purpose:
   Retrieves the value of a structure element.  This function will not produce
   an error if the tag and/or structure does not exist.
KEYWORDS:
  SUCCESS:  Named variable that will contain a 1 if the element was found
     or a 0 if not found.
  INDEX: a named variable in which the element index is returned.  The index
     will be -2 if struct is not a structure,  -1 if the tag is not found,
     and >= 0 if successful.
  ADD_REPLACE:  Set this keyword to add or replace a structure element.
  DELETE:   Set this keyword to delete the tagname.
  CLOSEST:  Set this keyword to allow near matchs (useful with _extra)
  VALUE: (obsolete) alternate method of returning value. (Will not work with recursion)
Notes:
  Value remains unchanged if the structure element does not exist.
  If tagname contains a '.' then the structure is recursively searched and
    index will be an array of indices.
  If struct is an array then results may be unpredictable.

Modifications:
  5/7/97: Added recursive searching of structure hierarchy.  D. Larson

CREATED BY:    Davin Larson
FILE:  str_element.pro
VERSION  1.10
LAST MODIFICATION: 01/10/08

(See ssl_general/misc/str_element.pro)


TAG_NAMES_R

[Previous Routine] [Next Routine] [List of Routines]
 FUNCTION:  TAG_NAMES_R(STRUCTURE, [TYPE=dt] )
 PURPOSE:  Very similar to the TAG_NAMES function but recursively
           obtains all structure names within imbedded structures as well.
 INPUT: STRUCTURE: A structure typically.
              If input is not a structure then a null string is returned
 KEYWORDS:
       TYPE=var; Named variable in which to return and array of data types.
 RETURNS:  Returns an array of strings

(See ssl_general/misc/tag_names_r.pro)


TCLIP

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 tclip
PURPOSE:
 wapper for xclip.pro allowing input of tplot variable names
CALLING SEQUENCE:
 tclip, varnames, amin, amax, _extra=_extra
INPUT:
 varnames = an array (or scalar) of tplot variable names
 amin, amax = the minumum and maximum values
KEYWORDS:
 flag = the value that clipped data are  set to, the default is
        -0.0/0.0 (NaN)
 newname = if set,give these names to the clipped data, the
                default is to append '_clip' to the input names and
                pass out the names in the newname variables,
                Unless /overwrite is set. This will not work for wild
                card input.
 overwrite = if set, write the new data back to the old tplot
             variables, do not set this with newname
HISTORY:
 2-feb-2007, jmm, jimm.ssl.berkeley.edu

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/tclip.pro)


TDEFLAG

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 tdeflag
PURPOSE:
 wapper for xdeflag.pro allowing input of tplot variable names
CALLING SEQUENCE:
 tdeflag, varnames, method, newname=newname, $
          overwrite = overwrite, _extra=_extra
INPUT:
 varnames = an array (or scalar) of tplot variable names
 method = set to "repeat", this will repeat the last good value.
          set to "linear", then linear interpolation is used, but for
          the edges, the closest value is used, there is no
          extrapolation
KEYWORDS:
 flag = the value that deflagged data will be set to, the default is
        6.8792e28, Nan's, Inf's are also deflagged
 maxgap = the maximum number of rows that can be filled? the default
           is n_elements(t)
 newname = if set,give these names to the deflagged data, the
                default is to append '_deflag' to the input names and
                pass out the names in the newname variables,
                Unless /overwrite is set
 overwrite = if set, write the new data back to the old tplot
             variables, do not set this with newname
HISTORY:
 2-feb-2007, jmm, jimm.ssl.berkeley.edu

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/tdeflag.pro)


TDEGAP

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 tdegap
PURPOSE:
 wrapper for xdegap.pro allowing input of tplot variable names
CALLING SEQUENCE:
 tdegap, varnames, dt=dt, margin=margin, maxgap=maxgap,$
         newname=newname, overwrite=overwrite
INPUT:
 varnames = an array (or scalar) of tplot variable names
KEYWORDS:
 dt = the nominal time resolution of the data that will be inserted,
      the default is to choose the median of the input time array
 margin = the margin used to determine if a gap is big enough, the
          default is 0.25 seconds
 maxgap = the maximum gap size that will be allowed to be filled, in
          units of dt. the default is to set this to the max number
          of data points
          (TDEGAP degaps anything that is greater than dt+margin 
          and less than maxgap*dt)
 newname = if set,give these names to the degapped data, the
                default is to append '_degap' to the input names and
                pass out the names in the newname variables,
                Unless /overwrite is set
 overwrite = if set, write the new data back to the old tplot
             variables, do not set this with newname
HISTORY:
 9-apr-2007, jmm, jimm.ssl.berkeley.edu

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/tdegap.pro)


TDPWRSPC

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 tdpwrspc
PURPOSE:
 wapper for dpwrspc.pro allowing input of a tplot variable name
CALLING SEQUENCE:
 ttpwrspc, varname, newname=newname,_extra=_extra
INPUT:
 varname = one tplot variable name
KEYWORDS:
 newname = if set,give this name to the new data, the
           default is to append '_dpwrspc' to the input name and
           pass out the name in the newname variable,
           Unless /overwrite is set
 overwrite = if set, write the new data back to the old tplot
             variable, do not set this with newname
HISTORY:
 27-mar-2007, jmm, jimm.ssl.berkeley.edu
 10-apr-2007, jmm, fixed 2 bugs wrt structure definition

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/tdpwrspc.pro)


THM_CORRELATE_TPLOT

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

 PURPOSE:
        Identified the amount of shift required to correlate two
        time series tplot variables and stores the result in a tplot
        variable. Only compares 1-d to 1-d data at a time So for example you
        can, compare the fge x and the fgl_x but can't do all three
        at a time. 


      Works by binning the timeseries data, then calculating the
      time shift required to maximally correlate each bin.  
      When too few points overlap bins are rejected.

 CATEGORY:
       THEMIS-SOC

 CALLING SEQUENCE:
      pro thm_correlate_tplot,var1_name, var1_y_dim, var2_name, var2_y_dim, store_name, correlation_floor = correlation_floor, point_number =  point_number, lag_step_number = lag_step_number, time_step_size = time_step_size, bin_size = bin_size

 INPUTS:
 
       var1_name: the tplot name of the first variable to be compared
       
       var1_y_dim: the numerical dimension of the first tplot y_var to look 
       at(from 0 to n-1)

       var2_name: the tplot name of the second variable to be
       compared

       var2_y_dim: the numerical dimension of the second tplot y_var
       to look at(from 0 to n-1)

       store_name: the name of a tplot variable in which to store the result
     
       correlation_floor: optional, if set filters all results where
       the correlation between functions is too poor(default:.9)

       point_number: optional, the minimum number of points of
       overlap necessary to try correlating a bin(default:200)

       lag_step_number: optional, checks plus or minus lag_steps * time steps
       to correlate the vectors (default:64)

       time_step_size: optional, the size of the time step to use when
       interpolating and correlating the vectors, in
       seconds(default:1/128 seconds)

       bin_size: optional, the size of each bin in seconds
       (default:60 seconds)
       

 OUTPUTS:
       
       stores the time and the shift values in the select tplot_var

 KEYWORDS:

 COMMENTS: This function will probably die horribly if time
  values are not monotonic.


 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:
       Written by: Patrick Cruce(pcruce@gmail.com)
       2007-05-24        V1.0

 KNOWN BUGS:

(See ssl_general/misc/thm_correlate_tplot.pro)


THM_CORRELATION_SHIFT

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

 PURPOSE:
      Calculates the shift required to correlate two tme series of
      data.  Does this by binning the timeseries data, then
      calculating the time shift required to maximally correlate each
      bin.  When too few points overlap bins are rejected.


 CATEGORY:
       THEMIS-SOC

 CALLING SEQUENCE:
       lag_time_series = thm_correlation_shift(var1_time_series,var2_time_series)

 INPUTS:
     
       var1_time_series: a 2xn matrix(column major) of n time/value pairs for var1

       var2_time_series: a 2xn matrix(column major) of n time/value pairs for var2

       n_pts: optional, the minimum number of points of overlap necessary to
       try correlating a bin

       lag_steps: optional, checks plus or minus lag_steps * time steps
       to correlate the vectors 

       time_step: optional, the size of the time step to use when
       interpolating and correlating the vectors

       bin_size: optional, the size of each bin in seconds
       

 OUTPUTS:
       
       an 3xn matrix(column major) of time/shift/correlation triplets  
       or -1L on failure,
       the output n is the number of bins constructed

 KEYWORDS:

 COMMENTS: This function will probably die horribly if time
  values are not monotonic.


 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:
       Written by:       Jim Lewis
       2007-04-19        Initial version
       Updated by: Patrick Cruce(pcruce@gmail.com)
       2007-05-22        V2.0 

 KNOWN BUGS:

(See ssl_general/misc/thm_correlation_shift.pro)


THM_FGM_FIT_CORRELATE_TPLOT.PRO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       thm_fgm_fit_correlate_tplot.pro

 Purpose:
       Uses thm_correlation_shift.pro to do a correlation shift
       analysis on the vector lengths(math not cs vectors) of a
       selected fgm mnemonic and fit data


 CATEGORY:
       THEMIS-SOC
 CALLING SEQUENCE:
      pro thm_fgm_fit_correlate_tplot,fit_name, fgm_name, store_name, correlation_floor = correlation_floor, point_number =  point_number, lag_step_number = lag_step_number, time_step_size = time_step_size, bin_size = bin_size

 INPUTS:
 
       fit_name: the tplot name of the fit data to be compared
      
       fgm_name: the tplot name of the fgm_data to be
       compared

       store_name: the name of a tplot variable in which to store the result
     
       correlation_floor: optional, if set filters all results where
       the correlation between functions is too poor(default:0.0)

       point_number: optional, the minimum number of points of
       overlap necessary to try correlating a bin(default:10)

       lag_step_number: optional, checks plus or minus lag_steps * time steps
       to correlate the vectors (default:5)

       time_step_size: optional, the size of the time step to use when
       interpolating and correlating the vectors, in
       seconds(default:1/8 seconds)

       bin_size: optional, the size of each bin in seconds
       (default:60 seconds)
       

 OUTPUTS:
       
       stores the time and the shift values in the selected tplot_var

 KEYWORDS:

 COMMENTS: This function will probably die horribly if time
  values are not monotonic.


 PROCEDURE:

 EXAMPLE:

 MODIFICATION HISTORY:
       Written by: Patrick Cruce(pcruce@gmail.com)
       2007-06-06        V1.0

 KNOWN BUGS: tcs_vector_length doesn't filter NANs so it may output 
 arithmetic warnings

(See ssl_general/misc/thm_fgm_fit_correlate_tplot.pro)


THM_TIME_CHECK[1]

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:     thm_time_check.pro
PURPOSE:   prints information about gaps between timestamps in cdf files
INPUT:
   dir: The directory in which to search for cdfs
   out: the output directory for the limit files
   LIM: reassign the limit if you want it is a 2 element array
   MNEM: optional regex to filter timestamp mnems
KEYWORDS:
   none

COMMENTS: Will check all timestamps for all cdfs in the directory and
output a seperate file for each type of timestamp.
File format is:
timestamp1 timestamp2 gap_size record_number

currently it signals a gap if a gap is over 180 seconds or negative

EXAMPLE: thm_time_check,'/','/dev/null'

CREATED BY:    Patrick Cruce (pcruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


THM_TIME_CHECK[2]

[Previous Routine] [Next Routine] [List of Routines]
SUB-FUNCTION:     thm_variable_defined
PURPOSE:   checks to see if a variable is defined in a given cdf file
INPUT:
   file: the name of the file
   mnem: the name of the mnem
OUTPUT: 
   returns 1 if yes 0 if no   
KEYWORDS:
   none

EXAMPLE: b=thm_variable_defined('filename','variable')

CREATED BY:    Patrick Cruce (pcruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


THM_TIME_CHECK[2]

[Previous Routine] [Next Routine] [List of Routines]
SUB-FUNCTION:     thm_union
PURPOSE: returns the union of two arrays,elements returned sorted
         runs in O(nlogn)

INPUT:
   a:the first array
   b:the second array
KEYWORDS:
   none

EXAMPLE: c = thm_union(a,b)

CREATED BY:    Patrick Cruce (pcruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


THM_TIME_CHECK[3]

[Previous Routine] [Next Routine] [List of Routines]
SUB-FUNCTION: thm_discrete_derivative
PURPOSE:   takes a length n array and returns a length n-1 array with
each element of the return array representing the ith-(i-1th) element
of that array
INPUT:
   a = the array on which the check is done
   b = name var to return result in
KEYWORDS:
   none

EXAMPLE: thm_discrete_derivative,a,b

CREATED BY:    Patrick Cruce (cruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


THM_TIME_CHECK[4]

[Previous Routine] [Next Routine] [List of Routines]
SUB-PROCEDURE:     thm_write_derivative_limits
PURPOSE:   takes the discrete derivative of a 1-d input array, and
writes an entry to a specified file whenever that derivative is out
of range
 output format is:
 v e1 e2 d i
 where:
 v= -1 if d le lim[0] and 1 if d gt lim[1]  
 e1 = the preceding element to the boundary violation
 e2 = the following element 
 d = e2-e1 or the difference that generated the violation 
 i = the approximate record entry where the violation occurred
INPUT:
   file: the file to be written
   a: the array to be analysed
   lim: 2-element array with format [low,high] representing interval [low,high)
KEYWORDS:
   none

EXAMPLE: thm_write_derivative_limits,file,a,lim

CREATED BY:    Patrick Cruce (pcruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


THM_TIME_CHECK[5]

[Previous Routine] [Next Routine] [List of Routines]
SUB-PROCEDURE:     thm_get_mnem_file
PURPOSE:   gets every value of a 1-d mnemonic from a file
INPUT:
   filename: The name of the file from which the values should be
   acquired
   mnem: the mnem from which the values should be acquired
   a: the named var in which values should be stored 

KEYWORDS:
   none

EXAMPLE: thm_get_mnem_file,'filename','mnem',a

CREATED BY:    Patrick Cruce (pcruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


THM_TIME_CHECK[6]

[Previous Routine] [Next Routine] [List of Routines]
SUB-PROCEDURE:     thm_time_list
PURPOSE:   lists the timestamp mnemonics for in a cdf file
INPUT:
   filename: The name of the file to be checked, or no filename to
   get dialog
   in: a named var to return the array of time names in
KEYWORDS:
   none

EXAMPLE: thm_time_list,'filename'

CREATED BY:    Patrick Cruce (pcruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


THM_TIME_CHECK[7]

[Previous Routine] [Next Routine] [List of Routines]
SUB-PROCEDURE:     thm_write_lims_dir
PURPOSE:   searches all the cdfs in a directory and writes the
results of a limit check over the discrete derivative of the
specified mnem in a file
INPUT:
   dir: The directory in which to search for cdfs
   mnem: the mnemonic to be acquired
   lim: a 2-element array specifying the required limits
   out: the output directory for the limit file
KEYWORDS:
   none

EXAMPLE: thm_write_lims_dir,'in_directory','out_directory','mnem_name',[0.0,1.0]

CREATED BY:    Patrick Cruce (pcruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


THM_TIME_CHECK[8]

[Previous Routine] [Next Routine] [List of Routines]
SUB-PROCEDURE:     thm_time_list_dir
PURPOSE:   lists the union of timestamp mnemonics for all cdfs in a directory 
INPUT:
   list: a list of files to be searched
   in: a named var to return the array of time names in
KEYWORDS:
   none

EXAMPLE: thm_time_list_dir,'dirname'

CREATED BY:    Patrick Cruce (pcruce@gmail.com)

(See ssl_general/misc/thm_time_check.pro)


TIME_DOUBLE

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION: time_double(time)
NAME:
  time_double
PURPOSE:
 A fast, vectorized routine that returns the number of seconds since 1970.
INPUT:  input can be any of the following types:
  double(s)      seconds since 1970   (returns the input)
  string(s)      format:  YYYY-MM-DD/hh:mm:ss  see "time_string"
  structure(s)   format returned in "time_struct"
  long array     (MUST be 2 dimensional!)  PB5 time  (req. by CDF)

OUTPUT:
  double, number of seconds since 1970  (UNIX time)
KEYWORDS:
  EPOCH:  if set, it implies the input is double precision EPOCH time.

SEE ALSO:  "time_string", "time_struct", "time_epoch", "time_pb5"

NOTE:
  This routine works on vectors and is designed to be fast.
  Output will have the same dimensions as the input
  Out of range values are interpreted correctly.
  ie.  1994-13-1/12:61:00  will be treated as:  1995-1-1/13:01:00

CREATED BY:    Davin Larson  Oct 1996
FILE:  time_double.pro
VERSION:  1.9
LAST MODIFICATION:  01/07/12

(See ssl_general/misc/time_double.pro)


TIME_EPOCH

[Previous Routine] [Next Routine] [List of Routines]
NAME:
  time_epoch
PURPOSE:
  Returns the EPOCH time required by CDF files.
USAGE:
  epoch = time_epoch(t)
 NOT TESTED!!!

CREATED BY:	Davin Larson  Oct 1996
FILE:  time_epoch.pro
VERSION:  1.1
LAST MODIFICATION:  96/10/16

(See ssl_general/misc/time_epoch.pro)


TIME_PB5

[Previous Routine] [Next Routine] [List of Routines]
NAME:
  time_pb5
PURPOSE:
  Returns the PB5 time required by CDF files.
USAGE:
  pb5 = time_pb5(t)
OUTPUT:
  2 dimensional long integer array with dimensions:  (n,3)  Where n is the number
  of elements in t
Not fully TESTED!!!!

CREATED BY:	Davin Larson  Oct 1996
FILE:  time_pb5.pro
VERSION:  1.3
LAST MODIFICATION:  97/01/27

(See ssl_general/misc/time_pb5.pro)


TIME_STAMP

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:   time_stamp,charsize=charsize
PURPOSE:
     Prints a time stamp along the lower right edge of the current plot box
KEYWORDS:  
     CHARSIZE:  The character size to be used.  Default is !p.charsize/2.
     ON:        if set, then timestamping is turned on. (No other action taken)
     OFF:       if set, then timestamping is turned off. (Until turned ON)

(See ssl_general/misc/time_stamp.pro)


TIME_STRING

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION: time_string(TIME)
NAME:
  time_string
PURPOSE:
  Converts time to a date string.
INPUTs:
  TIME  input can be a scaler or array of any dimension of type:
  double(s)      seconds since 1970
  string(s)      format:  YYYY-MM-DD/hh:mm:ss
  structure(s)   format:  given in "time_struct"
  float(s)
  longs(s)
                 values outside normal range will be corrected.
KEYWORDS:

  LOCAL_TIME ;      if set then local time is displayed.

  TFORMAT:   a format string such as:  "YYYY-MM-DD/hh:mm:ss.ff DOW TDIFF"
               the following tokens are recognized:
                    YYYY  - 4 digit year
                    yy    - 2 digit year
                    MM    - 2 digit month
                    DD    - 2 digit date
                    hh    - 2 digit hour
                    mm    - 2 digit minute
                    ss    - 2 digit seconds
                    .fff   - fractional seconds
                    MTH   - 3 character month
                    DOW   - 3 character Day of week
                    DOY   - 3 character Day of week
                    TDIFF - 5 character, hours different from UTC    (useful with LOCAL keyword)

        if TFORMAT is defined then the following keywords are ignored.

  FORMAT:         specifies output format.
    FORMAT=0:  YYYY-MM-DD/hh:mm:ss
    FORMAT=1:  YYYY Mon dd hhmm:ss
    FORMAT=2:  YYYYMMDD_hhmmss
    FORMAT=3:  YYYY MM dd hhmm:ss
    FORMAT=4:  YYYY-MM-DD/hh:mm:ss
    FORMAT=5:  YYYY/MM/DD hh:mm:ss
    FORMAT=6:  YYYYMMDDhhmmss
  SQL:            produces output format: "YYYY-MM-DD hh:mm:ss.sss"
                  (quotes included) which convenient for building SQL queries.
  PRECISION:      specifies precision
      -5:   Year only
      -4:   Year, month
      -3:   Year, month, date
      -2:   Year, month, date, hour
      -1:   Year, month, date, hour, minute
       0:   Year, month, date, hour, minute, sec
      >0:   fractional seconds
  AUTOPREC  If set PREC will automatically be set based on the array of times
  DELTAT:   (float) PREC set based on this precision.
  DATE_ONLY:   Same as PREC = -3
  MSEC:        Same as PREC = 3

OUTPUT:
  string with the following format: YYYY-MM-DD/hh:mm:ss (Unless
  modified by keywords.)

See Also:  "time_double"  , "time_struct" or "time_ticks"

NOTE:
  This routine works on vectors and is designed to be fast.
  Output will have the same dimensions as the input.

CREATED BY:    Davin Larson  Oct 1996
FILE:  time_string.pro
VERSION:  1.14
LAST MODIFICATION:  02/11/01

(See ssl_general/misc/time_string.pro)


TIME_STRUCT

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION: time_struct(time)
NAME:
  time_struct
PURPOSE:
 A fast, vectorized routine that returns a time structure.
INPUT:  input can be any of the following types:
  double(s)      seconds since 1970
  string(s)      format:  YYYY-MM-DD/hh:mm:ss
  structure(s)   similar to format below.

OUTPUT:
  structure with the following format:
** Structure TIME_STRUCT, 11 tags, length=40:
   YEAR            INT           1970            ; year    (0-14699)
   MONTH           INT              1            ; month   (1-12)
   DATE            INT              1            ; date    (1-31)
   HOUR            INT              0            ; hours   (0-23)
   MIN             INT              0            ; minutes (0-59)
   SEC             INT              0            ; seconds (0-59)
   FSEC            DOUBLE           0.0000000    ; fractional seconds (0-.999999)
   DAYNUM          LONG            719162        ; days since 0 AD  (subject to change)
   DOY             INT              0            ; day of year (1-366)
   DOW             INT              3            ; day of week  (subject to change)
   SOD             DOUBLE           0.0000000    ; seconds of day
   DST        =    INT      = 0                  ; Daylight saving time flag
   TZONE      =    INT      = 0                  ; Timezone  (Pacific time is -8)
   TDIFF      =    INT      = 0                  ; Hours from UTC

See Also:  "time_double", "time_string", "time_epoch", "time_pb5"

NOTE:
  This routine works on vectors and is designed to be fast.
  Output will have the same dimensions as the input

CREATED BY:    Davin Larson  Oct 1996
FILE:  time_struct.pro
VERSION:  1.15
LAST MODIFICATION:  02/11/01

(See ssl_general/misc/time_struct.pro)


TIME_TICKS

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:  time_tk_str = time_ticks(timerange,offset)
NAME:
  time_ticks
PURPOSE:
  Returns a structure that can be used to create time ticks for a plot.
  See "timetick" for more info
INPUT:
  timerange: Two element vector specifying the time range of the plot
      this input can be obtained from: "time_double", "time_struct"
      or "time_string"
  offset: named variable in which offset time is placed.
KEYWORDS:
  NUM_LAB_MIN:   minimum number of labels for bottom axis.

OUTPUT:
  a structure that can be used with the _EXTRA keyword of the PLOT routine

See Also: "box", "tplot"

 NOTES:

     The returned time_tk_str has tags named so that it can be used
     with the special _EXTRA keyword in the call to PLOT or OPLOT.

     The offset value that is returned from timetick must be
     subtracted from the time-axis data values before plotting.
     This is to maintain resolution in the PLOT routines, which use
     single precision floating point internally.  Remember that if
     the CURSOR routine is used to read a cursor position from the
     plot, this offset will need to be added back to the time-axis
     value to get seconds since  1970-01-01/00:00:00.

NOTE:
  This routine is an enhanced version of the routine "timetick"
  See this routine for more info on usage

WARNING!:
  This routine does not yet work on very small time scales.

CREATED BY:	Davin Larson  Oct 1996
FILE:  time_ticks.pro
VERSION:  1.16
LAST MODIFICATION:  02/04/17

(See ssl_general/misc/time_ticks.pro)


TPLOT2ASCII

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 tplot2ascii
PURPOSE:
 Dumps a tplot variable into an ascii file
CALLING SEQUENCE:
 tplot2ascii, varname, filename = filename, filepath = filepath
INPUT:
 varname = a tplot variable name
KEYWORDS:
 filename = a filename, if not set the default is to use the variable
            name appended with the start time of the data
 filepath = a path for the filename, the default is to dump it into
            the current working directory.
OUTPUT:
 None, it writes a file
HISTORY:
 24-apr-2007, jmm, jimm@ssl.berkeley.edu

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/tplot2ascii.pro)


TPWRSPC[2]

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 tpwrspc
PURPOSE:
 wapper for pwrspc.pro allowing input of a tplot variable name
CALLING SEQUENCE:
 tpwrspc, varnames, newname=newname,_extra=_extra
INPUT:
 varname = one tplot variable name
KEYWORDS:
 newname = if set,give this name to the new data, the
           default is to append '_pwrspc' to the input name and
           pass out the name in the newname variable,
           Unless /overwrite is set
 overwrite = if set, write the new data back to the old tplot
             variable, do not set this with newname
HISTORY:
 27-mar-2007, jmm, jimm.ssl.berkeley.edu

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/tpwrspc.pro)


TRANGE_STR

[Previous Routine] [Next Routine] [List of Routines]
FUNCTION:   trange_str,t1,t2
INPUT:  t1,t2   doubles,   seconds since 1970
OUTPUT:  string  with the format:  'YYYY-MM-DD/HH:MM:SS - HH:MM:SS'

CREATED BY:	Davin Larson
LAST MODIFICATION:	@(#)trange_str.pro	1.10 97/12/22

(See ssl_general/misc/trange_str.pro)


TSUB_AVERAGE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
 tsub_average
PURPOSE:
 Subtracts average or median values from the data in a tplot
 variable, returns a new variable, only one at a time for now
CALLING SEQUENCE:
 tsub_average, varname, out_name, new_name=new_name,median=median
INPUT:
 varname =  a tplot variable name
OUTPUT:
 out_name = variable name of the output tplot variable
KEYWORDS:
 new_name = can be used to input the new variable name, if not input
 the default is to add a '-d' to the input name (or '-m' for median
 subtraction) and the name is passed out in this variable
HISTORY:
 18-jul-2007, jmm, jimm@ssl.berkeley.edu
$LastChangedBy: $
$LastChangedDate: $
$LastChangedRevision: $
$URL: $

(See ssl_general/misc/tsub_average.pro)


WI

[Previous Routine] [Next Routine] [List of Routines]
PROCEDURE:     wi, wnum

PURPOSE:   Switch or open windows.

INPUT:
   wnum - the window number.

CREATED BY:    REE, 95-10-23
completely rewritten by DEL 2006
FILE: wi.pro
VERSION: 1.6
LAST MODIFICATION: 97/06/03

(See ssl_general/misc/wi.pro)


XCLIP

[Previous Routine] [Next Routine] [List of Routines]
 xclip 
PURPOSE:
 Replaces with FLAGs the values of the array that are BEYOND
 the limits specified.
CALLING SEQUENCE:
 xclip, amin, amax, y, flag=flag, _extra=_extra
INPUT:
 amin, amax = the minumum and maximum values
 y = the input array
OUTPUT:
 y = set to flag for points less than amin or greater than amax
KEYWORDS:
 flag = the value that clipped data will be set to, the default is
           -0.0/0.0 (NaN)
HISTORY:
 2-feb-2007, jmm, jimm.ssl.berkeley.edu from Vassilis'
 clip_deflag.pro
 9-feb-2007, change big value to Nan

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/xclip.pro)


XDEFLAG

[Previous Routine] [Next Routine] [List of Routines]
 xdeflag 
PURPOSE:
 Replaces FLAGs in arrays with interpolated or other values
CALLING SEQUENCE:
 xdeflag, method, t, y, flag=flag, _extra=_extra
INPUT:
 method = set to "repeat", this will repeat the last good value.
          set to "linear", then linear interpolation is used, but for
          the edges, the closest value is used, there is no
          extrapolation
 t = time array, in any useable tplot format
 y = the input array, n_elements(t) by n
OUTPUT:
 y = either interpolated or repated, where the value is > 0.98*flag,
     or NaN
KEYWORDS:
 flag = the value that flagged data are set to, the default is
           6.8792e28
 maxgap = the maximum number of rows that can be filled? the default
           is n_elements(t)
HISTORY:
 2-feb-2007, jmm, jimm.ssl.berkeley.edu from Vassilis' clip_deflag.pro

$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/xdeflag.pro)


XDEGAP

[Previous Routine] [List of Routines]
NAME:
 xdegap
PURPOSE:
 Locates gaps in data, and fills in with NaN
 This subroutine accepts the time array (can be cline time) t and the
 multi-dimensional array yarr that matches with the time array.
 It outputs the same arrays but with a different number of rows
 depending on how many rows were added. It then figures out where to
 add rows by checking which time differences are greater than or equal to
 deltat plus a margin and adds an array of rows of equispaced times of
 size tstep=gap/(number_of_points_that_fit_with_minimum_cumulative_error).
 The same number of rows is added to yarr with values equal to
 FLAGs.
 NOTE: ARRAYS AND STRUCTURES THAT NEED DEGAPPING ARE REDEFINED TO BE
 LARGER THAN BEFORE. THUS THE TIME COLUMN THAT HAS BEEN DEGAPPED
 WILL NOT CORRESPOND TO THE ELEMENTS OF AN ARRAY THAT HAS NOT BEEN
 DEGAPPED. CAUTION: DEGAP ALL ARRAYS OR STRUCTURES YOU ARE GOING TO USE
 TOGETHER, I.E., WITH ONE DEGAP CALL.
CALLING SEQUENCE:
 xdegap, dt, margin, ct, y, nowarning = nowarning, maxgap = maxgap
INPUT:
 dt = the time interval for tests
 margin = the margin 
 ct = the input time array
 y = the input array, can be 1 or 2d (n_elements(ct), m)
OUTPUT:
 ct_out = the output time array, 
 y_out = the input time array
KEYWORDS:
 nowarning = if set, suppresses warnings
 maxgap = the maximum gap size filled
HISTORY:
 From Vassilis' degap.pro, 2-apr-2007, jmm, jimm@ssl.berkeley.edu
 bug fix for undefined variable, jmm, 24-jun-2007
$LastChangedBy$
$LastChangedDate$
$LastChangedRevision$
$URL$

(See ssl_general/misc/xdegap.pro)