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

Last modified: Sat Jul 26 18:17:38 2025.

# Directory Listing of Routines

# projects/maven/sta/mvn_sta_functions

- C_4D
  Returns the counts in the data structure
- CB_4D
  Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
- CONTOUR4D
  Produces contour plots of energy-mass distributions from 4D data structures.
- DJ_4D
  Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
- DN_4D
  Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
- DV_4D
  Returns the velocity, [Vx,Vy,Vz], km/s for each mass bin
- EC_4D
  Returns the analyzer characteristic energy, Ec in eV, of the ions - the analyzer energy of the peak.
- GET_4DT
  To generate time series data for "tplot.pro"
- J_4D
  Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
- JE_4D
  Returns the energy flux, Je in eV/cm^2-s, corrects for spacecraft potential if dat.sc_pot exists
- M_4D
  Returns the components of the momentum tensor, corrects for spacecraft potential if dat.sc_pot exists
- MVN_STA_C6_BKG
  Returns the background for maven static apid c6 structures
- MVN_STA_GET
  Returns static data structure for keyword selected APID averaged over a time range
- MVN_STA_GET_2A
  Returns APID 2a data structure at a single time from common generated by mvn_sta_hkp_cal.pro
- MVN_STA_GET_C0
  Returns APID c0 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_C2
  Returns APID c2 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_C4
  Returns APID c4 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_C6
  Returns APID c6 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_C6_CO2
  Returns APID c6 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_C6E
  Returns APID c6e data structure at a single time from common generated by mvn_sta_make_c6e.pro
- MVN_STA_GET_C8
  Returns APID c8 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_CA
  Returns APID ca data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_CC
  Returns APID cc data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_CD
  Returns APID cd data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_CE
  Returns APID ce data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_CF
  Returns APID cf data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_D0
  Returns APID d0 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_D1
  Returns APID d1 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_D1E
  Returns synthetic data product d1e data structure at a single time from common generated by mvn_sta_make_d1e.pro
- MVN_STA_GET_D2
  Returns APID d2 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_D3
  Returns APID d3 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_D4
  Returns APID d4 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_D6
  Returns APID d6 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_D8
  Returns APID d8 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_D9
  Returns APID d9 data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_DA
  Returns APID da data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_DB
  Returns APID db data structure at a single time from common generated by mvn_sta_prod_cal.pro
- MVN_STA_GET_KK2
  Returns kk2 parameter for correcting ion suppression
- MVN_STA_GET_KK3
  Returns kk3 - a 4 element array for correcting ion suppression as a function of attenuator state
- MVN_STA_SET_TH_OFFSET2
  Returns parameters [efoldoffset,e0,scale1] for offset2 calculation used by th_4d.pro, th2_4d.pro and vp_4d.pro
- MVN_STA_V4D
- N_4D
  Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
- NB_4D
  Returns the density of a beam in units of km/s
- OMNI4D
- P_4D
  Returns the pressure tensor, [Pxx,Pyy,Pzz,Pxy,Pxz,Pyz], eV/cm^3
- SPEC4D
- SUM4D
- SUM4M
- T_4D
  Returns the temperature, [Tx,Ty,Tz,Tavg], eV
- TB_4D
  Returns the temperature of a beam in units of eV, assumes no s/c charging
- TH2_4D
  Returns the center theta of a low energy beam and the estimated instrumental offset
- TP_4D
  Returns the perp temperature of a beam from APID C8 in units of eV
- V_4D
  Returns the velocity, [Vx,Vy,Vz], km/s for each mass bin
- VB_4D
  Returns the velocity of a beam in units of km/s
- VB_POT_4D
  Returns the velocity of a beam in units of km/s -- needs modification for ion suppression correction accounting for anode variations
- VC_4D
  Returns the normalized velocity unit vector, [Vx,Vy,Vz]/Vmag, km/s for each mass bin
- VP_4D
  Returns the perpendicular velocity of a beam in units of km/s for apid C8
- WC_4D
  Returns the anisotropy

# Routine Descriptions

## CB_4D

[Next Routine] [List of Routines]

    FUNCTION:	cb_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
    NOTES:
    	Function normally called by "get_3dt" or "get_2dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	13-11-13
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/cb_4d.pro)

