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

Last modified: Mon Aug 25 17:03:10 2025.

# Directory Listing of Routines

# general/missions/rbsp/efw

- FINDPATH[1]
- RBSP_AC_HIGHPASS_RESPONSE (FUNCTION)[1]
  Calculate the response of the one-pole 10 Hz high-pass analog filter applied
- RBSP_ADC_RESPONSE (FUNCTION)[1]
  Calculate the responses of the RBSP DFB ADC chip.
- RBSP_ANTI_ALIASING_RESPONSE (FUNCTION)[1]
  Calculate the frequency responses of the anti-aliasing filters for RBSP
- RBSP_COROTATION_EFIELD
- RBSP_COTRANS (PROCEDURE)
  A wrapper of cotrans for RBSP, with a few mission-specific features added.
- RBSP_DESPIN (PROCEDURE)
  Rotate data from a spinning frame to DSC. By default, the spinning frame is
- RBSP_DFB_RESPONSE (FUNCTION)[1]
  Calculate DFB responses at given frequencies. Two modes are suppored. If the
- RBSP_EFW_BOOM_LENGTH (FUNCTION)[1]
  Return the boom length for a give time.
- RBSP_EFW_BOOM_RESPONSE (FUNCTION)[1]
- RBSP_EFW_CAL_FBK
- RBSP_EFW_CAL_SPEC
- RBSP_EFW_CAL_WAVEFORM (PROCEDURE)
  Calibrate EFW waveform data.
- RBSP_EFW_CAL_XSPEC
- RBSP_EFW_CLEAN_ESVY (PROCEDURE)
  Clean the axial component of EFW esvy data type.
- RBSP_EFW_CLEAN_VSVY (PROCEDURE)
  Clean the axial components (V5 and V6) of EFW vsvy data type.
- RBSP_EFW_CONFIG
- RBSP_EFW_CONFIG_FILEDIR
- RBSP_EFW_CREATE_ESVY_UVW_FROM_VSVY
- RBSP_EFW_DECONVOL_INST_RESP (FUNCTION)[1]
  De-convolve instrument responses for RBSP EFW data, including search-coil
- RBSP_EFW_DSC_TO_MGSE
- RBSP_EFW_GET_CAL_PARAMS (FUNCTION)
  Return RBSP EFW calibration parameters for converting L1 data to L2 data.
- RBSP_EFW_GET_GAIN_RESULTS[1]
  return structure with freq-dependent calibration curves for the searchcoil and EDC
- RBSP_EFW_INIT
- RBSP_EFW_READ_CONFIG
  Reads the rbsp_efw_config file
- RBSP_EMFISIS_REMOVE_PERIGEE_SPIKE[1]
- RBSP_GET_EFW_DFB_CONFIG (FUNCTION)[1]
  Decode the EFW DFB Config byte
- RBSP_GSE2MGSE
- RBSP_INTERP_SPIN_PHASE (FUNCTION)
  Calculate spin phases at arbitrary times using linear interpolation.
- RBSP_LOAD_EFW_BURST_TIMES
- RBSP_LOAD_EFW_ESVY_MGSE
- RBSP_LOAD_EFW_FBK_L2
- RBSP_LOAD_EFW_FIT
- RBSP_LOAD_EFW_SPEC
- RBSP_LOAD_EFW_SPEC_L2
- RBSP_LOAD_EFW_WAVEFORM
- RBSP_LOAD_EFW_WAVEFORM_L2
- RBSP_LOAD_EFW_WAVEFORM_L3
- RBSP_LOAD_EFW_XSPEC
- RBSP_LOAD_EMFISIS_BURST_TIMES
- RBSP_LOAD_MANEUVER_FILE
- RBSP_MGSE2GSE.
  Convert vector in mGSE coord to GSE. (Also see rbsp_gse2mgse.pro)
- RBSP_MSC_RESPONSE (FUNCTION)[1]
  Calculate the transmittance of the search-coil magnetometer.
- RBSP_POYNTING_FLUX
- RBSP_READ_ECT_MAG_EPHEM[2]
- RBSP_SPINFIT (PROCEDURE)
  Derive spin-fit E-field from instantaneous E-field measurements. The
- RBSP_SPLIT_FBK
- RBSP_UVW_TO_DSC
- RBSP_UVW_TO_GSE
- RBSP_UVW_TO_MGSE
- RBSP_VECTOR_BANDPASS
- SINTERPOL

# Routine Descriptions

## FINDPATH[1]

[Next Routine] [List of Routines]

    FUNCTION: findpath.pro

    PURPOSE: Finds the path to a particular file in current IDL paths

    ARGUMENTS:
        FILENAME  -> Name of the file to find   - STRING
        PATH      <- Path to file (without "/") - STRING

    RETURNS:  Status of find
                0 - Failure
                1 - Success (exact match)
                2 - Success (after adding ".pro")

    KEYWORDS:
        EXACT    /  Find exact match only (Don't try to add '.pro')
        VERBOSE  /  Print out search pathes

    CALLING SEQUENCE: found=findpath('filename',pathname)
                      case found of
                        0 : ERROR
                        1 : fullpath=pathname+'/'+filename
                        2 : fullpath=pathname+'/'+filename+'.pro'
                      endcase
                  or
                      if not findpath('filename',path,/exact) then ERROR

    NOTES:  By default, FINDPATH searches for exact match.  If not found
            looks for 'filename' with ".pro" appended (unless /EXACT keyword
            is set).

    CREATED BY: John P. Dombeck 7/03/2001

    MODIFICATION HISTORY:

      07/03/01- J. Dombeck    Original writing
      06/25/04- J. Dombeck    Added VERBOSE keyword
                              Changed close -> free_lun

(See general/missions/rbsp/efw/findpath.pro)

## RBSP_AC_HIGHPASS_RESPONSE (FUNCTION)[1]

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

     NAME:
       rbsp_ac_highpass_response (function)

     PURPOSE:
       Calculate the response of the one-pole 10 Hz high-pass analog filter applied
       to RBSP AC channel field signals.

     CATEGORIES:

     CALLING SEQUENCE:
       resp = rbsp_ac_highpass_response(f)

     ARGUMENTS:
       f: (Input, required) A frequency array for which the response of the filter
           is calcuated. The frequency should be in units of Hz.

     KEYWORDS:
       None.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-08-08: Created by Jianbao Tao, SSL, UC Berkeley.

     Version:

     $LastChangedBy: jianbao_tao $
     $LastChangedDate: 2012-09-06 11:42:13 -0700 (Thu, 06 Sep 2012) $
     $LastChangedRevision: 10895 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_ac_highpass_response.pro $

(See general/missions/rbsp/efw/rbsp_ac_highpass_response.pro)

## RBSP_ADC_RESPONSE (FUNCTION)[1]

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

     NAME:
       rbsp_adc_response (function)

     PURPOSE:
       Calculate the responses of the RBSP DFB ADC chip.

     CATEGORIES:

     CALLING SEQUENCE:
       response = rbsp_adc_response(f, channel, delay = delay)

     ARGUMENTS:
       f: (Input, required) A floating array of frequencies at which the responses
               are calculated.
       channel: (Input, required) A string of channel names. Valid channels are:
              'V1DC',  'V2DC',  'V3DC',  'V4DC',  'V5DC',  'V6DC',
              'E12DC', 'E34DC', 'E56DC', 'E12AC', 'E34AC', 'E56AC',
              'V1AC', 'V2AC', 'V3AC', 'V4AC', 'V5AC', 'V6AC',
              'MAGU', 'MAGV', 'MAGW', 'MSCU', 'MSCV', 'MSCW'

     KEYWORDS:
       delay: (Output, optional) A variable name to hold the time delay of the
              given channel.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-08-10: Created by Jianbao Tao (JBT), SSL, UC Berkley.

     Version:

     $LastChangedBy: jianbao_tao $
     $LastChangedDate: 2012-09-06 11:42:13 -0700 (Thu, 06 Sep 2012) $
     $LastChangedRevision: 10895 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_adc_response.pro $

(See general/missions/rbsp/efw/rbsp_adc_response.pro)

## RBSP_ANTI_ALIASING_RESPONSE (FUNCTION)[1]

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

     NAME:
       rbsp_anti_aliasing_response (function)

     PURPOSE:
       Calculate the frequency responses of the anti-aliasing filters for RBSP
       field signals.

     CATEGORIES:

     CALLING SEQUENCE:
       response = rbsp_anti_aliasing_response(f)

     ARGUMENTS:
       f: (Input, required) A floating array of frequencies at which the responses
               are calculated.

     KEYWORDS:
       None.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-08-10: Created by Jianbao Tao (JBT), SSL, UC Berkley.

     Version:

     $LastChangedBy: jianbao_tao $
     $LastChangedDate: 2012-09-06 11:42:13 -0700 (Thu, 06 Sep 2012) $
     $LastChangedRevision: 10895 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_anti_aliasing_response.pro $

(See general/missions/rbsp/efw/rbsp_anti_aliasing_response.pro)

## RBSP_COROTATION_EFIELD

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

     NAME: rbsp_corotation_efield

     PURPOSE: Determine the co-rotation electric field for RBSP. Saves as tplot variable

     INPUT: probe -> 'a' or 'b'
    		 date  -> ex '2012-10-13'

     KEYWORDS: no_spice_load -> don't load SPICE kernels

     NOTES: 1) I've tested this with the hires mag data as well as lowres 4-sec data.
    		 The lowres data work just as well.
            2) uses accurate 1-min cadence spinaxis pointing direction

     HISTORY:
       2013-07-08: Adapted by Aaron Breneman from program by Scott Thaller, University of Minnesota
       2014-12-12: added data_preloaded keyword. Designed for when I call
       this from rbsp_efw_vxb_subtract_crib (and other cribs) so that
       program doesn't reload a bunch of data that's already been loaded.

     VERSION:
     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2017-06-15 11:18:24 -0700 (Thu, 15 Jun 2017) $
     $LastChangedRevision: 23480 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_corotation_efield.pro $

(See general/missions/rbsp/efw/rbsp_corotation_efield.pro)

