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

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

# Directory Listing of Routines

# projects/themis/spacecraft/particles/ESA/background

- THM_LOAD_ESA_BKG
  Adds background count rates to the ESA data structures which can be used
- THM_LOAD_PEI_BKG
  Adds background count rates to the ESA structures for use by thm_pei_bkg_sub
- THM_PEE_BKG
  returns estimates of background determined from lowest counts in dat.data angle averaged array
- THM_PEE_BKG_SUB
  calculates secondary background from primary. Returns data structure with secondaries, photo-e, and Bremsstrahlung (dat.bkg) subtracted
- THM_PEI_BKG
  returns estimates of background determined from lowest counts in dat.data angle averaged array
- THM_PEI_BKG_SUB
  returns data structure with background subtracted, assumes dat.bkg in data structure, run thm_load_esa_bkg.pro first
- THM_PSE_BKG_AUTO
  Generates 'th'+sc+'_pser_minus_bkg' for use by thm_load_esa_bkg.pro -- Auto selects time interval for pser background subtract
- THM_PSI_BKG_SET
  User selects time interval for determining ion sst background counts, use fast survey if available
- THM_PSI_BKG_SUB
  returns psi data structure with background subtracted, run thm_psi_bkg_set.pro first

# Routine Descriptions

## THM_LOAD_ESA_BKG

[Next Routine] [List of Routines]

    PROCEDURE:
     thm_load_esa_bkg

    PURPOSE:
    	Adds background count rates to the ESA data structures which can be used
     by thm_pei_bkg_sub and thm_pee_bkg_sub for background removal.

    INPUT:
    	probe:  strarr		themis spacecraft - "a", "b", "c", "d", "e"
             if not set defaults to all
    	sc:		strarr		themis spacecraft - "a", "b", "c", "d", "e"
           if not set defaults to all
    	datatype:  string array specifying datatypes from which background is calculated
                valid inputs: "peir", "peer", "pser"
                if not set defaults to all
                peer data is also used for calculating pser background
     trange:  two element time range
              if not specified or set with timespan user will be prompted
    	user_select:  0/1	keyword not working -- code under construction
                   if set, will run thm_pse_bkg_set.pro to let the user select the interval for calculating pser sunlight background
                   if not set, will run thm_pse_bkg_auto.pro for automated pser sunlight background subtraction

    CREATED BY:	J. McFadden	08/12/31
    VERSION:	1
    LAST MODIFICATION:  08/12/31
    MOD HISTORY:
    				08/12/31
    				10/03/18	added peer background from scattered electrons
    				10/04/06	background array for electrons now filled using ion calculated background
         2016/06/30  minor changes to integrate with spedas
         2016/07/12  autoload all data, some code cleaning

    NOTES:
    		Autoloads pser, peir, peer, and state data if not present
    		If both iesa and sst data sets are used, will use the lower background estimate
    		Uses iesa data for background in the inner magnetosphere
    		Will only work properly if data includes a perigee pass

(See projects/themis/spacecraft/particles/ESA/background/thm_load_esa_bkg.pro)

## THM_LOAD_PEI_BKG

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

    PROCEDURE:	thm_load_pei_bkg
    PURPOSE:
    	Adds background count rates to the ESA structures for use by thm_pei_bkg_sub
    INPUT:

    KEYWORDS:
    	probe:		strarr		themis spacecraft - "a", "b", "c", "d", "e"
    					if not set defaults to all
    	sc:		strarr		themis spacecraft - "a", "b", "c", "d", "e"
    					if not set defaults to all
    	themishome:	string		path to data dir, where data dir contains the th* dir, where *=a,b,c,d,e
    	datatype	string or 0/1	if not set, uses both pser and peir data
    					if set to pser, uses pser only
    					if set to peir, uses peir only
    	user_select	0/1		if set, will let the user selected interval for pser sunlight background
    						assumes that thm_pse_bkg_set.pro has been run
    					if not set, will run thm_pse_bkg_auto.pro for automated background subtraction

    CREATED BY:	J. McFadden	08/12/31
    VERSION:	1
    LAST MODIFICATION:  08/12/31
    MOD HISTORY:
    				08/12/31
    				10/03/18	added peer background from scattered electrons

    NOTES:
    		Assumes pser data is loaded if pser data to be used for background
    		pser data is only used for times when the attenuators are closed
    		Assumes esa data is loaded
    		If both esa and sst data sets are used, will use the lower background estimate
    		Will only work properly if data includes a perigee pass

(See projects/themis/spacecraft/particles/ESA/background/thm_load_pei_bkg.pro)

## THM_PEE_BKG

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

    FUNCTION:	thm_pee_bkg(dat)
    INPUT:
    	dat:	data structure (n,3)	vector arrays dimension (n,3) or (3)
    PURPOSE:
    	returns estimates of background determined from lowest counts in dat.data angle averaged array
    CREATED BY:
    	J.McFadden	10-04-06
    Modifications
    	J.McFadden	10-04-06
     aflores   2016-06-30  minor changes to integrate with spedas

