This page was created by the IDL library routine `mk_html_help2`.

Last modified: Mon Aug 25 17:13:29 2025.

# Directory Listing of Routines

# projects/themis/common

- THM_BLANK_PANEL
- THM_COMPONENT_TO_TPLOT
  Checks the plot type (SPACECRAFT or COMPONENTS) and creates
- THM_CONFIG
- THM_CONFIG_FILEDIR
- THM_DATA2LOAD
  returns a list of variables that can be loaded for a given THEMIS
- THM_DATA_CALIBRATED
- THM_ESA_LIM4OVERPLOT
- THM_ESA_OVERVIEWS
- THM_FFFFBK_COMPOSITE
  Creates a composite FFF and FBK tplot variable for overview plots
- THM_FFTFBK_OVERPLOT
  Creates overview plots of FBK and FFT (in fast-survey FFF mode) for
- THM_FGM_FIT_CORRELATE_TPLOT.PRO
- THM_FGM_OVERVIEWS
- THM_FGM_SHELL
- THM_FILE_DOWNLOAD
- THM_FIT_FGM_CROSSCHECK.PRO
- THM_FITGMOM_OVERVIEWS
- THM_FITMOM_OVERVIEWS
- THM_FIX_SPEC_UNITS
- THM_FLIPBOOKIFY
  Turns the current tplot window into a "flipbook" containing:
- THM_GEN_MULTIPNG_PLOT
  Creates full day, 6 hour and 2 hour png files for data for a given
- THM_GEN_OVERPLOT
  To make mission overview plots of all instruments
- THM_GET_FGM_QUALITY_FLAGS
  returns an spd_qf_list object with quality flags
- [2]
  GUI for THEMIS data analysis
- [2]
  GUI for THEMIS data analysis
- THM_INIT
- THM_LOAD_PROC_ARG
- THM_LOAD_XXX
- THM_PROBE_NUM
- THM_RANDOM_DP
- THM_READ_CONFIG
  Reads the thm_config file
- THM_ROI_BAR
  creates the roi bar for overview plots
- THM_SAMPLE_RATE_BAR
  creates the sample rate bar for overview plots
- THM_SCPOT2DENS
- THM_SCPOT2DENS_OPT_N
  Convert the spacecraft potential to the electron density
- THM_SET_LIM
- THM_SET_VERBOSE
  Sets verbose level in !themis.verbose and in tplot_options
- THM_SPEC_LIM4OVERPLOT
- THM_SST_OVERVIEWS
- THM_THMSOC_DBLOG
  Database logging facility for IDL scripts. Useful for server runs.
- THM_TPLOT_TO_COMPONENT
  Checks the plot type (SPACECRAFT or COMPONENTS) and creates
- THM_TPLOT_VAR
- THM_UI_CONFIG
  A widget that allows the user to set some of the fields in the
- THM_VALID_INPUT
- THM_VALID_LEVEL
- THM_WRITE_CONFIG
  Writes the thm_config file
- THM_WRITE_PROBE_TIMING_TABLES

# Routine Descriptions

## THM_BLANK_PANEL

[Next Routine] [List of Routines]

    Purpose:
     Helper routine used by thm_fitgmom_overview and thm_fitmom_overviews
     Makes a blank panel if proper data quantities are not present

     $LastChangedBy: jimm $
     $LastChangedDate: 2018-04-16 10:47:48 -0700 (Mon, 16 Apr 2018) $
     $LastChangedRevision: 25050 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_blank_panel.pro $

(See projects/themis/common/thm_blank_panel.pro)

## THM_COMPONENT_TO_TPLOT

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

    FUNCTION:  thm_component_to_tplot, plot_type, active_vnames
    PURPOSE:
       Checks the plot type (SPACECRAFT  or COMPONENTS) and creates
       (if necessary) new tplot variables
    INPUT:  active_vars  string array of variable names (these are the
                         active variables that are currently available)
            cw           gui id for history window
            mw           gui id for progress window
    OUTPUT: new_vars     string array of new active variables, these
                         variables are regrouped by SPACECRAFT or COMPONENT
    KEYWORDS:
    SEE ALSO:  "STORE_DATA", "GET_DATA", "SPLIT_VEC", "OPTIONS", "TPLOT"

    CREATED BY:  Cindy Goethel
    MODIFICATION BY:
    LAST MODIFICATION:

(See projects/themis/common/thm_component_to_tplot.pro)

## THM_CONFIG

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

      PRO themis_config

      This procedure serves as the themis configuration file.  It sets global (system)
      variables and initializes devices

      This procedure will define the location of data files and the data server.
      This procedure is intended to be called from within the "THM_INIT" procedure.

      This should be the only THEMIS file that requires modification for use in different
      locations.

      There is no need to modify this file if:
         - Your computer is an SSL UNIX machine that mounts "/disks/data/"   (i.e. ALL Linux and Solaris machines at SSL)
         - You use a portable computer that will be caching files on a local hard drive.

      Settings  in this file will be overridden by settings in the environment.
      (see setup_themis or setup_themis_bash for examples of setting environment
      variables on UNIX-like systems.  The environment can also be set on Windows
      systems.)

      KEYWORDS
         no_color_setup   added to prevent cronjob to crash, hfrey, 2007-02-10

      Author:  Davin Larson Nov 2006
               jmm, 2007-05-17, Altered to read thm_comfig text file,
               this removes the need for someone to alter this program
               jmm, 2007-07-02, applies slashes to remote and local
               directories, if they are not there
               cg, 2008-5-6, reset default default directory

     $LastChangedBy: nikos $
     $LastChangedDate: 2024-11-13 13:45:30 -0800 (Wed, 13 Nov 2024) $
     $LastChangedRevision: 32962 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_config.pro $

(See projects/themis/common/thm_config.pro)

## THM_CONFIG_FILEDIR

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

    Function: thm_config_filedir.pro
    Purpose: Get the applications user directory for THEMIS data analysis software

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

(See projects/themis/common/thm_config_filedir.pro)

## THM_DATA2LOAD

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

    NAME:
     thm_data2load
    PURPOSE:
     returns a list of variables that can be loaded for a given THEMIS
     instrument. For the most part, it calls the appropriate thm_load
     routine with the /valid_names keyword set. The dataypes and
     valid_names keywords are used inconsistently in the thm_loads, and
     do not allow for the distinction between level2 data that is
     to be input from level2 files, and level2 data the is to be input
     from level1 files and calbrated, cotrans'ed, etc... but has the same
     name as an L2 variable. Designed to be called from
     thm_ui_valid_dtype.pro
    CALLING SEQUENCE:
     dtyp = thm_data2load(instrument, level)
    INPUT:
     instrument = the THEMIS instrument: one of:
               ['asi', 'ask', 'esa', 'efi', 'fbk', 'fft', 'fgm', 'fit', 'gmag', $
                'mom', 'scm', 'spin', 'sst', 'state', 'bau', 'hsk', 'trg']
     level = 'l1' for any data that can be gotten from the l1 file --
             including calibrated, etc... 'l2' for data gotten from L2
             files. 'l10' for data that only is loaded from L1 files. For
             ESA data, 'L10' data and 'L1' data are gotten from the
             packet files.
    OUTPUT:
     dtyp = a string array that can be used as an input to the datatype
            keyword for the given instrument
    HISTORY:
     started on 31-Jan-2008, jmm, jimm@ssl.berkeley.edu, this is under
     development for the next 6 months or so.
     9-apr-2008, jmm, added all instruments, for Version 4_00
    $LastChangedBy: jwl $
    $LastChangedDate: 2021-12-09 14:44:32 -0800 (Thu, 09 Dec 2021) $
    $LastChangedRevision: 30457 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_data2load.pro $