## CONTOUR4D

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

    PROCEDURE: contour4d,data
    PURPOSE:
    	Produces contour plots of energy-mass distributions from 4D data structures.
    INPUTS:
       data   - structure containing 4d data  (obtained from get_mvn_?() routine)
    		e.g. "get_mvn_c6, get_mvn_ce, etc."
    KEYWORDS:
    	LIMITS - A structure containing limits and display options.
                 see: "options", "xlim" and "ylim", to change limits
    	UNITS  - convert to given data units before plotting
    	TITLE - Title to be plotted,
    		- set title=' ' for NO Title!
    		- set title='1' for just the time in the title
    	XTITLE - xtitle to be plotted,
    		- set xtitle=' ' for NO xtitle!, default determined by VEL keyword
    	YTITLE - ytitle to be plotted,
    		- set ytitle=' ' for NO ytitle!, default=data.units_name
    	ZTITLE - ztitle to be plotted,
    		- set ztitle=' ' for NO ytitle!, default='Log!D10!N('+y_units+')'
    	RETRACE - set to number of retrace steps removed,
    		- default set to 0
    	VEL - If set, x-axis is velocity km/s  -- Default is Energy (eV)

    	NCONT - Number of contours to be plotted, default = 8
    	LEVELS - Explicit contour levels, default levels spaced down
    	         from max by 10^.5
    	FILL - If set, contours are filled with solid color or gray scale
    	BW - If set, contours are white, no affect on fill plots
    	PURE - If set, 6 pure colors are cycled through for levels
    	ROTATE - Exchanges x and y axes for non-polar plots
    	LABEL - Labels the contour levels
           XMARGIN - Change xmargin from default
    	YMARGIN - Change ymargin from default
    	POINTS - adds data points to plot

    See "conv_units" to change units.

     $LastChangedBy: dmitchell $
     $LastChangedDate: 2022-12-26 12:23:43 -0800 (Mon, 26 Dec 2022) $
     $LastChangedRevision: 31379 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/maven/sta/mvn_sta_functions/contour4d.pro $

    CREATED BY:	J. McFadden  14-02-07

(See projects/maven/sta/mvn_sta_functions/contour4d.pro)

## C_4D

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

    FUNCTION:	c_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the counts in the data structure
    NOTES:
    	Function normally called by "get_3dt" or "get_2dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	13-11-13
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/c_4d.pro)

## DJ_4D

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

    FUNCTION:	dj_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-02-26
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/dj_4d.pro)

## DN_4D

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

    FUNCTION:	dn_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=mass,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    	This routine does not work - its only a placeholder

    CREATED BY:
    	J.McFadden	13-11-13
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/dn_4d.pro)

## DV_4D

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

    FUNCTION:	dv_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    PURPOSE:
    	Returns the velocity, [Vx,Vy,Vz], km/s for each mass bin
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	14-02-26
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/dv_4d.pro)

## EC_4D

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

    FUNCTION:	ec_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the analyzer characteristic energy, Ec in eV, of the ions - the analyzer energy of the peak.
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-04-21
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/ec_4d.pro)