## RBSP_COTRANS (PROCEDURE)

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

     NAME:
       rbsp_cotrans (procedure)

     PURPOSE:
       A wrapper of cotrans for RBSP, with a few mission-specific features added.

     CATEGORIES:

     CALLING SEQUENCE:
       rbsp_cotrans, from_tvar, to_tvar $
         , gse2gsm = gse2gsm $
         , gsm2gse = gsm2gse $
         , dsc2gse = dsc2gse $
         , dsc2mgse = dsc2mgse $
         , dsc2gsm = dsc2gsm $
         , gse2dsc = gse2dsc $
         , gse2mgse = gse2mgse $
         , gsm2dsc = gsm2dsc $
         , dsc2fac = dsc2fac $
         , mat_dsc = mat_dsc $
         , tmag    = tmag    $
         , vectype = vectype $
         , verbose = verbose

       NOTES:
       1. A tplot variable of magnetic field in DSC, specified with tmag keyword,
          is required to perfrom dsc2fac. The default value of tmag is something
          like 'rbspa_mag_dsc'.
       2. A tplot variable of rotation matrix from DSC to GSE, specified with the
          mat_dsc keyword, is required to perform dsc2gse, gse2dsc, dsc2gsm,
          and gsm2dsc. The rotation matrix is usually generated by
          *rbsp_load_state*. The default value of mat_dsc is something like
          'rbspa_mat_dsc'.

     ARGUMENTS:
       from_tvar: (In, required) A tplot variable to which the rotation is applied.
       to_tvar: (Out, required) A tplot name for storing the rotation results.

     KEYWORDS:
       The following keywords enable the transformations indicated by their names.
       /gse2gsm, /gsm2gse, /dsc2gse, /dsc2gsm, /gse2dsc, /gsm2dsc

       mat_dsc: (In, optional) A tplot name of the rotation matrix between DSC and
             GSE. It is usually loaded in rbsp_load_state. By default, this name is
             derived as
                     strmid(from_tvar, 0, 6) + 'mat_dsc'
       vectype: (In, optional) The type of the vectors being transformed. Valid
             types are 'E', 'B', and 'V'. By default, vectype = ''. This string is
             used for labelling the to_tvar.
       verbose: (In, optional) A number to indicate the verbose level. See dprint.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-11-03: Created by Jianbao Tao (JBT), SSL, UC Berkley.
       2012-11-05: JBT, SSL, UC Berkley.
                   Initial release to TDAS.
       2012-11-20: JBT, SSL, UC Berkley.
                   1. Added dsc-to-fac transformation.

     VERSION:
     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2019-12-19 12:45:43 -0800 (Thu, 19 Dec 2019) $
     $LastChangedRevision: 28129 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_cotrans.pro $

(See general/missions/rbsp/efw/rbsp_cotrans.pro)

## RBSP_DESPIN (PROCEDURE)

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

     NAME:
       rbsp_despin (procedure)

     PURPOSE:
       Rotate data from a spinning frame to DSC. By default, the spinning frame is
       assumed to be the UVW frame.

     CATEGORIES:

     CALLING SEQUENCE:
       rbsp_despin, sc, tvar, angle_offset = angle_offset, pertvar = pertvar, $
         newname = newname, uvw = uvw, xyz = xyz, offset_name = offset_name, $
         no_axial_processing = no_axial_processing,  $
         no_offset_remove = no_offset_remove, $
         tper = tper, tphase = tphase

     ARGUMENTS:
       sc: (In, required) Spacecraft name. Should be 'a' or 'b'.
       tvar: (In, required) Tplot variable to be despun, such as 'rbspa_mag_uvw'.

     KEYWORDS:
       angle_offset: (In, optional) Angle offset additional to spin phase. For UVW,
             angle_offset is 10 degree, which is the default.
       pertvar: (In, optional) Spin period tplot data. By default,
             pertvar = 'rbsp' + strlowcase(sc[0]) + '_spinper'.
       newname: (In, optional) New name for the despun data. By default,
             newname = tvar + '_dsc'
       /uvw: Shortcut for rotating UVW data.
       /xyz: Shortcut for rotating XYZ data. Equivalent to set angle_offset = 45.
       offset_name: A tplot name for saving offsets in spin-plane components.
       /no_axial_processing: If set, axial component is not processed. By default,
             the first spin-tone harmonic is removed in the axial component.
       /no_offset_remove: If set, offsets in spin-plane components are not removed.
       tper: (In, optional) Tplot name of spin period data. By default,
             tper = pertvar. If tper is set, pertvar = tper.
       tphase: (In, optional) Tplot name of spin phase data. By default,
             tphase = 'rbsp' + strlowcase(sc[0]) + '_spinphase'
             Note: tper and and tphase are mostly used for using eclipse-corrected
             spin data.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-11-03: Created by Jianbao Tao (JBT), SSL, UC Berkley.
       2012-11-05: Initial release to TDAS. JBT, SSL/UCB.
       2012-11-06: JBT, SSL/UCB.
             1. Added tper and tphase to use eclipse-corrected spin data.
             2. Added keyword *no_offset_remove*.

     VERSION:
     $LastChangedBy: nikos $
     $LastChangedDate: 2016-10-06 16:51:43 -0700 (Thu, 06 Oct 2016) $
     $LastChangedRevision: 22061 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_despin.pro $

(See general/missions/rbsp/efw/rbsp_despin.pro)

## RBSP_DFB_RESPONSE (FUNCTION)[1]

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

     NAME:
       rbsp_dfb_response (function)

     PURPOSE:
       Calculate DFB responses at given frequencies. Two modes are suppored. If the
       sample rate keyword, SAMPLE_RATE, is specified, it will calculate the
       response of the low-pass output from DFB. If the the filter bank level
       keyword, FBK_LEVEL, is specified, it will calculate the response of the
       corresponding filter bank level.

       Warning: If both keywords are set, FBK_LEVEL is ignored. If neither is set,
                a NaN will be returned.

       Filter bank level look-up table:
           Frequency range in Hz  |  Level
               8192 - 4096        |    1
               4096 - 2048        |    2
               2048 - 1024        |    3
               1024 -  512        |    4
                512 -  256        |    5
                256 -  128        |    6
                128 -   64        |    7
                 64 -   32        |    8
                 32 -   16        |    9
                 16 -    8        |    10
                  8 -    4        |    11
                  4 -    2        |    12
                  2 -    1        |    13

     CATEGORIES:

     CALLING SEQUENCE:
       result = rbsp_dfb_response(f, sample_rate = sample_rate, $
                            fbk_level = fbk_level)

     ARGUMENTS:
       f: (Input, required) A floating array of frequencies at which the responses
               are calculated.

     KEYWORDS:
       sample_rate: (Input, optional) See PURPOSE.
       fbk_level: (Input, optional) See PURPOSE.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-08-08: Created by Jianbao Tao (JBT), SSL, UC Berkley.

     Version:

     $LastChangedBy: jianbao_tao $
     $LastChangedDate: 2012-09-06 11:42:13 -0700 (Thu, 06 Sep 2012) $
     $LastChangedRevision: 10895 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_dfb_response.pro $

(See general/missions/rbsp/efw/rbsp_dfb_response.pro)

## RBSP_EFW_BOOM_LENGTH (FUNCTION)[1]

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

     NAME:
       rbsp_efw_boom_length (function)

     PURPOSE:
       Return the boom length for a give time.

     CATEGORIES:

     CALLING SEQUENCE:
       result = rbsp_efw_boom_length(sc, time)

     ARGUMENTS:
       sc: (In, required) Spacecraft name. Should be 'a' or 'b'.
       time: (In, required) A value of time.

     KEYWORDS:

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-10-08: Created by Jianbao Tao (JBT), SSL, UC Berkley.
       2012-11-05: Initial release to TDAS. JBT, SSL/UCB.
       2013-06-20: JBT. Accounted for AXB trimming.

     VERSION:
     $LastChangedBy: jianbao_tao $
     $LastChangedDate: 2013-06-20 14:01:20 -0700 (Thu, 20 Jun 2013) $
     $LastChangedRevision: 12561 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_boom_length.pro $

(See general/missions/rbsp/efw/rbsp_efw_boom_length.pro)

## RBSP_EFW_BOOM_RESPONSE (FUNCTION)[1]

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

     NAME:
       rbsp_efw_boom_response (function)

     PURPOSE:

     CATEGORIES:

     CALLING SEQUENCE:
       resp = rbsp_efw_boom_response(f, boom_type, rsheath = rsheath, $
       H_before = H_before, H_after = H_after)

     ARGUMENTS:

     KEYWORDS:

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-08-12: Created by Jianbao Tao (JBT), SSL, UC Berkley.

     VERSION:
     $LastChangedBy: jianbao_tao $
     $LastChangedDate: 2012-08-14 18:00:24 -0700 (Tue, 14 Aug 2012) $
     $LastChangedRevision: 10823 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_boom_response.pro $

(See general/missions/rbsp/efw/rbsp_efw_boom_response.pro)

## RBSP_EFW_CAL_FBK

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

     NAME: rbsp_efw_cal_fbk

     PURPOSE: Calibrate RBSP filterbank data

     NOTES: -This is meant to be called from rbsp_load_efw_fbk.pro
    		 -No check at this point to see if the channel changes over day. Now I'm using
    		  the channels at the start of day.
    		 -Boom lengths currently set to     100.02000       100.02000       10.000000
    		 -add in boom shorting factor

     SEE ALSO:

     HISTORY:
       2012-xx-xx: Created by Aaron W Breneman, University of Minnesota
    	2013-04-xx: added support for FBK 7
    	2013-04-18: Added freq-dependent gain correction. At this point the gain curves
    				are "hard-wired" into the code. In the future they will be accessed
    				from the Berkeley RBSP website.
    	2013-05-15: freq-dependent gain curves now obtained from rbsp_get_efw_gain_results.pro and
    				are no longer "hard-wired" into this code. Also added the full
    				freq-dependent correction as well as the mu-metal square can (nT/v)
    				curves to correct the SCM data.
    	2013-09-20: Switched the channels for FBK7. Previously they were flipped.
    	2013-10-02: Re-switched the channels for FBK7. The L1 files have been corrected and
    				all works as it should.

     VERSION:
    $LastChangedBy: aaronbreneman $
    $LastChangedDate: 2020-01-03 14:13:58 -0800 (Fri, 03 Jan 2020) $
    $LastChangedRevision: 28162 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_cal_fbk.pro $

(See general/missions/rbsp/efw/rbsp_efw_cal_fbk.pro)