(See projects/themis/common/thm_data2load.pro)

## THM_DATA_CALIBRATED

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

    	Function: THM_DATA_CALIBRATED

    	Purpose:  Determine whether the data stored in a particular TPLOT variable has already been calibrated by examining the contents of it's DLIMIT structure.

    	Calling Sequence:
    		tplot_var = 'tha_eff'
    		get_data, tplot_var, data=d, limit=l, dlimit=dl
    		if thm_data_calibrated( dl) then return
                   ; -- or --
                   if thm_data_calibrated('tha_eff') then return

    	Arguements:
    		DL, Anonymous STRUCT or tplot varaible name

    	Notes:
    		None.

     $LastChangedBy: kenb-mac $
     $LastChangedDate: 2007-05-02 17:25:43 -0700 (Wed, 02 May 2007) $
     $LastChangedRevision: 629 $
     $URL $

(See projects/themis/common/thm_data_calibrated.pro)

## THM_ESA_LIM4OVERPLOT

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

    This program takes a variable and sets zero values to the minimum
    nonzero value not NaN's though. Hacked from
    thm_spec_lim4overplot.pro, to account for problems in solar wind mode
    for probes B and C where there are short intervals with much larger
    energy ranges, which make for ugly plotting. In this case, if the
    value for ymin or ymax are present for less than 1 hour total,
    (actually 1/24 of the total number of time intervals) then ignore
    those values.
    ro thm_esa_lim4overplot, var, trange, zmin = zmin, zmax = zmax, zlog = zlog, $
                             ymin = ymin, ymax = ymax, ylog = ylog, $
                             overwrite = overwrite, _extra = _extra
    Version:
     $LastChangedBy: jimm $
     $LastChangedDate: 2022-11-03 12:59:48 -0700 (Thu, 03 Nov 2022) $
     $LastChangedRevision: 31211 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_esa_lim4overplot.pro $

(See projects/themis/common/thm_esa_lim4overplot.pro)

## THM_ESA_OVERVIEWS

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

    Purpose:
    Generates esa overview plots for a given date
    this includes one day long plot and 4 1/4 day plots
    It stores these plots in the current directory

    Arguments:
           date: the date for which the plots will be generated

           directory(optional): an optional output directory

           device(optional):switch to 'z' device for cron plotting

    Example:
     thm_esa_overviews,'2007-03-23',dir='~/out',device='z'

     $LastChangedBy: jimm $
     $LastChangedDate: 2025-03-31 15:28:47 -0700 (Mon, 31 Mar 2025) $
     $LastChangedRevision: 33219 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_esa_overviews.pro $

(See projects/themis/common/thm_esa_overviews.pro)

## THM_FFFFBK_COMPOSITE

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

    NAME:
     thm_ffffbk_composite
    PURPOSE:
     Creates a composite FFF and FBK tplot variable for overview plots
    CALLING SEQUENCE:
     var = thm_ffffbk_composite(fffvar, fbkvar, scale = scale, $
                                min_gap = min_gap)
    INPUT:
     fffvar = the name of the FFF variable
     fbkvar = the name of the FBS variable
    OUTPUT:
     var = the name of the composite variable, will be fbkvar+'_mix'
    KEYWORDS:
     scale = scale factor to multiply the FFF data, the default is 1.0
     min_gap = the minimum gap size for FFF data, FBK data will not be
               inserted into gaps smaller than this. The default is 300.0
               seconds
    HISTORY:
     11-Aug-2010, jmm, jimm@ssl.berkeley.edu
    Version:
     $LastChangedBy: jimm $
     $LastChangedDate: 2025-04-03 12:41:12 -0700 (Thu, 03 Apr 2025) $
     $LastChangedRevision: 33222 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_ffffbk_composite.pro $

(See projects/themis/common/thm_ffffbk_composite.pro)

## THM_FFTFBK_OVERPLOT

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

    NAME:
     thm_fftfbk_overplot
    PURPOSE:
     Creates overview plots of FBK and FFT (in fast-survey FFF mode) for
     all probes. Two plots are created, one for the "inner probes" (a, d,
     e) and one for the "outer probes" (b, c). There are four quantities
     for each probe, two FBK and two FFF.
    CALLING SEQUENCE:
     thm_fftfbk_overplot, date=date,device = device, $
                          directory = directory, makepng = makepng
    INPUT:
     date = the date for the plots, e.g., '2012-12-21' in any tplottable
            format
    OUTPUT:
     none explicit, plots are generated
    KEYWORDS:
              DEVICE: sets the device (x or z) (default is x)
              MAKEPNG: keyword to generate 5 png files
              DIRECTORY: sets the directory where the above pngs are
              placed (default is './')
     $LastChangedBy: aaflores $
     $LastChangedDate: 2012-01-26 16:41:44 -0800 (Thu, 26 Jan 2012) $
     $LastChangedRevision: 9622 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_fftfbk_overplot.pro $

(See projects/themis/common/thm_fftfbk_overplot.pro)

## THM_FGM_FIT_CORRELATE_TPLOT.PRO

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

     NAME:
           thm_fgm_fit_correlate_tplot.pro

     Purpose:
           Uses ssl_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. RAW
           LEVEL 1 FIT DATA IS REQUIRED, E.G., 'tha_fit'

           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 projects/themis/common/thm_fgm_fit_correlate_tplot.pro)

## THM_FGM_OVERVIEWS

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

    Purpose:
    Generates fgm overview plots for a given date
    this includes one day long plot and 4 1/4 day plots
    It stores these plots in the current directory

    Arguments:
           date: the date for which the plots will be generated

           directory(optional): an optional output directory

           device(optional):switch to 'z' device for cron plotting

     $LastChangedBy: jimm $
     $LastChangedDate: 2025-01-28 16:16:23 -0800 (Tue, 28 Jan 2025) $
     $LastChangedRevision: 33102 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_fgm_overviews.pro $

(See projects/themis/common/thm_fgm_overviews.pro)

## THM_FGM_SHELL

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

     Purpose: wrapper for the thm_fgm_overviews procedure

     Arguments:
            date(optional): the input date (default: current date)

            reprocess(optional): set this keyword to reprocess all the
            plots

            test_reprocess(optional): set this keyword to perform jimm's
            reprocessing test

            directory(optional): the directory into which pngs will be
            output (default: current working directory)

     $LastChangedBy: aaflores $
     $LastChangedDate: 2012-01-06 12:37:07 -0800 (Fri, 06 Jan 2012) $
     $LastChangedRevision: 9507 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_fgm_shell.pro $

(See projects/themis/common/thm_fgm_shell.pro)

## THM_FILE_DOWNLOAD

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

    PROCEDURE:  thm_file_download
    PURPOSE:  This is a general purpose routine will download all THEMIS data files within
     a given time range.
      It looks for all procedures that match: "thm_load_*.pro" and executes them with the /DOWNLOADONLY keyword set.

     Warning -  This is a BETA  routine and may be deleted in a future release.
     23-may-2008, cg, added optional keyword /either to the call to
                      resolve_routine

