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

Last modified: Fri Oct 3 18:17:41 2025.

# Directory Listing of Routines

# projects/barrel

- BARREL_CONFIG_FILEDIR
- BARREL_INIT
- BARREL_LOAD_DATA
- BARREL_LOAD_EPHM
- BARREL_LOAD_FSPC
- BARREL_LOAD_HKPG
- BARREL_LOAD_MAGN
- BARREL_LOAD_MISC
- BARREL_LOAD_MSPC
- BARREL_LOAD_RCNT
- BARREL_LOAD_SSPC
- BARREL_PRELOAD_ACTIONS
- BARREL_READ_CONFIG
- BARREL_WRITE_CONFIG
- BRL_BINVERT
- BRL_DPUCOEFFS
- BRL_FIND511[1]
- BRL_FIND511[2]
- BRL_MAKEBKGD
- BRL_MAKEEDGES

# Routine Descriptions

## BARREL_CONFIG_FILEDIR

[Next Routine] [List of Routines]

    NAME: barrel_config_filedir

    DESCRIPTION: Get the applications user directory for SPEDAS

    $LastChangedBy: nikos $
    $LastChangedDate: 2014-10-29 11:36:02 -0700 (Wed, 29 Oct 2014) $
    $LastChangedRevision: 16081 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/barrel/barrel_config_filedir.pro $

(See projects/barrel/barrel_config_filedir.pro)

## BARREL_INIT

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

    NAME: barrel_init
    DESCRIPTION: Initializes system variables for BARREL.  Can be called
      from idl_startup or customized for non-standard installations.  The
      system variable !BARREL is defined here.  The elements of this
      structure are (mostly) the same as for !THEMIS.

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     RESET:        If set, force

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.96a KBY 06/15/2014 cleaned up commented out (dead) code
    Version 0.92f KBY 08/09/2013 REMOTE_DATA_DIR pointed to BARRELDATA.UCSC.EDU
    Version 0.92 KBY 06/04/2013 added support for data directories sorted by version number
    Version 0.91d KBY 06/04/2013 REMOTE_DATA_DIR pointed to SOC1 local; LOCAL_DATA_DIR to /barrel/
    Version 0.90b KBY 04/19/2013 REMOTE_DATA_DIR pointed to test directory for beta testing
    Version 0.84 KBY 12/04/2012 REMOTE_DATA_DIR pointed to SSL; added header
    Version 0.83 KBY 12/04/2012 initial beta release
    Version 0.80 KBY 10/29/2012 from 'goesmag/goes_init.pro' by JWL(?)

(See projects/barrel/barrel_init.pro)

## BARREL_LOAD_DATA

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

    NAME: barrel_load_data
    DESCRIPTION: master CDF-to-TDAS import routine for BARREL data products

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL launch order designators (e.g. '101').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '101 102').
                   If string contains two character alphanumeric identifiers
                     (e.g., '1A 1B'), then PROBE is assumed to specify a build order
                     designator instead.
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'MAGN',
                     'FSPC','MSPC','SSPC','HKPG','GPS','PPS','RCNT').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   if specified, a named variable into which a list of TPLOT
                     variable names is written immediately after import.
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        if specified, a named variable into which a list of source
                     filenames is written.

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.96c JMM 07/01/2016, defaults to v05
    Version 0.96b JGS 07/02/2015 RC1, defaults to v04 dataset
    Version 0.96a KBY 07/07/2014 RC1, defaults to v03 dataset
    Version 0.95b KBY 12/29/2013 default to v02 dataset
    Version 0.93e KBY 08/16/2013 rename "barrel_load_gps.pro" to "barrel_load_ephm.pro";
                   DROP SUPPORT/COMPATIBILITY FOR v01 CDFs
    Version 0.93a KBY 08/16/2013 deprecate "PPS-" datatype in favor of "MISC"
    Version 0.92c KBY 06/05/2013 string-split input of LEVEL; make VERSION scalar string
    Version 0.92a KBY 06/04/2013 introduced VERSION keyword
    Version 0.91a KBY 05/28/2013 updated to reflect namechange from 'gps' to 'ephm';
                   added file_retrieve keywords (no_download/update/clobber)
    Version 0.90a KBY 04/19/2013 updated for pending release of revised CDFs
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE keyword.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_data.pro)