## GET_4DT

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

    PROGRAM:	get_4dt,funct,routine
    INPUT:
    	funct:	function,	function that operates on structures generated
    					by mvn_sta_get_??
    				funct   = 'n_4d','j_4d','v_4d','p_4d','t_4d', ...

    	routine, 	a string that defines the 'routine' that returns a 4D data structure
    				routine = mvn_sta_get_??

    KEYWORDS
    	T1:	real or dbl	start time, seconds since 1970
    	T2:	real or dbl	end time, seconds since 1970
    	ENERGY:	fltarr(2),	min,max energy range to be passed to "funct"
    	ERANGE:	fltarr(2),	min,max energy bin numbers to be passed to "funct"
    	EBINS:	bytarr(na),	energy bins array to be passed to "funct"
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2),	min,max pitch angle range to be passed to "funct"
    	ARANGE:	fltarr(2),	min,max angle bin numbers to be passed to "funct"
    	BINS:	bytarr(nb),	angle bins array to be passed to "funct"
    					0,1=exclude,include,
    					nb = dat.ntheta
    	EBINS:	bytarr(na,nb),	energy/angle bins array to be passed to "funct"
    	MASS:	fltarr(2)		min,max mass range to be passed to "funct"
    	M_INT:	0/1		keyword to integerize mass to nearest AMU, passed to "funct"
    	Q	integer		particle charge passed to "funct" to be used instead of charge returned by "routine"
    	GAP_TIME: 		time gap big enough to signify a data gap
    				(def 200 sec, 8 sec for FAST)
    	NO_DATA: 		returns 1 if no_data else returns 0
    	NAME:  			New name of the Data Quantity
    				Default: funct+'_'+routine
    	BKG:  	string		name of routine that calculates bkg_data for background subtractions: dat.data=dat.data-bkg_data
    	FLOOR:  0/1		Sets the minimum value of any data point to sqrt(bkg).
    	MISSING: 		value for bad data. 	0,1=exclude,include

    PURPOSE:
    	To generate time series data for "tplot.pro"
    NOTES:
    	Program names time series data to funct+"_"+routine if NAME keyword not set
    		See 'tplot_names.pro'.

    CREATED BY:
    	J.McFadden
    LAST MODIFICATION:  14/03/17		developed from get_2dt.pro
    LAST MODIFICATION:  20/06/04		line 96, if dat.valid eq 0 then return
    MOD HISTORY:

    NOTES:
    	Current version only works for MAVEN

(See projects/maven/sta/mvn_sta_functions/get_4dt.pro)

## JE_4D

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

    FUNCTION:	je_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the energy flux, Je in eV/cm^2-s, corrects for spacecraft potential if dat.sc_pot exists
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-02-26
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/je_4d.pro)

## J_4D

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

    FUNCTION:	j_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-02-26
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/j_4d.pro)

## MVN_STA_C6_BKG

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

    FUNCTION:	mvn_sta_c6_bkg(dat)
    INPUT:
    	dat:	structure,	generated by mvn_sta_get_c6()
    KEYWORDS

    PURPOSE:
    	Returns the background for maven static apid c6 structures
    NOTES:
    	Function to calculate the straggling backgroud from maven static apid c6 packets
    	Function can be used as "bkg" keyword passed to get_4dt.pro for background subtraction

    	This generates a decent, energy independent background subtraction if coincident events can be ignored
    		proton straggling represents about ~2% of the events when coincident events can be ignored

    CREATED BY:
    	J.McFadden	14-05-08
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/mvn_sta_c6_bkg.pro)

## MVN_STA_GET

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

    PROCEDURE:	mvn_sta_get
    PURPOSE:
    	Returns static data structure for keyword selected APID averaged over a time range
    INPUT:
    	apid:		string		apid of data to be returned 'c0','c2','c4','c6'...

    KEYWORDS:

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/03/17
    MOD HISTORY:

    NOTES:
    	Program assumes tplot has been called
    	Returned data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro, omni4d.pro, sum4m.pro, sum4d.pro
    	Or as input to plotting programs like spec3d, plot3d, contour4d
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get.pro)

## MVN_STA_GET_2A

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

    PROCEDURE:	mvn_sta_get_2a
    PURPOSE:
    	Returns APID 2a data structure at a single time from common generated by mvn_sta_hkp_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/06/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_2a.pro)

## MVN_STA_GET_C0

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

    PROCEDURE:	mvn_sta_get_c0
    PURPOSE:
    	Returns APID c0 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/31
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_c0.pro)

## MVN_STA_GET_C2

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

    PROCEDURE:	mvn_sta_get_c2
    PURPOSE:
    	Returns APID c2 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  13/11/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_c2.pro)

## MVN_STA_GET_C4

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

    PROCEDURE:	mvn_sta_get_c4
    PURPOSE:
    	Returns APID c4 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/31
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_c4.pro)

## MVN_STA_GET_C6

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

    PROCEDURE:	mvn_sta_get_c6
    PURPOSE:
    	Returns APID c6 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  13/11/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_c6.pro)

## MVN_STA_GET_C6E

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

    PROCEDURE:	mvn_sta_get_c6e
    PURPOSE:
    	Returns APID c6e data structure at a single time from common generated by mvn_sta_make_c6e.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  16/04/05
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_4dt.pro, get_en_spec4dt.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_c6e.pro)