(See projects/themis/common/thm_file_download.pro)

## THM_FITGMOM_OVERVIEWS

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

    Purpose:
    Generates a set of field and moment plots.
    Only ground processed moments will be used.

    The plots include:

    Arguments:
           date: the date for which the plots will be generated

           probe: the probe for which the plots will be generated

           directory(optional): an optional output directory

           device(optional):switch to 'z' device for cron plotting

           makepng(optional):set this keyword to direct script to make a png

    Example:
     thm_fitgmom_overviews,'2007-03-23','b',dir='~/out',device='z'

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

(See projects/themis/common/thm_fitgmom_overviews.pro)

## THM_FITMOM_OVERVIEWS

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

    Purpose:
    Generates a set of field and moment plots.
    Spacecraft moments will be used whenever possible

    The plots include:

    Arguments:
           date: the date for which the plots will be generated

           probe: the probe for which the plots will be generated

           directory(optional): an optional output directory

           device(optional):switch to 'z' device for cron plotting

    Example:
     thm_fitmom_overviews,'2007-03-23','b',dir='~/out',device='z'

     $LastChangedBy: jimm $
     $LastChangedDate: 2007-12-03 16:23:07 -0800 (Mon, 03 Dec 2007) $
     $LastChangedRevision: 2138 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/trunk/idl/themis/common/thm_sst_overviews.pro $

(See projects/themis/common/thm_fitmom_overviews.pro)

## THM_FIT_FGM_CROSSCHECK.PRO

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

     NAME:
           thm_fit_fgm_crosscheck.pro

     Purpose:
           Load a day's worth of FIT, FGE, and FGL data, and produce packet
           by packet offset estimates by cross-correlating spin fits and
           waveforms.
     CATEGORY:
           THEMIS-SOC
     CALLING SEQUENCE:
          pro thm_fit_fgm_crosscheck,date=date,probe=probe
     INPUTS:

     OUTPUTS:

      Verbose diagnostic output + final summary

     KEYWORDS:

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

     PROCEDURE:

     EXAMPLE:

     MODIFICATION HISTORY:

(See projects/themis/common/thm_fit_fgm_crosscheck.pro)

## THM_FIX_SPEC_UNITS

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

    Procedure:
      thm_fix_spec_units

    Purpose:
      CDF2TPLOT automatically places the units in the y axis subtitle
      regardless of whether the variable is scpectrographic.
      This simply moves the y subtitle to the z axis title.

    Calling Sequence:
      thm_fix_spec_units

    Input:
      names: Array or scalar containing tplot variable names

    Output:
      none

    Notes:

    $LastChangedBy: aaflores $
    $LastChangedDate: 2014-05-23 12:38:29 -0700 (Fri, 23 May 2014) $
    $LastChangedRevision: 15224 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_fix_spec_units.pro $

(See projects/themis/common/thm_fix_spec_units.pro)

## THM_FLIPBOOKIFY

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

     PROCEDURE:
         thm_flipbookify

     PURPOSE:
         Turns the current tplot window into a "flipbook" containing:

         1) the current figure (vertical line at each time step)
         2) THEMIS distribution slices at each time step

     KEYWORDS:
         trange: limit the time range of plots produced (will draw a box around trange by default)
         instrument: instrument for the slices (default: 'esa')
         probe:  probe # for the slices (default: 'd')
         level: level of data for the slices (default: l2)
         data_rate: data rate to use for the slices (default: 'b')
         species: species of the slices; valid options include: (default: 'i')
             'e' for electrons or 'i' for ions

         xrange:  two-element array specifying x-axis range for the slices
         yrange:  two-element array specifying y-axis range for the slices
         zrange:  two-element array specifying z-axis range for the slices

         slices: three-element array specifying the slices to plot:
             'BV':  The x axis is parallel to B field; the bulk velocity defines the x-y plane
             'BE':  The x axis is parallel to B field; the B x V(bulk) vector defines the x-y plane
             'xy':  (default) The x axis is along the data's x axis and y is along the data's y axis
             'xz':  The x axis is along the data's x axis and y is along the data's z axis
             'yz':  The x axis is along the data's y axis and y is along the data's z axis
             'xvel':  The x axis is along the data's x axis; the x-y plane is defined by the bulk velocity
             'perp':  The x axis is the bulk velocity projected onto the plane normal to the B field; y is B x V(bulk)
             'perp_xy':  The data's x & y axes are projected onto the plane normal to the B field
             'perp_xz':  The data's x & z axes are projected onto the plane normal to the B field
             'perp_yz':  The data's y & z axes are projected onto the plane normal to the B field

             default: ['xy', 'xz', 'yz']

         three_d_interp: use the 3D interpolation method (default)
         two_d_interp: use the 2D interpolation method
         geometric: use the geometric interpolation method

         custom_rotation: Applies a custom rotation matrix to the data.  Input may be a
                       3x3 rotation matrix or a tplot variable containing matrices.
                       If the time window covers multiple matrices they will be averaged.
                       This is applied before other transformations

         /energy: produce energy slices instead of velocity slices

         thickness: thickness of the vertical line drawn at each time step
         linestype: style of the vertical line drawn at each time step

         note: box_* keywords require that you specify a trange
         box_color: color of the box
         box_style: linestyle of the box
         box_thickness: thickness of the box
         /no_box: disable the box

         left_margin: adjust the left-margin of the output images
         right_margin: adjust the right-margin of the output images (where the
             slices are stored)

         title: title of the plot; accepts common time string formats, e.g.,
             title="YYYY-MM-DD/hh:mm:ss.fff"

         seconds: specify the # of seconds for each slice
             (e.g., seconds=1.5 -> plot at every 1.5 seconds)
         time_step: integer specifying the interval to produce plots at
             (e.g., time_step=1 -> plot at every time, time_step=2 -> every other time, etc)

         /postscript: save the images as postscript files instead of PNGs

         output_dir: directory where the plots are saved (default: 'flipbook/')
         filename_suffix: suffix to append to the end of the newly created files

         /video: save the sequence of images as a video (.mp4) - currently only works for PNG
         vid_format: format of the output video; default .mp4;
             (options include: avi flv gif matroska mjpeg mov mp4 swf wav webm)
         vid_fps: frames per second for the video; default: 6

     EXAMPLES:

     NOTES:

        - experimental, work in progress! email problems to: egrimes@igpp.ucla.edu

     $LastChangedBy: egrimes $
     $LastChangedDate: 2018-08-27 15:20:51 -0700 (Mon, 27 Aug 2018) $
     $LastChangedRevision: 25699 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_flipbookify.pro $

(See projects/themis/common/thm_flipbookify.pro)