## RBSP_EFW_CAL_SPEC

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

     NAME: rbsp_efw_cal_spec

     PURPOSE: Calibrate RBSP spectral data

     NOTES: Intended to be called from rbsp_load_efw_spec.pro

     TO DO:
    		-No accounting for possible midday source change
    		-not using boom shorting factor

    		There are 7 returned spec channels. The possibilities are
    			Select 7 of: E12dc,E34dc,E56dc
    						 E12ac,E34ac,E56ac
    						 Edcpar,Edcprp
    						 Eacpar,Eacprp
    						 V1ac,V2ac,V3ac,V4ac,V5ac,V6ac
    						 SCMU,SCMV,SCMW
    						 SCMpar,SCMprp,
    						 (V1dc+V2dc+V3dc+V4dc)/4,
    						 Edcprp2, Eacprp2, SCMprp2

     Calibration procedure

    	subtract offset
    		vals = (double(vals) - offset[j])
       Compensate for 4 bit dynamic range compression
           vals /= 16.
    	Divide the 0th bin by 4 (from weirdness doc)
    		vals[*,0] /= 4.
    	Compensate for using Hanning window
    		vals /= 0.375^2
    	Apply ADC conversion
    		vals *= adc_factor^2
    	Apply channel gain
    		vals *= gain[j]^2   (V^2/Hz at this point)
    	Apply boom length to change from V^2/Hz to mV/m^2/Hz
    		vals *=  conversion[j]^2   ;mV/m ^2 /Hz

    	Apply freq dependent gain

     HISTORY:
       2012-09-xx: Created by Aaron W Breneman, University of Minnesota
    	2013-04-xx: added automated channel selection
    	2013-04-23: added freq-dependent gain
    	2013-05-15: freq-dependent gain curves now obtained from rbsp_efw_get_gain_results.pro and
    				are no longer "hard-wired" into this code. Also added the full
    				freq-dependent correction as well as the mu-metal square can (nT/v)
    				curves to correct the SCM data.

     VERSION:
     $LastChangedBy:  $
     $LastChangedDate:  $
     $LastChangedRevision:  $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/trunk/missions/rbsp/efw/rbsp_efw_cal_fbk.pro $

(See general/missions/rbsp/efw/rbsp_efw_cal_spec.pro)

## RBSP_EFW_CAL_WAVEFORM (PROCEDURE)

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

     NAME:
       rbsp_efw_cal_waveform (procedure)

     PURPOSE:
       Calibrate EFW waveform data.

     CATEGORIES:

     CALLING SEQUENCE:
       rbsp_efw_cal_waveform, probe = probe, datatype = datatype, $
         trange = trange, get_support_data = get_support_data, $
         coord = coord, no_adc = no_adc, $
         tper = tper, tphase = tphase

     ARGUMENTS:

     KEYWORDS:
       probe: (In, optional) RBSP spacecraft names, either 'a', or 'b', or
             ['a', 'b']. The default is ['a', 'b']
       datatype: (In, optional) A string scalar of data types that acceptable to
             *rbsp_load_efw_waveform*.
       trange: (In, optional) Time range for performing the calibration. By
             default, trange = timerange()
       /get_support_data: If set, offsets in spin-plane components are stored in a
             tplot variable with format '*_uvw_offset'.
       coord: (In, optional) If set to 'uvw', despinning will not be performed.
       /no_adc: If set, ADC-to-physical units is ignored.
       tper: (In, optional) Tplot name of spin period data. By default,
             tper = pertvar. If tper is set, pertvar = tper.
       tphase: (In, optional) Tplot name of spin phase data. By default,
             tphase = 'rbsp' + strlowcase(sc[0]) + '_spinphase'
             Note: tper and and tphase are mostly used for using eclipse-corrected
             spin data.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-08-07: Created by Jianbao Tao (JBT), SSL, UC Berkley.
       2012-11-06: JBT, SSL/UCB.
             1. Added despinning capability.
       2012-11-12: JBT, SSL/UCB.
             1. Added esvy and vsvy cleaning.
       2013-06-21: JBT, SSL/UCB.
             1. Added instrument response deconvolution for eb1.

     VERSION:
     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2019-01-29 10:01:48 -0800 (Tue, 29 Jan 2019) $
     $LastChangedRevision: 26513 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_cal_waveform.pro $

(See general/missions/rbsp/efw/rbsp_efw_cal_waveform.pro)

## RBSP_EFW_CAL_XSPEC

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

     NAME: rbsp_efw_cal_xspec

     PURPOSE: Calibrate RBSP cross-spectral data

     NOTES: meant to be called from rbsp_load_efw_xspec.pro

    	The default is that xspec0 is SCMw x E12AC
    	and xspec1 is V1AC x V2AC
    	xspec3 is not used at this time

    	A note on the various channels.

    		From the LASP DFB document Fig 4, the spectral FFT of each channel (ex SCMw and E12AC)
    		is sent directly into the Xspec processor. The "top" channel in this figure
    		shows the calculation of the real and imaginary parts.
    			FFT(SCMw) and FFT(E12AC) --> Xspec calc (eg SCMw x E12AC) --> bin averaging --> xspec compression
    		The power is calculated via the "bottom" channel
    			FFT(SCMw) --> FFT(SCMw)*FFT(SCMw)* --> bin averaging --> spec compression
    		These values are "src1" and "src2"

    	src1 and src2 refer to the individual sources that comprise the xspec. These
    	are power spectral densities

    	Data calibration (ex, starting with src1, described above)
    		subtract offset
    			src1_2 = (double(src1.y) - offset_chn1)
    		Compensate for dynamic range compression
    			src1_2 /= 16   (/8 for the real and imaginary parts)
    		Divide the 0th bin by 4 (from weirdness doc)
    			src1_2[*,0] /= 4.
    		Compensate for using Hanning window
    			src1_2 /= 0.375^2
    		Apply ADC conversion
    			src1_2 *= adc_factor^2
    		Apply channel gain
    			src1_2 *= gain[0]^2
    		Resulting data in V^2/Hz

    	The coherence values are calculated as in Eqn 3.91 in "Engineering Applications of
    	Correlation and Spectral Analysis" by Bendat and Piersol (vol 1 apparently)

    	Coherence(f) = |Gxy(f)|^2 / Gxx(f)*Gyy(f)
    		where
    			|Gxy(f)|^2 = (Real^2 + Imaginary^2)
    			Gxx(f) = src1_2
    			Gyy(f) = src2_2

     SEE ALSO:

     HISTORY:
       Sept 2012: Created by Aaron W Breneman, University of Minnesota

     VERSION:
     $LastChangedBy:  $
     $LastChangedDate:  $
     $LastChangedRevision:  $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/trunk/missions/rbsp/efw/rbsp_efw_cal_fbk.pro $

(See general/missions/rbsp/efw/rbsp_efw_cal_xspec.pro)

## RBSP_EFW_CLEAN_ESVY (PROCEDURE)

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

     NAME:
       rbsp_efw_clean_esvy (procedure)

     PURPOSE:
       Clean the axial component of EFW esvy data type.

     CATEGORIES:

     CALLING SEQUENCE:
       rbsp_efw_clean_esvy, tvar, newname = newname, $
         notch = notch, phase_tolerance = phase_tol, $
         ind_spike = ind_spike, threshold = thres, $
         sc = sc, tper = tper, tphase = tphase

     ARGUMENTS:
       tvar: (In, required) Tplot name of esvy data.

     KEYWORDS:
       newname: (In, optional) Tplot name for cleaned data. Default is something
             like 'rbspa_esvy_clean'.
       notch: (In, optional) Number of data points to be notched. Default = 43.
       phase_tolerance: (In, optional) Spin phase tolerance for locating spikes in
             the axial component. Default = 5 (degree)
       ind_spike: (Out, optional) A named variable to return the found spikes to.
       threhold: (In, optional) Threshold for finding extrema when locating spikes.
             Default = 1.
       sc: (In, optional) Spacecraft name. Default = strmid(tvar, 4, 1)
       tper: (In, optional) Tplot name of spin period data. Default is something
             like 'rbspa_spinper'.
       tphase: (In, optional) Tplot name of spin phase data. Default is something
             like 'rbspa_spinphase'.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-10-12: Created by Jianbao Tao (JBT), SSL, UC Berkley.
       2012-11-12: Initial release in TDAS. JBT, SSL/UCB.

     VERSION:
     $LastChangedBy: jianbao_tao $
     $LastChangedDate: 2012-11-12 14:34:49 -0800 (Mon, 12 Nov 2012) $
     $LastChangedRevision: 11226 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_clean_esvy.pro $

(See general/missions/rbsp/efw/rbsp_efw_clean_esvy.pro)

## RBSP_EFW_CLEAN_VSVY (PROCEDURE)

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

     NAME:
       rbsp_efw_clean_vsvy (procedure)

     PURPOSE:
       Clean the axial components (V5 and V6) of EFW vsvy data type.

     CATEGORIES:

     CALLING SEQUENCE:
       rbsp_efw_clean_vsvy, tvar, newname = newname, $
         notch = notch, phase_tolerance = phase_tol, $
         ind_spike = ind_spike, threshold = thres, $
         sc = sc, tper = tper, tphase = tphase

     ARGUMENTS:
       tvar: (In, required) Tplot name of esvy data.

     KEYWORDS:
       newname: (In, optional) Tplot name for cleaned data. Default is something
             like 'rbspa_esvy_clean'.
       notch: (In, optional) Number of data points to be notched. Default = 21.
       phase_tolerance: (In, optional) Spin phase tolerance for locating spikes in
             the axial component. Default = 5 (degree)
       ind_spike: (Out, optional) A named variable to return the found spikes to.
       threhold: (In, optional) Threshold for finding extrema when locating spikes.
             Default = 0.1.
       sc: (In, optional) Spacecraft name. Default = strmid(tvar, 4, 1)
       tper: (In, optional) Tplot name of spin period data. Default is something
             like 'rbspa_spinper'.
       tphase: (In, optional) Tplot name of spin phase data. Default is something
             like 'rbspa_spinphase'.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-11-11: Created by Jianbao Tao (JBT), SSL, UC Berkley.
       2012-11-12: Initial release in TDAS. JBT, SSL/UCB.

     VERSION:
     $LastChangedBy: jianbao_tao $
     $LastChangedDate: 2012-11-12 14:34:49 -0800 (Mon, 12 Nov 2012) $
     $LastChangedRevision: 11226 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_clean_vsvy.pro $

(See general/missions/rbsp/efw/rbsp_efw_clean_vsvy.pro)

## RBSP_EFW_CONFIG

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

      PRO rbsp_efw_config

      This procedure serves as the RBSP EFW 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 "RBSP_EFW_INIT" procedure.

      This should be the only RBSP EFW 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: do not set colors if already taken care of

      Author:  Peter Schroeder Jul 2011

     $LastChangedBy: peters $
     $LastChangedDate: 2012-02-09 14:17:52 -0800 (Thu, 09 Feb 2012) $
     $LastChangedRevision: 9704 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_config.pro $

(See general/missions/rbsp/efw/rbsp_efw_config.pro)

## RBSP_EFW_CONFIG_FILEDIR

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

    Function: rbsp_efw_config_filedir.pro
    Purpose: Get the applications user directory for RBSP EFW data analysis software

    $LastChangedBy: peters $
    $LastChangedDate: 2011-12-28 10:26:47 -0800 (Wed, 28 Dec 2011) $
    $LastChangedRevision: 9477 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_config_filedir.pro $