(See projects/themis/spacecraft/particles/ESA/background/thm_pee_bkg.pro)

## THM_PEE_BKG_SUB

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

    FUNCTION:	thm_pee_bkg_sub(dat,bkg=bkg)

    PURPOSE:
    	calculates secondary background from primary. Returns data structure with secondaries, photo-e, and Bremsstrahlung (dat.bkg) subtracted

    INPUT:
    	dat:	themis pee data structure
    KEYWORDS:

    Assumptions
     Secondary electron spectral shape determined from a fit to TH-B on 08-03-05 in shadow (see first results paper)
     	Secondary spectra for this day fits ~ 1./(1.+(E/5.4)^3), where E is the secondary energy
    	sec ~ 1./(1.+(E/5.4)^3)
    	5.4 was determined empirically from the fit

    CREATED BY:
    	J.McFadden	09-11-18
    Modifications
    	J.McFadden	10-04-06	Changed to allow dat2.bkg subtraction of Bremstrahlung X-rays and seconda
     aflores   2016-06-30  minor changes to integrate with spedas

(See projects/themis/spacecraft/particles/ESA/background/thm_pee_bkg_sub.pro)

## THM_PEI_BKG

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

    FUNCTION:	thm_pei_bkg(dat)
    INPUT:
    	dat:	data structure (n,3)	vector arrays dimension (n,3) or (3)
    PURPOSE:
    	returns estimates of background determined from lowest counts in dat.data angle averaged array
    CREATED BY:
    	J.McFadden	08-12-31
    Modifications
    	J.McFadden	08-12-31
     aflores   2016-06-30  minor changes to integrate with spedas

(See projects/themis/spacecraft/particles/ESA/background/thm_pei_bkg.pro)

## THM_PEI_BKG_SUB

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

    FUNCTION:	thm_pei_bkg_sub(dat,bkg=bkg)

    PURPOSE:
    	returns data structure with background subtracted, assumes dat.bkg in data structure, run thm_load_esa_bkg.pro first

    INPUT:
    	dat:	themis pei data structure
    KEYWORDS:
    	bkg:		flt		if set, uses this value in background subtraction

    Assumptions
    	Program assumes no energy dependence for contamination
    	Program assumes dat.bkg is already computed
    	dat.bkg is added to structure by thm_load_esa_bkg.pro

    CREATED BY:
    	J.McFadden	08-12-29
    Modifications

    	Mcfadden	09-01-09	added relative bkg dependence as a function of anode
    	mcfadden	09-01-30	changed dat.bkg to an array
     aflores   2016-06-30  minor changes to integrate with spedas

(See projects/themis/spacecraft/particles/ESA/background/thm_pei_bkg_sub.pro)

## THM_PSE_BKG_AUTO

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

    PROCEDURE:	thm_pse_bkg_auto,sc=sc,t1=t1,t2=t2
    INPUT:

    PURPOSE:
    	Generates 'th'+sc+'_pser_minus_bkg' for use by thm_load_esa_bkg.pro -- Auto selects time interval for pser background subtract

    CREATED BY:
    	J.McFadden	09-01-01
    Modifications
    	J.McFadden	09-02-05	modified to work with both attenuator on and off
    	J.McFadden	09-04-15	modified to include correct calibrations
    	J.McFadden	09-09-16	modified to include modes with psef w/ spin resolution and pser w/o spin resolution
     aflores   2016-06-30  minor changes to integrate with spedas
    Assumptions
    	SST data is already loaded
    	Uses pser data only - assumes it is the highest time resolution

(See projects/themis/spacecraft/particles/ESA/background/thm_pse_bkg_auto.pro)

## THM_PSI_BKG_SET

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

    PROCEDURE:	thm_psi_bkg_set,sc=sc,tt_on=tt_on,tt_off=tt_off
    INPUT:

    PURPOSE:
    	User selects time interval for determining ion sst background counts, use fast survey if available

    CREATED BY:
    	J.McFadden	10-04-25
    Modifications
    	J.McFadden

    Assumptions
    		Needs corrections for different detector gf for psir6

(See projects/themis/spacecraft/particles/ESA/background/thm_psi_bkg_set.pro)

## THM_PSI_BKG_SUB

[Previous Routine] [List of Routines]

    FUNCTION:	thm_psi_bkg_sub(dat)
    INPUT:
    	dat:	data structure (n,3)	vector arrays dimension (n,3) or (3)
    PURPOSE:
    	returns psi data structure with background subtracted, run thm_psi_bkg_set.pro first

    Assumptions
    	Assumes thm_psi_bkg_set.pro has been run
    	Assumes input distribution is in counts
    	Output distribution will have no negative numbers

    CREATED BY:
    	J.McFadden	08-12-30
    Modifications
    	mcfadden	09-02-03	modified to work for both atten on and off

(See projects/themis/spacecraft/particles/ESA/background/thm_psi_bkg_sub.pro)