## THM_GEN_MULTIPNG_PLOT

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

    NAME:
     thm_gen_multipng_plot
    PURPOSE:
     Creates full day, 6 hour and 2 hour png files for data for a given
     day, Note that the data must have already been plotted for this
     routine to work properly. It calls tplot without arguments.
    CALLING SEQUENCE:
     thm_gen_multipng_plot, filename_proto, date, directory=directory
    INPUT:
     filename_proto = the first part of the eventual filename, e.g.,
                      'tha_l2_overview', dates and times are appended to
                      make up the full filename
     date = the date for the data
    OUTPUT:
     png files, with names directory+filename_proto+yyddmm_hshf.png,
     where hshf refers to start and end hours for the plot.
    KEYWORDS:
     directory = the output directory, remember the trailing slash....
     vars24 = the variable names to plot for the full 24hr plot, the
              default is to call tplot without any inputs
     vars06 = the variable names to plot for the 6hr plots, the
              default is to call tplot without any inputs
     vars02 = the variable names to plot for the 2hr plots, the
              default is to call tplot without any inputs
    HISTORY:
     21-may-2008, jmm, jimm@ssl.berkeley.edu
     $LastChangedBy: nikos $
     $LastChangedDate: 2015-03-26 11:16:29 -0700 (Thu, 26 Mar 2015) $
     $LastChangedRevision: 17191 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_gen_multipngplot.pro $

(See projects/themis/common/thm_gen_multipngplot.pro)

## THM_GEN_OVERPLOT

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

    NAME:
       thm_gen_overplot

    PURPOSE:
       To make mission overview plots of all instruments
       This can be called either from SPEDAS GUI or from a server script to create png images

    CALLING SEQUENCE:
       thm_gen_overplot

    INPUT:
       none

    KEYWORDS:
       PROBES: spacecraft ('a','b','c','d','e')
       DATE: the date string or seconds since 1970 ('2007-03-23')
       DUR: duration (default units are days)
       DAYS: redundant keyword to set the units of duration (but its comforting to have)
       HOURS: keyword to make the duration be in units of hours
       DEVICE: sets the device (x or z) (default is x)
       MAKEPNG: keyword to generate 5 png files
       DIRECTORY: sets the directory where the above pngs are placed (default is './')
       FEARLESS: keyword that prevents program from quitting when it fears its in an infinite loop
         (infinite loop is feared when catch statement has been call 1000 times)
       DONT_DELETE_DATA:  keyword to not delete all existing tplot variables before loading data in for
          the overview plot (sometimes old variables can interfere with overview plot)
       gui_plot: 1 for gui plot, 0 for server plot
       no_draw: flag passed to tplot_gui for gui overview plots
       error: 0 if it run to the end

    OUTPUT:
       A set of png files or a set of plots for the GUI

    EXAMPLES:
       thm_gen_overplot,probe='a',date='2007-03-23',dur=1
         The above example will produce the overview plots for a full day in the X window.
       thm_gen_overplot, probes='a', date='2008-03-23',dur=1, makepng=1, device='z', directory='c:\tmp'
         The above example will produce a set of 17 plots in c:\temp
       thm_gen_overplot, probes='a', date='2009-03-23', dur = 1, makepng = 0, fearless = 0, dont_delete_data = 1, error=error, gui_plot = 1
         The above example calls this function from the SPEDAS GUI

    HISTORY:
      This has replaced the older spd_ui_overplot.pro which was written specifically for GUI overview plots.

    $LastChangedBy: jimm $
    $LastChangedDate: 2025-05-19 11:45:05 -0700 (Mon, 19 May 2025) $
    $LastChangedRevision: 33318 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_gen_overplot.pro $

(See projects/themis/common/thm_gen_overplot.pro)

## THM_GET_FGM_QUALITY_FLAGS

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

    NAME:
     thm_get_fgm_quality_flags

    PURPOSE:
     returns an spd_qf_list object with quality flags

    CALLING SEQUENCE:
     fgm_qf = thm_get_fgm_quality_flags('tha',trange=trange) ;

    INPUT:
     probe = string, has to me a single probe 'a' or 'b' etc

    KEYWORDS:
     trange = time range

    OUTPUT:
     fgm_qf = quality flags for FGM

    EXAMPLES:
     qf = thm_get_fgm_quality_flags('a',trange=['2014-02-01/00:00:00','2014-02-05/00:00:00'])
     qf->qf_print()

    NOTES:
    Quality flags:
         1:boom not deployed, 2:in shadow, 3:uncorrected shadow, 4:noisy
         waveforms, 8:Bz estimated from spin-plane components

    FGM/SCM boom deploy:
    THEMIS_A: 2007/056 21:00
    THEMIS_B: 2007/056 10:20
    THEMIS_C: 2007/056 09:40
    THEMIS_D: 2007/058 00:05
    THEMIS_E: 2007/058 00:40

    EFI deploy completed:
    THEMIS_A: spin plane: 2008/012 21:43
    axial: 2008/014 16:30
    THEMIS_B: spin plane: 2007/321 18:43
    axial: 2007/322 06:05
    THEMIS_C: spin plane: 2007/134 22:25
    axial: 2007/136 20:40
    THEMIS_D: spin plane: 2007/156 22:50
    axial: 2007/158 17:40
    THEMIS_E: spin plane: 2007/156 23:55
    axial: 2007/158 18:45

    Data for thc are wrong for 2011:

    Nov 26 10:10 – Nov 26 24:00
    Nov 28 23:10 – Nov 29 03:00
    Nov 30 05:00 – Nov 30 24:00
    Dec 07 15:00 – Dec 08 24:00
    Dec 27 15:00 – Dec 27 24:00

    Data for thb are wrong for 2012:;
    Jan 04 20:45 – Jan 04 24:00

    RELATED:
    spd_qf_list__define

    HISTORY:;
    $LastChangedBy: jimm $
    $LastChangedDate: 2024-11-20 12:14:41 -0800 (Wed, 20 Nov 2024) $
    $LastChangedRevision: 32969 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_get_fgm_quality_flags.pro $

(See projects/themis/common/thm_get_fgm_quality_flags.pro)