(See general/missions/rbsp/efw/rbsp_efw_config_filedir.pro)

## RBSP_EFW_CREATE_ESVY_UVW_FROM_VSVY

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

     NAME: rbsp_efw_create_esvy_uvw_from_vsvy.pro
           (see rbsp_efw_create_esvy_uvw_from_vsvy_testing.pro to compare to known
            good data)
     SYNTAX:
     PURPOSE: Create the UVW Ew waveform data from the single-ended measurements.
              Returns tplot variable rbspx_efw_esvy.
              This routine is similar to rbsp_load_efw_waveform.pro called with
              the 'esvy' keyword. That routine will just load Esvy straight from
              the L1 files. However, the output is based on V12 and V34, which is
              not useful if one of the antennas is bad. This routine allows you
              to construct Esvy UVW from any combination of antenna pairs.
     INPUT:    date -> 'yyyy-mm-dd'
               probe -> 'a' or 'b'
               bad_probe -> (integer) probe to avoid (1,2,3, or 4)
     KEYWORDS:
               pairs -> can directly input antenna pairs to be used instead of
                        just indicating the bad_antennas
               rerun -> don't reload spice kernels or other stuff
               method -> 1 = (default) Calculate Ew directly using linear combination of diagonal antenna pairs.
                             Project the result onto the usual u or v axis. For
                             ex, if V1 is bad we can calculate V12 from V23 and V24
               method -> 2 = Calculate Ew using average of good boom pair. Ex, if V1
                             is bad then E12 = 2*(V3+V4)/2 - V2

               method -> 3 = (NOT WORKING YET) mimic the bad antenna by time-shifting data from adjacent
                             antenna by 1/4 spinperiod. For ex, if V4 is bad we can
                             substitute V4 data with time-shifted V1 data. This method
                             can be useful if two probe potentials are misbehaving. Ex.
                             2015-03-17 at 20:00. Only V2 and V4 are good.
                      Comparison of method 1 and 2
                      method 1 -> disadvantage: shorter baseline for calculating Ew
                                  (length*cos(45)
                                  advantage: No time-shift involved. Higher resolution
                                  for final data product
                      method 2 -> disadvantage: larger time-shift (1/4 sp as opposed to 1/8)
                                  advantage: longer antenna baselines. Always 100 m.

     OUTPUT: tplot variable rb_efw_esvy, which is the Efield in UVW coord.
             This can then be despun using rbsp_uvw_to_mgse.pro or spinfit
             with rbsp_spinfit.

     EXAMPLES: Call for two bad antennas.
            rbsp_efw_create_esvy_uvw_from_vsvy,'a',bad_antennas=[1,2],method=1
            For this example V34 will be time-shifted by 1/4 spinperiod to mimic V12

            Call for one bad antenna
            rbsp_efw_create_esvy_uvw_from_vsvy,'a',bad_antennas=1,method=1

            explicitly define antenna pairs to be used (assume V4 is bad)
            rbsp_efw_create_esvy_uvw_from_vsvy,'a',pairs=['12','31'],method=1
            In this case V1 will be time-shifted by 1/4 spinperiod to mimic V4.

     HISTORY: Written by Aaron W Breneman, June 2016
     VERSION:

(See general/missions/rbsp/efw/rbsp_efw_create_esvy_uvw_from_vsvy.pro)

## RBSP_EFW_DECONVOL_INST_RESP (FUNCTION)[1]

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

     NAME:
       rbsp_efw_deconvol_inst_resp (function)

     PURPOSE:
       De-convolve instrument responses for RBSP EFW data, including search-coil
       data that are channeled into EFW. It will return a tplot data structure.

     CATEGORIES:

     CALLING SEQUENCE:
       result = rbsp_efw_deconvol_inst_resp(data, probe, datatype)

     ARGUMENTS:
       data: (Input, required) A tplot data structure, i.e., a structure with the
             form {x:time_array, y:[nt, 3]}.

       probe: (Input, required) RBSP probe name. It should be 'a' or 'b'.

       datatype: (Input, required) Data type name. Valid names are:
             'eb2', 'mscb1', 'mscb2'.

     KEYWORDS:
       None.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-08-23: Created by Jianbao Tao (JBT), SSL, UC Berkley.
       2013-06-21: JBT.
             1. Added support to eb1.
             2. Removed hard-wired sample rate.
    	2014-06-01: AWB
    		  Checks to be sure that block length is greater than kernel length
    		  Not doing this can cause blk_con to fail for short bursts.

     Version:

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2014-09-17 14:33:45 -0700 (Wed, 17 Sep 2014) $
     $LastChangedRevision: 15817 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_deconvol_inst_resp.pro $

(See general/missions/rbsp/efw/rbsp_efw_deconvol_inst_resp.pro)

## RBSP_EFW_DSC_TO_MGSE

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

     NAME:	RBSP_EFW_DSC_TO_MGSE

     SYNTAX:
       rbsp_dsc_to_mgse,'a',tplot_var,wgse

     PURPOSE:	Rotates data from despun spacecraft coordinates (DSC) into the
    			modified GSE (MGSE) coordinate system.

    			DSC is defined:
    				Z_DSC is the spin axis direction, W_SC
    				X_DSC is the sun sensor triggering direction, perpendicular to
    					the spin axis
    				Y_DSC completes the RH system in the spin plane

    			MGSE is defined:
    				Y_MGSE=-W_SC(GSE) x Z_GSE
    				Z_MGSE=W_SC(GSE) x Y_MGSE
    				X_MGSE=Y_MGSE x Z_MGSE

     INPUT:
    	probe	- either 'a' or 'b'
    	tvar	- TPLOT variable containing 3-component DSC data (either string or
    				integer).
    	tvar_wgse    - TPLOT variable containing the spin axis pointing direction in GSE coord.
    					Get this from rbsp_load_spice_cdf_file.pro

     KEYWORDS:
    	suffix = 'string', suffix appended to the tplot variable name. Default is
    			'mgse'
    	uangle = degrees, angle between sun sensor and +U (EFW 1) boom
    	/debug - save various quantities for debugging

     NOTES:
    	0) This routine does not check that the supplied data is in DSC system.

     HISTORY:
    	1. Created July 2020 - Aaron Breneman forked from Kris Kersten's rbsp_dsc_to_mgse.pro

     VERSION:
       $LastChangedBy: aaronbreneman $
       $LastChangedDate: 2020-09-11 13:41:36 -0700 (Fri, 11 Sep 2020) $
       $LastChangedRevision: 29145 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_dsc_to_mgse.pro $

(See general/missions/rbsp/efw/rbsp_efw_dsc_to_mgse.pro)

## RBSP_EFW_GET_CAL_PARAMS (FUNCTION)

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

     NAME:
       rbsp_efw_get_cal_params (function)

     PURPOSE:
       Return RBSP EFW calibration parameters for converting L1 data to L2 data.

     CATEGORIES:

     CALLING SEQUENCE:
       cp = rbsp_efw_get_cal_params(time)

     ARGUMENTS:
       time: (Input, required) A floating time scalar for determining
             time-dependent calibration parameters.

     KEYWORDS:
       None.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-08-07: Created by Jianbao Tao (JBT), SSL, UC Berkley.

     VERSION:
     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2014-02-25 11:57:04 -0800 (Tue, 25 Feb 2014) $
     $LastChangedRevision: 14428 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_get_cal_params.pro $

(See general/missions/rbsp/efw/rbsp_efw_get_cal_params.pro)

## RBSP_EFW_GET_GAIN_RESULTS[1]

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

     NAME:
       rbsp_efw_get_gain_results

     PURPOSE:
       return structure with freq-dependent calibration curves for the searchcoil and EDC
    	channnels on EFW. Also includes notes on how to apply the calibration

     CATEGORIES:

     CALLING SEQUENCE:
       x = rbsp_efw_get_gain_results()

     ARGUMENTS:

     KEYWORDS:

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2013-05-15: Created by Aaron Breneman (UMN)

     VERSION:
     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2013-05-16 13:03:08 -0700 (Thu, 16 May 2013) $
     $LastChangedRevision: 12351 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_get_gain_results.pro $

(See general/missions/rbsp/efw/rbsp_efw_get_gain_results.pro)

## RBSP_EFW_INIT

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

    PROCEDURE:  rbsp_efw_init
    PURPOSE:    Initializes system variables for RBSP EFW.  Can be called from idl_startup to set
                custom locations.

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

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

     !RBSP_EFW.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.
                      (NOT YET IMPLEMENTED)

    KEYWORDS:
       RESET:           Reset !rbsp 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/rbsp/'               ; This master directory is read only.
       REMOTE_DATA_DIR = ''                                  ; Should be empty string. (/disks/data/rbsp and server are the same)

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

              laptop WINDOWS computer located far from a data server, but with internet connection.
       LOCAL_DATA_DIR  = 'C;\data\rbsp\'                              ; 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/rbsp/'                              ; 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 Peter Schroeder July 2011

    $LastChangedBy: peters $
    $LastChangedDate: 2014-02-06 15:28:08 -0800 (Thu, 06 Feb 2014) $
    $LastChangedRevision: 14187 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_init.pro $

(See general/missions/rbsp/efw/rbsp_efw_init.pro)

## RBSP_EFW_READ_CONFIG

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

    NAME:
     rbsp_efw_read_config
    PURPOSE:
     Reads the rbsp_efw_config file
    CALLING SEQUENCE:
     cstruct = rbsp_efw_read_config()
    INPUT:
     none, the filename is hardcoded, 'rbsp_efw_config.txt',and is s put in a
     folder given by the routine rbsp_efw_config_filedir, that uses the IDL
     routine app_user_dir to create/obtain it
    OUTPUT:
     cstruct = a structure with the changeable fields of the !rbsp_efw
               structure
    HISTORY:
     01-jul-2011, peters
    $LastChangedBy: jwl $
    $LastChangedDate: 2025-08-20 11:11:05 -0700 (Wed, 20 Aug 2025) $
    $LastChangedRevision: 33563 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_efw_read_config.pro $

(See general/missions/rbsp/efw/rbsp_efw_read_config.pro)

## RBSP_EMFISIS_REMOVE_PERIGEE_SPIKE[1]

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

     Remove spikes around perigee due to mode switch.

(See general/missions/rbsp/efw/rbsp_emfisis_remove_perigee_spike.pro)