## BARREL_LOAD_EPHM

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

    NAME: barrel_load_ephm
    DESCRIPTION: CDF-to-TDAS import routine for BARREL ephemeris/gps (EPHM) data products

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'EPHM').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        (not implemented)

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.93e KBY 08/28/2013 explicit support for 'support_data' (e.g., FrameGroup);
                   rename from "barrel_load_gps" to "barrel_load_ephm";
                   support for noting VALID_MIN and VALID_MAX values
    Version 0.93d KBY 08/23/2013 quality indicator ("Q") renamed "Quality";
                   take unit labels from CDF metadata; update documentation.
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.93a KBY 08/16/2013 CDF variable "GPS_Time" deprecated (removed
                   from v02 CDF files); specify default value for "unit"
    Version 0.92 KBY 06/04/2013 introduced VERSION keyword
    Version 0.91c KBY 05/31/2013 handling of ISTP fill values
    Version 0.91b KBY 05/31/2013 check for and delete existing variables of same name
    Version 0.91a KBY 05/28/2013 updated to reflect namechange from 'gps' to 'ephm';
                   added file_retrieve keywords (no_download/update/clobber)
    Version 0.90a KBY 04/22/2013 re-factoring of generic load actions; update CDF compatibility
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.82 KBY 11/27/2012 debugging with updated CDF definitions
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE
                   keyword; distinction between L1 and L2 data product handling.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_ephm.pro)

## BARREL_LOAD_FSPC

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

    NAME: barrel_load_fspc
    DESCRIPTION: CDF-to-TDAS import routine for BARREL fast-speed spectral
                   (FSPC) data products (also 'FSPEC')

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'FSPC').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        (not implemented)

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.96a KBY 06/15/2014 fixed bug in FSPC1 reconstruction routine (campaign 1 compatibility)
    Version 0.95b KBY 12/29/2013 recreation of FSPC1 channel from FSPC1a + FSPC1b + FSPC1c components
    Version 0.95a KBY 12/27/2013 preliminary support for new FSPC variables "FSPC1a", "FSPC1b", "FSPC1c"
    Version 0.94a KBY 09/13/2013 support for new FSPC variable "FSPC_Edges"
    Version 0.93e KBY 08/28/2013 support for noting VALID_MIN and VALID_MAX values;
                   rename 'LCx' variables to 'FSPCx'
    Version 0.93d KBY 08/23/2013 quality indicator ("Q") renamed "Quality";
                   take unit labels from CDF metadata; update documentation.
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.93a KBY 08/16/2013 accomodate v02 CDF namechange of "LC[1-4]_ERROR" to "cnt_error[1-4]";
                  specify default value for "units"
    Version 0.92 KBY 06/04/2013 introduced VERSION keyword
    Version 0.91c KBY 05/31/2013 handling of ISTP fill values
    Version 0.91b KBY 05/31/2013 check for and delete existing variables of same name
    Version 0.91a KBY 05/28/2013 added file_retrieve keywords (no_download/update/clobber)
    Version 0.90a KBY 04/19/2013 re-factoring of generic load actions; update CDF compatibility
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.82 KBY 11/27/2012 debugging with updated CDF definitions
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE
                   keyword; distinction between L1 and L2 data product handling.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_fspc.pro)

## BARREL_LOAD_HKPG

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

    NAME: barrel_load_hkpg
    DESCRIPTION: CDF-to-TDAS import routine for BARREL housekeeping (HKPG) data
                   (also 'HSK')

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'HKPG').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        (not implemented)

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.93e KBY 08/28/2013 explicit support for 'support_data' (e.g., FrameGroup);
                   support for noting VALID_MIN and VALID_MAX values
    Version 0.93d KBY 08/23/2013 quality indicator ("Q") renamed "Quality";
                   take unit labels from CDF metadata; update documentation.
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.93a KBY 08/16/2013 specify default value for 'unit'
    Version 0.92 KBY 06/04/2013 introduced VERSION keyword
    Version 0.91c KBY 05/31/2013 handling of ISTP fill values
    Version 0.91b KBY 05/31/2013 check for and delete existing variables of same name
    Version 0.91a KBY 05/28/2013 added file_retrieve keywords (no_download/update/clobber)
    Version 0.90c KBY 05/03/2013 corrected shift in conversion tables
    Version 0.90a KBY 04/22/2013 re-factoring of generic load actions; update CDF compatibility
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.82 KBY 11/27/2012 debugging with updated CDF definitions
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE
                   keyword; distinction between L1 and L2 data product handling.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_hkpg.pro)