## THM_INIT

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

    PROCEDURE:  thm_init
    PURPOSE:    Initializes system variables for themis.  Can be called from idl_startup to set
                custom locations.

     The system variable !THEMIS is defined here.  The elements of this structure are explained below:

     !THEMIS.LOCAL_DATA_DIR    This is the root location for all THEMIS data files.
                      The THEMIS software expects all data files to reside in specific subdirectories relative
                      to this root directory.;

     !THEMIS.REMOTE_DATA_DIR   This is the URL of the server that can provide the data files.
                      (default is: "http://themis.ssl.berkeley.edu/data/themis/")
                      if the software does not find a needed file in LOCAL_DATA_DIR,
                      then it will attempt to download the data from the URL and REMOTE_DATA_DIR is defined,
                      the software will attempt to download the file from REMOTE_DATA_DIR, place it in LOCAL_DATA_DIR
                      with the same relative pathname, and then continue processing.

    KEYWORDS:
       RESET:           Reset !themis to values in environment (or values in keywords).
       LOCAL_DATA_DIR:  use given value for local_data_dir, rather than environment. Only works on
                        initial call or reset.
       REMOTE_DATA_DIR: Use given value for remote_data_dir, rather than env.  Only works on inital
                        call or reset.
       NO_COLOR_SETUP   do not set colors if already taken care of

     Typical examples:

              Desktop UNIX/LINUX computer located at SSL
       LOCAL_DATA_DIR  = '/disks/data/themis/'               ; This master directory is read only.
       REMOTE_DATA_DIR = ''                                  ; Should be empty sting. (/disks/data/themis and server are the same)

              Desktop WINDOWS computer located at SSL
       LOCAL_DATA_DIR  = '\\justice\data\themis\'            ; Justice is a samba server (physically the same as /disk/data/themis)
       REMOTE_DATA_DIR = ''

              laptop WINDOWS computer located far from a data server, but with internet connection.
       LOCAL_DATA_DIR  = 'C;\data\themis\'                              ; Local (portable) directory on laptop
       REMOTE_DATA_DIR = 'http://themis.ssl.berkeley.edu/data/themis/'    ;  URL used to download data to LOCAL_DATA_DIR

              MacOS computer located away from SSL without a nearby data server
       LOCAL_DATA_DIR  = '/data/themis/'                              ; Local (portable) directory on laptop
       REMOTE_DATA_DIR = 'http://themis.ssl.berkeley.edu/data/themis/'    ;  URL used to download data to LOCAL_DATA_DIR

       Note: If automatic downloads are used. (i.e. REMOTE_DATA_DIR is not an empty string) the user must ensure that
       LOCAL_DATA_DIR is writeable.

       Note to WINDOWS users: the WINDOWS version of IDL accepts both the '\' and '/' character as the directory
       separation character. The converse is not true.

    HISTORY
     Written by Davin Larson
     2006-12-16 KRB Can now be called from idl_startup to set paths using
     optional keywords.
     2007-07-02, jmm, Adds trailing slash to local and remote data dirs,
                      if not there
     2013-02-27, jmm, Added comment to test SVN commit
     2019-08-30, egrimes, moved !debug_process_events=0 to spedas_init

    $LastChangedBy: egrimes $
    $LastChangedDate: 2019-08-30 10:49:38 -0700 (Fri, 30 Aug 2019) $
    $LastChangedRevision: 27704 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_init.pro $

(See projects/themis/common/thm_init.pro)

## THM_LOAD_PROC_ARG

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

    Procedure: THM_LOAD_PROC_ARG

    Purpose:  Generic argument validation routine for THEMIS Data File Loading
       routines, meant to be called by
       instrument-specific thm_load procedures.

    keywords:
      post_process_proc: name of procedure to call after cdf2tplot is called
                         will be called w/ keywords sname, dt (datatype), lvl,
                         and _extra.
      relpath_funct: name of routine to call in place of file_dailynames
                     may simply be a wrapper.
                     will be called w/ keywords sname, dt (datatype), lvl,
                     and _extra.
      cdf_to_tplot: user-supplied procedure to override cdf2tplot
      sname  = site or probe name. The default is 'all',
      type_sname = string, set to 'probe' or 'site'
      vsnames = space-separated list of valid probes/sites
      datatype = Can be any datatype from the list of valid datatypes
                 or 'all'
      vdatatypes = space-separated list of valid data types
      file_vdatatypes = space-separated list of file types corresponding to each
              valid data type.  If there is a one-to-one correpspondence
              between filetype and datatype, vfiletypes may be left undefined.
              If all datatypes are in a single file, then vfiltypes may contain
              a single name, rather than a list.
      vL2datatypes= space-separated list of datatypes valid for L2 data
      vL2coord= space-separated list of coordinates valid for L2 data
      file_vL2datatypes=same as file_vdatatypes, but for L2 data.  Defaults to
              value of file_vdatatypes.
      TRANGE= (Optional) Time range of interest  (2 element array), if
              this is not set, the default is to prompt the user. Note
              that if the input time range is not a full day, a full
              day's data is loaded
      level = the level of the data, the default is 'l1', or level-1
              data. A string (e.g., 'l2') or an integer can be used. 'all'
              can be passed in also, to get all levels.
      vlevels=A space-separated list of valid levels, e.g. 'l1 l2'
      proc_type =  the type of data, i.e. 'raw' or 'calibrated'. This is
              for validating the 'type' keyword to thm_load procs.
      vtypes =A space-separated list of valid types, e.g. 'raw calibrated'
              No validation on proc_type if not set.
      deftype = default for type.  only applied to L1.  If not supplied,
                then 'calibrated' will be uses as the default value.
      CDF_DATA: named variable in which to return cdf data structure: only works
              for a single spacecraft and datafile name.
      VARNAMES: names of variables to load from cdf: default is all.
      /GET_SUPPORT_DATA: load support_data variables as well as data variables
                          into tplot variables.
      /NO_UPDATE: prevent contact to server if local file already exists.
      /valid_names, if set, then this routine will return the valid probe, datatype
              and/or level options in named variables supplied as
              arguments to the corresponding keywords.
      files   named varible for output of pathnames of local files.
      /VERBOSE  set to output some useful info
      msg_out:  A named variable to output an array of error messages
                which can be printed to the console later when they
                will be more visible to the user.  Null string is returned
                if no applicable errors are encountered.

    Output Keywords:
      oft     distinct file types that need to be loaded.  Array of strings.
      ofdt    datatypes corresponding to each file type in ofts. Array of
              strings, each containing a space-separate list of datatypes .
      odt     validated datatypes
      olvl    validated levels.
      otyp    validated type.
    Notes:
      This routine is a utility function used to implement thm_load_??? routines.

     $LastChangedBy: aaflores $
     $LastChangedDate: 2015-04-30 15:28:49 -0700 (Thu, 30 Apr 2015) $
     $LastChangedRevision: 17458 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_load_proc_arg.pro $

(See projects/themis/common/thm_load_proc_arg.pro)

## THM_LOAD_XXX

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

    Procedure: THM_LOAD_XXX

    Purpose:  Generic THEMIS Data File Loading routine, meant to be called by
       type specific thm_load procedures.

    keywords:
      post_process_proc: name of procedure to call after cdf2tplot is called
                         will be called w/ keywords sname, dt (datatype), lvl,
                         and _extra.
      relpath_funct: name of routine to call in place of file_dailynames
                     may simply be a wrapper.
                     will be called w/ keywords sname, dt (datatype), lvl,
                     and _extra.
      cdf_to_tplot: user-supplied procedure to override cdf2tplot
      sname  = site or probe name. The default is 'all',
      type_sname = string, set to 'probe' or 'site'
      /all_sites_in_one: set this if all sites are contained in a single file.
      vsnames = space-separated list of valid probes/sites
      datatype = Can be any datatype from the list of valid datatypes
                 or 'all'
      vdatatypes = space-separated list of valid data types
      file_vdatatypes = space-separated list of file types corresponding to each
              valid data type.  If there is a one-to-one correpspondence
              between filetype and datatype, vfiletypes may be left undefined.
              If all datatypes are in a single file, then file_vdatatypes may
              contain a single name, rather than a list.
      TRANGE= (Optional) Time range of interest  (2 element array), if
              this is not set, the default is to prompt the user. Note
              that if the input time range is not a full day, a full
              day's data is loaded
      level = the level of the data, the default is 'l1', or Level 1
              data. A string (e.g., 'l2') or an integer can be used.
      vlevels=A space-separated list of valid levels, e.g. 'l1 l2'
      proc_type =  the type of data, i.e. 'raw' or 'calibrated'. This is
              for validating the 'type' keyword to thm_load procs.
      vtypes =A space-separated list of valid types, e.g. 'raw calibrated'
      vL2datatypes= space-separated list of datatypes valid for L2 data
      vL2coord= space-separated list of coordinates valid for L2 data
      file_vL2datatypes=same as file_vdatatypes, but for L2 data.  Defaults to
              value of file_vdatatypes.
      coord = coordinate system of data to  be loaded.  For L2, may be an array or
              space-separated list, which will checked against vL2coord.
              For L1, no checking: passed on to post_process_proc.
      CDF_DATA: named variable in which to return cdf data structure: only works
              for a single spacecraft and datafile name.
      VARNAMES: names of variables to load from cdf: default is all.
      /GET_SUPPORT_DATA: load support_data variables as well as data variables
                          into tplot variables.
      /DOWNLOADONLY: download file but don't read it.
      /NO_UPDATE: prevent contact to server if local file already exists.
      /valid_names, if set, then this routine will return the valid probe, datatype
              and/or level options in named variables supplied as
              arguments to the corresponding keywords.
      files   named varible for output of pathnames of local files.
      /VERBOSE  set to output some useful info
      suffix  suffix to add to names of tplot variables loaded from CDF
              Note that the suffix is *not* applied to support_data.
      SCM_CAL: structure that contains calibration paramters
      msg_out: A named variable to output any useful error messages,
               messages can be printed to the console later when they
               will be more visible to the user.

    Notes:
      This routine is (should be) platform independent.

     $LastChangedBy: jimm $
     $LastChangedDate: 2022-07-27 10:47:49 -0700 (Wed, 27 Jul 2022) $
     $LastChangedRevision: 30961 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_load_xxx.pro $