## RBSP_GET_EFW_DFB_CONFIG (FUNCTION)[1]

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

     NAME:
       rbsp_get_efw_dfb_config (function)

     PURPOSE:
       Decode the EFW DFB Config byte

     CALLING SEQUENCE:
       result = rbsp_get_efw_dfb_config(config_byte)

     ARGUMENTS:
       config_byte: (Input, required) Integer or array of integers containing the DFB config byte

     KEYWORDS:

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2013-04-03: Created by Peter Schroeder (PCS), SSL, UC Berkley.

     Version:

     $LastChangedBy: peters $
     $LastChangedDate: 2013-04-08 10:45:51 -0700 (Mon, 08 Apr 2013) $
     $LastChangedRevision: 11983 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_get_efw_dfb_config.pro $

(See general/missions/rbsp/efw/rbsp_get_efw_dfb_config.pro)

## RBSP_GSE2MGSE

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

    Procedure: rbsp_gse2mgse

    Purpose:  Transforms from GSE to MGSE (modified GSE coord..defined below)

    	If W gse is the spin axis unit vector in GSE coordinates, then
    	(1) Ymgse = -(Wgse x Zgse)

    	So Ymgse is now in the spin plane and in the ecliptic plane and duskward. (nearly same as Ygse)
    	(2) Zmgse =  (Wgse x Ymgse)

    	So Z mgse points in the spin plane nearly along the positive normal to the ecliptic
    	(3) Xmgse= Ymgse x Zmgse

    	This actually the spin axis of the spacecraft X mgse= W gse

    	One of the properties of this coordinate system is that if the spin axis points
    	towards the sun, then the MGSE system is exactly the same as the GSE system.
    	This is a real advantage when thinking about the data and comparing to other instruments.

    	Second, since on RBSP the spin axis has a large angle relative to the z GSE axis the
    	cross product in equation 1 is well defined. None of the cross products involve nearly
    	parallel vectors- nothing is ever close to degenerate.

    Input : tname = the tplot variable with data in GSE coord [n,3]
    		 wgse = the w-antenna direction in GSE coord. This can either be a [3] element
    		   	    array or an [n,3] element array.
    		 Here's how to get wgse:
        1) rbsp_efw_position_velocity_crib.pro
    		 2) rbsp_load_state,probe='a',datatype=['spinper','spinphase','mat_dsc','Lvec']
    		 Whichever way you choose, you'll get the direction from:
    	   get_data,rbspx+'_spinaxis_direction_gse',data=wsc_GSE
    	   wgse = wsc_gse.y

    		 newname = name for output tplot variable. If not set then new name is
    					old name + '_mgse'

    Example:
    	rbsp_gse2mgse,'mag_gse',[1,0,0],/nochange

    Written by Aaron Breneman, Oct 31, 2012
    	2013-10-02 -> added a check to make sure the WGSE array is the correct size.
    				  Returns if it isn't.
     	2022-08-07 -> just use rbsp_mgse2gse with inverse.

(See general/missions/rbsp/efw/rbsp_gse2mgse.pro)

## RBSP_INTERP_SPIN_PHASE (FUNCTION)

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

     NAME:
       rbsp_interp_spin_phase (function)

     PURPOSE:
       Calculate spin phases at arbitrary times using linear interpolation.

     CATEGORIES:

     CALLING SEQUENCE:
       phase = rbsp_interp_spin_phase(sc, time_array, $
         newname = newname $
         , tper = tper $
         , tphase = tphase $
         , tumbra_sta = tumbra_sta $
         , tumbra_end = tumbra_end $
         , umbra_pad = umbra_pad)

     ARGUMENTS:
       sc: (In, required) Spacecraft name. Should be 'a' or 'b'.
       time_array: (In, required) A time array at which spin phases are returned.

     KEYWORDS:
       newname: (In, optional) A tplot name for storing the returned spin phases.
           If not provided, the spin phases are not stored into a tplot name.
       tper: (In, optional) Spin-period tplot name. By default,
               tper = 'rbsp' + strlowcase(sc[0]) + '_spinper'
       tphase: (In, optional) Spin-phase tplot name. By default,
               tphase = 'rbsp' + strlowcase(sc[0]) + '_spinphase'
       tumbra_sta: (In, optional) Umbra starting time tplot name. By default,
               tumbra_sta = 'rbsp' + strlowcase(sc[0]) + '_umbta_sta'
       tumbra_end: (In, optional) Umbra ending time tplot name. By default,
               tumbra_sta = 'rbsp' + strlowcase(sc[0]) + '_umbta_end'
       umbra_pad: (In, optional) Time padding to the umbra times. By default,
               umbra_pad = [-20d, 20d] * 60d
             This padding is to account for spin-period distrotion around umbra.
             APL has learned this problem, so this default padding will likely
             change in the future.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-10-24: Created by Jianbao Tao (JBT), SSL, UC Berkley.
       2012-11-05: Initial release to TDAS. JBT, SSL/UCB.

     VERSION:
     $LastChangedBy: nikos $
     $LastChangedDate: 2016-10-06 16:51:43 -0700 (Thu, 06 Oct 2016) $
     $LastChangedRevision: 22061 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_interp_spin_phase.pro $

(See general/missions/rbsp/efw/rbsp_interp_spin_phase.pro)

## RBSP_LOAD_EFW_BURST_TIMES

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

     NAME: RBSP_LOAD_EFW_BURST_TIMES

     SYNTAX:
    	rbsp_load_efw_burst_times,probe='a b'

     PURPOSE: Loads EFW B1 and B2 availability

     KEYWORDS:
    	probe = 'a', 'b', 'a b', or ['a','b']
    	trange = time range
    	local_data_dir = local data directory, for overriding default location set
    		in !rbsp_efw or root_data_dir()
    	b1_times, b2_times -> set to named variables to return [x,2] arrays of the start
    		and stop times of each burst in trange

     HISTORY:
    	11/2012 - Created - Kris Kersten, kris.kersten@gmail.com
    	22 Apr 2013 - changed remote_data_dir location
    	04 Sept 2013 - added support for EB1,2 and MSCB1,2
    	13 Jan 2014 - added b1_times, b2_times keywords (AWB)

     VERSION:
       $LastChangedBy: aaronbreneman $
       $LastChangedDate: 2020-01-13 10:26:26 -0800 (Mon, 13 Jan 2020) $
       $LastChangedRevision: 28188 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_burst_times.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_burst_times.pro)

## RBSP_LOAD_EFW_ESVY_MGSE

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

     NAME:	RBSP_LOAD_EFW_ESVY_MGSE

     SYNTAX:
       rbsp_load_efw_esvy_mgse,probe='a'
       rbsp_load_efw_esvy_mgse,probe='a',/no_spice_load

     PURPOSE:	Loads EFW ESVY data and despins using SPICE via rbsp_uvw_to_mgse.pro

    			The MGSE coordinate system is defined:
    				Y_MGSE=-W_SC(GSE) x Z_GSE
    				Z_MGSE=W_SC(GSE) x Y_MGSE
    				X_MGSE=Y_MGSE x Z_MGSE
    			where W_SC(GSE) is the spin axis direction in GSE.

    			This is equivalent to the GSE coordinate system if the spin axis
    			lies along the X_GSE direction.

     KEYWORDS:
    	probe = 'a' or 'b'  NOTE: single spacecraft only, does not accept ['a b']
    		NOTE: defaults to probe='a'
    	/no_spice_load - skip loading/unloading of SPICE kernels
    		NOTE: This assumes spice kernels have been manually loaded using:
    			rbsp_load_spice_predict ; (optional)
    			rbsp_load_spice_kernels ; (required)
    	/debug - prints debugging info
    	/qa - load the QA test file instead of standard L1 file
     bad_probe -> integer indicating a bad probe.

     NOTES:

     HISTORY:
    	1. Created Nov 2012 - Kris Kersten, kris.kersten@gmail.com

     VERSION:
       $LastChangedBy: aaronbreneman $
       $LastChangedDate: 2017-04-05 10:09:53 -0700 (Wed, 05 Apr 2017) $
       $LastChangedRevision: 23110 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_esvy_mgse.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_esvy_mgse.pro)

## RBSP_LOAD_EFW_FBK_L2

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

    Procedure: RBSP_LOAD_EFW_FBK_L2

    Purpose:  Loads RBSP EFW L2 filterbank data

    keywords:
      probe = Probe name. The default is 'all', i.e., load all available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      varformat=strin
      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
                           kw to narrow the data products.  Wildcards and glob-style patterns accepted (e.g., ef?, *_dot0).
      VARNAMES: names of variables to load from cdf: default is all.
      /DOWNLOADONLY: download file but don't read it. (NOT IMPLEMENTED YET)
      /ETU: If set, load data from the ETU.
      /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
       tper: (In, optional) Tplot name of spin period data. By default,
             tper = pertvar. If tper is set, pertvar = tper.
       tphase: (In, optional) Tplot name of spin phase data. By default,
             tphase = 'rbsp' + strlowcase(sc[0]) + '_spinphase'
             Note: tper and and tphase are mostly used for using eclipse-corrected
             spin data.
    Example:
       rbsp_load_efw_filterbank_l2,probe=['a', 'b']

     HISTORY:
       1. Written by Aaron Breneman, August, 2015

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2018-12-17 14:55:59 -0800 (Mon, 17 Dec 2018) $
     $LastChangedRevision: 26349 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_fbk_l2.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_fbk_l2.pro)

## RBSP_LOAD_EFW_FIT

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

    Procedure: RBSP_LOAD_EFW_FIT

    Purpose:  Loads RBSP EFW FIT data

    keywords:
      probe = Probe name. The default is 'all', i.e., load all available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      varformat=string
      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
      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. (NOT IMPLEMENTED YET)
      /INTEGRATION: If set, load data from integration.
      /QA: If set, load data from l1_qa testing directory.
      /MSIM: If set, load data from mission simulations.
      /ETU: If set, load data from the ETU.
      /DOWNLOADONLY: download file but don't read it. (NOT IMPLEMENTED YET)
      /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
      type:  set to 'calibrated' to automatically convert data into physical units
    Example:
       rbsp_load_efw_fit,/get_suppport_data,probe=['a', 'b']
    Notes:
     1. Written by Peter Schroeder, February 2012

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2018-12-17 14:57:49 -0800 (Mon, 17 Dec 2018) $
     $LastChangedRevision: 26350 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_fit.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_fit.pro)

## RBSP_LOAD_EFW_SPEC

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

    Procedure: RBSP_LOAD_EFW_SPEC

    Purpose:  Loads RBSP EFW SPEC data

    keywords:
      probe = Probe name. The default is 'all', i.e., load all available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      varformat=string
      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
      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. (NOT IMPLEMENTED YET)
      /DOWNLOADONLY: download file but don't read it. (NOT IMPLEMENTED YET)
      /QA: If set, load data from 11_qa testing directory.
      /INTEGRATION: If set, load data from integration.
      /MSIM: If set, load data from mission simulations.
      /ETU: If set, load data from the ETU.
      /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
      type:  set to 'calibrated' to automatically convert data into physical units
    Example:
       rbsp_load_efw_spec,/get_support_data,probe=['a', 'b']
    Notes:
     1. Written by Peter Schroeder, February 2012

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2018-12-17 14:27:59 -0800 (Mon, 17 Dec 2018) $
     $LastChangedRevision: 26344 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_spec.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_spec.pro)