## MVN_STA_GET_C6_CO2

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

    PROCEDURE:	mvn_sta_get_c6_co2
    PURPOSE:
    	Returns APID c6 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  13/11/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_c6_co2.pro)

## MVN_STA_GET_C8

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

    PROCEDURE:	mvn_sta_get_c8
    PURPOSE:
    	Returns APID c8 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_c8.pro)

## MVN_STA_GET_CA

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

    PROCEDURE:	mvn_sta_get_ca
    PURPOSE:
    	Returns APID ca data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_ca.pro)

## MVN_STA_GET_CC

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

    PROCEDURE:	mvn_sta_get_cc
    PURPOSE:
    	Returns APID cc data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_cc.pro)

## MVN_STA_GET_CD

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

    PROCEDURE:	mvn_sta_get_cd
    PURPOSE:
    	Returns APID cd data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_cd.pro)

## MVN_STA_GET_CE

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

    PROCEDURE:	mvn_sta_get_ce
    PURPOSE:
    	Returns APID ce data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_ce.pro)

## MVN_STA_GET_CF

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

    PROCEDURE:	mvn_sta_get_cf
    PURPOSE:
    	Returns APID cf data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_cf.pro)

## MVN_STA_GET_D0

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

    PROCEDURE:	mvn_sta_get_d0
    PURPOSE:
    	Returns APID d0 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d0.pro)

## MVN_STA_GET_D1

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

    PROCEDURE:	mvn_sta_get_d1
    PURPOSE:
    	Returns APID d1 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d1.pro)

## MVN_STA_GET_D1E

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

    PROCEDURE:	mvn_sta_get_d1e
    PURPOSE:
    	Returns synthetic data product d1e data structure at a single time from common generated by mvn_sta_make_d1e.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  16/04/04
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_4dt.pro, get_en_spec4dt.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d1e.pro)

## MVN_STA_GET_D2

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

    PROCEDURE:	mvn_sta_get_d2
    PURPOSE:
    	Returns APID d2 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/06/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d2.pro)

## MVN_STA_GET_D3

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

    PROCEDURE:	mvn_sta_get_d3
    PURPOSE:
    	Returns APID d3 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/06/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d3.pro)

## MVN_STA_GET_D4

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

    PROCEDURE:	mvn_sta_get_d4
    PURPOSE:
    	Returns APID d4 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/01/09
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d4.pro)

## MVN_STA_GET_D6

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

    PROCEDURE:	mvn_sta_get_d6
    PURPOSE:
    	Returns APID d6 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/08/27
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d6.pro)

## MVN_STA_GET_D8

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

    PROCEDURE:	mvn_sta_get_d8
    PURPOSE:
    	Returns APID d8 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/06/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d8.pro)

## MVN_STA_GET_D9

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

    PROCEDURE:	mvn_sta_get_d9
    PURPOSE:
    	Returns APID d9 data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/06/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_d9.pro)

## MVN_STA_GET_DA

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

    PROCEDURE:	mvn_sta_get_da
    PURPOSE:
    	Returns APID da data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/06/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_da.pro)

## MVN_STA_GET_DB

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

    PROCEDURE:	mvn_sta_get_db
    PURPOSE:
    	Returns APID db data structure at a single time from common generated by mvn_sta_prod_cal.pro
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:
    	start:		0,1		if set, gets first time in common block
    	en:		0,1		if set, gets last time in common block
    	advance		0,1		if set, gets next time in common block
    	retreat		0,1		if set, gets previous time in common block
    	index		long		gets data at the index value "ind" in common block
    	calib:		0,1		not working yet, allows alternate calibration
    	times		0,1		returns an array of times for all the data, returns 0 if no data

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  14/06/12
    MOD HISTORY:

    NOTES:
    	Data structures can be used as inputs to functions such as n_4d.pro, v_4d.pro
    	Or used in conjunction with iterative programs such as get_2dt.pro, get_en_spec.pro

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_db.pro)