## BARREL_LOAD_MAGN

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

    NAME: barrel_load_magn
    DESCRIPTION: CDF-to-TDAS import routine for BARREL magnetometer (MAGN)
                   data products (also 'MAG', 'FGM')

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'MAGN').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        (not implemented)

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.96a KBY 06/15/2014 removed dead code
    Version 0.93e KBY 08/28/2013 explicit support for 'support_data' (e.g., FrameGroup);
                   support for noting VALID_MIN and VALID_MAX values
    Version 0.93d KBY 08/23/2013 quality indicator ("Q") renamed "Quality";
                   take unit labels from CDF metadata; update documentation.
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.93a KBY 08/16/2013 accomodate v02 CDF namechange of "MAG_[X,Y,Z]" to "MAG_[X,Y,Z]_uncalibrated"
                   via variable rename (back to MAG_X/Y/Z); fix bug with handling of VERSION keyword;
                   specify default value for "unit"
    Version 0.92 KBY 06/04/2013 introduced VERSION keyword
    Version 0.91c KBY 05/31/2013 handling of ISTP fill values
    Version 0.91b KBY 05/31/2013 check for and delete existing variables of same name
    Version 0.91a KBY 05/28/2013 added file_retrieve keywords (no_download/update/clobber)
    Version 0.90a KBY 04/22/2013 re-factoring of generic load actions; update CDF compatibility
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.82 KBY 11/27/2012 debugging with updated CDF definitions
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE
                   keyword; distinction between L1 and L2 data product handling.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_magn.pro)

## BARREL_LOAD_MISC

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

    NAME: barrel_load_misc
    DESCRIPTION: CDF-to-TDAS import routine for miscellaneous BARREL data products
                   (note: formerly the "pulse-per-second" / PPS datatype)

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'MISC').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        (not implemented)

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.93e KBY 08/28/2013 explicit support for 'support_data' (e.g., FrameGroup);
                   support for noting VALID_MIN and VALID_MAX values
    Version 0.93d KBY 08/23/2013 quality indicator ("Q") renamed "Quality";
                   take unit labels from CDF metadata; update documentation.
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.93a KBY 08/16/2013 v02+ CDFs introduce renaming of "PPS-" datatype to "MISC";
                   freeze "barrel_load_pps.pro" at v0.92 for backwards compatibility with
                   v01 CDFs; specify default value for "unit"
    Version 0.92 KBY 06/04/2013 introduced VERSION keyword
    Version 0.91c KBY 05/31/2013 handling of ISTP fill values
    Version 0.91b KBY 05/31/2013 check for and delete existing variables of same name
    Version 0.91a KBY 05/28/2013 added file_retrieve keywords (no_download/update/clobber)
    Version 0.90a KBY 04/22/2013 re-factoring of generic load actions; update CDF compatibility
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.82 KBY 11/27/2012 debugging with updated CDF definitions
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE
                   keyword; distinction between L1 and L2 data product handling.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_misc.pro)

## BARREL_LOAD_MSPC

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

    NAME: barrel_load_mspc
    DESCRIPTION: CDF-to-TDAS import routine for BARREL medium-speed spectral
                   (MSPC) data products (also 'MSPEC')

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'MSPC').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        (not implemented)

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.95a KBY 12/23/2013 fixed intermittant display of colorbar bug
    Version 0.94b KBY 10/02/2013 fixed mislabeling of MSPC "cnt_error" variable
    Version 0.93e KBY 08/28/2013 support for noting VALID_MIN and VALID_MAX values
    Verison 0.93d KBY 08/25/2013 update documentation.
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.93b KBY 08/23/2013 quality indicator ("Q") renamed "Quality";
                   insert datatype identifier in "cnt_error" variable name;
                   take unit labels from CDF metadata; remove timestamp shift (see v0.90b)
    Version 0.93a KBY 08/16/2013 accomodate v02 CDF namechange of "MSPC_ERROR" to "cnt_error";
                  specify default value for "unit"
    Version 0.92f KBY 08/09/2013 CDF-specified "energy bin centers" unmodified
    Version 0.92 KBY 06/04/2013 introduced VERSION keyword
    Version 0.91c KBY 05/31/2013 handling of ISTP fill values
    Version 0.91b KBY 05/31/2013 check for and delete existing variables of same name
    Version 0.91a KBY 05/28/2013 updated MPM's 'brl_makeedges.pro" to most recent version;
                   added file_retrieve keywords (no_download/update/clobber)
    Version 0.90c KBY 05/03/2013 fixed bug in timestamp shift
    Version 0.90a KBY 04/22/2013 re-factoring of generic load actions; update CDF compatibility
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.82 KBY 11/27/2012 debugging with updated CDF definitions
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE
                   keyword; distinction between L1 and L2 data product handling.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_mspc.pro)