## RBSP_LOAD_EFW_SPEC_L2

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

    Procedure: RBSP_LOAD_EFW_SPEC_L2

    Purpose:  Loads RBSP EFW L2 spectrogram data from EFW server

    keywords:
      probe = Probe name. The default is 'all', i.e., load all available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      varformat=strin
      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
                           kw to narrow the data products.  Wildcards and glob-style patterns accepted (e.g., ef?, *_dot0).
      VARNAMES: names of variables to load from cdf: default is all.
      /DOWNLOADONLY: download file but don't read it. (NOT IMPLEMENTED YET)
      /ETU: If set, load data from the ETU.
      /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
       tper: (In, optional) Tplot name of spin period data. By default,
             tper = pertvar. If tper is set, pertvar = tper.
       tphase: (In, optional) Tplot name of spin phase data. By default,
             tphase = 'rbsp' + strlowcase(sc[0]) + '_spinphase'
             Note: tper and and tphase are mostly used for using eclipse-corrected
             spin data.
    Example:
       rbsp_load_efw_spec_l2,probe=['a', 'b']

     HISTORY:
       1. Written by Aaron Breneman, August, 2015

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2020-07-27 13:36:11 -0700 (Mon, 27 Jul 2020) $
     $LastChangedRevision: 28942 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_spec_l2.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_spec_l2.pro)

## RBSP_LOAD_EFW_WAVEFORM

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

    Procedure: RBSP_LOAD_EFW_WAVEFORM

    Purpose:  Loads RBSP EFW Waveform data

    keywords:
      probe = Probe name. The default is 'all', i.e., load all available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      varformat=strin
      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
      DATATYPE:    Input, string.  Default setting is to calibrate all raw quantites and also produce all _0 and _dot0 quantities.  Use DATATYPE
                           kw to narrow the data products.  Wildcards and glob-style patterns accepted (e.g., ef?, *_dot0).
      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. (NOT IMPLEMENTED YET)
      /DOWNLOADONLY: download file but don't read it. (NOT IMPLEMENTED YET)
      /QA: If set, load data from l1_qa testing directory.
      /INTEGRATION: If set, load data from integration.
      /MSIM: If set, load data from mission simulations.
      /ETU: If set, load data from the ETU.
      /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
      type:  set to 'calibrated' to automatically convert data into physical units
      coord: Set to 'uvw' to return data in UVW. Otherwise the output is in DSC
              coordinate system
       tper: (In, optional) Tplot name of spin period data. By default,
             tper = pertvar. If tper is set, pertvar = tper.
       tphase: (In, optional) Tplot name of spin phase data. By default,
             tphase = 'rbsp' + strlowcase(sc[0]) + '_spinphase'
             Note: tper and and tphase are mostly used for using eclipse-corrected
             spin data.
    Example:
       rbsp_load_efw_waveform,/get_suppport_data,probe=['a', 'b']

     HISTORY:
       1. Written by Peter Schroeder, February 2012
       2012-11-06: JBT, SSL/UCB.
             1. Added keywords *coord*, *tper*, and *tphase* that are passed into
                 *rbsp_efw_cal_waveform*.

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2018-12-17 14:06:25 -0800 (Mon, 17 Dec 2018) $
     $LastChangedRevision: 26341 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_waveform.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_waveform.pro)

## RBSP_LOAD_EFW_WAVEFORM_L2

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

    Procedure: RBSP_LOAD_EFW_WAVEFORM_L2

    Purpose:  Loads RBSP EFW L2 Waveform data

    keywords:
      probe = Probe name. The default is 'all', i.e., load all available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      varformat=strin
      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
      DATATYPE:    Input, string.  Default setting is to calibrate all raw quantites and also produce all _0 and _dot0 quantities.  Use DATATYPE
                           kw to narrow the data products.  Wildcards and glob-style patterns accepted (e.g., ef?, *_dot0).
      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. (NOT IMPLEMENTED YET)
      /DOWNLOADONLY: download file but don't read it. (NOT IMPLEMENTED YET)
      /QA: If set, load data from l1_qa testing directory.
      /INTEGRATION: If set, load data from integration.
      /MSIM: If set, load data from mission simulations.
      /ETU: If set, load data from the ETU.
      /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
      type:  set to 'calibrated' to automatically convert data into physical units
      coord: Set to 'uvw' to return data in UVW. Otherwise the output is in DSC
              coordinate system
       tper: (In, optional) Tplot name of spin period data. By default,
             tper = pertvar. If tper is set, pertvar = tper.
       tphase: (In, optional) Tplot name of spin phase data. By default,
             tphase = 'rbsp' + strlowcase(sc[0]) + '_spinphase'
             Note: tper and and tphase are mostly used for using eclipse-corrected
             spin data.
    Example:
       rbsp_load_efw_waveform_l2,/get_suppport_data,probe=['a', 'b']

     HISTORY:
       1. Written by Peter Schroeder, February 2012
       2012-11-06: JBT, SSL/UCB.
             1. Added keywords *coord*, *tper*, and *tphase* that are passed into
                 *rbsp_efw_cal_waveform*.

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2018-12-17 14:16:58 -0800 (Mon, 17 Dec 2018) $
     $LastChangedRevision: 26342 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_waveform_l2.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_waveform_l2.pro)

## RBSP_LOAD_EFW_WAVEFORM_L3

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

    Procedure: RBSP_LOAD_EFW_WAVEFORM_L3

    Purpose:  Loads RBSP EFW L3 Waveform data

    keywords:
      probe = Probe name. The default is 'all', i.e., load all available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      varformat=strin
      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
                           kw to narrow the data products.  Wildcards and glob-style patterns accepted (e.g., ef?, *_dot0).
      VARNAMES: names of variables to load from cdf: default is all.
      /DOWNLOADONLY: download file but don't read it. (NOT IMPLEMENTED YET)
      /ETU: If set, load data from the ETU.
      /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
       tper: (In, optional) Tplot name of spin period data. By default,
             tper = pertvar. If tper is set, pertvar = tper.
       tphase: (In, optional) Tplot name of spin phase data. By default,
             tphase = 'rbsp' + strlowcase(sc[0]) + '_spinphase'
             Note: tper and and tphase are mostly used for using eclipse-corrected
             spin data.
    Example:
       rbsp_load_efw_waveform_l3,probe=['a', 'b']

     HISTORY:
       1. Written by Peter Schroeder, February 2012
       2012-11-06: JBT, SSL/UCB.
             1. Added keywords *coord*, *tper*, and *tphase* that are passed into
                 *rbsp_efw_cal_waveform*.

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2018-12-17 14:19:27 -0800 (Mon, 17 Dec 2018) $
     $LastChangedRevision: 26343 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_waveform_l3.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_waveform_l3.pro)

## RBSP_LOAD_EFW_XSPEC

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

    Procedure: RBSP_LOAD_EFW_XSPEC

    Purpose:  Loads RBSP EFW XSPEC data

    keywords:
      probe = Probe name. The default is 'all', i.e., load all available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      varformat=string
      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
      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. (NOT IMPLEMENTED YET)
      /DOWNLOADONLY: download file but don't read it. (NOT IMPLEMENTED YET)
      /QA: If set, load data from l1_qa testing directory.
      /INTEGRATION: If set, load data from integration.
      /MSIM: If set, load data from mission simulations.
      /ETU: If set, load data from the ETU.
      /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
      type:  set to 'calibrated' to automatically convert data into physical units
    Example:
       rbsp_load_efw_xspec,/get_suppport_data,probe=['a', 'b']
    Notes:
     1. Written by Peter Schroeder, February 2012

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2018-12-17 14:50:55 -0800 (Mon, 17 Dec 2018) $
     $LastChangedRevision: 26347 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_efw_xspec.pro $

(See general/missions/rbsp/efw/rbsp_load_efw_xspec.pro)

## RBSP_LOAD_EMFISIS_BURST_TIMES

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

     NAME: RBSP_LOAD_EMFISIS_BURST_TIMES

     SYNTAX:
    	rbsp_load_emfisis_burst_times,probe='a b'

     PURPOSE: Loads EMFISIS Burst data availability. Creates a tplot
    	variable indicating available times.

    	date = 'yyyy-mm-dd'
    	probe = 'a' or 'b'

     VERSION:
       $LastChangedBy: aaronbreneman $
       $LastChangedDate: 2018-12-06 09:25:24 -0800 (Thu, 06 Dec 2018) $
       $LastChangedRevision: 26261 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_emfisis_burst_times.pro $

(See general/missions/rbsp/efw/rbsp_load_emfisis_burst_times.pro)

## RBSP_LOAD_MANEUVER_FILE

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

     NAME: rbsp_load_maneuver_file
     SYNTAX: x = rbsp_load_maneuver_file(probe,date)
     PURPOSE: Returns a structure with start and end times of maneuvers
     from the MOC data product "maneuver_sequence" files.
     INPUT: probe = 'a' or 'b'
            date = '2012-10-13' format

     http://themis.ssl.berkeley.edu/data/rbsp/MOC_data_products

     NOTES: uses the MAXARMTIME variable to determine the extent of the
     maneuver. This may be the maximum upper limit maneuver time and not
     the actual maneuver time. Unfortunately the final maneuver log files are
     Word documents.

     HISTORY: Written by Aaron W Breneman - University of Minnesota 2014-10-26
     VERSION:
       $LastChangedBy: aaronbreneman $
       $LastChangedDate: 2019-12-19 11:19:56 -0800 (Thu, 19 Dec 2019) $
       $LastChangedRevision: 28126 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_load_maneuver_file.pro $

(See general/missions/rbsp/efw/rbsp_load_maneuver_file.pro)