## MVN_STA_GET_KK2

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

    PROCEDURE:	mvn_sta_get_kk2
    PURPOSE:
    	Returns kk2 parameter for correcting ion suppression
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  16/02/08
    MOD HISTORY:

    NOTES:
    	kk2 ion suppression correction may be limited to times after 20151101

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_kk2.pro)

## MVN_STA_GET_KK3

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

    PROCEDURE:	mvn_sta_get_kk3
    PURPOSE:
    	Returns kk3 - a 4 element array for correcting ion suppression as a function of attenuator state
    INPUT:
    	time:		dbl		time of data to be returned

    KEYWORDS:

    CREATED BY:	J. McFadden
    VERSION:	1
    LAST MODIFICATION:  16/04/25
    MOD HISTORY:

    NOTES:
    	kk3 ion suppression correction may be limited to times after 20151101

(See projects/maven/sta/mvn_sta_functions/mvn_sta_get_kk3.pro)

## MVN_STA_SET_TH_OFFSET2

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

    PROGRAM:	mvn_sta_set_th_offset2
    INPUT:
    	time:	dbl,		input time
    KEYWORDS
    					0,1=exclude,include
    PURPOSE:
    	Returns parameters [efoldoffset,e0,scale1] for offset2 calculation used by th_4d.pro, th2_4d.pro and vp_4d.pro
    		offset2=efoldoffset*(1.-erf((energy-e0)/(scale1*e0)))

    NOTES:
    	Function normally called by th_4d.pro, th2_4d.pro and vp_4d.pro
    	offset2 is an energy dependent angle offset determined by ion suppression whose functional form is emperical

    CREATED BY:
    	J.McFadden	2016-10-28
    LAST MODIFICATION:
    	J.McFadden	2020-01-24

(See projects/maven/sta/mvn_sta_functions/mvn_sta_set_th_offset2.pro)

## MVN_STA_V4D

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

    PROCEDURE:       MVN_STA_V4D

    PURPOSE:         Calculates ion bulk velocity correcting for spacecraft
                     potential and spacecraft motion.  Also transforms result
                     to different frames.

    INPUTS:

        trange:      Time or time range for loading data.

    KEYWORDS:

           FRAME:    Transform the results to this frame.  See mvn_frame_name
                     for a list of frames.  Default = 'MAVEN_MSO'.

            MASS:    Selects ion mass/charge range.

            MMIN:    Defines the minimum ion mass/charge to use.

            MMAX:    Defines the maximum ion mass/charge to use.

           M_INT:    Assumed ion mass/charge. Default = 1.

            APID:    Specifies the STATIC APID to use.

           DOPOT:    If set, correct for the spacecraft potential.  The default is
                     to use the potential stored in the L2 CDF's or calculated by
                     mvn_sta_scpot_load.  If this estimate is not available, no
                     correction is made.

          SC_POT:    Override the default spacecraft potential with this.

             VSC:    Correct for the spacecraft velocity.

          ERANGE:    Specifies the energy range to use.

          TEMPLATE:  Just return the result structure template.

          NO_SPICE_CHECK: Do not perform SPICE checks.  The check performed by
                     this routine can be overkill, if SPICE coverage has already
                     been checked.

    NOTE:            This routine is based on 'mvn_sta_slice2d_snap' created by
                     Yuki Harada and modified by Takuya Hara.

    CREATED BY:      D. L. Mitchell.

    LAST MODIFICATION:
     $LastChangedBy: dmitchell $
     $LastChangedDate: 2018-09-13 14:02:32 -0700 (Thu, 13 Sep 2018) $
     $LastChangedRevision: 25793 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/maven/sta/mvn_sta_functions/mvn_sta_v4d.pro $

(See projects/maven/sta/mvn_sta_functions/mvn_sta_v4d.pro)

## M_4D

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

    FUNCTION:	m_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the components of the momentum tensor, corrects for spacecraft potential if dat.sc_pot exists
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-02-27
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/m_4d.pro)

## NB_4D

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

    FUNCTION:	nb_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the density of a beam in units of km/s
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-05-2
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/nb_4d.pro)

## N_4D

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

    FUNCTION:	n_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the density array, n, 1/cm^3, corrects for spacecraft potential if dat.sc_pot exists
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	13-11-13
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/n_4d.pro)