(See projects/themis/common/thm_load_xxx.pro)

## THM_PROBE_NUM

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

    Function: thm_probe_num

    Purpose:  Converts probe letters into probe numbers and vice versa.  Provide a single
     character or number to this routine, or an array of characters and numbers and it will
     return those values but converted into the alternative representation.

    Inputs: name:  Either an array or a single element.  Can be either numbers or letters.

     Outputs: A single element or an array of elements converted to the alternative representation.

    Example:
       print,thm_probe_num(['a','b','c','d','e'])
     5           1           2           3           4
       print,thm_probe_num([1,2,3,4,5])
     b c d e a
    Notes:

     $LastChangedBy: pcruce $
     $LastChangedDate: 2008-06-30 16:26:54 -0700 (Mon, 30 Jun 2008) $
     $LastChangedRevision: 3229 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_probe_num.pro $

(See projects/themis/common/thm_probe_num.pro)

## THM_RANDOM_DP

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

    Returns a random value for probe, and sets timespan to a random
    date. For testing. Can input start_data and end_date as keywords to
    search smaller time ranges; the default is the full mission after
    2007-03-23
     $LastChangedBy: jimm $
     $LastChangedDate: 2018-04-16 10:47:48 -0700 (Mon, 16 Apr 2018) $
     $LastChangedRevision: 25050 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_random_dp.pro $

(See projects/themis/common/thm_random_dp.pro)

## THM_READ_CONFIG

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

    NAME:
     thm_read_config
    PURPOSE:
     Reads the thm_config file
    CALLING SEQUENCE:
     cstruct = thm_read_config()
    INPUT:
     none, the filename is hardcoded, 'thm_config.txt',and is s put in a
     folder given by the routine thm_config_filedir, that uses the IDL
     routine app_user_dir to create/obtain it: my linux example:
     /disks/ice/home/jimm/.idl/themis/thm_config-4-linux
    OUTPUT:
     cstruct = a structure with the changeable fields of the !themis
               structure
    HISTORY:
     17-may-2007, jmm, jimm@ssl.berkeley.edu
     2-jul-2007, jmm, 'Add trailing slash to data directories, if necessary
     10-aug-2011, lphilpott, Modified to allow to read a THEMIS template path from the config file
    $LastChangedBy$
    $LastChangedDate$
    $LastChangedRevision$
    $URL$

(See projects/themis/common/thm_read_config.pro)