## RBSP_MGSE2GSE.

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

     TYPE:
       function.

     NAME:
       rbsp_mgse2gse.

     PURPOSE:
       Convert vector in mGSE coord to GSE. (Also see rbsp_gse2mgse.pro)

     PARAMETERS:
       tname, in, type = string or int, required.
           tplot variable name or number, data must be in [n,3].

       wgse, in/out, type = [3] or [n,3], optional.
           The w-antenna direction in GSE.
           By default, we load wgse automatically. It is saved for backward compatibility.
           If set, then keywords probe and no_spice_load has no effect.
           If omitted, then use spice to get wgse.

     KEYWORDS:
       newname = newname, in, string, optional.
           name of output tplot variable. If not set, newname = oldname+'_mgse'.

       inverse = inverse, in, boolean, optional.
           If set do gse->mgse, otherwise do mgse->gse.

       probe = probe, in, string, optional.
           probe can be 'a' or 'b'. Default is 'a'.
           Used only when wgse is not set.

       no_spice_load = no_spice_load, in, boolean, optional.
           Set when spice kernel is loaded already. Set to 0, to use spice kernel.

     RETURN:
       none.

     EXAMPLE:
       rbsp_mgse2gse, 'rbspa_pos_mgse', wgse, newname = 'rbspa_pos_gse'

       rbsp_mgse2gse, 'rbspa_pos_gse', wgse, newname = 'rbspa_pos_mgse', /inverse

       rbsp_mgse2gse, 'rbspa_pos_mgse', newname = 'rbspa_pos_gse', $
           probe = 'a', /no_spice_load

       rbsp_mgse2gse, 'rbspa_pos_gse', newname = 'rbspa_pos_mgse', /inverse, $
           probe = 'a', /no_spice_load

     DEPENDENCE:
       idl_icy module, see icy_test.pro in tdas.

     NOTES:
       * wgse and x_mgse are the same, x_mgse = {sint*cosp, sint*sinp, cost}.
       * v_gse = {vx_gse, vy_gse, vz_gse},
         v_mgse = {vx_mgse, vy_mgse, vz_mgse},
         gse->mgse, M1 = | sint*cosp, sint*sinp, cost |
                         | -sinp    , cosp     , 0    |
                         |-cost*cosp,-cost*sinp, sint |
         mgse->gse, M2 = transpose(M1), v_gse = M2*v_mgse.

     HISTORY:
       Sheng Tian, UMN 2013-09-18 (created)
       Sheng Tian, 2022-07-08, load wsc_gse from spice_var.

     VERSION:
       $LastChangedBy: jimm $
       $LastChangedDate: 2024-07-10 12:50:20 -0700 (Wed, 10 Jul 2024) $
       $LastChangedRevision: 32732 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_mgse2gse.pro $

(See general/missions/rbsp/efw/rbsp_mgse2gse.pro)

## RBSP_MSC_RESPONSE (FUNCTION)[1]

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

     NAME:
       rbsp_msc_response (function)

     PURPOSE:
       Calculate the transmittance of the search-coil magnetometer.

     CATEGORIES:

     CALLING SEQUENCE:
       response = rbsp_msc_response(f, probe, component)

     ARGUMENTS:
       f: (Input, required) A floating array of frequencies at which the responses
               are calculated.

       probe: (Input, required) RBSP probe name. It should be 'a' or 'b'.

       component: (Input, required) Component name. Valid names are:
             'Bu', 'Bv', 'Bw'.

     KEYWORDS:
       None.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2012-09-04: Created by Jianbao Tao (JBT), SSL, UC Berkley.

     Version:

     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2014-02-25 12:02:41 -0800 (Tue, 25 Feb 2014) $
     $LastChangedRevision: 14431 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_msc_response.pro $

(See general/missions/rbsp/efw/rbsp_msc_response.pro)

## RBSP_POYNTING_FLUX

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

      PROCEDURE :  rbsp_poynting_flux

      PURPOSE  : calculates Poynting flux (ergs/s/cm^2). Separates into field-aligned and perp components
    			  Returns results as tplot variables. Includes
    			  values with and w/o spinaxis component

      REQUIRES:  tplot library

      KEYWORDS:
           Bw -> tplot name of the [n,3] magnetic field
                 waveform (nT) in MGSE
    			  Ew -> tplot name of the [n,3] electric field
    			        waveform (mV/m) in MGSE
    			  Tshort, Tlong -> short and long period of waveform to use.

           Bo -> (optional keyword) array of DC magnetic field directions in MGSE.
    					Use, for example, if Bw is from AC-coupled data.
             If not included then Bw is downsampled and used as background field

           method1 -> uses smoothing instead of a bandpass_filter which
                      results in a sharper freq rolloff than smoothing method.
                      Both methods give very similar results for test chorus waves
           method2 (default -- seems to work much better for higher freqs) ->
                      The waveform data are first downsampled to 1/Tshort to avoid the wasted
    			             computation of having to run program with data at unnecessarily high
    			             sample rate. The waveform is then run through
    			             bandpass_filter to the frequency range flow=1/Tlong...fhigh=1/Tshort

       NOTES:     DO NOT INPUT DATA WITH SIGNIFICANT GAPS

    ********************************************************************
                 Tested on Van Allen Probes chorus from EFW's B1
                 data on 2014-08-27 at ~07:42 on probe A. A is at +20
                 mlat and the Pflux indicates propagation away from eq
                 with magnitude values consistent with those in Li et
                 al., 2013 and Santolik et al., 2010
    ********************************************************************
    			 Poynting flux coord system
       		 	P1mgse = Bmgse x xhat_mgse  (xhat_mgse is spin axis component)
    				  P2mgse = Bmgse x P1mgse
      		   	P3mgse = Bmgse

    			 The output tplot variables are:

    			 	These three output variables contain a mix of spin axis and spin plane components:
    		 		  pflux_perp1  -> Poynting flux in perp1 direction
    			 		pflux_perp2  -> Poynting flux in perp2 direction
     			 	pflux_para   -> Poynting flux along Bo

    			 	These partial Poynting flux calculations contain only spin plane Ew.
    			 		pflux_nospinaxis_perp
    			 		pflux_nospinaxis_para

           All of the above variables projected
           to the ionosphere

       CREATED:  11/28/2012
       CREATED BY:  Aaron W. Breneman
        LAST MODIFIED:  MM/DD/YYYY   v1.0.0
        MODIFIED BY:

(See general/missions/rbsp/efw/rbsp_poynting_flux.pro)

## RBSP_READ_ECT_MAG_EPHEM[2]

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

     NAME: rbsp_read_ect_mag_ephem
     SYNTAX:
     PURPOSE: Read in RBSP ECT's official magnetic field model predicted quantities
     INPUT: sc -> 'a' or 'b'
    		 date -> '2014-01-01'
            type -> defaults to OP77Q. Can also have "TS04D" (definitive)
            or "T89Q" for predicted.
     OUTPUT: tplot variables with prefix 'rbsp'+sc+'_ME_'
    		  Will also return perigeetimes as keyword
     KEYWORDS:
     HISTORY: Written by Aaron W Breneman, UMN
     VERSION:
       $LastChangedBy: $
       $LastChangedDate: $
       $LastChangedRevision: $
       $URL: $

(See general/missions/rbsp/efw/rbsp_read_ect_mag_ephem.pro)

## RBSP_SPINFIT (PROCEDURE)

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

     NAME:
       rbsp_spinfit (procedure)

     PURPOSE:
       Derive spin-fit E-field from instantaneous E-field measurements. The
       spin-fit model is as such:
               fit = A + B * cos(phi) + C * sin(phi)
       where B and C are E-fields in the DSC X and Y dimensions, and angle is the
       angle between the DSC X direction and the EFW spin plane boom used in the
       spin-fit derivation, as demonstrated below.

           DSC Y
                |       / EFW spin plane boom
                |      /
                |     /
                |    /
                |   /
                |  /
                | /
                |/)angle________ DSC X

       NOTES: 1. Similar to thm_spinfit.pro, this routine is a wrapper of
                 spinfit.pro for RBSP. Unlike thm_spinfit, this routine only works
                 on one tplot variable at a time.
              2. Normally, this routine saves four tplot variables, such as
                      'rbspa_efw_esvy_spinfit_a'
                      'rbspa_efw_esvy_spinfit_b'
                      'rbspa_efw_esvy_spinfit_c'
                      'rbspa_efw_esvy_spinfit'
                 where the first three are the three cooefficients from the fit and
                 the last one is like a normal EFW data type in DSC.

     CATEGORIES:

     CALLING SEQUENCE:
       rbsp_spinfit ,var_name_in, $
                 sigma=sigma, npoints=npoints, spinaxis=spinaxis, median=median, $
                 plane_dim=plane_dim, axis_dim=axis_dim,  $
                 min_points=min_points,alpha=alpha,beta=beta, $
                 phase_mask_starts=phase_mask_starts, $
                 phase_mask_ends=phase_mask_ends, $
                 sc = sc, force = force, tper = tper, tphase = tphase

     ARGUMENTS:
       var_name_in: IN, REQUIRED
             EFW tplot data used for the spin-fit derivation. Must be in UVW.

     KEYWORDS:
       sc: IN, OPTIONAL
             Spacecraft name. Must be 'a' or 'b'.
       /force: IN, OPTIONAL
             If set, force to do the derivation. Useful when the input tplot data
             do not have coord_sys information.
       tper: IN, OPTIONAL
             Spin-period tplot name.
       tphase: IN, OPTIONAL
             Spin-phase tplot name.

         See spinfit.pro and thm_spinfit.pro for usage of other keywords.
         Exception:
         AXIS_DIM defaults to 2 instead of 0 in this routine.

     COMMON BLOCKS:

     EXAMPLES:

     SEE ALSO:

     HISTORY:
       2013-01-22: Created by Jianbao Tao (JBT), SSL, UC Berkley.

     VERSION:
     $LastChangedBy: aaronbreneman $
     $LastChangedDate: 2018-12-21 11:30:03 -0800 (Fri, 21 Dec 2018) $
     $LastChangedRevision: 26393 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_spinfit.pro $

(See general/missions/rbsp/efw/rbsp_spinfit.pro)

## RBSP_SPLIT_FBK

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

     NAME:	rbsp_split_fbk

     PURPOSE:	Split the filterbank data into separate tplot variables for
    			each channel. Can also combine peak and average on a single panel

     KEYWORDS:
    	probe = 'a' or 'b'  NOTE: single spacecraft only, does not accept ['a b']
    	combine -> set to combine peak and average onto a single plot
    	meansz -> number of data points over which to calculate the number of values
    			  the local mean is away from the local standard deviation. This is used
    			  to set y-scaling. If not done then the yscale of the FBK plots
    			  is often dominated by single large amplitude spikes, masking the majority
    			  of the data.  Default is 100.
    ;	meansz -> number of data points over which to calculate the mean. This is used
    ;			  to set y-scaling. If not done then the yscale of the FBK plots
    ;			  is often dominated by single large amplitude spikes, masking the majority
    ;			  of the data.  Default is 20.
    ;	ysc -> Scale factor for y-scaling. Default is 1.  This should be set to
    ;			values greater than 1 for meansz larger than the default.  For
    ;			example, ysc=3. works well for meansz=1000.

     CREATED: Aaron Breneman 11/07/2012

     MODIFIED: changed y-scaling based on a running average rather than the max value
    			for each FBK channel. This avoids having a ridiculous yscaling based on a few
    			very large amplitude spiky events.

     VERSION:
    $LastChangedBy: aaronbreneman $
    $LastChangedDate: 2014-04-21 13:19:06 -0700 (Mon, 21 Apr 2014) $
    $LastChangedRevision: 14901 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_split_fbk.pro $