## BARREL_LOAD_RCNT

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

    NAME: barrel_load_rcnt
    DESCRIPTION: CDF-to-TDAS import routine for BARREL (RCNT)
                   data products

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'RCNT').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        (not implemented)

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.93e KBY 08/28/2013 explicit support for 'support_data' (e.g., FrameGroup);
                   support for noting VALID_MIN and VALID_MAX values
    Version 0.93d KBY 08/23/2013 quality indicator ("Q") renamed "Quality";
                   take unit labels from CDF metadata, update documentation.
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.93a KBY 08/16/2013 specify default value for 'unit'
    Version 0.92 KBY 06/04/2013 introduced VERSION keyword
    Version 0.91c KBY 05/31/2013 handling of ISTP fill values
    Version 0.91b KBY 05/31/2013 check for and delete existing variables of same name
    Version 0.91a KBY 05/28/2013 added file_retrieve keywords (no_download/update/clobber)
    Version 0.90a KBY 04/22/2013 re-factoring of generic load actions; update CDF compatibility
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.82 KBY 11/27/2012 debugging with updated CDF definitions
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE
                   keyword; distinction between L1 and L2 data product handling.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_rcnt.pro)

## BARREL_LOAD_SSPC

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

    NAME: barrel_load_sspc
    DESCRIPTION: CDF-to-TDAS import routine for BARREL slow-speed spectral
                   (SSPC) data products (also 'SSPEC')

    REQUIRED INPUTS:
     none

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'SSPC').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     CDF_DATA:     (not implemented)
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     MAKE_MULTI_TPLOTVAR: (not implemented)
     VARFORMAT:    String (passed through to 'cdf2tplot').
     /VALID_NAMES: (not implemented)
     FILES:        (not implemented)

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.95a KBY 12/23/2013 fixed intermittant display of colorbar bug
    Version 0.93e KBY 08/28/2013 support for noting VALID_MIN and VALID_MAX values
    Version 0.93d KBY 08/25/2013 update documentation
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.93b KBY 08/20/2013 quality indicator ("Q") renamed "Quality";
                   insert datatype identifier in "cnt_error" variable name;
                   take unit labels from CDF metadata; remove timestamp shift (see v0.90b)
    Version 0.93a KBY 08/16/2013 typo fixed at line 256; accomodate v02 CDF namechange of
                   "SSPC_ERROR" to "cnt_error"; specify default value for "unit"
    Version 0.92f KBY 08/09/2013 CDF-specified "energy bin centers" unmodified
    Version 0.92d KBY 07/04/2013 introduced support for "Peak_511" variable
    Version 0.92 KBY 06/04/2013 introduced VERSION keyword
    Version 0.91c KBY 05/31/2013 handling of ISTP fill values; fixed SSPC plot code
    Version 0.91b KBY 05/31/2013 check for and delete existing variables of same name
    Version 0.91a KBY 05/28/2013 updated MPM's 'brl_makeedges.pro" to most recent version;
                   added file_retrieve keywords (no_download/update/clobber)
    Version 0.90c KBY 05/03/2013 fixed bug in timestamp shift
    Version 0.90b KBY 04/26/2013 timestamp shift to center of accumulation period for plotting
    Version 0.90a KBY 04/22/2013 re-factoring of generic load actions; update CDF compatibility
    Version 0.83 KBY 11/28/2012 initial beta release
    Version 0.82 KBY 11/28/2012 debugging with updated CDF definitions; revision
                   of timestamp convention passed to 'file_dailynames' (conflict
                   with lowercase 'sspc' being interpreted as 2-digit 'ss' SECONDS.
    Version 0.81 KBY 11/21/2012 new CDF definitions; updated treatment of PROBE
                   keyword; distinction between L1 and L2 data product handling.
    Version 0.8 KBY 10/29/2012 from 'rbsp_load_efw_spec.pro' (Peter Schroeder),
                   and 'thm_load_goesmag.pro'

(See projects/barrel/barrel_load_sspc.pro)

## BARREL_PRELOAD_ACTIONS

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

    NAME: barrel_preload_actions

    DESCRIPTION: CDF-to-TDAS pre-import routine for BARREL data

    REQUIRED INPUTS: (see Required Keyword Arguments, below)
     **NOTE** 'barrel_preload_actions' is not intended to be a user-facing routine.
                Please use the BARREL master load routine 'barrel_load_data.pro', or
                individual load routines of form 'barrel_load_<datatype>.pro'

    REQUIRED KEYWORD ARGUMENTS:
     VDATATYPES:   String [array] of valid datatype identifiers, appropriate for desired datatype
     VLEVELS:       String [array] of valid level codes, appropriate for desired datatype

    KEYWORD ARGUMENTS (OPTIONAL):
     PROBE:        String [array] of BARREL identifiers (e.g., '1A', '1B').
                     Default is 'all' (i.e., all available payloads).  May also be
                     a single string delimited by spaces (e.g., '1A 1B').
     DATATYPE:     String [array] of BARREL datatype identifiers (e.g. 'FSPC').
     TRANGE:       Time range for tplot (2 element array).  Loads data in whole-day
                     chunks, and will prompt user if not specified.
     LEVEL:        String [array] of data level code (e.g. 'l1', 'l2').
     VERSION:      String specifying data revision number (e.g. 'v01', 'v02').
     /VERBOSE:
     /GET_SUPPORT_DATA: Load support_data variables as well as data variables.
     TPLOTNAMES:   (passed through to 'cdf2tplot' and 'cdf_info_to_tplot')
     VARFORMAT:    String (passed through to 'cdf2tplot').

     (FILE_RETRIEVE KEYWORDS-- descriptions borrowed from file_retrieve.pro)
     /DOWNLOADONLY:
                   Set to 1 to only download files but not load files into memory.
     /NO_SERVER:   Set to 1 to prevent any contact with a remote server.
     /NO_DOWNLOAD: Identical to NO_SERVER keyword. Obsolete, but retained for backward compatibility
     /NO_UPDATE:   Set to 1 to prevent contact to server if local file already exists. (this is similar to no_clobber)
     /NO_CLOBBER:  Set to 1 to prevent existing files from being overwritten. (A warning message will be displayed if remote server has)

    RETURN VALUE:
     a structure, with tags 'level' and 'tplot_variables'
     -1, if required keyword (VLEVELS or VDATATYPES) not specified

    OUTPUTS:
     none

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.96a KBY 07/04/2014 RC1; definitive campaign 2 payload list (+ fix for wildcarded looping)
    Version 0.95b KBY 12/29/2013 enable campaign 2 payloads
    Version 0.93e KBY 08/28/2013 updated documentation
    Version 0.93c KBY 08/23/2013 BARREL payload identifiers shortened to alphanumeric build
                   order only (e.g., '1A', '1B'), following change to CDF naming convention
    Version 0.92d KBY 07/04/2013 improved handling of VERSION keyword (original not overwritten)
    Version 0.92c KBY 06/05/2013 sanitize PROBE arguments; update VERSION defaults
    Version 0.92b KBY 06/04/2013 introduced VERSION keyword, with default preference for 'v01'
    Version 0.91a KBY 05/28/2013 updated to reflect namechange from 'gps' to 'ephm';
                   added file_retrieve keywords (no_download/update/clobber) and create/update
                   a local copy of !barrel to override global defaults
    Version 0.90b KBY 04/25/2013 make request DATATYPE a guaranteed scalar (like request LEVEL)
    Version 0.90a KBY 04/19/2013 re-factoring of generic pre-load and read actions
                   from datatype specific load procedures

(See projects/barrel/barrel_preload_actions.pro)

## BARREL_READ_CONFIG

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

    NAME: barrel_read_config
    DESCRIPTION: Reads the barrel_config file

    REQUIRED INPUTS:
     none (filename is hardcoded, 'barrel_config.txt', and is put in a folder
       given by the routine 'barrel_config_filedir', that uses the IDL routine
       app_user_dir to create/obtain it:
     e.g. (MacOS X)
       /Users/username/.idl/themis/barrel_config-4_darwin

    KEYWORD ARGUMENTS (OPTIONAL):
     none

    OUTPUT:
     cstruct = a structure with the changeable fields of the !BARREL
           structure

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.90a KBY 04/19/2013 no changes (note that '/' functions as univeral PATH_SEP)
    Version 0.85 KBY 12/09/2012 fixed trailing character bug (Windows only)
    Version 0.84 KBY 12/04/2012 added header
    Version 0.83 KBY 12/04/2012 initial beta release
    Version 0.80 KBY 10/29/2012 from 'goesmag/goes_read_config.pro' by JWL(?)

(See projects/barrel/barrel_read_config.pro)

## BARREL_WRITE_CONFIG

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

    NAME: barrel_write_config

    DESCRIPTION:
      Writes the barrel_config file

    REQUIRED INPUTS:
     none (filename is hardcoded, 'barrel_config.txt', and is put in a folder
       given by the routine 'barrel_config_filedir', that uses the IDL routine
       app_user_dir to create/obtain it:
     e.g. (MacOS X)
       /Users/username/.idl/themis/barrel_config-4_darwin

    KEYWORD ARGUMENTS (OPTIONAL):
     COPY:         If set, make a copy, creating a new file whose filename
           is timestamped with an appended !STIME.

    OUTPUT
     the file is written, and a copy of any old file is generated

    STATUS:

    TO BE ADDED: n/a

    EXAMPLE:

    REVISION HISTORY:
    Version 0.90a KBY 04/19/2013 no changes
    Version 0.84 KBY 12/04/2012 added header
    Version 0.83 KBY 12/04/2012 initial beta release
    Version 0.80 KBY 10/29/2012 from 'goesmag/goes_write_config.pro' by JWL(?)

(See projects/barrel/barrel_write_config.pro)

## BRL_BINVERT

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

     INPUT: start is an initial estimate of bin value(s)
            f is a temperature/detector dependent constant

     KEYWORD: none

     OUTPUT: returns an object of the same type and dimension
             as start; object contains energy value(s)

     METHOD: two iterations of Newton-Raphson to solve a
            transcendental equation. A tricky part is the
            argument for alog() can be negative, due to
            electronics offsets (say bin 5 is 0 keV). Since only
            brl_makeedges() calls, we assume some properties
            of argument start. If start is a scalar, then
            we're working on the 511keV line, so we won't have
            start <= 0. For slo, we can have several early
            start values negative. Force these to be NaN, and
            proceed with calculations, then force these to
            ascending negative values on return.

            An accurate approach is to use complex numbers and
            discard the imaginary part of the result. This gives
            correct negative energy results for bin edges, but
            doubles computational effort. It's not worth it.

     NOTES: brl_binvert() should be used only by brl_makeedges()

     REVISION HISTORY:
           14Sep2013: first version
           17Sep2013: added workaround for negative energy

(See projects/barrel/brl_binvert.pro)

## BRL_DPUCOEFFS

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

     INPUT: flightID is a two-character string to identify
            which payload through a flight inumber (e.g., '1A')

     OUTPUT: [[a1,a2],[b1,b2],[c1,c2]] is a list of 3 sets of
             linear model coefficients, used by brl_makeedges()

     METHOD: linear search; guess if unrecognized input

     REVISION HISTORY:
           16Jan2014 Added constants for payload 2I
           14Sep2013 first version

(See projects/barrel/brl_dpucoeffs.pro)

## BRL_FIND511[1]

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

           pro mygauss() and function brl_find511()

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

     evaluate gaussian + linear model for use with curvefit()

     model is f(x) = a[0]*exp(-((x-a[1])/a[2])^2) + a[3]x + a[4]

     INPUT: x is where the model is to be evaluated
            a is the current list of 5 parameter values; these
              must be initialized by the caller

     OUTPUT: f is evaluated as a linear+gaussian model
            pder is a list of 5 partial derivatives of f wrt a

     WARNING: for speed, no checks for foolish function evaluation
            requests. Caller is responsible! For instance,
            if one sets a[2]=0 or (x-a[1])/a[2]=1000 for some x,
            expect error msgs and/or nonsense output.

(See projects/barrel/brl_find511.pro)

## BRL_FIND511[2]

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

    + find the slow spectrum bin value of the 511 line

     INPUT: slo list of 256 slow spectrum count rates (counts/second)
            the slo list should not be normalized by bin widths

     OUTPUT: bin value for the 511 peak (usually not an integer)
             -1 on failure (511 peak not found)

     OPTIONS: offset=offset low bdy for 511 search region (default is 100)
              err=err 1-sigma uncertainties for each slo value;
                      this should be should be a list of
                      sqrt(# of counts)/(integration time in seconds)

     ACTION: limit the search to a reasonable part of the
             entire spectrum. Fit a line to the two endpoints
             of the search region, and subtract off the line.
             Then find the midpoint position of the list of
             values exceeding 50% of the max residual. That
             becomes a start guess for the peak location,
             modeled by a line+Gaussian. Amplitude and width are
             hard-coded typical values. Fit model to data and
             get best fit peak location. If the fit looks good,
             return its position; else return -1 to signal failure.

     HISTORY: first version working 31Dec2012/mm

     FUTURE: might need to adjust testing for valid 511 peak

     EXAMPLE: peak = brl_find511(spec, offset=95)
              peak = brl_find511(spec, err=sigmas)

(See projects/barrel/brl_find511.pro)

## BRL_MAKEBKGD

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

     INPUT: energylist is a list of energies (keV)
            alt is altitude in km (25<alt<40)
            mlat is magnetic latitude in degrees (55<|mlat|<90)

     OUTPUT: returns a list of counts/s/kev corresponding to energylist
             returns -1 for input out of range

     METHOD: based on an empirical model derived from BARREL flights
             model is ok between 30 and 8000 keV
             background is primarily two power law components
                these turn over at low energy
                the 511 line contributes several features
             prevent underflows by avoiding exp(-huge number)

     CALLS: none

     EXAMPLE: result = brl_makebkgd([10,20,50,100],33.2,63)
                calculates bkgd differential count rate at the
                4 specified energies for a detector at mag lat
                63 degrees and altitude 33.2 km.

     FUTURE WORK:

    COMMENT
     model ignores solar cycle changes of cosmic ray and associated background X-ray intensity
     the estimation for < 60keV is to some extent affected by detector temperature effect.
     REVISION HISTORY:
     works, tested mm/18 Dec 2012
     version 2, updated LZ/ May 28th, 2013 .

(See projects/barrel/brl_makebkgd.pro)

## BRL_MAKEEDGES

[Previous Routine] [List of Routines]

     INPUT: all inputs through keywords

     KEYWORD: keyword parameters
            flightID=flightID      2 char identifier (e.g., '1S')
            dpu_temp=dpu_temp      dpu temperature in C
            xtal_temp=xtal_temp    scintillator temperature in C
            peak511=peak511        sspc location for 511keV; 200
                                   nominal; 0<peak511<4095

     OUTPUT: 3 lists of bin edges are populated with energy values
            slo is a fltarr(257)
            med is a fltarr(49)
            fst is a fltarr(5)
            For these 3 lists, each pair of edges brackets one of the
              256/48/4 spectrum bins. Energy units are keV.
            Energy values below 0 are forced to 0, so it is
            possible for multiple low-end slo bins to have 0
            energy. Counts in these bins should be ignored.

     METHOD: invert an empirical model of bin(Energy). The model
            is bin(E) = k*(offset + gain*E + nonlin*E*Log(E))
            where offset, gain, and nonlin are linear functions
            of DPU temperature, and k is a quadratic function
            of crystal temperature. The dpu
            temperature-dependent linear functions use coefficients
            extracted from thermal chamber data, and are
            retrieved via a function call. Because the coupling
            between scintillator and crystal can change with air
            pressure, the peak511 parameter should be used to
            improve the model for flight data.

            default values for missing options are probably not
            sufficiently accurate

     CALLS: brl_dpucoeffs(flightID) returns temperature model
                    coefficients for associated dpu hardware.
            brl_binvert(start,f) inverts bin(energy) function;
                    needs a start value and factor f

     REVISION HISTORY:
    	works, tested mm/Oct 2012
           25Nov2012: added temperature compensation and
                      corrections for crystal nonlinearity
           14Sep2013: re-parameterized & re-built bin-energy model

(See projects/barrel/brl_makeedges.pro)