## THM_ROI_BAR

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

    NAME:
     thm_roi_bar
    PURPOSE:
     creates the roi bar for overview plots
    CALLING SEQUENCE:
     p = thm_roi_bar(in_data)

     INPUT:
      in_data: the name of the roi variable to
               be plotted(generally something like 'thb_state_roi'

    OUTPUT:
     p = the variable name of the roi_bar, set to '' if not
     successfule
    HISTORY:
     2007-02-28 pcruce@ssl.berkeley.edu

     $LastChangedBy: pcruce $
     $LastChangedDate: 2008-01-25 15:07:47 -0800 (Fri, 25 Jan 2008) $
     $LastChangedRevision: 2315 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/trunk/idl/themis/common/thm_sample_rate_bar.pro $

(See projects/themis/common/thm_roi_bar.pro)

## THM_SAMPLE_RATE_BAR

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

    NAME:
     thm_sample_rate_bar
    PURPOSE:
     creates the sample rate bar for overview plots
    CALLING SEQUENCE:
     p = thm_sample_rate_bar(date,duration,probe)
    INPUT:
     date =  the date for the start of the timespan,
     duration = the duration of your bar in days
     probe = THEMIS probe Id

    KEYWORDS:
     outline: set this to 1 to generate a sample rate panel with
              a black outline rather than no outline
    OUTPUT:
     p = the variable name of the sample_rate_bar, set to '' if not
         sccessful
    HISTORY:
     20-nov-2007, jmm, jimm@ssl.berkeley.edu
     $LastChangedBy: nikos $
     $LastChangedDate: 2016-02-17 10:47:06 -0800 (Wed, 17 Feb 2016) $
     $LastChangedRevision: 20029 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_sample_rate_bar.pro $

(See projects/themis/common/thm_sample_rate_bar.pro)

## THM_SCPOT2DENS

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

    function THM_SCPOT2DENS.PRO

    Purpose:
      This stand-alone function calculates the spacecraft potential derived density.  All argindex_esa_e[0] uments should be 1-d arrays.
      Average temps will be interpolated onto the SCPOT, using the time values (SCPTIME).

    Result:
      The plasma density as a function of SCPOT keeping the same time base (SCPTIME).

    Calling sequence:
      RESULT = THM_SCPOT2DENS( scpot, scptime, Te, Tetime, dens_e, dens_e_time, dens_i, dens_i_time )

      where

      SCPOT: 		The spacecraft potential time (call THM_LOAD_ESA, DATATYPE = 'peer_sc_pot').
      SCPTIME:		The time base of SCPOT.
      TE: 			The electron temperature (a la THM_LOAD_ESA, DATATYPE = 'peer_avgtemp').
      TETIME: 		The time base of TE.
      DENS_E: 		The electron density (call THM_LOAD_ESA, DATATYPE = 'peer_density').
      DENS_E_TIME: 	The time base for DENS_E.
      DENS_I: 		The ion density (call THM_LOAD_ESA, DATATYPE = 'peir_density').
      DENS_I_TIME: 	The time base for DENS_I.

    W.M.Feuerstein, 2009-05-18.

    Example:
     see THM_CRIB_SCPOT2DENS.PRO

    History:
     clrussell, 09-26-2012  Fixed bug when converting probe number to a character

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

(See projects/themis/common/thm_scpot2dens.pro)

## THM_SCPOT2DENS_OPT_N

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

     NAME:
        thm_scpot2dens_opt_n

     PURPOSE:
        Convert the spacecraft potential to the electron density

     CATEGORY:
        EFI, ESA

     CALLING SEQUENCE:
        thm_scpot2dens_opt_n,sc=sc,datatype_esa=datatype_esa,trange=trange

     EXAMPLE:
        thm_scpot2dens_opt_n,sc='d',datatype_esa='peer' ;scpot and vthermal from peer

     PRE-REQUIREMENTS:
        Timespan for the calculation like
        timespan,'2009-01-01/00:00:00',1,/day

     KEYWORD PARAMETERS:
        probe         spacecraft name: 'a', 'b', 'c', 'd' or 'e'. Default is 'a'.
        datatype_esa       ESA datatype: 'peef', 'peer', 'peem' or
                           'peeb'. Default is 'peer'.
        trange     The time range to input, if not set, then the timespan
                   value is used.
        no_data_load - if set, do not load data
        nscpot_ion_density_threshold - data for times where the ion
                                      density is above this value are
                                      flagged as 'bad' and set to
                                      'NaN'. The default value is 4.0e1
     OUTPUTS:
        'th?_*_density' Electron density in cm-3
     RESTRICTIONS:
        The calculated electron density may include
        uncertainties. Uncertainties are larger where the thermal
        velocity of electrons is not accurately estimated: in the
        plasmasphere, plasmatrough and lobe. Error data in the electron
        thermal speed or spacecraft potential give unreliable denisities.

     MODIFICATION HISTORY:
        Written by: Toshi Nishimura@UCLA/NAGOYA, 05/02/2009 (toshi at atmos.ucla.edu)
        Modification 05/26/2009 Add keywords 'datatype_esa'.
        Modification 07/13/2009 Update the scpot-density relation mainly
        for the plasmasphere.
        Modfication 10/08/2009 Added trange keyword, jmm, jimm@ssl.berkeley.edu

        Collaborators: Vassilis Angelopoulos, John Bonnell and Wen Li
        It is recommended to contact people listed above before
        presentations or publications using the data created by this
        code.

(See projects/themis/common/thm_scpot2dens_opt_n.pro)

## THM_SET_LIM

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

    Purpose:
    This is a helper procedure that will set the maximum and minimum for a given mnemonic
    within a specific time range (used by thm_fitmom_overviews and thm_fitgmom_overviews)

    Example:
     thm_fitmom_overviews,'2007-03-23','b',dir='~/out',device='z'

     $LastChangedBy: jimm $
     $LastChangedDate: 2023-09-25 13:43:30 -0700 (Mon, 25 Sep 2023) $
     $LastChangedRevision: 32122 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_set_lim.pro $

(See projects/themis/common/thm_set_lim.pro)

## THM_SET_VERBOSE

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

    NAME:
     thm_set_verbose
    PURPOSE:
     Sets verbose level in !themis.verbose and in tplot_options
    CALLING SEQUENCE:
     thm_set_verbose, vlevel
    INPUT:
     vlevel = a verbosity level, if not set then !themis.verbose is used
              (this is how you would propagate the !themis.verbose value
              into tplot options)
    HISTORY:
     21-aug-2012, jmm, jimm@ssl.berkeley.edu
     12-oct-2012, jmm, Added this comment to test SVN
     12-oct-2012, jmm, Added this comment to test SVN, again
     18-oct-2012, jmm, Another SVN test
     31-oct-2016, jmm, Added setting to dprint too
     $LastChangedBy: jimm $
     $LastChangedDate: 2016-10-31 13:25:10 -0700 (Mon, 31 Oct 2016) $
     $LastChangedRevision: 22240 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_set_verbose.pro $

(See projects/themis/common/thm_set_verbose.pro)

## THM_SPEC_LIM4OVERPLOT

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

    This program takes a variable and sets zero values to the minimum
    nonzero value -- not NaN's though
    ro thm_spec_lim4overplot, var, zmin = zmin, zmax = zmax, zlog = zlog, $
                              ymin = ymin, ymax = ymax, ylog = ylog, $
                              overwrite = overwrite, _extra = _extra
    Version:
     $LastChangedBy: jimm $
     $LastChangedDate: 2017-05-01 15:47:29 -0700 (Mon, 01 May 2017) $
     $LastChangedRevision: 23257 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_spec_lim4overplot.pro $

(See projects/themis/common/thm_spec_lim4overplot.pro)

## THM_SST_OVERVIEWS

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

    Purpose:
    Generates sst overview plots for a given date
    this includes one day long plot and 4 1/4 day plots
    It stores these plots in the current directory

    Arguments:
           date: the date for which the plots will be generated

           directory(optional): an optional output directory

           device(optional):switch to 'z' device for cron plotting

    Example:
     thm_sst_overviews,'2007-03-23',dir='~/out',device='z'

     $LastChangedBy: nikos $
     $LastChangedDate: 2021-10-19 11:41:37 -0700 (Tue, 19 Oct 2021) $
     $LastChangedRevision: 30377 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_sst_overviews.pro $

(See projects/themis/common/thm_sst_overviews.pro)

## THM_THMSOC_DBLOG

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

    NAME:
     thm_thmsoc_dblog

    PURPOSE:
     Database logging facility for IDL scripts. Useful for server runs.

    CALLING SEQUENCE:
     spd_thmsoc_dblog

    INPUT:
     none

    KEYWORDS:
       server_run: 1 for server run
       process_name: the name of the calling procedure
       severity: 1-2-3, severity 4-5 is not reported (good for testing)
       str_message: explanation about the error
       args: COMMAND_LINE_ARGS
       testing: prints a message that this log record is due to testing

    OUTPUT:
     Database logging

    EXAMPLES:
      Example of how thmsoc_dblog.php is called from ksh scripts:
         thmsoc_dblog.php make_ae_index.ksh 1 "$msg"
      Example of how to call spd_thmsoc_dblog:
         thm_thmsoc_dblog, server_run=1, process_name='make_ae_index', severity='1', str_message='Error: GMAG cdf file not found'

    NOTES:
      This script should only be used on server runs.
      It is distributed as a part of SPEDAS so that logging from overview plots will compile without errors.

    HISTORY:

    $LastChangedBy: jwl $
    $LastChangedDate: 2023-06-28 10:36:20 -0700 (Wed, 28 Jun 2023) $
    $LastChangedRevision: 31913 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_thmsoc_dblog.pro $

(See projects/themis/common/thm_thmsoc_dblog.pro)

## THM_TPLOT_TO_COMPONENT

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

    FUNCTION:  thm_tplot_to_component, active_vnames, cw, mw
    PURPOSE:
       Checks the plot type (SPACECRAFT  or COMPONENTS) and creates
       (if necessary) new tplot variables
    INPUT:  active_vars  string array of variable names (these are the
                         active variables that are currently available)
            cw           gui id for history window
            mw           gui id for progress window
    OUTPUT: new_vars     string array of new active variables, these
                         variables are regrouped by SPACECRAFT or COMPONENT
    KEYWORDS:
    SEE ALSO:  "STORE_DATA", "GET_DATA", "SPLIT_VEC", "OPTIONS", "TPLOT"

    CREATED BY:  Cindy Goethel
    MODIFICATION BY:
    LAST MODIFICATION:

(See projects/themis/common/thm_tplot_to_component.pro)

## THM_TPLOT_VAR

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

    Function: THM_TPLOT_VAR

    Purpose:  Creates TPLOT variable name from SC id and data qty strings.
    keywords:
       /VERBOSE or VERBOSE=n ; set to enable diagnostic message output.
    		higher values of n produce more and lower-level diagnostic messages.
       /ALL

    Example:
    	sc = 'a'
    	name = 'eff'
       tplot_var = thm_tplot_var( sc, name)
    Notes:

     $LastChangedBy: kenb-mac $
     $LastChangedDate: 2007-02-08 10:02:45 -0800 (Thu, 08 Feb 2007) $
     $LastChangedRevision: 329 $
     $URL $

(See projects/themis/common/thm_tplot_var.pro)

## THM_UI_CONFIG

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

    NAME:
     thm_ui_config
    PURPOSE:
     A widget that allows the user to set some of the fields in the
     !themis system variable: Also allows the user to set the themis
     configuration text file, and save it
    HISTORY:
     17-may-2007, jmm, jimm@ssl.berkeley.edu
     2-jul-2007, jmm, 'Add trailing slash to data directories, if necessary
     5-may-2008, cg, removed text boxes and replaced with radio buttons or
                     pulldowns, fixed reset to default
     11-feb-2009, jmm, restored old version
    $LastChangedBy: lphilpott $
    $LastChangedDate: 2012-02-16 11:17:44 -0800 (Thu, 16 Feb 2012) $
    $LastChangedRevision: 9761 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_ui_config.pro $

(See projects/themis/common/thm_ui_config.pro)

## THM_VALID_INPUT

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

    function thm_valid_input
    purpose:
      for thm_load routines to validate the input keyword and set it to a standard
      format ('l1', 'l2', etc.).
    parameters:
      input:  keyword input to be validated from thm_load routine: array or scalar
      label:  name of input keyword that is being validated
    keywords:
      vinputs: a space-separated string, like 'l1 l2'
      definput: a string like 'l2'.  Required.
      include_all:  if set will accept multiple values on input, and include 'all'
                    as a valid input. 'all' is equivalent to '*'
      verbose: to maintain control of verbosity
      format: format to use to convert numerical input to string.  Numerical input
              disallowed if absent.  examples: "('l',I1)" or "('v', I02)"
     return value:
        a scalar string, e.g. 'l1'
        if /include_all: an array of strings
        on error: empty string: ''
    example:
            lvl = thm_valid_input(level,'Level',vinputs='l1 l2',definput='l1',$
                                   foramt="('l', I1)", verbose=verbose)
            if lvl eq '' then return

(See projects/themis/common/thm_valid_input.pro)

## THM_VALID_LEVEL

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

    function thm_valid_level
    purpose:
      for thm_load routines to validate the level keyword and set it to a standard
      format ('l1', 'l2', etc.).  Only a single level is allowed.
    keywords:
      level:  level keyword input from thm_load routine
      vlevels: a space-separated string, like 'l1 l2'
      deflevel: a string like 'l2'.  defaults to 'l1'
    example:
            lvl = thm_valid_level('l1','l1 l2','l1')

(See projects/themis/common/thm_valid_level.pro)

## THM_WRITE_CONFIG

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

    NAME:
     thm_write_config
    PURPOSE:
     Writes the thm_config file
    CALLING SEQUENCE:
     thm_write_config, copy=copy
    INPUT:
     none, the filename is hardcoded, 'thm_config.txt',and is s put in a
     folder given by the routine thm_config_filedir, that uses the IDL
     routine app_user_dir to create/obtain it: my linux example:
     /disks/ice/home/jimm/.idl/themis/thm_config-4-linux
    OUTPUT:
     the file is written, and a copy of any old file is generated
    KEYWORD:
     copy = if set, the file is read in and a copy with the !stime
            appended is written out
    HISTORY:
     17-may-2007, jmm, jimm@ssl.berkeley.edu
     18-mar-2009, jmm, fixed problem with writing string representations
                       of byte values
     10-aug-2011, lphilpott, modified to write a template path to the config file too.
    $LastChangedBy$
    $LastChangedDate$
    $LastChangedRevision$
    $URL$

(See projects/themis/common/thm_write_config.pro)

## THM_WRITE_PROBE_TIMING_TABLES

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

     Procedure: thm_write_probe_timing_tables.pro

     Purpose:  This routine takes two string file names as input arguments, reads all 'phases_???.txt' files present in the WD,
               determines the primary (statistically significant) apid sampling times in terms on one-second-mark 'ticks' and spin 'sectors',
               writes 'ticks' and 'sectors' found to probe timing table files, and generates png images of the timelines per apid.

     Inputs:   Parameters: ticks_table_file, sectors_table_file (to be generated by the routine)
               Non-Parameters: phases_xxx.txt files in PWD (ASCII files containing apid:xxx header times, one second mark phases, spin phases, and delta_phi timeline)
                 These ASCII files need to be generated by write_probe_timing_phases.bash

     Keywords:
               NO_PNG: If set, png images are not produced
               TEST:   If set, ALL tick counts are recorded and written to file (except for apid:410)
                       Otherwise, only tick counts = 1,2,8,16 and 32 are recorded and written to file

     Outputs:  ticks_table_file, sectors_table_file and png images of phases per apid (default)

     Examples:
               thm_write_probe_timing_tables,'ticks_table.txt','sectors_table.txt'
               thm_write_probe_timing_tables,'ticks_table.txt','sectors_table.txt',/no_png
               thm_write_probe_timing_tables,'ticks_table.txt','sectors_table.txt',/no_png,/test

     See Also:
               ${TMTOOLS_ROOT}/src/scripts/write_probe_timing_phases.bash

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

(See projects/themis/common/thm_write_probe_timing_tables.pro)

## [2]

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

    NAME:

     thm_gui_new

    PURPOSE:
     GUI for THEMIS data analysis

    CALLING SEQUENCE:
     thm_gui_new

    INPUT:
     none

     Keywords:
       Reset - If set will reset all internal settings.
               Otherwise, it will try to load the state of the previous call.
       template_filename - The file name of a previously saved themis template document,
                       can be used to store user preferences and defaults.

    OUTPUT:
     none

    HISTORY:
     Made into a wrapper for spd_gui.pro, jmm, 2014-02-11

    $LastChangedBy: jimm $
    $LastChangedDate: 2014-02-12 15:49:01 -0800 (Wed, 12 Feb 2014) $
    $LastChangedRevision: 14368 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_gui_new.pro $

(See projects/themis/common/thm_gui_new.pro)

## [2]

[Previous Routine] [List of Routines]

    NAME:

     thm_gui

    PURPOSE:
     GUI for THEMIS data analysis

    CALLING SEQUENCE:
     thm_gui

    INPUT:
     none

     Keywords:
       Reset - If set will reset all internal settings.
               Otherwise, it will try to load the state of the previous call.
       template_filename - The file name of a previously saved themis template document,
                       can be used to store user preferences and defaults.

    OUTPUT:
     none

    HISTORY:
     Made into a wrapper for spd_gui.pro, jmm, 2014-02-11

    $LastChangedBy: jimm $
    $LastChangedDate: 2014-02-12 15:49:01 -0800 (Wed, 12 Feb 2014) $
    $LastChangedRevision: 14368 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/common/thm_gui.pro $

(See projects/themis/common/thm_gui.pro)