## OMNI4D

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

    FUNCTION:  omni4d
    PURPOSE:  produces an omnidirectional spectrum structure by summing
     over the non-zero bins in the keyword bins.
     this structure can be plotted with "spec3d"

    CREATED BY:	McFadden from omni3d.pro
    LAST MODIFICATION:	14/01/31

     WARNING:  This is a very crude structure; use at your own risk.

(See projects/maven/sta/mvn_sta_functions/omni4d.pro)

## P_4D

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

    FUNCTION:	p_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q)
    INPUT:
    	dat:	structure,	3d data structure filled by themis routines get_th?_p???
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    PURPOSE:
    	Returns the pressure tensor, [Pxx,Pyy,Pzz,Pxy,Pxz,Pyz], eV/cm^3
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	00-2-24
    LAST MODIFICATION:
    	J.McFadden	05-2-8		Fixed diagonalization
    	J.McFadden	06-2-23		changed the s/c pot calculation to the same as n_2d_new.pro
    	J.McFadden	09-4-29		added a diagonalization to Pxx and Pyy to maximize difference

(See projects/maven/sta/mvn_sta_functions/p_4d.pro)

## SPEC4D

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

    PROCEDURE: spec4d,data
       Plots 3d data as energy spectra.
    INPUTS:
       data   - 3d data structure filled by themis routines get_th?_p???
    KEYWORDS:
       LIMITS - A structure containing limits and display options.
                 see: "options", "xlim" and "ylim", to change limits
       UNITS  - convert to given data units before plotting
       COLOR  - array of colors to be used for each bin
       BINS   - array of bins to be plotted  (see "edit3dbins" to change)
       OVERPLOT  - Overplots last plot if set.
       LABEL  - Puts bin labels on the plot if set.

    See "plot3d" for another means of plotting data.
    See "conv_units" to change units.
    See "time_stamp" to turn time stamping on and off.

    CREATED BY:	Davin Larson  June 1995
    FILE:  spec4d.pro
    VERSION 1.25
    MODIFICATIONS:
    	09-05-24	mcfadden	keyword 'sec' added to plot internal secondary spectra
    	14-01-10	mcfadden	modified to accept mass dimension

(See projects/maven/sta/mvn_sta_functions/spec4d.pro)

## SUM4D

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

    FUNCTION: sum4d
    PURPOSE: Takes two 4D structures and returns a single 4D structure whose data is the sum of the two
    INPUTS: d1,d2  each must be 4D structures obtained from the get_?? routines
    	e.g. "get_mvn_d0"
    RETURNS: single 4D structure

    CREATED BY:	McFadden
    LAST MODIFICATION:	@(#)sum3d.pro	1.6 14/01/31

    Notes: This is a very crude subroutine. Use at your own risk.

(See projects/maven/sta/mvn_sta_functions/sum4d.pro)

## SUM4M

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

    FUNCTION:  sum4m
    PURPOSE:  produces an omnidirectional spectrum structure by summing
     over the non-zero bins in the keyword bins.
     this structure can be plotted with "spec3d"

    CREATED BY:	McFadden from omni4d.pro
    LAST MODIFICATION:	14/02/04

     WARNING:  This is a very crude structure; use at your own risk.

(See projects/maven/sta/mvn_sta_functions/sum4m.pro)

## TB_4D

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

    FUNCTION:	tb_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	MASS:	intarr(nm)	optional,
    PURPOSE:
    	Returns the temperature of a beam in units of eV, assumes no s/c charging
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-02-27
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/tb_4d.pro)

## TH2_4D

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

    FUNCTION:	th2_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    PURPOSE:
    	Returns the center theta of a low energy beam and the estimated instrumental offset
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".
    	Modified to use tplot structure 'mvn_sta_o2+_c6_ec'
    	Only valid <500 km altitude

    CREATED BY:
    	J.McFadden	2016-06-30
    LAST MODIFICATION:
    	J.McFadden	2016-09-18

(See projects/maven/sta/mvn_sta_functions/th2_4d.pro)