(See general/missions/rbsp/efw/rbsp_split_fbk.pro)

## RBSP_UVW_TO_DSC

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

     NAME:	RBSP_UVW_TO_DSC

     SYNTAX:
       rbsp_uvw_to_dsc,'a',tplot_var
       rbsp_uvw_to_dsc,'a',tplot_var,/no_spice_load

     PURPOSE:	Rotates data from spinning spacecraft (UVW) coordinates into despun
    			spacecraft (DSC) coordinates.

    			DSC is defined:
    				Z_DSC is the spin axis direction, W_SC
    				X_DSC is the sun sensor triggering direction, perpendicular to
    					the spin axis
    				Y_DSC completes the RH system in the spin plane

     INPUT:
    	probe	- either 'a' or 'b'
    	tvar	- TPLOT variable containing 3-component UVW data (either string or
    				integer).

     KEYWORDS:
       uangle = degrees, angle between SSH and U
    	suffix = 'string', suffix appended to the tplot variable name. Default is
    			'mgse'
    	/debug - save various quantities for debugging

     NOTES:
    	0) This routine does not check that the supplied data is in UVW system.

     HISTORY:
    	1. Created Nov 2012 - Kris Kersten, kris.kersten@gmail.com

     VERSION:
       $LastChangedBy: aaronbreneman $
       $LastChangedDate: 2020-09-21 18:16:09 -0700 (Mon, 21 Sep 2020) $
       $LastChangedRevision: 29174 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_uvw_to_dsc.pro $

(See general/missions/rbsp/efw/rbsp_uvw_to_dsc.pro)

## RBSP_UVW_TO_GSE

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

     NAME:	RBSP_UVW_TO_GSE

     SYNTAX:
       rbsp_uvw_to_gse,'a','rbspa_efw_esvy'
       rbsp_uvw_to_gse,'a','rbspa_efw_esvy',/no_spice_load

     PURPOSE:	Transforms from spinning UVW (RBSP SCIENCE) frame to GSE.

     INPUT:
    	probe	- either 'a' or 'b'
    	tvar	- TPLOT variable containing 3-component UVW data
    			(either string or integer tplot variable id)

     KEYWORDS:
    	suffix=suffix - optional suffix for rotated tplot variable names
    	/no_spice_load - skip loading/unloading of SPICE kernels
    		NOTE: This assumes spice kernels have been manually loaded using:
    			rbsp_load_spice_predict ; (optional)
    			rbsp_load_spice_kernels ; (required)
    	/remove_offset - remove slowly varying offsets in spin plane
    	/debug - prints debugging info

     NOTES:

     HISTORY:
    	1. Created Jan 2013 - Kris Kersten, kris.kersten@gmail.com

     VERSION:
       $LastChangedBy: aaronbreneman $
       $LastChangedDate: 2019-08-14 14:21:17 -0700 (Wed, 14 Aug 2019) $
       $LastChangedRevision: 27604 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_uvw_to_gse.pro $

(See general/missions/rbsp/efw/rbsp_uvw_to_gse.pro)

## RBSP_UVW_TO_MGSE

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

     NAME:	RBSP_UVW_TO_MGSE

     SYNTAX:
       rbsp_uvw_to_mgse,'a','rbspa_efw_esvy'
       rbsp_uvw_to_mgse,'a','rbspa_efw_esvy',/no_spice_load

     PURPOSE:	Transforms from spinning UVW (RBSP SCIENCE) frame to MGSE.

    			The MGSE coordinate system is defined:
    				Y_MGSE=-W_SC(GSE) x Z_GSE
    				Z_MGSE=W_SC(GSE) x Y_MGSE
    				X_MGSE=Y_MGSE x Z_MGSE
    			where W_SC(GSE) is the spin axis direction in GSE.

    			This is equivalent to the GSE coordinate system if the spin axis
    			lies along the X_GSE direction.

     INPUT:
    	probe	- either 'a' or 'b'
    	tvar	- TPLOT variable containing 3-component UVW data
    			(either string or integer tplot variable id)

     OUTPUT: N/A
    	Rotated timeseries is saved in a new tplot var with _mgse suffix..

     KEYWORDS:
    	suffix=suffix - suffix for rotated tplot var name (default is _mgse)
    	/no_offset - skip offset removal in spin plane
    	/force_offset - force offset removal for slowly sampled data
    	/nointerp - use SPICE to calculate rotation matrix directly at each timestep
    				instead of default quaternion interpolation rotation matrix
    	nointerp=2 - use SPICE to calculate spin axis pointing at each timestep
    				instead of interpolating from 5m cadence pointing
    				(this may be useful during maneuvers)
    	_extra --> useful keywords are:
    						'no_spice_load'
    						'no_rbsp_efw_init'

    	/debug - prints debugging info

     NOTES:
    	By default this routine uses SPICE to generate the spin axis pointing
    	direction at a 5 minute cadence, and the despinning matrix at a 1s cadence.
    	These quantities are interpolated (spin axis linearly, and despinning matrix
    	via quaternion interpolation) to the sample times of the input time series.

    	If the input time series is sampled at <= 1S/s, the routine will calculate
    	the SPICE pointing and rotation directly at each time stamp rather than using
    	the interpolation described above.

    	The nointerp keyword is provided to bypass the interpolation and calculate the
    	spin axis pointing direction and rotation matrix at the time stamps of the input
    	time series.  Calling the routine with /nointerp or nointerp=1 will cause the
    	rotation matrix to be calculated directly.  Calling with nointerp=2 will cause
    	both the rotation matrix and the spin axis pointing direction to be calculated
    	directly.  This will be VERY time consuming for high time resolution data, but
    	may be useful for debugging or during spacecraft maneuvers.

    	SPIN PLANE OFFSETS:
    	By default, offsets in the spin plane quantities are removed.  This is only
    	valid for quantities sampled faster than the spin period (~12s).  The offset
    	removal is automatically skipped for quantities sampled at or below 1S/s.  This
    	can be overridden by using the /force_offset keyword.

     HISTORY:
    	1. Created Nov 2012 - Kris Kersten, kris.kersten@gmail.com

     VERSION:
       $LastChangedBy: aaronbreneman $
       $LastChangedDate: 2020-09-21 18:15:56 -0700 (Mon, 21 Sep 2020) $
       $LastChangedRevision: 29173 $
       $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/missions/rbsp/efw/rbsp_uvw_to_mgse.pro $

(See general/missions/rbsp/efw/rbsp_uvw_to_mgse.pro)

## RBSP_VECTOR_BANDPASS

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

    *****************************************************************************************

      FUNCTION :   vector_bandpass.pro
      PURPOSE  :   This program does a bandpass filter on the input data using IDL's
                     built-in FFT.PRO routine.  The data is first padded with zeroes
                     to ensure the number of elements remains an integer power of 2.
                     The user defines the input vector array of data, the sample rate,
                     and frequency range(s) before running the program, then tells the
                     program whether a low-pass (i.e. only return low frequency
                     signals), high-pass, or middle frequency bandpass filter.  The
                     program eliminates the postitive AND negative frequency bins in
                     frequency space to ensure symmetry before performing the inverse
                     FFT on the data.

      CALLED BY:   NA

      CALLS:
                   power_of_2.pro

      REQUIRES:    NA

      INPUT:
                   DAT    :  [N,3]-Array of magnetic or electric field data
                   SR     :  Scalar defining the sample rate (mHz, Hz, kHz, etc. doesn't
                               matter as long as everything is consistent)
                   LF     :  Scalar defining the low frequency cutoff (Default = 0)
                              [Note:  MUST be same units as SR]
                   HF     :  Scalar defining the high frequency cutoff (Default = Nyquist)
                              [Note:  MUST have same units as SR AND LF]

      EXAMPLES:
                     htr_mfi2tplot,DATE=date
                     get_data,'WIND_B3_HTR(GSE,nT)',DATA=mag
                     magf  = mag.Y
                     tt    = mag.X                        ; -Unix time (s since 01/01/1970)
                     nt    = N_ELEMENTS(tx)
                     evl   = MAX(tt,/NAN) - MIN(tt,/NAN)  ; -Event length (s)
                     nsps  = ((nt - 1L)/evl)              ; -Approx Sample Rate (Hz)
                     lfmf1 = vector_bandpass(magf,nsps,15d-2,15d-1,/LOWF)

      KEYWORDS:
                   LOWF   :  If set, program returns low-pass filtered data with freqs
                               below LF
                   MIDF   :  If set, program returns bandpass filtered data with freqs
                               between LF and HF  **[Default]**
                   HIGHF  :  If set, program returns high-pass filtered data with freqs
                               above HF

       CHANGED:  1)  Fixed Low Freq. bandpass to get rid of artificial
                       zero frequency bin created by FFT calc.  [01/14/2009   v1.0.1]
                 2)  Fixed case where NaN's are in data         [01/18/2009   v1.0.2]
                 3)  Changed program my_power_of_2.pro to power_of_2.pro
                       and renamed                              [08/10/2009   v2.0.0]

       CREATED:  12/30/2009
       CREATED BY:  Lynn B. Wilson III
        LAST MODIFIED:  08/10/2009   v2.0.0
        MODIFIED BY: Lynn B. Wilson III

    *****************************************************************************************

(See general/missions/rbsp/efw/rbsp_vector_bandpass.pro)

## SINTERPOL

[Previous Routine] [List of Routines]

     Type: function.
     Purpose: Interpolate given data of at abscissa x to new x.
     Parameters:
       data, in, [*], req. For scalar array, dimension is [n0].
         For m dimension vector array, dimension is [m, n0] or [n0, m].
       oldabs, in, [n0], req. Old abscissa.
       newabs, in, [n1], req. New abscissa.
     Keywords:
       _extra = extra, in, struct, opt. Keywords for interpol, see idl help.
         /LSQuadratic, /NaN, /Quatradic, /Spline.
     Return: [*]. If data is array of [n0], then return [n1];
         if data is array of [m, n0], then return, [m, n1].
         if data is array of [n0, m], then return, [n1, m].
     Notes: Do not work if given data has more than 2 dimensions. Do NOT set /NaN
       automatically for interpol().
     History:
       2011-07-20, Sheng Tian, create.
       2011-08-16, Sheng Tian, add throw exterpolate.
       2012-09-17, Sheng Tian, auto deal with dims.

(See general/missions/rbsp/efw/sinterpol.pro)