## TP_4D

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

    FUNCTION:	tp_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include

    PURPOSE:
    	Returns the perp temperature of a beam from APID C8 in units of eV
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-03-12
    LAST MODIFICATION:
    		20190808  factor of 2 error corrected, vth^2= 2.*sigma^2: tp=2.*total((v*sth - v0#replicate(1.,nth))^2*data)/(total(data)>1.e-20

(See projects/maven/sta/mvn_sta_functions/tp_4d.pro)

## T_4D

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

    FUNCTION:	t_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    PURPOSE:
    	Returns the temperature, [Tx,Ty,Tz,Tavg], eV
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-02-27
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/t_4d.pro)

## VB_4D

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

    FUNCTION:	vb_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    PURPOSE:
    	Returns the velocity of a beam in units of km/s
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	2014-02-27
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/vb_4d.pro)

## VB_POT_4D

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

    FUNCTION:	vb_pot_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    	mass:	fltarr(2)	optional, min,max 	mass range for integration
    	m_int:	flt		optional, assumed 	mass used for entire mass range
    	mincnt:	flt		optional, if total counts in energy-mass-angle range is <mincnt, then returns !Values.F_NAN
    	no_co2:	0,1		if set, will not use pot_co2_avg or pot_co2, will instead use dat.sc_pot
    	no_min:	0,1		if set, will allow use of sc_pot>-.01V - for testing purposes

    PURPOSE:
    	Returns the velocity of a beam in units of km/s -- needs modification for ion suppression correction accounting for anode variations
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".
    	Modified to only be valid below 500 km

    CREATED BY:
    	J.McFadden	2014-02-27
    LAST MODIFICATION:
    	J.McFadden	2019-01-18		added gaussfit

(See projects/maven/sta/mvn_sta_functions/vb_pot_4d.pro)

## VC_4D

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

    FUNCTION:	vc_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    PURPOSE:
    	Returns the normalized velocity unit vector, [Vx,Vy,Vz]/Vmag, km/s for each mass bin
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	14-02-26
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/vc_4d.pro)

## VP_4D

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

    FUNCTION:	vp_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_get_c8.pro
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    PURPOSE:
    	Returns the perpendicular velocity of a beam in units of km/s for apid C8
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".
    	Modified to use tplot structure 'mvn_sta_o2+_c6_ec'
    	Only valid <500 km altitude

    CREATED BY:
    	J.McFadden	2014-02-27
    LAST MODIFICATION:
    	J.McFadden	2018-09-18

(See projects/maven/sta/mvn_sta_functions/vp_4d.pro)

## V_4D

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

    FUNCTION:	v_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include
    PURPOSE:
    	Returns the velocity, [Vx,Vy,Vz], km/s for each mass bin
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	14-02-26
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/v_4d.pro)

## WC_4D

[Previous Routine] [List of Routines]

    FUNCTION:	wc_4d(dat,ENERGY=en,ERANGE=er,EBINS=ebins,ANGLE=an,ARANGE=ar,BINS=bins,MASS=ms,m_int=mi,q=q,mincnt=mincnt)
    INPUT:
    	dat:	structure,	4d data structure filled by themis routines mvn_sta_c6.pro, mvn_sta_d0.pro, etc.
    KEYWORDS
    	ENERGY:	fltarr(2),	optional, min,max energy range for integration
    	ERANGE:	fltarr(2),	optional, min,max energy bin numbers for integration
    	EBINS:	bytarr(na),	optional, energy bins array for integration
    					0,1=exclude,include,
    					na = dat.nenergy
    	ANGLE:	fltarr(2,2),	optional, angle range for integration
    				theta min,max (0,0),(1,0) -90<theta<90
    				phi   min,max (0,1),(1,1)   0<phi<360
    	ARANGE:	fltarr(2),	optional, min,max angle bin numbers for integration
    	BINS:	bytarr(nb),	optional, angle bins array for integration
    					0,1=exclude,include,
    					nb = dat.ntheta
    	BINS:	bytarr(na,nb),	optional, energy/angle bins array for integration
    					0,1=exclude,include

    PURPOSE:
    	Returns the anisotropy
    NOTES:
    	Function normally called by "get_4dt" to
    	generate time series data for "tplot.pro".

    CREATED BY:
    	J.McFadden	14-02-26
    LAST MODIFICATION:

(See projects/maven/sta/mvn_sta_functions/wc_4d.pro)