F0READ $SSW/packages/lparl/idl/io/f0read.pro
[Previous] [Next]
NAME:
	F0READ
PURPOSE:
	for reading F0 format compressed files written by ANA.
SAMPLE CALLING SEQUENCES:
	x=f0read('jan97hr_0686.mags',h)
	img=anard('/tmp_mnt/hosts/tarbell/disk3/lp92/3jul/le132f18w6563p700n0865.rigd',h)
INPUT:
	filename of image to be read
OUTPUT:
	x will contain the image array
	h will contain the file header  <<< INPUT!?!?!
NOTES:
	Rice and F0 decompression uses decrunch.c and associated
	files (crunchstuff.c, anarw.c) and will write
	decompressed results to a temporary file, then read from
	this file.  To use this routine on outside systems, the
	C code executables must be present and pathnames for
	locating them may need to be changed in the IDL code.
	The user may also wish to change the location of the
	temporary file.  
	The f0read and rice functions, as well as the decrunch
	program, may be used individually.
 CALLS: ***
	scratch [1], scratch [2], ssw_bin
HISTORY:
       Original PROCEDURE F0RD
       taken from Stu Ferguson to make it easy for Jake to
	obtain CCD files.
	Z. Frank 3/97, added to anafrd set, based on R. Shine's
	reading, writing, and decompression routines
	29-Apr-97 (MDM) - Modified how spawning to executable works
			  (to use SSW_BIN routine)


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


F_2THERM_POW $SSW/packages/xray/idl/f_2therm_pow.pro
[Previous] [Next]
 Name:
	F_2THERM_POW
 Purpose:
	This function returns the differential photon spectrum from a model of 
	a double thermal bremsstrahlung plus broken power-law with a low-energy
	cutoff.

 CALLED BY:
	FLARE_XRAY_MODEL, GE_WINDOW [1], HESSI_MODEL_COUNTS
 Procedure:
	Identical to F_MULTI_SPEC.
	Uses f_vth for the optically thin thermal bremsstrahlung radiation function
	differential spectrum seen at Earth in units of photon/(cm2 s keV) and
	f_bpow for the broken power-law parameterization.

INPUTS:
	E- energy vector in keV, 2xN edges or mean energy vector
	A- Free parameters described below
 Thermal 1
	a(0)= emission measure in units of 10^49 cm-3
	a(1)= KT	 plasma temperature in keV
 Thermal 2
	a(2)= emission measure in units of 10^49 cm-3
	a(3)= KT	 plasma temperature in keV

Uses broken power law function, F_BPOW, for power-law
	a(4) - normalization of broken power-law at Epivot (usually 50 keV)
	a(5) - negative power law index below break
	a(6) - break energy
	a(7) - negative power law index above break
	a(8) - low energy cutoff for power-law, spectrum goes as E^(-1.5) 
	a(9) - spectral index below cutoff between -1.5 and -2.0

 Calls: ***
	F_MULTI_SPEC
 History:
	ras, ~1994
	VERSION 2, RAS, 1996, Since it was functionally identical to
	F_MULTI_SPEC, it was made into a wrapper function.


F_3POW $SSW/packages/xray/idl/f_3pow.pro
[Previous] [Next]
 NAME:
	F_3POW

 PURPOSE: triple broken power-law function with/without discontinuities in the
	derivatives

 CALLING SEQUENCE: result = f_3pow(x, a)

 CATEGORY: SPEX, spectral fitting

 INPUTS:
	x - independent variable, nominally energy in keV under SPEX
	    if a 2xN array is passed, these are interpreted as edges
	    and the value is calculated at the arithmetic mean
	a - parameters describing the broken power-law
	a(0) - normalization at epivot, photon flux of first power-law
	       at epivot
	a(1) - negative power law index below break energy1
	a(2) - break energy1
	a(3) - negative power law index above break energy1, below break energy2
	a(4) - break energy2
	a(5) - negative power law index above break energy2
 OUTPUTS:
	result of function, a triple broken power law
 OPTIONAL OUTPUTS:

 PROCEDURE:	passes calculation onto threepow.pro

 CALLS: ***
	CHECKVAR [1], THREEPOW, checkvar [2], edge_products
 COMMON BLOCKS:
	none

 RESTRICTIONS: power-law cannot be flatter then x^(-.01)

 MODIFICATION HISTORY:
	ras, 1 nov 1995
 Kim Tolbert, 2004/07/16 - added _extra so won't crash if keyword is used in call


F_3POW_DEFAULTS $SSW/packages/spex/idl/object_spex/f_3pow_defaults.pro
[Previous] [Next]
 NAME:
	F_3POW_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_3pow function.

 CALLING SEQUENCE: defaults = f_3pow_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, July 2004


F_BPOS_NLINE $SSW/packages/xray/idl/f_bpos_nline.pro
[Previous] [Next]
 NAME:
   F_BPOS_NLINE
	
 PURPOSE: 
   broken power-law function with/without discontinuities in the
   derivatives + gaussian line function
	
 CALLING SEQUENCE: 
   result = f_bpos_nline( energy_bins, parameters )
		
 INPUTS:
   energy_bins - independent variable, nominally energy in keV under SPEX
   parameters - parameters describing the broken power-law, annihilation line
       with positronium fraction, and n gaussians

       parameters[0] - normalization at Epivot (see function_com.pro).
       parameters[1] - power law index below break
       parameters[2] - break energy
       parameters[3] - power law index above break

       parameters[4] - Annihilation line flux, normalized to 1 photon/cm^2
       parameters[5] - Positronium flux
       parameters[6] - Annihilation line FWHM
	parameters[7] - Annihilation line centroid

       parameters[8+3n] - integrated line intensity of line n
       parameters[9+3n] - line centroid
       parameters[10+3n] - line sigma

 OUTPUTS:
   sum of a broken power law, annihilation line with positronium 
   continuum, and gaussian lines

 OUTPUT KEYWORDS:
   NLINE - number of gaussian lines in model

 CALLS: ***
	CHECKVAR [1], F_BPOW, F_NLINE, F_POSITRONIUM, checkvar [2]
 MODIFICATION HISTORY:
   Paul Bilodeau, 30-sep-2002 - changed f_posit_wfrac call to
     f_positronium.  Documentation updates.
   Paul Bilodeau, 08-nov-2002 - removed code for manipulating input
     array energy_bins.


F_BPOW $SSW/packages/xray/idl/f_bpow.pro
[Previous] [Next]
 NAME:
   F_BPOW

 PURPOSE: broken power-law function with/without discontinuities in the
   derivatives

 CALLING SEQUENCE: result = f_bpow(x, a)

 INPUTS:
   x - independent variable, nominally energy in keV under SPEX
   a - parameters describing the broken power-law, where:
     a(0) - normalization at epivot of the single powerlaw determined
      by a(0) and a(1).  If Epivot is gt A(2), then the total
      f_bpow function will lay below this normalization point.
     a(1) - negative power law index below break
     a(2) - break energy
     a(3) - negative power law index above break
     a(4) - low energy cutoff
     a(5) - negative power law index of low energy cutoff, 1<Eco<2, default 1.5
 OPTIONAL INPUTS:
   Fname- the name of the function to really use, either 'bpow' or 'bpow_taper'
     defaults to 'bpow'
 OUTPUTS:
   result of function, a broken power law
 OPTIONAL OUTPUTS:

 CALLED BY:
	Ai_vth_bpow [1], Ai_vth_bpow [2], F_BPOS_NLINE, F_COMPOSITE, F_MTH_EXP_BPOW
	F_MTH_POW_BPOW, F_MULTI_SPEC, F_NUCLEAR, F_VTHC_BPOW_NLINE
	Flux model of a thermal bremsstrahlung plus broken powerlaw
	HESSI_MODEL_COUNTS, HSI_CSPECTRUM_DIST, hessi_background, hsi_find_count_dist
	hsi_qlook_init_apar [1], hsi_qlook_init_apar [2]
 PROCEDURE:    uses a spline interpolation to give a smooth
   transitions at the break energies at bpow_taper otherwise
   normal power-law with hard breaks

 CALLS: ***
	BPOW, FCHECK, bpow_taper
 COMMON BLOCKS:
   f_bpow_com

 RESTRICTIONS:
   break energy should be higher than the low energy cutoff by at least dx
 MODIFICATION HISTORY:
   ras, 15 March 1995
 Kim Tolbert, 2004/03/04 - added _extra so won't crash if keyword is used in call
   30-apr-2004, richard.schwartz@gsfc.nasa.gov,
     added documentation about meaning of normalization


F_BPOW_DEFAULTS $SSW/packages/spex/idl/object_spex/f_bpow_defaults.pro
[Previous] [Next]
 NAME:
	F_BPOW_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_bpow function.

 CALLING SEQUENCE: defaults = f_bpow_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, February 2004


F_BPOW_NLINE $SSW/packages/xray/idl/f_bpow_nline.pro
[Previous] [Next]
 NAME:
   F_BPOW_NLINE

 PURPOSE: broken power-law function with/without discontinuities in the
   derivatives + gaussian line function

 CALLING SEQUENCE: result = f_bpow_nline(x, a)

 INPUTS:
   x - independent variable, nominally energy in keV under SPEX
   a - parameters describing the broken power-law and gaussian
     a(4+3n) - integrated line intensity of line n(<3)
     a(5+3n) - line centroid
     a(6+3n) - line sigma

     a(0) - normalization at epivot
     a(0) - normalization at epivot of the single powerlaw determined
      by a(0) and a(1).  If Epivot is gt A(2), then the total
      f_bpow function will lay below this normalization point.
     a(1) - negative power law index below break
     a(2) - break energy
     a(3) - negative power law index above break

 OUTPUTS:
   result of function, a broken power law + gaussian line
 OPTIONAL OUTPUTS:

 KEYWORDS:
   NLINE - number of gaussian lines in model, defaults to 5

 PROCEDURE:

 CALLS: ***
	F_VTHC_BPOW_NLINE
 COMMON BLOCKS:
   f_bpow_nline

 RESTRICTIONS:
   when used in SPEX, limited to 8 lines on 21-jan-1996

 MODIFICATION HISTORY:
   ras,  21-jan-1996
   richard.schwartz@gsfc.nasa.gov, 11-jan-2001, support arbitrary number of lines.
   richard.schwartz@gsfc.nasa.gov, 30-jun-2003, rewritten to use f_vthc_bpow_nline
   richard.schwartz@gsfc.nasa.gov, 5-aug-2003, fixed bug from 30-jun-2003 in call
     to f_vthc_bpow_nline
   30-apr-2004, richard.schwartz@gsfc.nasa.gov,
     added documentation about meaning of normalization


F_BPOW_THICK $SSW/packages/xray/idl/f_bpow_thick.pro
[Previous] [Next]
 NAME:
	F_BPOW_THICK

 PURPOSE: broken power-law function from bremsstrahlung thick model

 CALLING SEQUENCE: result = f_bpow(x, a)

 INPUTS:
   x - independent variable, nominally energy in keV under SPEX
   a - parameters describing the nonthermal electron broken power-law, where:
   a(0) - normalization factor, i.e. nonthermal electron density * area
	   densty = number density of nonthermal electrons (cm^-3);
	   area = area of the radiating source region (cm^2).
   a(1) - negative power law index below break
   a(2) - break energy (keV)
   a(3) - negative power law index above break
   a(4) - low energy cutoff (keV)
   a(5) - high energy cutoff (keV)

 OPTIONAL INPUTS:

 OUTPUTS:
  result of function, a power law photon flux due to the input broken electron
  distibution

 OPTIONAL OUTPUTS:

 PROCEDURE:	
   With power law electron distribution input, using bremsstrahlung thick
   target to compute photon flux

 CALLS: ***
	Brm_BremThick, edge_products
 COMMON BLOCKS:

 RESTRICTIONS:
	break energy should be higher than the low energy cutoff by at least dx
 MODIFICATION HISTORY:



F_COMPOSITE $SSW/packages/xray/idl/f_composite.pro
[Previous] [Next]
 PROJECT:
	SDAC

 NAME:       
	F_COMPOSITE


 PURPOSE:   
	This function generates a composite demonstration spectrum from 1 keV to > 10 MeV
	using X-ray lines, thermal continuua, non-thermal continuua, and a gamma-ray
	line template.


 CATEGORY:
	XRAY, GAMMA-RAY, SPECTRUM

 CALLING SEQUENCE:
	photon_spectrum = F_COMPOSITE( EM ) ; fluence in units of photons/cm2/ MeV

 CALLED BY:


 CALLS: ***
	CHECKVAR [1], F_BPOW, INTERPOL, LOC_FILE [1], LOC_FILE [2], LOC_FILE [3]
	READ_SEQFILE, Vlth, checkvar [2], curdir [1], curdir [2], edge_products
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	Em - channel midpoints in keV
 KEYWORDS:
  Optional Inputs:	
	ATHERM- parameters for thermal function [EM_49, TE_6]
	 	where EM_49 is the emission measure of a plasma at the Sun observed
		at the Earth in units of 1.0e49 cm^(-3) and temperature, TE_6, measured
		in MegaKelvin.
	ABPOW- broken power-law parameters, [a_50, g1, Eb, g2(, Elow, g0)]
		a_50 - photon flux at 50 keV in photons/cm2/s/keV of component below Eb
		g1   - spectral index below the break energy Eb
		Eb   - Break energy in keV
		g2   - spectral index above Eb
		Elow - low energy cutoff (Elow lt Eb) in keV
		g0   - spectral index below Elow
		
	ANUCL- a normalization constant for the spectrum in the file
		hesi2_ramaty.dat in the directory PERM_DATA or SSWDB_XRAY
	ERROR-Returns 1 if database file not found
  Optional Outputs:

	EDGES- channel boundaries used in keV
	FTHERM- thermal component of photon_spectrum
	FBPOW-  non-thermal component
	FNUCL- nuclear component

 COMMON BLOCKS:
	f_composite_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	This was not developed as a general purpose function, but was created for
	the HESI project.  However, it may be used as a template or stand-alone with
	some care.

 PROCEDURE:
	Builds the spectrum from the thermal, non-thermal, and line components.

 MODIFICATION HISTORY:
	ras, 1994
	mod, ras, 8-mar-1995, added edges to output
	Version 2
	ras, 20 May 1996
	ras, 3-jun-1996, changed 11.6=>(1./.08617)
	ras, 4-dec-1996, used LOC_FILE and RD_TEXT
	Version 6, ras, 8-apr-1997, use rd_ascii and add SSWDB_XRAY to datafile path.
       Version 7, richard.schwartz@gsfc.nasa.gov, 24-jul-1997, removed PERM_DATA.
       Version 8, richard.schwartz@gsfc.nasa.gov, 14-may-1998, changed rd_ascii to read_seqfile.


F_CON_LIN $SSW/packages/xray/idl/f_con_lin.pro
[Previous] [Next]
 NAME: 
	F_CON_LIN	
 PURPOSE:
	This function returns the sum of a thermal bremsstrahlung 
	continuum and line spectra with variable element abundances
	for FE, SI, S, and CA.  All the emission functions have the same
	temperature.  
 CATEGORY:
	Xray, Spectra
 CALLING SEQUENCE:
	flux = f_con_lin( energy, apar )
 INPUTS:
	energy - photon energy in keV, must be 2XN
	apar   - up to 7 elements.
		apar(0)- normalization for flux at Earth in units of 1e49cm-3
		apar(1)- temperature in units of keV
		apar(2:5)- relative abundances to the standard Meyer 1985 values
		used as the default in Mewe_spec and Mewe_kev for Fe, Si, S, and Ca.
		apar(6:7)- thickness of attenuation elements in cm for 
			elements specified by the environmental SPEX_ATTEN
			which returns the Z.  The default is is ['14', '0'], Si and no element.
	

 KEYWORDS:
	none

 OUTPUTS:
	flux in photons/cm2/s/keV at the earth for a source at the Sun
	with an emission measure of 1e49 cm-3
 OPTIONAL OUTPUTS:

 CALLS: ***
	MEWE_KEV, STR2ARR [1], STR2ARR [2], edge_products, xsec
 CALLED BY:
	F_MULTI_SPEC
 COMMON BLOCKS:
	none
 PROCEDURE:
	This function provides an interface into mewe_kev.

 RESTRICTIONS:

 MODIFICATION HISTORY:
	richard.schwartz@gsfc.nasa.gov 13-aug-1997


F_CONVERSION [1] $SSW/packages/spex/idl/original_spex/f_conversion.pro
[Previous] [Next]
 NAME:
	F_CONVERSION

 PURPOSE:
	Calculates conversion factors for the current model and drm
	and to load them into CONVI

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	result = f_conversion(Edges, Drm, E_in, F_model, Apar_arr)

 INPUTS:
	E_IN : 2xM input energy bins
	DRM  : Detector response matrix dimensioned n x m where n is the number
	of output energy bins and m is the number of input energy bins.
	Edges : 2xN output energy bins.
	F_MODEL : Spectral model used, e.g. power law or thermal brem.
	APAR_arr : Array of Parameters used in call to F_MODEL.

 OPTIONAL INPUTS:
	if the inputs aren't givent the current values in spex_commons are used
	throught the routine SPEX_CURRENT
	
 KEYWORD PARAMETERS:

 OUTPUTS:
	Result - Conversion factors for each channel for each set of parameters in
	Apar_arr

 RESTRICTIONS:

 PROCEDURE:
	Run Get_conversion for each set of parameters in Apar_arr

 EXAMPLE:

		Convi = F_conversion( Edges, Drm, E_in, F_model, Apar_arr)

 CALLS: ***
	EXIST, get_conversion [1], get_conversion [2], spex_current [1]
	spex_current [2]
 MODIFICATION HISTORY:
	Version 1, RAS, 21-mar-1996


F_CONVERSION [2] $SSW/packages/spex/pre2002/idl/f_conversion.pro
[Previous] [Next]
 NAME:
	F_CONVERSION

 PURPOSE:
	Calculates conversion factors for the current model and drm
	and to load them into CONVI

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	result = f_conversion(Edges, Drm, E_in, F_model, Apar_arr)

 INPUTS:
	E_IN : 2xM input energy bins
	DRM  : Detector response matrix dimensioned n x m where n is the number
	of output energy bins and m is the number of input energy bins.
	Edges : 2xN output energy bins.
	F_MODEL : Spectral model used, e.g. power law or thermal brem.
	APAR_arr : Array of Parameters used in call to F_MODEL.

 OPTIONAL INPUTS:
	if the inputs aren't givent the current values in spex_commons are used
	throught the routine SPEX_CURRENT
	
 KEYWORD PARAMETERS:

 OUTPUTS:
	Result - Conversion factors for each channel for each set of parameters in
	Apar_arr

 RESTRICTIONS:

 PROCEDURE:
	Run Get_conversion for each set of parameters in Apar_arr

 EXAMPLE:

		Convi = F_conversion( Edges, Drm, E_in, F_model, Apar_arr)

 CALLS: ***
	EXIST, get_conversion [1], get_conversion [2], spex_current [1]
	spex_current [2]
 MODIFICATION HISTORY:
	Version 1, RAS, 21-mar-1996


f_drm_mod $SSW/packages/spex/idl/object_spex/f_drm_mod.pro
[Previous] [Next]
Name:
   f_drm_mod
PURPOSE:
   This pseudo function always returns an array of 0s.  It allows us to find the
   best values of several RHESSI DRM parameters by varying them (and
   computing a new DRM) while fitting.


CATEGORY:
   SPECTRA, XRAY

INPUTS:
   E  energy vector in keV, 2XN edges or N mean energies
   apar(0)  FWHM fraction
   apar(1)  gain offset
   apar(2)  center thickness ratio

 Written: Kim Tolbert, 27-Jun-2006
 CALLS:


f_drm_mod_defaults $SSW/packages/spex/idl/object_spex/f_drm_mod_defaults.pro
[Previous] [Next]
 NAME:
	f_drm_mod_defaults

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting with drm_mod function.  drm_mod is a pseudo function - the function
   value is always 0., but the params are used to create a new RHESSI DRM.

 CALLING SEQUENCE: defaults = f_drm_mod_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, 27-Jun-2006


F_GAUSS_INTG [2] $SSW/packages/xray/idl/f_gauss_intg.pro
[Previous] [Next]
 PROJECT:
       SDAC
 NAME:
	F_GAUSS_INTG

 PURPOSE:
	This function returns the sum of a Gaussian and 2nd order polynomial.      

 CATEGORY:
	E2 - CURVE AND SURFACE FITTING.
 CALLS: ***
	GAUSS_INTG
 CALLING SEQUENCE:
	out = F_GAUSS_INTG(X,A)
 CALLED BY:
	BATSE_SPEC_DRM, F_LINE, F_NLINE
 EXAMPLES:
        if a(4+i*3) ne 0.0 then line(0) =line + $
         f_gauss_intg( x, [ f_div( a(4+i*3)/sqrt(2*!pi), a(6+i*3)),  a(5+i*3+ w2 )] )  

 INPUTS:
	X = VALUES OF INDEPENDENT VARIABLE, 2 X N, LO AND HI EDGES
	A = PARAMETERS OF EQUATION DESCRIBED BELOW.
 OUTPUTS:
	None.


 OPTIONAL OUTPUT PARAMETERS:

 COMMON BLOCKS:
	NONE.
 SIDE EFFECTS:
	NONE.
 RESTRICTIONS:
	NONE.
 PROCEDURE:
	THIS GAUSSIAN IS EVALUATED BY INTEGRATING A GAUSSIAN OVER
	AN INTERVAL AND DIVIDING BY THE INTERVAL WIDTH.
	IT USES THE FUNCTION GAUSSINT TO INTEGRATE THE GAUSSIAN.
	F = A(0)*EXP(-Z^2/2) + A(3) + A(4)*X + A(5)*X^2
	Z = (X-A(1))/A(2)
	F IS INTEGRATED FROM X_LO TO X_HI 
 MODIFICATION HISTORY:
	changed gaussian to integrating gaussian over an interval
	RAS, 21-MAR-95
 CONTACT:
	richard.schwartz@gsfc.nasa.gov


F_ION $SSW/packages/xray/idl/f_ion.pro
[Previous] [Next]

 NAME:
   F_ION

 PURPOSE:
   Function wrapper for ION_FIT procedure.

 CALLING SEQUENCE:
   spectrum = f_ion( energy, parameters )

 INPUTS:
   energy - independent variable, nominally energy in keV under SPEX
   parameters - parameters for ionization spectrum
     parameters[0] - normalization
     parameters[1] - spectral index of electron flux
     parameters[2] - break energy

 OUTPUTS:
   Non-uniform target ionization spectrum.

 CALLS: ***
	ION_FIT, edge_products
 CALLED BY
	F_VTH_ION


F_ION_DEFAULTS $SSW/packages/spex/idl/object_spex/f_ion_defaults.pro
[Previous] [Next]
 NAME:
	F_ION_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_ion function.

 CALLING SEQUENCE: defaults = f_ion_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, Aug 4, 2004


F_LINE $SSW/packages/xray/idl/f_line.pro
[Previous] [Next]
 PROJECT:
       HESSI
 NAME:
	F_LINE

 PURPOSE:
	This function returns a single Gaussian function (a0 is normalized)

 CATEGORY:
	E2 - CURVE AND SURFACE FITTING.
 CALLS: ***
	F_DIV, F_GAUSS_INTG [1], F_GAUSS_INTG [2]
 CALLING SEQUENCE:
	out = F_LINE(X,A)

 INPUTS:
	X = VALUES OF INDEPENDENT VARIABLE, 2 X N, LO AND HI EDGES
	A = PARAMETERS OF GAUSSIAN FUNCTION
       A[0] - integrated intensity
       A[1] - centroid
       A[2] - sigma
       (see F_GAUSS_INTG, GAUSS_INTG for more explanation)
 OUTPUTS:
	Function values

 OPTIONAL OUTPUT PARAMETERS:

 COMMON BLOCKS:
	NONE.
 SIDE EFFECTS:
	NONE.
 RESTRICTIONS:
	NONE.
 WRITTEN: Kim Tolbert 30-Jan-2004


F_LINE_DEFAULTS $SSW/packages/spex/idl/object_spex/f_line_defaults.pro
[Previous] [Next]
 NAME:
	F_LINE_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_line function.

 CALLING SEQUENCE: defaults = f_line_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, February 2004


F_MTH_EXP_BPOW $SSW/packages/xray/idl/f_mth_exp_bpow.pro
[Previous] [Next]
 NAME: F_MTH_EXP_BPOW

 PURPOSE: Multithermal function plus a broken power-law function for fitting hard X-ray spectra.
          The differential emission measure has an exponential dependence on temperature.

 CALLING SEQUENCE: result = f_mth_exp_bpow(e, a)

 INPUTS:
   e - independent variable, nominally energy in keV under SPEX
   a - parameters describing the function:

       Multi-thermal parameters:
       a(0) - differential emission measure at T = 2 keV in units of 10^49 cm^(-3) keV^(-1)
       a(1) - minimum plasma temperature in keV
       a(2) - maximum plasma temperature in keV
       a(3) - temperature scale length in keV for caculating differential emission measure
              at temperature T:
              DEM = a(0) * exp( (2. - T) / a(3) )

       Broken power law parameters:

       a(4) - normalization at 50 keV (or epivot) of the single powerlaw determined
           by a(4) and a(5).  If Epivot is gt A(6), then the total
           f_bpow function will lay below this normalization point.
       a(5) - negative power-law index below break
       a(6) - break energy
       a(7) - negative power-law index above break


 OUTPUTS:
   Sum of multi-thermal and broken power law functions.

 PROCEDURE:
   See f_multi_therm_exp and f_bpow.

 CALLS: ***
	CHECKVAR [1], F_BPOW, F_MULTI_THERM_EXP, checkvar [2]
 RESTRICTIONS:
   The normalization for the differential emission measure, a(0), is fixed
   at T = 2 keV in F_THERM_DEM_EXP.

 WRITTEN:
   Paul Bilodeau, 24-February-2003

 REVISED:
   Gordon Holman, 14 August 2003
   Linhui Sui, 28 August 2003, write separate multi-thermal model functions for power-law and
               exponential dependence of DEM on temperature
   30-apr-2004, richard.schwartz@gsfc.nasa.gov,
     added documentation about meaning of normalization


F_MTH_POW_BPOW $SSW/packages/xray/idl/f_mth_pow_bpow.pro
[Previous] [Next]
 NAME: F_MTH_POW_BPOW

 PURPOSE: Multithermal function plus a broken power-law function for fitting hard X-ray spectra.
          The differential emission measure has a power-law dependence on temperature.

 CALLING SEQUENCE: result = f_mth_pow_bpow(e, a)

 INPUTS:
   e - independent variable, nominally energy in keV under SPEX
   a - parameters describing the function:

       Multi-thermal parameters:
       a(0) - differential emission measure at T = 2 keV in units of 10^49 cm^(-3) keV^(-1)
       a(1) - minimum plasma temperature in keV
       a(2) - maximum plasma temperature in keV
       a(3) - power-law index for caculating differential emission measure at temperature T:
              DEM(T) = a(0) * (T/2.)^(-a(3))

       Broken power law parameters:

       a(4) - normalization at 50 keV (or epivot) of the single powerlaw determined
           by a(4) and a(5).  If Epivot is gt A(6), then the total
           f_bpow function will lay below this normalization point.
       a(5) - negative power-law index below break
       a(6) - break energy
       a(7) - negative power-law index above break

 OUTPUTS:
   Sum of multi-thermal and broken power law functions.

 PROCEDURE:
   See f_multi_therm_pow and f_bpow.

 CALLS: ***
	CHECKVAR [1], F_BPOW, F_MULTI_THERM_POW, checkvar [2]
 RESTRICTIONS:
   The normalization for the differential emission measure, a(0), is fixed
   at T = 2 keV in F_THERM_DEM_POW.

 WRITTEN:
   Paul Bilodeau, 24-February-2003

 REVISED:
   Gordon Holman, 14 August 2003
   Linhui Sui, 28 August 2003, write separate multi-thermal model functions for power-law and
               exponential dependence of DEM on temperature
   30-apr-2004, richard.schwartz@gsfc.nasa.gov,
     added documentation about meaning of normalization


F_MULTI_SPEC $SSW/packages/xray/idl/f_multi_spec.pro
[Previous] [Next]

 NAME:
   F_MULTI_SPEC


 PURPOSE:
   This function returns the differential photon spectrum from a model of
   a double thermal bremsstrahlung plus broken power-law with a low-energy
   cutoff.


 CATEGORY:
   XRAY, SPECTRA


 CALLING SEQUENCE:  output = f_multi_spec( energy, parameters )


 CALLED BY: get_conversion


 CALLS: ***
	CHECKVAR [1], F_BPOW, F_CON_LIN, F_VTH, checkvar [2], edge_products, xsec
 INPUTS:
       energy
   a
       See Procedure for a description
 OPTIONAL INPUTS:
   none

 OUTPUTS:
       function returns photon spectrum in each bin in (/cm2/s/keV)

 OPTIONAL OUTPUTS:
   none

 CALLED BY:
	F_2THERM_POW
 COMMON BLOCKS:
   function_com

 SIDE EFFECTS:
   none

 RESTRICTIONS:
   This function is essentially identical to f_2therm_pow and both are
   preserved for the moment, May 1996

 PROCEDURE:
   The spectrum is built from the sum of two calls to f_vth() and one to f_bpow().

   Uses f_vth for the optically thin bremsstrahlung radiation function,
   the differential spectrum seen at Earth in units of photon/(cm2 s keV).

INPUTS for f_vth
   E- energy vector in keV, 2XN edges or N mean energies
   A- free parameters, where the elements of A have these meanings:
   a(0)= emission measure in units of 10^49 cm-3
   a(1)= KT   plasma temperature in keV

And the second one
   a(2)= emission measure in units of 10^49 cm-3
   a(3)= KT   plasma temperature in keV


Uses broken power law function, F_BPOW
   see F_BPOW for more on defaults.
   a(4) - normalization of broken power-law at Epivot (usually 50 keV)
   a(5) - negative power law index below break
   a(6) - break energy
   a(7) - negative power law index above break
   a(8) - low energy cutoff for power-law, spectrum goes as E^(-1.5)
   a(9) - spectral index below cutoff between -1.5 and -2.0
   default parameters - a(8) and a(9) default to 10 keV and -1.5
   can be overwritten by values in common function_com
   none
!!!!!!!!!!!!N.B. For developmental purposes this routine can be modified through
   the use of two environment variables.
   SPEX_ATTEN- This can be used to set fixed values for additional attenuation.
   There should be two values separated by a space or comma which are
   interpreted as the thickness in cm and the atomic number, Z.
   Set SPEX_ATTEN to 0 to use apar(6:7) [see below] for the attenuation
   variables.
   SPEX_NEWMODEL- Currently, this only has meaning if it is set to F_CON_LIN.
   In this case the two thermal components are the two components of
   F_CON_LIN, a thermal continuum (conflx) and thermal line spectrum (linflx)
   from MEWE_SPEC which can have independent emission measures apar(0) and apar(2)
   and can have independent or identical temperatures apar(1) and apar(3).  For
   linked temperatures apar(3) must be set less than or equal to 0.  In this
   case apar(6) and apar(7) are used for the attenuation constants, thickness
   and Z if apar(7) is between 1 and 94 and an integer. Also, the broken
   power-law doesn't have a high energy break, but is fixed to the value of
   apar(5)

 MODIFICATION HISTORY:
   ras, 8-March-1995
   Version 2, richard.schwartz@gsfc.nasa.gov, 14-aug-1997, added
   private controls through environment variables
   Version 3, richard.schwartz@gsfc.nasa.gov, 28-oct-1997,
   fixed bug added by private controls, was potentially adding
   attenuation where none was wanted.  Now, for attenuation,
   fixed or variable SPEX_ATTEN must be defined to some value.
   ras, 13-aug-03, call f_vth and f_bpow with energy to preserve 2xN input.
   ras, 29-sep-03, made sure attenuate path is only used by design
     previously apar_use(6:7) were being set to 100 and apar_use(5) because
     this had been designed for low energy work.  Now it's general again.


F_MULTI_THERM $SSW/packages/xray/idl/f_multi_therm.pro
[Previous] [Next]

 NAME:
 		F_MULTI_THERM

 PURPOSE:
 This function returns the photon spectrum seen at the Earth
 for a multithermal model (optically thin thermal bremsstrahlung function,
 normalized to the Sun-Earth distance)
 The differential emission measure can have an exponential or powerlaw dependence on temperature.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = f_multi_therm( eph, a, therm=therm, pow=pow )

 CALLED BY: f_mth_exp_bpow

 CALLS: ***
	Brm_GauLeg, DEFAULT, F_MEXP, F_MPOW, F_THERM_DEM, F_VTH
 INPUTS:
 eph - energy vector in keV, 2N edges or N mean energies
 a -   model parameters defined below
   a(0) = differential emission measure at T = 2 keV in units of 10^49 cm^(-3) keV^(-1)
   a(1) = minimum plasma temperature in keV
   a(2) = maximum plasma temperature in keV
   a(3) = temperature scale length in keV for calculating the differential emission measure
          at temperature T:  DEM(T) = a(0) * exp( (2. - T) / a(3) )
   a(4)  Relative abundance for Iron and Nickel
            Relative to coronal abundance for chianti
            Relative to solar abundance for mewe
           (unless user selects a different abundance table manually)
   If rel_abun keyword is used, apar(4) is set to keyword value.

 KEYWORD INPUTS:
   REL_ABUN - 2x2 array giving Fe, Ni abundance [ 26,x],[28,x] ],  If rel_abun keyword not used,
     the value of x is taken from apar(4) to make 2x2 array.  If that's not there either, x is 1.
   In _extra, can pass /full, /continuum, /lines, /mewe, /chianti keywords (see f_vth)
  EXPONENTIAL  - if set use the exponential dem
  POW - if set use the powerlaw dem, default is to use POW
 OUTPUTS:
 Array of photon fluxes at photon energies determined by eph

 CALLED BY:
	F_MULTI_THERM_EXP, F_MULTI_THERM_POW
 PROCEDURE:
 Thermal bremsstrahlung fluxes are computed by integrating the isothermal bremsstrahlung
 from plasma in the temperature range a(1) (t_min) to a(2) (t_max) with differential
 emission measure DEM(T).  The DEM and bremsstrahlung emissivity are provided in F_THERM_DEM.
 The integration is performed using Gaussian Quadrature.  The Gaussian Quadrature abscissas
 and weights are provided by BRM_GAULEG.

 WRITTEN: Linhui Sui, 2003/08/28

 REVISED: Gordon Holman, 2003/09/04, Enhanced documentation.
 Linhui Sui, 2004/03/04: check a[0] before start computation. If a[0]= 0., then
						  output zero fluxes at all energy bands

 Kim Tolbert, 2004/03/04 - added _extra so won't crash if keyword is used in call
 Kim Tolbert, 2006/03/21 - pass _extra through to f_therm_dem_exp
 Kim, 19-Apr-2006.  Now has 5 params - added abundance (for Fe,Ni) as 5th param.
 18-jul-2006, richard.schwartz@gsfc.nasa.gov; changed () to [] as appropriate
	l, l1, l2 to L, L1, L2 to prevent confusion with 1
	forces all bins with hi edge below 10 keV to be computed each time,
	this prevents bad interaction with chianti_kev_lines which attempts
	to spread narrow lines out over adjacent bins.
	Combined f_multi_therm_exp and f_multi_therm_pow into a single
	procedure differentiated only by the dem function passed through
	to the integrating routine


F_MULTI_THERM_EXP $SSW/packages/xray/idl/f_multi_therm_exp.pro
[Previous] [Next]

 NAME:
 		F_MULTI_THERM_EXP

 PURPOSE:
 This function returns the photon spectrum seen at the Earth
 for a multithermal model (optically thin thermal bremsstrahlung function,
 normalized to the Sun-Earth distance)
 The differential emission measure has an exponential dependence on temperature.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = f_multi_therm_exp( eph, a )

 CALLED BY: f_mth_exp_bpow

 CALLS: ***
	F_MULTI_THERM
 INPUTS:
 eph - energy vector in keV, 2N edges or N mean energies
 a -   model parameters defined below
   a(0) = differential emission measure at T = 2 keV in units of 10^49 cm^(-3) keV^(-1)
   a(1) = minimum plasma temperature in keV
   a(2) = maximum plasma temperature in keV
   a(3) = temperature scale length in keV for calculating the differential emission measure
          at temperature T:  DEM(T) = a(0) * exp( (2. - T) / a(3) )
   a(4)  Relative abundance for Iron and Nickel
            Relative to coronal abundance for chianti
            Relative to solar abundance for mewe
           (unless user selects a different abundance table manually)
   If rel_abun keyword is used, apar(4) is set to keyword value.

 KEYWORD INPUTS:
   REL_ABUN - 2x2 array giving Fe, Ni abundance [ 26,x],[28,x] ],  If rel_abun keyword not used,
     the value of x is taken from apar(4) to make 2x2 array.  If that's not there either, x is 1.
   In _extra, can pass /full, /continuum, /lines, /mewe, /chianti keywords (see f_vth)

 OUTPUTS:
 Array of photon fluxes at photon energies determined by eph

 CALLED BY:
	F_MTH_EXP_BPOW
 PROCEDURE:
 Thermal bremsstrahlung fluxes are computed by integrating the isothermal bremsstrahlung
 from plasma in the temperature range a(1) (t_min) to a(2) (t_max) with differential
 emission measure DEM(T).  The DEM and bremsstrahlung emissivity are provided in F_THERM_DEM_EXP.
 The integration is performed using Gaussian Quadrature.  The Gaussian Quadrature abscissas
 and weights are provided by BRM_GAULEG.

 WRITTEN: Linhui Sui, 2003/08/28

 REVISED: Gordon Holman, 2003/09/04, Enhanced documentation.
 Linhui Sui, 2004/03/04: check a[0] before start computation. If a[0]= 0., then
						  output zero fluxes at all energy bands

 Kim Tolbert, 2004/03/04 - added _extra so won't crash if keyword is used in call
 Kim Tolbert, 2006/03/21 - pass _extra through to f_therm_dem_exp
 Kim, 19-Apr-2006.  Now has 5 params - added abundance (for Fe,Ni) as 5th param.
 18-jul-2006, richard.schwartz@gsfc.nasa.gov; changed () to [] as appropriate
	l, l1, l2 to L, L1, L2 to prevent confusion with 1
	forces all bins with hi edge below 10 keV to be computed each time,
	this prevents bad interaction with chianti_kev_lines which attempts
	to spread narrow lines out over adjacent bins.


F_MULTI_THERM_EXP_DEFAULTS $SSW/packages/spex/idl/object_spex/f_multi_therm_exp_defaults.pro
[Previous] [Next]
 NAME:
	F_MULTI_THERM_EXP_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_multi_therm_exp function.

 CALLING SEQUENCE: defaults = f_multi_therm_exp_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, February 2004
 7-Apr-2006, Kim.  Added fit_comp_spectrum,fit_comp_model
 19-Apr-2006, Kim.  added defaults for 5th param (rel abun)
 13-Jul-2006, Kim.  Default for a[2] maximum changed from 1e4 to 1e1
 13-Nov-2006, Kim.   Default for a[2] maximum changed from 1e1 to 8.


F_MULTI_THERM_POW $SSW/packages/xray/idl/f_multi_therm_pow.pro
[Previous] [Next]

 NAME:
 		F_MULTI_THERM_POW

 PURPOSE:
 This function returns the photon spectrum seen at the Earth
 for a multithermal model (optically thin thermal bremsstrahlung function,
 normalized to the Sun-Earth distance)
 The differential emission measure has a power-law dependence on temperature.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = f_multi_therm_pow( eph, a )

 CALLED BY: f_mth_pow_bpow

 CALLS: ***
	F_MULTI_THERM
 INPUTS:
 eph - energy vector in keV, 2N edges or N mean energies
 a -   model parameters defined below
   a(0) = differential emission measure at T = 2 keV in units of 10^49 cm^(-3) keV^(-1)
   a(1) = minimum plasma temperature in keV
   a(2) = maximum plasma temperature in keV
   a(3) = power-law index for calculating the differential emission measure at temperature T:
          DEM(T) = a(0) * (2./T)^a(3)
   a(4)  Relative abundance for Iron and Nickel
            Relative to coronal abundance for chianti
            Relative to solar abundance for mewe
           (unless user selects a different abundance table manually)
   If rel_abun keyword is used, apar(4) is set to keyword value.

 KEYWORD INPUTS:
   REL_ABUN - 2x2 array giving Fe, Ni abundance [ 26,x],[28,x] ],  If rel_abun keyword not used,
     the value of x is taken from apar(4) to make 2x2 array.  If that's not there either, x is 1.
   In _extra, can pass /full, /continuum, /lines, /mewe, /chianti keywords (see f_vth)

 OUTPUTS:
 Array of photon fluxes at photon energies determined by eph

 CALLED BY:
	F_MTH_POW_BPOW
 PROCEDURE:
 Thermal bremsstrahlung fluxes are computed by integrating the isothermal bremsstrahlung
 from plasma in the temperature range a(1) (t_min) to a(2) (t_max) with differential
 emission measure DEM(T).  The DEM and bremsstrahlung emissivity are provided in F_THERM_DEM_POW.
 The integration is performed using Gaussian Quadrature.  The Gaussian Quadrature abscissas
 and weights are provided by BRM_GAULEG.

 WRITTEN: Linhui Sui, 2003/08/28

 REVISED: Gordon Holman, 2003/09/04, Enhanced documentation.
 Linhui Sui, 2004/03/04: check a[0] before start computation. If a[0]= 0., then
						  output zero fluxes at all energy bands

 Kim Tolbert, 2004/03/04 - added _extra so won't crash if keyword is used in call
 Kim Tolbert, 2006/03/21 - pass _extra through to f_therm_dem_pow
 Kim, 19-Apr-2006.  Now has 5 params - added abundance (for Fe,Ni) as 5th param.
 18-jul-2006, richard.schwartz@gsfc.nasa.gov; changed () to [] as appropriate
	l, l1, l2 to L, L1, L2 to prevent confusion with 1
	forces all bins with hi edge below 10 keV to be computed each time,
	this prevents bad interaction with chianti_kev_lines which attempts
	to spread narrow lines out over adjacent bins.


F_MULTI_THERM_POW_DEFAULTS $SSW/packages/spex/idl/object_spex/f_multi_therm_pow_defaults.pro
[Previous] [Next]
 NAME:
	F_MULTI_THERM_POW_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_multi_therm_pow function.

 CALLING SEQUENCE: defaults = f_multi_therm_pow_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, February 2004
 7-Apr-2006, Kim.  Added fit_comp_spectrum,fit_comp_model
 19-Apr-2006, Kim.  added defaults for 5th param (rel abun)
 13-Jul-2006, Kim.  Default for a[2] maximum changed from 1e4 to 1e1
 6-Sep-2006, Kim.   Default for a[2] maximum changed from 1e4 to 8.


F_NLINE $SSW/packages/xray/idl/f_nline.pro
[Previous] [Next]
 NAME:
   F_NLINE

 PURPOSE:
   Calculate the sum of several normalized gaussian functions, based
   on the input parameter vector.

 CALLING SEQUENCE:
   result = f_nline( energy_bins, [1e3,250.,15.,1e4,400.,10.], nline=nline )

 INPUTS:
   energy_bins - energy values on which the function is evaluated.  If a 2 x N
       array, the e[0,*] are the lower bounds and the e[1,*] are the
       upper bounds of the bins, and the mean values are calculated.
   parameters - vector of line parameters:
     The index i varies from 0 to the number of lines-1, where the number of
     lines is equal to the number of input parameters divided by 3.
     parameters[i*3]   - amplitudes of gaussian lines.
     parameters[i*3+1] - centroids of gaussian lines.
     paramaters[i*3+2] - sigmas of gaussian lines.

 OUTPUTS:
   result - sum of the gaussian lines.

 OUTPUT KEYWORDS:
   NLINE - number of gaussian lines used in the calculation.

 CALLS: ***
	F_DIV, F_GAUSS_INTG [1], F_GAUSS_INTG [2], GAUSSIAN
 CALLED BY:
	EVAL_LINE_COMPLEX, F_BPOS_NLINE, F_NUCLEAR, F_VTHC_BPOW_NLINE
 MODIFICATION HISTORY:
  Paul Bilodeau, 5-nov-2002 - replaced gaussian with f_gauss_intg


F_NUCLEAR $SSW/packages/xray/idl/f_nuclear.pro
[Previous] [Next]
 NAME:
	F_NUCLEAR

 PURPOSE:
	This function returns a template nuclear line spectral model
	including independent broken power-law, 2230 keV line, and 511
	keV line.

 CATEGORY:
	XRAY, GAMMA_RAYS, SPECTRUM, SPEX

 CALLING SEQUENCE:  spectrum = f_nuclear( ekev, par)

 CALLS: ***
	F_BPOW, F_DIV, F_NLINE, F_NUCLEAR_TABLE, F_POSITRONIUM, INTERP2INTEG, LINE_COMPLEX
	NUCLEAR_TABLE_LOAD, edge_products, printx [1], printx [2]
 INPUTS:
   ekev - photon energies in keV, 2xN, upper and lower energy
          bounds for N channels

   parameters  - model parameters:
       parameters[0] - nuclear line template flux, normalized to 1
                photon/cm2, from file 'nuclear_template.sav'
       parameters[1] - Annihilation line  flux, normalized to 1 photon/cm^2
       parameters[2] - Positronium flux
       parameters[3] - Annihilation line sigma
       parameters[4] - Annihilation line centroid
       parameters[5] - 2.223 MeV line flux, normalized to 1 photon/cm^2
       parameters[6] - 2.223 MeV line centroid
       parameters[7] - 2.223 MeV sigma
       parameters[8->8+ntemp-1] - flux values for line templates,
                       normalized to 1 photon/cm^2.  Number of
                       parameters ( ntemp ) is number of line
                       templates defined in LINE_COMPLEX_COM.
       parameters[8+ntemp -> 8+ntemp+5 ] - f_bpow parameters
       parameters[8+ntemp] - normalization, flux at Epivot (Epivot defaults
                       to 50 keV - see function_com.pro)
       parameters[8+ntemp+1] - power law index below break energy
       parameters[8+ntemp+2] - break energy
       parameters[8+ntemp+3] - power law index above break energy
       parameters[8+ntemp+4] - low energy cutoff
       parameters[8+ntemp+5] - power law index below low energy
                        cutoff, 1<Eco<2, default value is 1.5

 If the break energy is set to zero, the break is ignored and the power
 law is calculated over the full range.

 OUTPUTS:
  flux - photons/cm2/keV for each bin

 OUTPUT KEYWORDS:
  N_LINE - Number of line templates in LINE_COMPLEX_COM
  ERROR - Set to [ 0 / 1 ] if an error [ did not / did ] occur.

 KEYWORDS:
  Any additional keywords are passed by reference to LINE_COMPLEX.

 COMMON BLOCKS:
 F_NUCLEAR_COM

 MODIFICATION HISTORY:
	ras, 17-jun-94, based on line template from Ron Murphy and Gerry Share
	Version 2, ras, 6-oct-94
	Version 3, ras, 8-apr-97, add SSWDB_XRAY to data file search.
       Version 4, richard.schwartz@gsfc.nasa.gov, 24-jul-1997,
       removed PERM_DATA.
 	31-May-2001, Paul Bilodeau - now accepts 1 or 2-d arrays of
       energy bounds for input. First element of enucl read in from
       template file is at least 1.001 keV.
 	14-June-2001, Paul Bilodeau - added positronium component and
       two gaussian complexes.  Reorganzied list of parameters.
 	15-June-2001, Paul Bilodeau - added GAUSS_TEMPLATE keyword.
       19-August-2002, Paul Bilodeau - Rewrote to use line_complex
         code, changed keywords and keyword handling,  and updated
         documentation.
       30-sep-2002, Paul Bilodeau - changed from posit_wfrac to
         f_positronium.  Allow annihilation line (511 keV) centroid
         as a parameter to facilitate fitting.
       12-nov-2002, Paul Bilodeau and RAS, use interp2integ for
         nuclear_template.sav rebinning.
	13-nov-02, ras, protect against negative extension of
	extrapolation
       27-nov-2002, Paul.Bilodeau@gsfc.nasa.gov - fix doc error
          regarding 2.223 MeV line width and update positronium line
          width description.
	mar-2006, ras, broke out f_nuclear_table to support newest nuclear_table_load.pro


f_pileup_mod $SSW/packages/spex/idl/object_spex/f_pileup_mod.pro
[Previous] [Next]
Name:
   f_pileup_mod
PURPOSE:
   This pseudo function always returns an array of 0s.  Parameters are varied
   during fit and used to add pileup effects to the model on the fly.



CATEGORY:
   SPECTRA, XRAY

INPUTS:
   E  energy vector in keV, 2XN edges or N mean energies
   apar(0)  FWHM fraction
   apar(1)  gain offset
   apar(2)  center thickness ratio

 Written: Kim Tolbert, 27-Jun-2006
 CALLS:


f_pileup_mod_defaults $SSW/packages/spex/idl/object_spex/f_pileup_mod_defaults.pro
[Previous] [Next]
 NAME:
	f_pileup_mod_defaults

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting with pileup_mod function.  pileup_mod is a pseudo function - the function
   value is always 0., but the params are used to add pileup effects to the model.

 CALLING SEQUENCE: defaults = f_pileup_mod_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, 6-Oct-2006
 11-Oct-2006, Kim.  Added 3rd parameter (smoothing)
 15-Oct-2006, Kim.  Added 4th parameter (multiplicative factor)


F_POSIT_WFRAC $SSW/packages/xray/idl/f_posit_wfrac.pro
[Previous] [Next]
 NAME:
   F_POSIT_WFRAC

 PURPOSE:
   Function wrapper for posit_wfrac procedure.  Calculates 511 keV
   line with positronium continuum.

 CALLING SEQUENCE:
   result = f_posit_wfrac( energy_bins, parameters )

 INPUTS:
   e - energy bins on which the function is evaluated.  If a vector,
       these are interpreted as the mean values of the bins and the
       bins are calculated to be the mean values plus or minus the
       widths of the bins.  If a 2 x N array, the e[0,*] are the
       lower bounds and the e[1,*] are the upper bounds.
   a - vector of parameters:
     a[0] - 511 keV line flux
     a[2] - Positronium continuum fraction
     a[3] - 511 keV line sigma
     a[4] - 511 keV centroid
 OUTPUTS:
   result - 511 line with positronium continuum.

 RESTRICTIONS:
   If e is a vector input, the minimum bin boundary value will be at
   least 1e-20.  Negative or zero energy values are not allowed in
   this case.  If e is a 2 x N array, no such check is performed.

 CALLS: ***
	POSIT_WFRAC


F_POSITRONIUM $SSW/packages/xray/idl/f_positronium.pro
[Previous] [Next]
 NAME:
   F_POSITRONIUM

 PURPOSE:
   Function wrapper for positronium procedure.  Calculates 511 keV
   line with positronium continuum.

 CALLING SEQUENCE:
   result = f_positronium( energy_bins, parameters )

 INPUTS:
   energy_bins - energy bins on which the function is evaluated.  If a vector,
       these are interpreted as the mean values of the bins and the
       bins are calculated to be the mean values plus or minus the
       widths of the bins.  If a 2 x N array, the e[0,*] are the
       lower bounds and the e[1,*] are the upper bounds.
   parameters - vector of parameters:
     parameters[0] - Annihilation line flux
     parameters[1] - Positronium continuum flux
     parameters[2] - Annihilation line sigma
     parameters[3] - Annihilation line centroid

 OUTPUTS:
   positronium_spectrum - Annihilation line with positronium continuum.

 CALLS: ***
	POSITRONIUM, edge_products
 CALLED BY
	F_BPOS_NLINE, F_NUCLEAR


F_POW $SSW/packages/xray/idl/f_pow.pro
[Previous] [Next]
 NAME:
	F_POW

 PURPOSE: power-law function

 CALLING SEQUENCE: result = f_pow(x, a)

 CATEGORY: SPEX, spectral fitting

 INPUTS:
	x - independent variable, nominally energy in keV under SPEX
	    if a 2xN array is passed, these are interpreted as edges
	    and the value is calculated at the arithmetic mean
	a - parameters describing the broken power-law
	a(0) - normalization at epivot, photon flux of first power-law
	       at epivot
	a(1) - negative power law index
 OPTIONAL INPUTS:

 OUTPUTS:
	result of function, a power law
 OPTIONAL OUTPUTS:

 PROCEDURE:

 CALLS: ***
	CHECKVAR [1], F_DIV, checkvar [2], edge_products
 COMMON BLOCKS:
	none

 RESTRICTIONS: power-law cannot be flatter then x^(-.01)

 MODIFICATION HISTORY:
	ras, 3-OCT-2001


F_TH_DEFAULTS $SSW/packages/spex/idl/object_spex/f_vth_defaults.pro
[Previous] [Next]
 NAME:
	F_TH_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_th function.

 CALLING SEQUENCE: defaults = f_th_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 CALLS: ***
	F_VTH_DEFAULTS
 MODIFICATION HISTORY:
 Kim Tolbert, February 2006
 7-Apr-2006, Kim.  Added fit_comp_spectrum,fit_comp_model
 19-Apr-2006, Kim.  added defaults for 3rd param (rel abun)
 13-Nov-2006, Kim.  Default for a[1] (temp) changed from 5e1 to 8.


F_TH_NT $SSW/packages/xray/idl/f_th_nt.pro
[Previous] [Next]
 PROJECT: SDAC

 NAME:
      F_TH_NT 
 PURPOSE:
	Function to call Steve Benka's XSPEC FORTRAN program to calculate 
	thermal/non-thermal X-ray spectra.
	The fortran program has been altered to use an approximation to one 
	of the integrals in the original code.
	The approximation is good from 10-600 keV. For other photon energies
	the code returns a value of zero
 CALLING SEQUENCE:
	Result = f_th_nt(e,param)
 INPUTS:
       e = array of x-ray energy values
	param = 5 element array of spectral paramters:
	    param(0): Emission Measure  (1e49 cm^(-3))
	    param(1): Temperature (keV)
	    param(2): Area of thick target times the density of thermal
		      electrons in the current sheet (1e25 cm^(-1))
	    param(3): Critical energy for run-away electron production (keV)
	    param(4): High energy cut-off for runaway electrons (keV) 
	
 OUTPUTS:
	Result = Thermal/non-thermal spectra in floating point array 
     		 of same length as e
 KEYWORDS: 
	FullRes: Do the calculation with full energy resolution. If not
		 set by this keyword or with the common block, the calculation
		 is done with lower resolution and the value at the input
		 energies are determined by bilinear extrapolation. 
 CALLS: ***
	CHKARG, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], concat_dir [4]
	edge_products, set_logenv [1], set_logenv [2]
 COMMON BLOCKS:
	EnResCom - contains LowRes which controls whether the calculation
		   is done for all the given energy points (LowRes =1 -> No).
 SIDE EFFECTS:
	None.
 RESTRICTIONS:
	The files f_th_nt.exe and kernal.dat must be accesable
 PROCEDURE:
       Param parameters are assigned to variables, which are then entered
		into a call_external of the F_TH_NT FORTRAN code.	
 MODIFICATION HISTORY:
	Written by Terry Kucera, Aug. 1994
	Parameter representing AREA now AREA_DENS in units of 1e25/cm. 
	There is no longer an input for the length of the current sheet. 
								TAK 10/6/94
	Changes made in the way the low-resolution energies are calculated
	to fix problem at high energies. Also made improvement in
	approximations in fortran program. There may be some differences
	in the resulting fits.					TAK 12/5/94 
       Decreased lower bound of approximation to 1 keV, for purposes of
	deconvolution. Withing SPEX function should still be used only
	in range 10-600 keV.					TAK 2/19/95 
	Made code relocatable anywhere in !path, 		RAS 3/06/96
	Version 2, ras, 21-May-1996, transportable to Unix and Windows if
	executable is compiled.
	Version 3, ras, 8-Apr-1997, changed setlog and setenv to set_logenv


F_THERM_DEM_EXP $SSW/packages/xray/idl/f_therm_dem_exp.pro
[Previous] [Next]

 NAME:
 		F_THERM_DEM_EXP

 PURPOSE:
 This function returns the differential photon spectrum at the Earth, d(Flux)(eph)/dt,
 from plasma with temperature t.
 The differential emission measure has an exponential dependence on temperature.
 This is the integrand for the numerical integration in F_MULTI_THERM_EXP.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = F_THERM_DEM_EXP(eph, t, emission, alpha)

 CALLED BY: f_multi_therm_exp

 CALLS: ***
	F_VTH
 INPUTS:
       eph -      array of photon energies or energy bands in keV
       t -        temperature in keV
       emission - differential emission measure (DEM) at t = 2 keV
       alpha -    exponential decay scale in keV for computation of
                  DEM(t) = a(0) * exp( (2. - t)/alpha )
 KEYWORD INPUTS:
       rel_abun - relative abundance (see f_vth)


 WRITTEN: Linhui Sui, 2003/08/28

 REVISED: Gordon Holman, 2003/09/04, Expanded documentation.
 10-Mar-2006, Kim Tolbert.  Added _extra keyword so chianti/mewe and cont/lines keyword
   will get passed into f_vth
 24-mar-2006, richard.schwartz@gsfc.nasa.gov, revised
   to take advantage of new vector temperature feature
   of F_vth
 19-Apr-2006, Kim.  call f_vth with t in multi_temp keyword, and with rel_abun keyword


F_THERM_DEM_POW $SSW/packages/xray/idl/f_therm_dem_pow.pro
[Previous] [Next]

 NAME:
 		F_THERM_DEM_POW

 PURPOSE:
 This function returns the differential photon spectrum at the Earth, d(Flux)(eph)/dt,
 from plasma with temperature t.
 The differential emission measure has a power-law dependence on temperature.
 This is the integrand for the numerical integration in F_MULTI_THERM_POW.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = F_THERM_DEM_POW(eph, t, emission, alpha)

 CALLED BY: f_multi_therm_pow

 CALLS: ***
	F_VTH
 INPUTS:
       eph -      array of photon energies or energy bands in keV
       t -        temperature in keV
       emission - differential emission measure (DEM) at t = 2 keV
       alpha -    power-law index for computation of DEM(t) = a(0) * (2./t)^(alpha)
 KEYWORD INPUTS:
       rel_abun - relative abundance (see f_vth)


 WRITTEN: Linhui Sui, 2003/08/28

 REVISED: Gordon Holman, 2003/09/04, Expanded documentation.
 10-Mar-2006, Kim Tolbert.  Added _extra keyword so chianti/mewe and cont/lines keyword
   will get passed into f_vth
 24-mar-2006, richard.schwartz@gsfc.nasa.gov, revised
   to take advantage of new vector temperature feature
   of F_vth
 19-Apr-2006, Kim.  call f_vth with t in multi_temp keyword, and with rel_abun keyword


F_THICK $SSW/packages/xray/idl/f_thick.pro
[Previous] [Next]

 NAME: F_THICK

 PURPOSE: This function returns ?

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = F_THICK( E, A )

 CALLS: ***
	f_vth_thick
 INPUTS:
 E -energy vector in keV, 2XN edges or N mean energies
 A -model parameters defined below
   a(0) - Total integrated electron flux, in units of 10^35 electrons sec^-1.
   a(1) - Power-law index of the electron distribution function below
          eebrk.
   a(2) - Break energy in the electron distribution function (in keV)
   a(3) - Power-law index of the electron distribution function above
          eebrk.
   a(4) - Low energy cutoff in the electron distribution function
          (in keV).
   a(5) - High energy cutoff in the electron distribution function (in keV).

 MODIFICATION HISTORY:
 Kim Tolbert 24-Mar-2004
 2004/12/02, Kim    update the documentation


F_THICK_DEFAULTS $SSW/packages/spex/idl/object_spex/f_thick_defaults.pro
[Previous] [Next]
 NAME:
	F_THICK_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_thick function.

 CALLING SEQUENCE: defaults = f_thick_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, February 2004


F_THIN $SSW/packages/xray/idl/f_thin.pro
[Previous] [Next]

 NAME: F_THIN

 PURPOSE: This function returns ?

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = F_THIN( E, A )

 CALLS: ***
	F_VTH_THIN
 INPUTS:
 E -energy vector in keV, 2XN edges or N mean energies
 A -model parameters defined below
   a(0) - normalization factor in units of 1.0d55 cm-2 sec-1,
             i.e. plasma density * volume of source * integrated nonthermal electron flux density
   a(1) - Power-law index of the electron distribution function below
          eebrk.
   a(2) - Break energy in the electron distribution function (in keV)
   a(3) - Power-law index of the electron distribution function above
          eebrk.
   a(4) - Low energy cutoff in the electron distribution function
          (in keV).
   a(5) - High energy cutoff in the electron distribution function (in keV).

 MODIFICATION HISTORY:
 Kim Tolbert 24-Mar-2004


F_THIN_DEFAULTS $SSW/packages/spex/idl/object_spex/f_thin_defaults.pro
[Previous] [Next]
 NAME:
	F_THIN_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_thin function.

 CALLING SEQUENCE: defaults = f_thin_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, February 2004


F_VTH $SSW/packages/xray/idl/f_vth.pro
[Previous] [Next]
Name:
   F_VTH
PURPOSE:
   This function returns the optically thin thermal bremsstrahlung radiation function
   as differential spectrum seen at Earth in units of photon/(cm2 s keV)

CATEGORY:
   SPECTRA, XRAYS (>1 keV)
INPUTS:
   E  energy vector in keV
   apar(0)  em_49, emission measure units of 10^49
   apar(1)  KT, plasma temperature in keV
   apar(2)  Relative abundance for Iron and Nickel
            Relative to coronal abundance for Chianti
            Relative to solar abundance for Mewe
           (unless user selects a different abundance table manually)
   If vth for multiple temperatures is desired, pass an array of temperatures through
   multi_temp keyword.  apar[1] will be ignored in this case.
   If rel_abun keyword is used, apar[2] is set to keyword value.

KEYWORD INPUTS:
   LINES - Only return lines
   CONTINUUM - Only return continuum (same as setting NOLINE keyword)
   NOLINE - Only return continuum
   CHIANTI - If set, use chianti_kev
   MEWE - If set, use mewe_kev
   REL_ABUN - 2x2 array giving Fe, Ni abundance [ 26,x],[28,x] ],  If rel_abun keyword not used,
     the value of x is taken from apar(2) to make 2x2 array.  If that's not there either, x is 1.

   Defaults are to return full spectrum (lines+continuum), chianti

CALLS: ***
	BREM_49, EXIST, GET_EDGES, MK_CONTIGUOUS
 CALLED BY:
	F_MULTI_SPEC, F_MULTI_THERM, F_THERM_DEM_EXP, F_THERM_DEM_POW, F_VTHC_BPOW_NLINE
	F_VTH_ION, F_VTH_NOLINE
	Flux model of a thermal bremsstrahlung plus broken powerlaw
	Flux model of thermal bremsstrahlung plus thintarget broken, f_vth_thick
Common Blocks:
   None

Method:
   If energy array starts at gt 8 keV, then noline is set to calc pure
     free-free continuum from either chianti_kev or mewe_kev.
   If edges weren't passed as 2xn array, use Brem_49 function.

 History:
   ras, 17-may-94
   ras, 14-may-96, checked for 2xn energies, e
   Version 3, 23-oct-1996, revised check for 2xn energies, e
   ras, 10-apr-2002, ras, default to vlth() when bottom energy
   is less than 8 keV.
   ras, 2-may-2003, support relative abundance pass through to mewe_kev
     call mewe_kev directly, no longer uses interpolation table in vlth.pro
   ras, 25-jun-2003, added NOLINE keyword passed through to mewe_kev
   Kim Tolbert, 2004/03/04 - added _extra so won't crash if keyword is used in call
   ras, 31-aug-2005, modified to allow calls to chianti_kev via VTH_METHOD environment var.
   Kim Tolbert, 10-Mar-2006.  removed f_vth_funct keyword, added chianti, mewe, lines,
     and continuum keywords.  Chianti is now the default.
   ras 24-mar-2006, support call with multiple temperatures (used in dem integration)
     through extension of apar.  apar[1:*] is the temperature array
   Kim, 4-Apr-2006, merged ras 24-mar changes with 10-mar changes.
     Also fixed bug: transpose result if mewe *AND* multi temp.
     Also, if brem_49 is called, it didn't handle multi temp, so loop through temps
     Now brem_49 is only called if e does not have lower/upper edges.  If lowest e is
     > 8., set noline but call mewe_kev or chianti_kev (previously called brem_49)
   Kim, 19-Apr-2006.  Now vth has 3 params - added abundance (for Fe,Ni) as 3rd param.
     Changed RAS multi temp implementation.  Now if multiple temps pass through multi_temp
     keyword.  Also added noline keyword back in for compatibility with spex.



F_VTH_ION $SSW/packages/xray/idl/f_vth_ion.pro
[Previous] [Next]

 NAME:
 F_VTH_ION

 PURPOSE:
 Flux model of a thermal bremsstrahlung plus non-uniform target ionization.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = F_VTH_ION( E, A )

 CALLS: ***
	CHECKVAR [1], F_ION, F_VTH, checkvar [2], edge_products
 INPUTS:
 E -energy vector in keV, 2XN edges or N mean energies
 A -model parameters defined below
 For the thermal function using F_VTH.PRO:
   a(0)= emission measure in units of 10^49 cm-3
   a(1)= KT   plasma temperature in keV

 For the non-uniform target ionization, ION_FIT is used.
   a(2) - normalization
   a(3) - spectral index of the electron flux
   a(4) - Break energy in the electron distribution function (in keV)

 COMMON BLOCKS:
 FUNCTION_COM

 WRITTEN:
   20-nov-2002, Paul.Bilodeau@gsfc.nasa.gov
   26-mar-2003, richard.schwartz@gsfc.nasa.gov - call f_vth with 2xN energy edges.
   4-aug-2004, Kim Tolbert, added _extra keyword


F_VTH_NOLINE $SSW/packages/xray/idl/f_vth_noline.pro
[Previous] [Next]
Name:
	F_VTH_NOLINE
PURPOSE:
	This function returns the thermal continuum (no lines) function
	as differential spectrum seen at Earth in units of photon/(cm2 s keV)

CATEGORY:
	SPECTRA, XRAYS (>1 keV)
INPUTS:
	E	 energy vector in keV
	apar(0)  Emission measure in units of 1e49 cm^(-3)
	apar(1)  KT, plasma temperature in keV

CALLS: ***
	F_VTH
 History:
 Kim, 30-Jan-2004


F_VTH_NOLINE_DEFAULTS $SSW/packages/spex/idl/object_spex/f_vth_noline_defaults.pro
[Previous] [Next]
 NAME:
	F_VTH_NOLINE_DEFAULTS

 PURPOSE: Function to return default values for
   parameters, minimum and maximum range, and free parameter mask when
   fitting to f_vth_noline function.

 CALLING SEQUENCE: defaults = f_vth_noline_defaults()

 INPUTS:
	None
 OUTPUTS:
	Structure containing default values

 MODIFICATION HISTORY:
 Kim Tolbert, February 2004


f_vth_thick $SSW/packages/xray/idl/f_vth_thick.pro
[Previous] [Next]

 NAME: f_vth_thick
 Flux model of a thermal bremsstrahlung plus thick-target broken
 power-law electron distribution function (GHolman)

 PURPOSE:
 This function returns the differential photon spectrum seen at the Earth
 for a two component model comprised of a thermal
 bremsstrahlung function plus a thick-target,
 non-thermal, broken power-law function with low- and high-energy cutoffs.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = F_VTH_THICK( E, A )

 CALLS: ***
	Brm_BremThick, CHECKVAR [1], F_VTH, checkvar [2], edge_products
 INPUTS:
 E -energy vector in keV, 2XN edges or N mean energies
 A -model parameters defined below
 For the thermal function using F_VTH.PRO:
   a(0)= emission measure in units of 10^49 cm-3
   a(1)= KT   plasma temperature in keV
   a(2) - Total integrated electron flux, in units of 10^35 electrons sec^-1.
   a(3) - Power-law index of the electron distribution function below
          a(4) (=eebrk).
   a(4) - Break energy in the electron distribution function (in keV)
   a(5) - Power-law index of the electron distribution function above
          eebrk.
   a(6) - Low-energy cutoff in the electron distribution function
          (in keV).
   a(7) - High-energy cutoff in the electron distribution function (in keV).

 CALLED BY:
	F_THICK
 COMMON BLOCKS:
 FUNCTION_COM

 HISTORY:
 VERSION 1, RAS, ~1991
 VERSION 2, RAS, MAY 1996, FULLY DOCUMENTED
 2002/12/12 Linhui Sui-- fix infinity and nan output
                 and avoid spextra index = 1.
   26-mar-2003, richard.schwartz@gsfc.nasa.gov - call f_vth with 2xN energy edges.
 2003/3/28, Linhui Sui-- in ans expression, change 1.0e25 to 1.0e35 for consistency of
                 change from density distribution to flux distribution
   24-Mar-2004, Kim Tolbert - added no_vth and _extra keywords.  If no_vth set,
     then 6 params are for brm_bremspec, otherwise first two are for vth, next
     six are for brm_bremspec.
 2004/04/16, Linhui Sui, to speed up the fitting with OSPEX, check the normalization factor a[2] or
          a[0] if /no_vth.
          if eq 0 then do not call thick target function brm_bremthick.pro.  Return 0.
 2004/11/09, Kim Tolbert - change Lin's change of 2004/04/16 to return correctly dimensioned
          array of 0's instead of scalar.
 2004/12/02, Linhui Sui    update the documentation


F_VTHC_BPOW_NLINE $SSW/packages/xray/idl/f_vthc_bpow_nline.pro
[Previous] [Next]
 NAME:
   F_VTHC_BPOW_NLINE

 PURPOSE: thermal continuum (nolines) + broken power-law function with/without
   discontinuities in the
   derivatives + gaussian line function

 CALLING SEQUENCE: result = F_VTHC_BPOW_NLINE(x, a)

 INPUTS:
   x - independent variable, nominally energy in keV under SPEX, 2xN
   a - parameters describing the broken power-law and gaussian
     a[6+3n] - integrated line intensity of line n(<3)
     a[7+3n] - line centroid
     a[8+3n] - line sigma

     Thermal Continuum from Mewe_kev
     a[0] - Emission measure in units of 1e49 cm^(-3)
     a[1] - Temperature in keV
     Broken Power Law

       a[2] - normalization at 50 keV (or epivot) of the single powerlaw determined
           by a[2] and a[3].  If Epivot is gt A[4], then the total
           f_bpow function will lay below this normalization point.
     a[3] - negative power law index below break
     a[4] - break energy
     a[5] - negative power law index above break

 OUTPUTS:
   result of function, a broken power law + gaussian line
 OPTIONAL OUTPUTS:

 KEYWORDS:
   NLINE - number of gaussian lines in model, defaults to 5

 CALLED BY:
	F_BPOW_NLINE
 PROCEDURE:

 CALLS: ***
	F_BPOW, F_NLINE, F_VTH
 COMMON BLOCKS:
   F_VTHC_BPOW_NLINE

 RESTRICTIONS:
   when used in SPEX, limited to 8 lines on 21-jan-1996

 MODIFICATION HISTORY:
   ras,  21-jan-1996
   richard.schwartz@gsfc.nasa.gov, 11-jan-2001, support arbitrary number of lines.
   25-jun, richard.schwartz@gsfc.nasa.gov, included thermal continuum
   30-apr-2004, richard.schwartz@gsfc.nasa.gov,
     added documentation about meaning of normalization


FB_RAD_LOSS $SSW/packages/chianti/idl/low_level/fb_rad_loss.pro
[Previous] [Next]
 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics 
       of Astrophysical Plasmas. It is a collaborative project involving 
       the Naval Research Laboratory (USA), the University of Florence 
       (Italy), the University of Cambridge and the Rutherford Appleton 
       Laboratory (UK). 

 NAME:

       FB_RAD_LOSS

 PURPOSE:

       Calculate the total radiative losses of a plasma due to the 
       free-bound (radiative recombination) continuum.

 EXPLANATION

       This routine does not use the same method of calculating the ion 
       continuum emissivities as the FREEBOUND routine. This is because a 
       modified version of FREEBOUND would be very slow for this purpose. 
       Instead, we use the method of Mewe et al. (A&AS 65, 511, 1986) which 
       is outlined in their Sect.2.2. The integration over the quantity 
       P_c(lambda,T) is very simple as the gaunt factor, G_c, has no 
       intrinsic lambda dependence other than through the limits.

       Comparisons between the wavelength-resolved continuum emission 
       derived from the Mewe et al. method with the more sophisticated 
       method employed in FREEBOUND show excellent agreement with at most 
       10% differences at specific wavelengths.

 CALLING SEQUENCE:

      fb_rad_loss, temp, int, min_abund=min_abund, /no_setup

 OUTPUTS

	TEMP    Temperatures (K). These are the temperatures at which the 
               ion fractions are defined (typically 10^4 to 10^8 in 0.1 
               dex intervals).

       INT     The emissivity in units of erg cm^3 s^-1.


 OPTIONAL INPUTS:

       MIN_ABUND Exclude elements whose abundances are less than MIN_ABUND. 
                 (Note that Ab(H)=1.)
	
 KEYWORD PARAMETERS:

	NO_SETUP   If the procedure setup_elements has already been called 
                  then the keyword /nosetup should be set to avoid 
                  repeating this step

 PROGRAMMING NOTES

       This routine computes the free-bound gaunt factor following the 
       prescription set out in Sect.2.2 of Mewe et al. (1986). The 
       expression for f_2 (Eq. 16 of Mewe et al.) contains several 
       quantities that need to be computed. Zeta_0 is computed internally 
       by the function ZETA_0 through a prescription evident from browsing 
       Table I of Mewe et al. Z_0 is computed from the ionization potential 
       of the recombined ion which is contained in the .ip file within the 
       database. The quantity n_0 (also used in deriving Z_0) is derived 
       using the routine CONF2N which extracts the highest n value from 
       the configuration description of the ground term of each ion.

       The quantity Z is just the charge on the recombined ion; E_0 is the 
       ionization potential of the recombined ion, while E_n_0+1 is derived 
       from Mewe's Eq.7 with the prescription that z_n=Z and n=n_0+1.

       The ions that are considered for the continuum are those for which 
       .fblvl files exist.

 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2], READ_FBLVL
	READ_IP, SETUP_ELEMENTS, ZETA_0, ZION2FILENAME, concat_dir [4], file_exist [1]
	file_exist [3], get_ieq
 CALLED BY:
	RAD_LOSS [1], RAD_LOSS [2], ZETA_0
 COMMON BLOCKS:

	common elements,abund,abund_ref,ioneq,ioneq_t,ioneq_ref

 INTERNAL FUNCTIONS

       ZETA_0

 CALLS

       READ_IP,  ZION2FILENAME, SETUP_ELEMENTS, FILE_EXIST,
       READ_FBLVL, CONCAT_DIR, GET_IEQ

 EXAMPLES

       IDL> fb_rad_loss,temp,int
       IDL> plot,temp,int,/xlog,/ylog

 MODIFICATION HISTORY:

     Ver.1, 1-Aug-2002, Peter Young
          Completely new version of fb_rad_loss. Incorporates code from 
          a version of freebound not available in CHIANTI.

       V 2, 25-May-2005, GDZ 
                  corrected routine header.

 VERSION:   2, 25-May-2005


fcount_rate [1] $SSW/packages/spex/idl/original_spex/fcount_rate.pro
[Previous] [Next]
 PROJECT: SDAC

 NAME: fcount_rate


 PURPOSE: Compute the counting rate, counts/cm2/keV, from the response
	   matrix and a photon flux model parameters

 CATEGORY:  SPEX, Spectral analysis, fitting.


 CALLING SEQUENCE: c_rate = fcount_rate( e_in, par)
                

 INPUTS:
	Eout - dummy parameter,  the meaning of these values are represented
	by the detector response matrix drm which is loaded on the initial call.

	Par  - parameters to be used in call to F_MODEL. Par may be a two-dimensional
	array where the first index references a single argument list, and 
	the second references each set.  For example, a thermal model with two
	parameters in the function call and thirty sets of models would be
	dimensioned 2x30 and would return 30 vectors of count rates, where the
	first index would be on the energy axis.

	Ein - photon flux in units of 1/(cm2 s keV), must be 2XN array 
	and must be in a form acceptable by the function in the string F_MODEL
	found in the common block function_com.
	drm  - response matrix which returns the count rate in counts/cm2/sec/keV
	       per unit photon/cm2, saves drm if drm isn't input.
	
 KEYWORD INPUTS:
	WUSE - return count rates for these indices.  If WUSE isn't passed, the
	value is take from SPEX_COMMONS if it exists, otherwise the full output
	vector of drm(i.e. the first index) is used, i.e. wuse=indgen(n_elements(drm(*,0))).
	MODEL - string with name of photon spectral form.
 CALLS: ***
	CHECKVAR [1], FCHECK, Model_components [1], Model_components [2], checkvar [2]
	edge_products, spex_current [1], spex_current [2]
 CALLED BY:
	RUN_CURVEFIT [1], RUN_CURVEFIT [2], spectral_ratio [1], spectral_ratio [2]
 common blocks:
	function_com - contains name of fitting function, f_model
	fcount_rate_com - holds the drm
 Procedure:
	Count rates are generated by obtaining numbers of photons in
	each input band, these are multiplied by the DRM to get the rate.
 Restrictions- to be used inside of SPEX if DRM, EIN, and WUSE aren't supplied.
	       These values are taken using spex_current.pro
		
 MODIFICATION HISTORY: ras, 24 Sept. 1993
	Version 2, Totally revised, richard.schwartz@gsfc.nasa.gov, 18-aug-1997 
	Version 3, richard.schwartz@gsfc.nasa.gov, 28-jan-1998, allow PAR to
	be multiple parameter sets.
	Version 4, richard.schwartz@gsfc.nasa.gov, 10-dec-1998, let model override f_model in common.


fcount_rate [2] $SSW/packages/spex/pre2002/idl/fcount_rate.pro
[Previous] [Next]
 PROJECT: SDAC

 NAME: fcount_rate


 PURPOSE: Compute the counting rate, counts/cm2/keV, from the response
	   matrix and a photon flux model parameters

 CATEGORY:  SPEX, Spectral analysis, fitting.


 CALLING SEQUENCE: c_rate = fcount_rate( e_in, par)
                

 INPUTS:
	Eout - dummy parameter,  the meaning of these values are represented
	by the detector response matrix drm which is loaded on the initial call.

	Par  - parameters to be used in call to F_MODEL. Par may be a two-dimensional
	array where the first index references a single argument list, and 
	the second references each set.  For example, a thermal model with two
	parameters in the function call and thirty sets of models would be
	dimensioned 2x30 and would return 30 vectors of count rates, where the
	first index would be on the energy axis.

	Ein - photon flux in units of 1/(cm2 s keV), must be 2XN array 
	and must be in a form acceptable by the function in the string F_MODEL
	found in the common block function_com.
	drm  - response matrix which returns the count rate in counts/cm2/sec/keV
	       per unit photon/cm2, saves drm if drm isn't input.
	
 KEYWORD INPUTS:
	WUSE - return count rates for these indices.  If WUSE isn't passed, the
	value is take from SPEX_COMMONS if it exists, otherwise the full output
	vector of drm(i.e. the first index) is used, i.e. wuse=indgen(n_elements(drm(*,0))).
	MODEL - string with name of photon spectral form.
 CALLS: ***
	CHECKVAR [1], FCHECK, Model_components [1], Model_components [2], checkvar [2]
	edge_products, spex_current [1], spex_current [2]
 CALLED BY:
	RUN_CURVEFIT [1], RUN_CURVEFIT [2], spectral_ratio [1], spectral_ratio [2]
 common blocks:
	function_com - contains name of fitting function, f_model
	fcount_rate_com - holds the drm
 Procedure:
	Count rates are generated by obtaining numbers of photons in
	each input band, these are multiplied by the DRM to get the rate.
 Restrictions- to be used inside of SPEX if DRM, EIN, and WUSE aren't supplied.
	       These values are taken using spex_current.pro
		
 MODIFICATION HISTORY: ras, 24 Sept. 1993
	Version 2, Totally revised, richard.schwartz@gsfc.nasa.gov, 18-aug-1997 
	Version 3, richard.schwartz@gsfc.nasa.gov, 28-jan-1998, allow PAR to
	be multiple parameter sets.
	Version 4, richard.schwartz@gsfc.nasa.gov, 10-dec-1998, let model override f_model in common.


FF_RAD_LOSS $SSW/packages/chianti/idl/low_level/ff_rad_loss.pro
[Previous] [Next]

 PROJECT:  CHIANTI

       CHIANTI is an atomic database package for the calculation of
       continuum and emission line spectra from astrophysical plasmas. It is a 
       collaborative project involving the Naval Research Laboratory
       (Washington DC, USA), the Arcetri Observatory (Firenze, Italy), and the
       Cambridge University (United Kingdom).

 NAME:
           FF_RAD_LOSS
	

 PURPOSE:

	Calculate the free-free radiative energy losses losses.
       Uses the free-free integrated gaunt factor calculations of 
       Sutherland, 1998, MNRAS, 300, 321


 CALLING SEQUENCE:

      FF_RAD_LOSS,Temperature,LossRate


 INPUTS:



 OPTIONAL INPUTS:

	None
	
 KEYWORD PARAMETERS:

	NO_SETUP:   If the procedure setup_elements has already been called then
                  the keyword /no_setup should be set to avoid repeating this step

       MIN_ABUND:  If set, calculates the continuum only from those elements which 
                   have an abundance greater than min_abund.  Can speed up the 
                   calculations.  For example:
                   abundance (H)  = 1.
                   abundance (He) = 0.085
                   abundance (C)  = 3.3e-4
                   abundance (Si) = 3.3e-5
                   abundance (Fe) = 3.9e-5


 OUTPUTS:

	Temperature:	temperature in degrees Kelvin, can be a 1 D array
       LossRate:       radiative energy loss rate in erg s^-1 cm^3
                       (radiative loss rate per emission measure (N_e N_H V)



 CALLS: ***
	READ_GFFINT, READ_IP, SETUP_ELEMENTS
 CALLED BY:
	RAD_LOSS [1], RAD_LOSS [2]
 COMMON BLOCKS:

	common elements,abund,abund_ref,ioneq,ioneq_t,ioneq_ref



 EXAMPLE:

             > ff_rad_loss,t,rad
             > ff_rad_loss,t,rad,min_abund=3.e-5
             > ff_rad_loss,t,rad,/no_setup,min_abund=1.e-6


 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	April 2000:     Version 3.0


FIELDLINE $SSW/packages/ztools/magnetic/fieldline.pro
[Previous] [Next]
 NAME:
	FIELDLINE

 PURPOSE
	Given a set of magnetic planes from the local_mag_extrap routine
	and a starting location, extrapolate a single fieldline 
	until you hit a null point, a singularity, or the edge of the
	integration box.  Return a list of coordinates of vertices on the
	fieldline.

 CALLING SEQUENCE
	line = fieldline(xyz,cube,ind,func)

 INPUTS
	CUBE - Some magnetic setup data to be fed to FUNCTION
	IND -  Some ancillary data to be fed to FUNCTION
	XYZ - a 3-vector with a starting point

 KEYWORD INPUTS:
	BOUNDS - upper bound on x, y, and z (lower bound of each is 0).
		(default is the size of the input box, up to the maximum 
		altitude in the "Z" array)
 KEYWORD OUTPUTS:
	SLIST - Returns a list of the step numbers at which printing happened
	TLIST - Returns a list of the parametrized times at which printing 
		happened.
	PLIST - Returns the vertices.

 RETURNS
	a 3xN array containing a list of vertices along the 
	extrapolated fieldline.
 
 METHOD
	Just uses RK4 to step the thing...

 HISTORY
	Written 16-19 Apr 1999, Craig DeForest
 CALLS:


FILE_SEARCHER [1] $SSW/packages/spex/idl/original_spex/file_searcher.pro
[Previous] [Next]

 NAME: FILE_SEARCHER


 PURPOSE: Look for files satisfying passed directory and filename strings,
	   Find file or files satisfying passed strings, and let user select filename
	   of choice.  Passed strings may also be a set of templates using wildcards
	   and replacement values

 CATEGORY: i/o


 CALLING SEQUENCE: file_searcher, templates=templates, wildcard=wildcard, spex_test_dir=spex_test_dir, $
	inserts=inserts, out_fname=out_fname, out_dir=out_dir, nointeract=nointeract

 CALLED BY: SPEX menu
	

 CALLS TO:
	BUILD_FNAME, LOC_FILE, XSEL_LIST, PRINTX

 INPUTS:
	templates - possible formats for filename including wildcards for
		    substitution (see build_fname.pro)
	spex_test_dir  - directory(ies) to be combined with templates using concat_dir
	(see build_fname.pro for explanations of the following optional arguments)
	wildcard  - string to be substituted for in templates
	inserts   - substitution strings for wildcard in templates for test_file
	/nointeract- if set, then user is NOT asked to select if multiple files are found.

 OUTPUTS:
	Files - files found satisfying inputs.
 KEYWORDS:
       out_fname - filename satisfying input specification, '' if none
       out_dir   - directory satisfying input specification, '' if none

 CALLED BY:
	Run_FILE_SEARCH [1], Run_FILE_SEARCH [2], batse_file_search [1]
	batse_file_search [2]
 PROCEDURE: uses build_fname and findfile to test strings in filename searches.
	     if more than one is returned, requests the user to specify interactively.
            If templates are passed, then they are checked first before test_file and spex_test_dir
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], BUILD_FNAME [1], BUILD_FNAME [2]
	CHECKVAR [1], EMENU, F_USE_WIDGET, LOC_FILE [1], LOC_FILE [2], LOC_FILE [3]
	XSEL_LIST [1], XSEL_LIST [2], break_file [4], checkvar [2], printx [1], printx [2]
	uniqo [1], uniqo [2]
 RESTRICTIONS:
	Developed for SPEX, but being modified for general usage.
 MODIFICATION HISTORY:
	Version 1, ras, 1992
	Version 5?, ras, 18-oct-1996, using loc_file and xsel_list
	Version 6, richard.schwartz@gsfc.nasa.gov, don't select unless there are
	really 2 or more files.
	Version 7, richard.schwartz@gsfc.nasa.gov, fix conflict with test_dir()


FILE_SEARCHER [2] $SSW/packages/spex/pre2002/idl/file_searcher.pro
[Previous] [Next]

 NAME: FILE_SEARCHER


 PURPOSE: Look for files satisfying passed directory and filename strings,
	   Find file or files satisfying passed strings, and let user select filename
	   of choice.  Passed strings may also be a set of templates using wildcards
	   and replacement values

 CATEGORY: i/o


 CALLING SEQUENCE: file_searcher, templates=templates, wildcard=wildcard, spex_test_dir=spex_test_dir, $
	inserts=inserts, out_fname=out_fname, out_dir=out_dir, nointeract=nointeract

 CALLED BY: SPEX menu
	

 CALLS TO:
	BUILD_FNAME, LOC_FILE, XSEL_LIST, PRINTX

 INPUTS:
	templates - possible formats for filename including wildcards for
		    substitution (see build_fname.pro)
	spex_test_dir  - directory(ies) to be combined with templates using concat_dir
	(see build_fname.pro for explanations of the following optional arguments)
	wildcard  - string to be substituted for in templates
	inserts   - substitution strings for wildcard in templates for test_file
	/nointeract- if set, then user is NOT asked to select if multiple files are found.

 OUTPUTS:
	Files - files found satisfying inputs.
 KEYWORDS:
       out_fname - filename satisfying input specification, '' if none
       out_dir   - directory satisfying input specification, '' if none

 CALLED BY:
	Run_FILE_SEARCH [1], Run_FILE_SEARCH [2], batse_file_search [1]
	batse_file_search [2]
 PROCEDURE: uses build_fname and findfile to test strings in filename searches.
	     if more than one is returned, requests the user to specify interactively.
            If templates are passed, then they are checked first before test_file and spex_test_dir
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], BUILD_FNAME [1], BUILD_FNAME [2]
	CHECKVAR [1], EMENU, F_USE_WIDGET, LOC_FILE [1], LOC_FILE [2], LOC_FILE [3]
	XSEL_LIST [1], XSEL_LIST [2], break_file [4], checkvar [2], printx [1], printx [2]
	uniqo [1], uniqo [2]
 RESTRICTIONS:
	Developed for SPEX, but being modified for general usage.
 MODIFICATION HISTORY:
	Version 1, ras, 1992
	Version 5?, ras, 18-oct-1996, using loc_file and xsel_list
	Version 6, richard.schwartz@gsfc.nasa.gov, don't select unless there are
	really 2 or more files.
	Version 7, richard.schwartz@gsfc.nasa.gov, fix conflict with test_dir()


find_contig [2] $SSW/packages/lparl/idl/ucon/morrison/get_pks.pro
[Previous] [Next]
NAME:
	find_contig
PURPOSE:
	Find the contiguous subscripts.  Used for finding
	unique peaks.
METHOD:
	Return the first subscript

	a = [4,5,6,  10,  21,22]  returns [4,10,21]
	a = [1,    10,    30]     returns [1,10,30]
	a = [1,2,3,4]		  returns [1]
	a = 10			  returns 10
 CALLS: ***
	GAUSSFIT3, GAUSS_FUNCT3, deriv_arr [1], deriv_arr [2], get_pks, plottimes [1]
	plottimes [2]
 CALLED BY:
	SPEX__DEFINE, get_pks
HISTORY:
	Written 29-Jul-97 by M.Morrison


find_launchpoints $SSW/packages/ztools/magnetic/older/find_launchpoints.pro
[Previous] [Next]
 NAME:
	find_launchpoints
 PURPOSE:
	Find the places (near dipole sources) from whence to launch 
	field lines.
 CALLING SEQUENCE:
	launchlist = find_launchpoints(dloc,m,n=n,r=r)
 INPUTS:
	dloc -- the 3-coordinates ofthe dipoles -- a (3xn) array.
	m    -- the dipoles' magnetic moment vectors
 KEYWORD INPUTS:
	n - the number of field lines overall
	r - if specified, this is the radius from each dipole from which
		fieldlines should be launched.
 RETURNS:
	a 3xN array of launchpoints that are close to the dipoles.  
	In this case, N is only "about equal" to n, because of the 
	integer nature of fieldlines.

 LIMITATIONS:
	At the moment, only launches fieldlines on the outbound side of the
	dipoles.  This should be fixed.
 AUTHOR: 
	Craig DeForest
 CALLS: ***
	CROSS, ISVALID [1], ISVALID [2], ISVALID [3], NLM [1], NLM [2], normal
 HISTORY:
	Written 16-Dec-97


findex $SSW/packages/chianti/idl/low_level/findex.pro
[Previous] [Next]
 ROUTINE:  findex

 PURPOSE:  Compute "floating point index" into a table using binary
           search.  The resulting output may be used with INTERPOLATE.

 USEAGE:   result = findex(u,v)

 INPUT:    
   u       a monitically increasing or decreasing 1-D grid
   v       a scalor, or array of values

 OUTPUT:
   result  Floating point index. Integer part of RESULT(i) gives
           the index into to U such that V(i) is between
           U(RESULT(i)) and U(RESULT(i)+1).  The fractional part
           is the weighting factor

                          V(i)-U(RESULT(i))
                          ---------------------
                     U(RESULT(i)+1)-U(RESULT(i))


 DISCUSSION: 
           This routine is used to expedite one dimensional
           interpolation on irregular 1-d grids.  Using this routine
           with INTERPOLATE is much faster then IDL's INTERPOL
           procedure because it uses a binary instead of linear
           search algorithm.  The speedup is even more dramatic when
           the same independent variable (V) and grid (U) are used
           for several dependent variable interpolations.

  
 CALLED BY:
	rebinw
 EXAMPLE:  

; In this example I found the FINDEX + INTERPOLATE combination
; to be about 60 times faster then INTERPOL.

  u=randomu(iseed,200000) & u=u(sort(u))
  v=randomu(iseed,10)     & v=v(sort(v))
  y=randomu(iseed,200000) & y=y(sort(y))

  t=systime(1) & y1=interpolate(y,findex(u,v)) & print,systime(1)-t
  t=systime(1) & y2=interpol(y,u,v)            & print,systime(1)-t
  print,f='(3(a,10f7.4/))','findex:   ',y1,'interpol: ',y2,'diff:     ',y1-y2

 AUTHOR:   Paul Ricchiazzi                        21 Feb 97
           Institute for Computational Earth System Science
           University of California, Santa Barbara
           paul@icess.ucsb.edu

 REVISIONS:


fit_comp__define $SSW/packages/spex/idl/object_spex/fit_comp__define.pro
[Previous] [Next]
 Name: fit_comp__define
 Purpose: Object definition for each fit component

 Written:  Kim Tolbert
 Modifications:
 7-Apr-2006, Kim.  In process, call fit_comp_kw to get keyword options (so far
   that's the spectrum and model keywords) into a structure to
   call the function with.
   In init, initialize source if not passed in.

 CALLS:


fit_comp_info $SSW/packages/spex/idl/object_spex/fit_comp_info.pro
[Previous] [Next]
 Name: fit_comp_info
 Purpose: Function to initialize fit_comp info params

 Written: Kim Tolbert 1-Apr-2006
 Modifications

 CALLED BY
	fit_comp__define


fit_comp_info__define $SSW/packages/spex/idl/object_spex/fit_comp_info__define.pro
[Previous] [Next]
 Name: fit_comp_info__define
 Purpose: Define fit_comp_info parameter structure

 Written: Kim Tolbert
 Modifications:
 7-Apr-2006 Kim.  Added spectrum,model params


fit_comp_kw $SSW/packages/spex/idl/object_spex/fit_comp_kw.pro
[Previous] [Next]
 OSPEX function  fit_comp_kw handles the fit component keywords

 Function returns 0 or 1 indicating if there are any fit keywords to use.  In addition
 there are a number of keyword options for returning different types of information:

 Arguments:
   struct - either the structure of spex_summ... params or fit_comp... params
 Keywords:

 obj - Some of the options require the ospex object reference (this function can't be
   an ospex obj method (like in spex_gen) because, e.g the fit_comp class doesn't
   inherit spex_gen)

 nkw - returns the number of keywords being used (except for summary_string output)

 summary_string - If requested, struct must be a spex_summ structure. Return a string array
   with keywords for each function component for time interval time_int, e.g.
     bpow: none
     vth: /cont /chianti5.2
 time_int - used with summary_string, time_interval index in struct to use

 process_struct - return structure with keyword values appropriate for passing via
   _extra into call to compute function component

 plot_label - return string array of 5-character keyword values for plot label
 long_label - used with plot_label.  If set, return full info in plot_label

 fix_default - if set, then check if kw tags are in default structure, and if not,
   add the tags with -1 values. struct arg itself is changed and returned.

 list_string - return string array for inclusion in list_function output

 Written:  Kim Tolbert March 2006
 Modifications:
 29-May-2006, Kim.  Use trim when checking func_spectrum and func_model in case they = '  '

 CALLS:
 CALLED BY
	SPEX_GEN__DEFINE, SPEX__DEFINE, fit_comp__define
	to return the structure of default values for the specified function


fit_function_defaults $SSW/packages/spex/idl/object_spex/fit_function_defaults.pro
[Previous] [Next]
 Name: fit_function_defaults
 Purpose: return a structure with the default values for a specified fit function (which
  can contain multiple fit components (e.g. 'vth+bpow')

 Kim, 4-Oct-2003
 CALLED BY
	to return information about a function which can consist of multiple


fit_gcross $SSW/packages/lparl/idl/ucon/morrison/fit_gcross.pro
[Previous] [Next]
NAME:
	fit_gcross
PURPOSE:
	To fit a gaussian curve to a grid cross in an image
 CALLS: ***
	GAUSSFIT2, GAUSS_FUNCT2 [1], GAUSS_FUNCT2 [2], PAUSE [1], PMM [3], STDEV, pause [2]
	pmm [1], pmm [2]
 CALLED BY:
	do_fit_gcross, make_fake_dark
HISTORY:
	Written Feb-94 by M.Morrison
	27-Apr-94 (MDM) - Modified first guess parameter to be where the
			  minimum lies, not where the extraction was guessing
			  the grid location to be.


fit_model_components $SSW/packages/spex/idl/object_spex/fit_model_components.pro
[Previous] [Next]
 Name: fit_model_components

 Purpose: Return function component name or description for all available components, or for a
	specified component.  Reads ascii list of function component names in fit_model_components.txt.

 Category: FITTING, SPEX

 Input:
	comp - Unique string identifying component to return name or description for ( e.g. 'bpow').
		If not passed, then all are returned.
	full - if set, return name, description

 Output (optional):
	desc - variable to return description in (e.g. Broken Power Law)

 Written: Kim Tolbert, April 2, 2003
 Modifications:
 30-Sep-2005, Kim.  Use OSPEX_MODELS_DIR env. var. to find fit_model_components.txt file
   (instead of SSW_OSPEX) so users can add models and point to their own
   fit_model_components.txt file.

 CALLS:
 CALLED BY
	fit_comp__define


Fits_spectra [1] $SSW/packages/spex/idl/original_spex/fits_spectra.pro
[Previous] [Next]

 NAME:   Fits_spectra


 PURPOSE:  read and time sequenced spectra as FITS binary tables


 CATEGORY: i/o, spectral analysis


 CALLING SEQUENCE:


 CALLED BY:


 CALLS TO:
	none

 INPUTS:
       filename
 OPTIONAL INPUTS:



 INPUTS/OUTPUTS
       ut
       rate
       erate
       livetime
       start_time
       end_time
       edges
       width
       det_id
       dsel
       channels - Pha channel numbers
       error

 OUTPUTS:
       headers


 CALLS: ***
	ATIME [1], ATIME [2], CHECKVAR [1], FCHECK, FXBCLOSE [1], FXBCLOSE [2], FXBFIND [1]
	FXBFIND [2], FXBOPEN [1], FXBOPEN [2], FXBOPEN [3], FXBREAD [1], FXBREAD [2]
	FXBREAD [3], FXPAR [1], FXPAR [2], HEADFITS [1], HEADFITS [2], HEADFITS [3], LIMITS
	TJD2YMD, anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], checkvar [2]
	edge_products, where_are [1], where_are [2]
 CALLED BY:
	bfits_burst [1], bfits_burst [2], read_hirex_4_spex [1], read_hirex_4_spex [2]
	where_are [1], where_are [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	assumes 2 extensions - 1 with pha calibration
			       2 with time and rate, flux, spectra, count data

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, test version for HIREX, 19-Sep-94
	ras, 10-feb-95 fixed bfits bugs


Fits_spectra [2] $SSW/packages/spex/pre2002/idl/fits_spectra.pro
[Previous] [Next]

 NAME:   Fits_spectra


 PURPOSE:  read and time sequenced spectra as FITS binary tables


 CATEGORY: i/o, spectral analysis


 CALLING SEQUENCE:


 CALLED BY:


 CALLS TO:
	none

 INPUTS:
       filename
 OPTIONAL INPUTS:



 INPUTS/OUTPUTS
       ut
       rate
       erate
       livetime
       start_time
       end_time
       edges
       width
       det_id
       dsel
       channels - Pha channel numbers
       error

 OUTPUTS:
       headers


 CALLS: ***
	ATIME [1], ATIME [2], CHECKVAR [1], FCHECK, FXBCLOSE [1], FXBCLOSE [2], FXBFIND [1]
	FXBFIND [2], FXBOPEN [1], FXBOPEN [2], FXBOPEN [3], FXBREAD [1], FXBREAD [2]
	FXBREAD [3], FXPAR [1], FXPAR [2], HEADFITS [1], HEADFITS [2], HEADFITS [3], LIMITS
	TJD2YMD, anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], checkvar [2]
	edge_products, where_are [1], where_are [2]
 CALLED BY:
	bfits_burst [1], bfits_burst [2], read_hirex_4_spex [1], read_hirex_4_spex [2]
	where_are [1], where_are [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	assumes 2 extensions - 1 with pha calibration
			       2 with time and rate, flux, spectra, count data

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, test version for HIREX, 19-Sep-94
	ras, 10-feb-95 fixed bfits bugs


FITSBASIC $SSW/packages/lparl/idl/ucon/zayer/fitsbasic.pro
[Previous] [Next]
 NAME:
	FITSBASIC
 PURPOSE:
	Setup basic FITS header information for a given array.
 CATEGORY:
	File IO. Low level.
 CALLING SEQUENCE:
	HEADER=FITSBASIC(ARRAY)
 INPUTS:
	ANARRAY, an n dimensional array of byte, word or longs.
	BITPIX, NAXIS, NAXISi, DATE are set.
 KEYWORD PARAMETERS:
 OUTPUTS:
	HEADER, FITS header to created and updated.
 CALLS: ***
	PUTFITSVAL, STARTFITS
 CALLED BY:
	FITSW
 COMMON BLOCKS:
 SIDE EFFECTS:
	ROWNO in FITSW common block is updated.
 RESTRICTIONS:
	Only one open file.
 PROCEDURE:
 MODIFICATION HISTORY:
	Jul. 1992  I. Zayer    LPARL. get rid of BSCALE & BZERO.
	Oct. 1990  P. Milford  Stanford University.


FITSRD $SSW/packages/lparl/idl/ucon/zayer/fitsrd.pro
[Previous] [Next]
 NAME:
	FITSRD
 PURPOSE:
	READS FITS FORMAT DATA FROM A FILE
	INTO HEADER AND DATA OUTPUT VARIABLES
 CATEGORY:
	DATA INPUT/OUTPUT
 CALLING SEQUENCE:
	FITSRD,ifile,DATA,HDR
 INPUTS:
	Input file ifile must be present
 OPTIONAL INPUT PARAMETERS:

 KEYWORD PARAMETERS:

 OUTPUTS:
	Data is the name of the output structure containing FITS
	  data.  
 OPTIONAL OUTPUT PARAMETERS:
	NONE
 CALLS: ***
	DECI_STR, FIND_KEY, GETFITSVAL, swabi
 CALLED BY:
	exp_scale min_exp max_exp [1], get_linearity sig e_min e_max, ltc
	read_ltc file
 COMMON BLOCKS:
	NONE
 SIDE EFFECTS:
	NONE
 RESTRICTIONS:
	Data is assumed to be compatible with FITS formats for BYTE,
	  INTEGER*2, and INTEGER*4 data types.  This has not yet been tested.
 PROCEDURE:
	FITSRD,ifile,Data,Hdr
	User is prompted for the name of the file to be read.  If the keyword
	'SIMPLE =' with a value of 'T' or 'F' is not found, the message 'This
	is not a FITS FORMAT File' is printed, and no values are returned.
	If 'SIMPLE = F', a warning message is printed, but no automatic termin-
	ation is applied (in deference to AAT FITS tapes which write out data
	in REAL*4 format).
	Degenerate (NAXIS=0) FITS files are supported.
 MODIFICATION HISTORY:
	Modified Sep 1992 IZ. Modified for hdr to be bytarr & use getfitsval.
	Modified Jan 1991 PNM. Fixed bug when 'END' appeard not at start of
	line.
	Modified Oct 1990, PNM.  Hack for 3D data. Hack for real data.
	Modified Jan 1990, PNM.  Split interactive and non interactive
	portions of FITSRD2.
	Written JUNE 1988 EMH.  Uses function YESNO and procedure GET_KEYWORD.
	Also uses function DECI-STR.


FITSW $SSW/packages/lparl/idl/ucon/zayer/fitsw.pro
[Previous] [Next]
 NAME:
	FITSW
 PURPOSE:
	Write a FITS format image/header to disk.
 CATEGORY:
	File IO. Low level.
 CALLING SEQUENCE:
	FITS,OFILE,IMAGE,HEADER
 INPUTS:
	OFILE, output file name
	IMAGE, LP image, int*2 data to be saved.
	HEADER, optional image header (f0 or fits)
 KEYWORD PARAMETERS:
	none.
 OUTPUTS:
	Writes to OFILE.
 CALLS: ***
	FITSBASIC, FITSHEADER
 CALLED BY:
	FZTOFITS
 SIDE EFFECTS:
 RESTRICTIONS:
	Does not check errors.
 PROCEDURE:
	Write the two structures.
 MODIFICATION HISTORY:
	Jul. 1992  I. Zayer    LPARL. Modified to be stand-alone & renamed
	Jan. 1990  P. Milford  Stanford University.


fixinate_eit $SSW/packages/ztools/soho/fixinate_eit.pro
[Previous] [Next]
 fixinate_eit

 Provide proper image-plane positional headers for an eit file. 

 Use:
	fixinate_eit,file=file,ahdr,a  - Loads "file" and returns in a and ahdr
	fixinate_eit,ahdr              - Assumes the file is already loaded, 
				         and tweaks ahdr in-place.
 INPUT parameters:
	ahdr  - The fits header to manipulate

 OUTPUT parameters:
	ahdr, a - The header and image to be returned.  The image is 
	returned in 'a' if the filename is specified with the 'file' keyword.

 INPUT KEYWORD PARAMETERS:
	file -  optional.  Name of the file to load into a & ahdr.
	x0   -  optional.  Value of CRPIX1 for the image.
	y0   -  optional.  Value of CRPIX2 for the image.

 If x0 and y0 aren't specified, and there is no "CRPIX1" or "CRPIX2" header 
 line then the disk center is guessed based on the value in March 1996.

 CALLS: ***
	EIT_PIXSIZE, FUG, ISVALID [1], ISVALID [2], ISVALID [3], JOIN_STRUCT [1]
	JOIN_STRUCT [2], NLM [1], NLM [2], READFITS [1], READFITS [2], READFITS [3], UTC2STR
	WRITEFITS [1], WRITEFITS [2], safetag, struct2fitshead, zcheck_hdr, zstr2utc [1]
	zstr2utc [2]
 CALLED BY:
	datify
 HISTORY:
	Written and hacked up a lot, 1996-1997 Craig DeForest 
		(who's not particularly proud of it)
	Regularized scaling and included cheezy recursive vectorization, 
		13-Aug-1997 CED
	Fixed CRPIXn usage, 13-Mar-1998 CED 
	IR-regularized summing to match LEB's idiosyncrasies, 15-Nov-98 CED
 CAVEAT:
	This is probably sort-of obsolete now that EIT has their
	pointing information pretty well fixed up.  Especially after 
	Spring 1998, this routine is probably redundant.  Nope, it's not -- 15-Nov-98


fixinate_lasco $SSW/packages/ztools/soho/fixinate_lasco.pro
[Previous] [Next]
 fixinate_lasco

 Provide proper image-plane positional headers for a lasco file.

 Use:

	fixinate_lasco,file=file,ahdr,a	- loads "file" and returns in a and ahdr
	fixinate_lasco,ahdr 		- tweaks ahdr in-place


 Design notes:  We use the width of the image as a determinant of plate
 scale, as I've never heard of an E-W clipped LASCO image.  If the width
 isn't a nice fraction of 1024, we throw up our hands.

 Fixed this to use structures, 1-April-1998
 CALLS:
 CALLED BY
	datify


fixinate_mdi $SSW/packages/ztools/soho/fixinate_mdi.pro
[Previous] [Next]
 fixinate_mdi

 Fixes up alignments with mdialign.pro, then
 inserts some calibration information based on the current
 (4-Aug-97) guesstimates supplied by Hoeksema.
 21-Jul-99:  Added B0 correction to header.

magfact = 2.81                 ; 2.816 Gauss per DN
magzero = 7.0/16.0 * magfact   ; 7/16 DN offset
sumfact = 5.0                  ; 5-minute sums
dopfact = 8.0                  ; 8 m/s per DN for dopplergrams
 CALLS:
 CALLED BY
	zradialize


fixinate_trace $SSW/packages/ztools/soho/fixinate_trace.pro
[Previous] [Next]
 fixinate_trace

 Provide proper image-plane positional headers for a trace file. 

 Use:
	fixinate_trace,file=file,ahdr,a  - Loads "file" and returns in a and 
					   ahdr
	fixinate_trace,ahdr              - Assumes the file is already loaded, 
				         and tweaks ahdr in-place.
 INPUT parameters:
	ahdr  - The fits header to manipulate

 OUTPUT parameters:
	ahdr, a - The header and image to be returned.  The image is 
	returned in 'a' if the filename is specified with the 'file' keyword.

 INPUT KEYWORD PARAMETERS:
	file -  optional.  Name of the file to load into a & ahdr.

 CALLS: ***
	ISVALID [1], ISVALID [2], ISVALID [3], NLM [1], NLM [2], READFITS [1], READFITS [2]
	READFITS [3], anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], safetag
	zcheck_hdr
 CALLED BY:
	unpack_trace
 HISTORY:
	Written by hacking up fixinate_eit, 9-Aug-1998, C DeForest

 Method:
	We add the infamous CROTA tag and the EXPTIME tag,
	and clean up the date stamps a bit.  (there are confusing
	kinds of date stamp floating around).


fixupmagnetograms $SSW/packages/ztools/util/fixup-magnetograms.pro
[Previous] [Next]
 Hack to stick proper header values in the
 HR magnetograms...

 One-time use.
 Craig DeForest, 21-Feb-99


FLUORESCENCE $SSW/packages/xray/idl/fluorescence.pro
[Previous] [Next]

 NAME:  
	FLUORESCENCE

 PURPOSE:
	Calculate X-ray fluorescence from the escape of K-alpha,beta  photons
	from a detector surface
 CATEGORY:


 CALLING SEQUENCE:
	result = fluorescence( E,kp,ke,detector=det,error=error)

 CALLED BY:


 CALLS: ***
	CHECKVAR [1], FCHECK, checkvar [2], xsec
 INPUTS:
	E		Input energy vector
	detector	only 'Ge','NaI', 'CsI', 'Si', or 'SXS'
			SXS refers to the Yohkoh Soft Xray Spectrometer (Xe and CO2)
			default is Germanium
 OPTIONAL INPUTS:
	theta - 	angle of incidence of the beam to the normal, degrees
			default is 0 degrees
 OUTPUTS:
	kp		Probability of fluorescence at ke
	ke		Vector of escape energies

 OPTIONAL OUTPUTS:
	ERROR - Set to 1 if detector isn't from list.

 CALLED BY:
	RESP_CALC response calculation
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	only selected detector materials allowed

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 20-dec-94


Flux model of a thermal bremsstrahlung plus broken powerlaw $SSW/packages/xray/idl/f_vth_bpow.pro
[Previous] [Next]

 NAME:
   Flux model of a thermal bremsstrahlung plus broken power-law

 PURPOSE:
   This function returns the differential photon spectrum seen at the Earth
   for a two component model comprised of an optically thin thermal bremsstrahlung
   function normalized to the Sun-Earth distance plus a non-thermal broken power-law
   function normalized to the incident flux on the detector.

 CATEGORY

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = F_VTH_BPOW( E, A )

 CALLS: ***
	CHECKVAR [1], F_BPOW, F_VTH, F_VTH_BPOW, checkvar [2], edge_products
 INPUTS:
   E -energy vector in keV, 2XN edges or N mean energies
   A -model parameters defined below
   For the thermal function using F_VTH.PRO:
     a(0)= emission measure in units of 10^49 cm-3
     a(1)= KT     plasma temperature in keV


   For the "non-thermal" function it uses the broken power law function, F_BPOW.PRO:

     a(2) - normalization at 50 keV (or epivot) of the single powerlaw determined
           by a(2) and a(3).  If Epivot is gt A(4), then the total
           f_bpow function will lay below this normalization point.
     a(3) - negative power law index below break
     a(4) - break energy
     a(5) - negative power law index above break
     a(6) - low energy cutoff for power-law, spectrum goes as E^(-1.5)
     a(7) - spectral index below cutoff between -1.5 and -2.0
     default parameters - a(6) and a(7) default to 10 keV and -1.5
     can be overwritten by values in common function_com

 COMMON BLOCKS:
   FUNCTION_COM

 HISTORY:
   VERSION 1, RAS, ~1991
   VERSION 2, RAS, MAY 1996, FULLY DOCUMENTED
   Version 3, ras, 26-oct-2002, pass 2xn format for e to f_vth
   30-apr-2004, richard.schwartz@gsfc.nasa.gov,
     added documentation about meaning of normalization


Flux model of thermal bremsstrahlung plus thintarget broken $SSW/packages/xray/idl/f_vth_thin.pro
[Previous] [Next]

 NAME:
 Flux model of thermal bremsstrahlung plus thin-target broken
 power-law electron distribution function (GHolman)

 PURPOSE:
 This function returns the differential photon spectrum seen at the Earth
 for a two component model comprised of a thermal
 bremsstrahlung function plus a thin-target,
 non-thermal broken power-law function with low- and high-energy cutoffs.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
       Flux = F_VTH_THIN( E, A )

 CALLS: ***
	Brm_BremSpec, CHECKVAR [1], F_VTH, F_VTH_THIN, checkvar [2], edge_products
 INPUTS:
 E -energy vector in keV, 2XN edges or N mean energies
 A -model parameters defined below
 For the thermal function using F_VTH.PRO:
   a(0)= emission measure in units of 10^49 cm-3
   a(1)= KT   plasma temperature in keV


 For the "non-thermal" function it uses the broken power law
 function, F_BREMSPEC.PRO:
   a(2) - normalization factor in units of 1.0d55 cm-2 sec-1,
             i.e. plasma density * volume of source * integrated nonthermal electron flux
   a(3) - Power-law index of the electron distribution function below
          a(4) (=eebrk).
   a(4) - Break energy in the electron distribution function (in keV)
   a(5) - Power-law index of the electron distribution function above
          eebrk.
   a(6) - Low energy cutoff in the electron distribution function
          (in keV).
   a(7) - High energy cutoff in the electron distribution function (in keV).

 COMMON BLOCKS:
 FUNCTION_COM

 HISTORY:
 VERSION 1 2002/11/19 Adapted from f_vth_thick.pro for compuation of
                electron mean flux distribution from photon spectra
     Lin   2002/12/12 Fix infinity and nan output, spetral index 1.0 is avoided
   26-mar-2003, richard.schwartz@gsfc.nasa.gov - call f_vth with 2xN energy edges.
   24-Mar-2004, Kim Tolbert - added no_vth and _extra keywords.  If no_vth set,
     then 6 params are for brm_bremspec, otherwise first two are for vth, next
     six are for brm_bremspec.
 2004/04/16, Linhui Sui, to speed up the fitting with OSPEX, check the normalization factor a[2],
             if eq 0 then do not call thick target function brm_bremspec.pro
 2006/05/24, Kim Tolbert - change Lin's change of 2004/04/16 to return correctly dimensioned
          array of 0's instead of scalar.


focus_trace [1] $SSW/packages/lparl/idl/ucon/tarbell/focus_trace_d.pro
[Previous] [Next]
NAME:
	focus_trace
PURPOSE:
	To analyze a single set of TRACE grid target focus data
SAMPLE CALLING SEQUENCES:
	focus_trace, /get_files
	focus_trace, /get_files, /hc
	focus_trace, /get_files, /hc, /dark_sub
(or)
	ff = file_list('/td02/log/rawimage', '*')
	ss = xmenu_sel(ff)
	ff = ff(ss)
	focus_trace, ff
	focus_trace, ff, next=512, pos=[-40, -20, 15, 40]
	focus_trace, ff, dark_sub='filename'
INPUTS:
	ff	- files to read
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONGRID [1], CONGRID [2]
	CONGRID [3], FOCUS3, FOCUS_TRACE_D, break_file [4], data_type [1], data_type [2]
	disp1focus [1], disp1focus [2], find_grid, rd_trace_i0 [1], rd_trace_i0 [2]
	tr_decode_head [1], tr_decode_head [2], xrd_trace, yesnox [1], yesnox [2]
OPTIONAL KEYWORD INPUT:
	get_files- if set, then put up a menu prompt for the files
	hc	- make hardcopy
	next	- extract next x next pixels to search for grid (def = 300)
	pos	- An array with the focus position values
	dark_sub- The file name for the dark subtraction.
		  If using the "GET_FILES" option, it can be
		  simply set as an integer and you will be prompted
		  with a menu for the dark file name.
	xcen, ycen  - Center of extracted next x next sub-image.
		  Uses centered extract if xcen or ycen not given.
	ncr	- size of extract centered on grid crossing (def = 100)
	quad	- if set, use squared derivatives for sharpness, not abs()
	nogrid	- if set, works on arbitrary image (no crosshair needed)
	diagonal- if set, rotate images by -45 degrees before analyzing
	drift	- [delta_x,delta-y] image motion between focus steps
		  Roughly [2,-9] for B (UV) quadrant and 20 focus steps

HISTORY:
	Written 19-Sep-96 by M.Morrison
	21-Oct-96 (MDM) - Rename from trcfocus to focus_trace
			- Added documentation header
	31-Oct-96 (MDM) - Gutted some code and added call to XRD_TRACE
	16-Dec-96 (MDM) - Added DARK_SUB
			- Added writing out info about the frame
	25-Feb-97 (TDT)	- Derived from focus_trace to use focus3 for sharpness
	12-Mar-97 (TDT) - Ver 1.1 in title, fixed bug (hardcopy displaying img)
V2.0	 9-Jul-97 (MDM) - Renamed from focus3_trace to focus_trace
			- Patched extract 9:1032 code
V2.1	 9-Jul-97 (MDM) - Made the POS get the data out of DP header
V2.2	 9-Jul-97 (MDM) - Made hardcopy use proper title (progver)
V2.3	10-Jul-97 (TDT)	- NOGRID option: can work on any image
			- DIAGONAL option: rotates images -45 degrees
			- DRIFT option:  compensate image motion with focus


freebound $SSW/packages/chianti/idl/freebound.pro
[Previous] [Next]
 PROJECT:  CHIANTI

      CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
      Astrophysical Plasmas. It is a collaborative project involving the Naval
      Research Laboratory (USA), the University of Florence (Italy), the
      University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME

      FREEBOUND

 PURPOSE:
      Calculates the free-bound (radiative recombination) continuum.

 INPUTS

      TEMP    Temperature in K (can be an array).

      WVL     Wavelength in angstroms (can be an array). If /keV is
              set, then WVL is assumed to contain energies in keV units.

 OUTPUTS

      INT     Free-bound continuum intensity in units of 
              10^-40 erg cm^3/s/sr/Angstrom 
              ( integral(N_H N_e dh) in cm^-5) if a DEM is not defined. 

              If DEM values are defined, it is assumed that they are given
              as N_H N_e dh/dT.  The units are 10^-40 erg/cm^2/s/srAngstrom 

              If T is given as a 1-D array, then the output will be a 
              2-D array, with one element for each temperature and 
              wavelength (but also see SUMT).

              If the keyword /keV is set, then the units of INT will be 
              10^-40 erg cm^3/s/sr/keV

 OPTIONAL INPUTS

      DEM_INT The intensity array is multiplied by a DEM number for 
              each temperature. DEM_INT needs to be of the same size 
              as TEMPERATURE. It is needed for the synthetic spectrum 
              routines.

      IZ     Only calculate continuum for the element with atomic 
             number IZ

      ION    (To be used in conjunction with IZ.) Calculated continuum 
             for a single ion (IZ, ION).

 KEYWORDS

      NO_SETUP If the procedure setup_elements has already been called 
               then the keyword /nosetup should be set to avoid 
               repeating this step

      MIN_ABUND If set, calculates the continuum only from those 
                elements which have an abundance greater than 
                min_abund.  Can speed up the calculations.  For 
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], READ_IP, READ_KLGFB
	SETUP_ELEMENTS, concat_dir [4], freebound_ion, get_ieq
 CALLED BY:
	ISOTHERMAL, MAKE_CHIANTI_SPEC
                example:
                   abundance (H)  = 1.
                   abundance (He) = 0.085
                   abundance (C)  = 3.3e-4
                   abundance (Si) = 3.3e-5
                   abundance (Fe) = 3.9e-5

      PHOTONS  The output spectrum is given in photon units rather 
               than ergs.

      SUMT     When a set of temperatures is given to FREEBOUND, the 
               default is to output INTENSITY as an array of size 
               (nwvl x nT). With this keyword set, a summation over 
               the temperatures is performed.

      VERBOSE  Output information from FREEBOUND.

      KEV      If set, then WVL is assumed to contain energies in keV units
               rather than wavelengths in Angstroms.

 COMMON BLOCKS

      ELEMENTS

 CALLS

      FREEBOUND_ION, SETUP_ELEMENTS, READ_KLGFB, GET_IEQ

 HISTORY

      Ver.1, 24-Jul-2002, Peter Young

      Ver.2, 26-Jul-2002, Peter Young
           revised call to freebound_ion; corrected ion fraction problem

       V 3, 25-May-2005, GDZ 
                  corrected routine header.

      Ver.4, 10-Mar-2006, Peter Young
           added keV keyword

 VERSION     :  4, 10-Mar-2006


freebound_ion $SSW/packages/chianti/idl/low_level/continuum/freebound_ion.pro
[Previous] [Next]
 PROJECT:  CHIANTI

      CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
      Astrophysical Plasmas. It is a collaborative project involving the Naval
      Research Laboratory (USA), the University of Florence (Italy), the
      University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME

      FREEBOUND

 EXPLANATION

      Calculates the free-bound (radiative recombination) continuum 
      from a single ion. Note that the output does not contain the ion 
      fraction, element abundance or differential emission measure term.

 INPUTS

      TEMP    Temperature in K (can be an array).

      WVL     Wavelength in angstroms (can be an array). If the keyword
              /keV is set, then wvl should instead be given in units of
              keV.

      IZ      Atomic number of ion (e.g., 26 = Fe)

      ION     Spectroscopic number of ion (e.g., 13 = XIII)

 OUTPUTS

      INT     Free-bound continuum intensity. Needs to be multiplied by 
              element abundance, ion fraction and DEM to obtain the final 
              continuum intensity.

 OPTIONAL INPUTS

      IP      The ionization potential of the ion.

      VDATA   An array containing the Verner & Yakovlev data array.

      PE      An array containing the PE data from READ_FBLVL

      KLGFB   An array containing the KLGFB data from READ_FBLVL

      [Note: the above 3 inputs are used when calling freebound_ion from 
       freebound]

 KEYWORDS

      NOVERNER  If set, then the Verner & Yakovlev cross-sections will 
                not be used.

      KEV      If set, then WVL is assumed to contain energies in keV units
               rather than wavelengths in Angstroms.

 COMMON BLOCKS

      None.

 CALLS

      READ_FBLVL, ZION2FILENAME, VERNER_XS, KARZAS_XS, CONCAT_DIR,
      READ_IP, READ_KLGFB, FILE_EXIST

 PROGRAMMING NOTES

      The way I treat the exponential function in the expression for the 
      emissivity may seem strange, but it saves a bit of time in the 
      calculation. Basically calculating exp(E-IP+E_i/T) for each level 
      was time consuming so I split it into exp(E-IP/T)*exp(E_i/T). The 
      first term comes out of the for loop, while the second term is the 
      exponential of a vector rather than an array. This made a ~30% 
      time-saving for freebound.

 HISTORY

      Ver.1, 24-Jul-2002, Peter Young

      Ver.2, 26-Jul-2002, Peter Young
          Added /noverner keyword.

      Ver.3, 30-Jul-2002, Peter Young
          Speeded up routine by modifying treatment of exponential.

      Ver.4, 10-Mar-2006, Peter Young
          Added /keV keyword
 CALLS:
 CALLED BY
	freebound


freefree $SSW/packages/chianti/idl/freefree.pro
[Previous] [Next]
 PROJECT     :  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME

     FREEFREE

  PURPOSE:

     This routine computes the free-free continuum (bremsstrahlung) 
     using the fitting formulae of Itoh et al. (ApJS 128, 125, 2000) 
     and Sutherland (MNRAS 300, 321, 1998).

     The Itoh et al. data are valid for smaller ranges for temperature 
     and wavelength than Sutherland and so for points outside of their 
     ranges we use the data of Sutherland.

 INPUTS

    TEMP    Temperature (in K).

    WVL     Wavelengths in angstroms. Can be a scalar or vector. If /keV is
            set, then WVL is assumed to contain energies in keV units.

 OUTPUTS

    INT     Free-free continuum intensity in units of 
            10^-40 erg cm^3/s/sr/Angstrom  
            [ integral(N_H N_e dh) in cm^-5 ] if a DEM is not defined. 

            If DEM values are defined, it is assumed that they are given
            as N_H N_e dh/dT.  The units are 10^-40 erg/cm^2/s/sr/Angstrom. 

            If T is given as a 1-D array, then the output will be a 2-D array,
            with one element for each temperature and wavelength 
            (but also see SUMT).

            If the keyword /keV is set, then the units of INT will be 
            10^-40 erg cm^3/s/sr/keV

 OPTIONAL INPUTS

    DEM_INT An array of same length as TEMP which contains the 
            differential emission measure values at each temperature. 
            The emissivity at each temperature is multiplied by the 
            DEM value and the d(logT) value.

    MIN_ABUND This keyword allows the specification of a minimum abundance, 
              such that any elements with an abundance (relative to 
              hydrogen) less than MIN_ABUND will not be included in the 
              calculation. E.g., MIN_ABUND=1e-5.

 KEYWORDS

    NO_SETUP By default the routine asks the user which ion balance 
             and abundance files to use via pop-up widgets. If 
             /no_setup is used then this data is taken from the common 
             block.

    SUMT     The default is to output the intensity array as an array 
             of size (nwvl x nT). Setting this keyword performs a sum 
             over the temperatures to yield a vector of same size as 
             the input wavelengths, thus producing the complete 
             free-free spectrum.

    PHOTONS  Gives output emissivity in photon units rather than ergs.

    KEV      If set, then WVL is assumed to contain energies in keV units
             rather than wavelengths in Angstroms.

 CALLS

    SUTHERLAND, ITOH

 COMMON BLOCKS

    ELEMENTS

 PROGRAMMING NOTES

    The Itoh fitting formula is only valid for (6.0 LE logT LE 8.5). 
    For temperatures below this, we thus switch to the Sutherland 
    fitting formula. There is very little (<1%) between the two at 
    logT=6.

    Itoh also has a constraint on the quantity u=hc/kTl (l=wavelength), 
    such that (-4 LE log u LE 1.0). The upper limit corresponds to the 
    continuum being cut-off prematurely at low wavelengths. E.g., for 
    T=10^6 the cutoff is at 14.39 angstroms. For these low wavelengths 
    we also use the Sutherland data to complete the continuum. Note that 
    the continuum at these wavelengths is very weak

 MODIFICATION HISTORY

    Ver.1, 5-Dec-2001, Peter Young
         Completely revised to call the separate itoh.pro and 
         sutherland.pro routines.

    V. 2, 21-May-2002,  Giulio Del Zanna (GDZ),
          Corrected the description of the  units.
          Added verbose keyword and a printout.

    V. 3, 22-May-2002,  Peter Young (PRY)
          Added MIN_ABUND optional input.
          Changed ioneq_t to ioneq_logt (GDZ).

    V 4, 25-May-2005, GDZ 
                  corrected routine header.

    V. 5, 9-Mar-2006, Peter Young
          Added /kev keyword

 VERSION     :  5, 9-Mar-2006

 CALLS:
 CALLED BY
	ISOTHERMAL, MAKE_CHIANTI_SPEC


ft_sumread_fits $SSW/packages/ztools/soho/ft_sumread_fits.pro
[Previous] [Next]
#Project          : SOHO - SUMER                                            #
#                                                                           #
#Procedure_name   : FT_SUMREAD_FITS                                         #
#                                                                           #
#Author           : Nicolas Morisset                                        #
#Language         : IDL                                                     #
#Purpose          : Read columns from a Sumer FITS file                     #
#                                                                           #
#Creation date    : 16-DEC-1995                                             #
#Update             25-FEB-1995                                             #
#                   Add primary header parameter and more output arrays.    #
#External modules :                                                         #
#                                                                           #
#Call sequence    :                                                         #
#                  ft_sumread_fits, filename, header, binheader, nb_images, #
#			data1,.., data13,/HELP,/ALL,columns=[2,3]            #
#Arguments        :                                                         #
#                                                                           #
# Inputs :                                                                  #
# ------                                                                    #
#   Filename   --> Character string contains the FITS filename              #
#                                                                           #
# Output                                                                    #
# ------                                                                    #
#   Header     --> String Array of primary header                           #
#   Binheader  --> String Array of BTE header                               #
#   nb_images  --> Array containing the number of images of output          #
#                  DATA arrays                                              #
#   nb_images  --> Array containing the number of images of output DATA     #
#                  arrays                                                   #
#   Data1..13  --> Data arrays                                              #
#                                                                           #
# Keyword                                                                   #
# -------                                                                   #
#   HELP       -->     Optional keyword which permits to display some       #
#                      information on the routine. 			     #
#   ALL	-->     Optional Keyword which instructs the program to      #
#			automatically read in all the data. 		     #
#   Columns    --> 	Optional keyword specifying which columns should     #
#			be read. 					     #
#			The order of columns may vary between files, so	     #
#			use this keyword only if you are certain of the	     #
#			file's contents. ALL and COLUMNS only work for       #
#                      some data formats.                                   #
# Description     :                                                         #
#     This routine is able to read one or more Sumer data columns.          #
#     The progam needs the following information :                          #
#       (1) Which Binary Table Extension you wish (if any)                  #
#       (2) How many data columns you wish                                  #
#       (3) Which data columns you wish                                     #
#     The output data arrays contain all data columns you select.           #
#     If you want the HELP use the keyword /HELP                            #
#                                 WARNING                                   #
#               You may select up 13 columns at the same time               #
#                           OPTIONAL COLUMN NAME                            #
#             SUM_STATUS, DEL_TIME, EXPTIME, SOLAR_X, SOLAR_Y               #
# Remark :                                                                  #
#        (1) If you want all columns enter the total number of columns      # 
#            but don't forget the maximun won't exceed 13 columns           #
#        (2) When you read a Spectral Scan FITS file this routine stores    #
#            all data into the same output array (first one)                #  
# 
 CALLS:
 CALLED BY
	mk_atlas, sum_FField, sum_FField_FTS


full_graph_gif $SSW/packages/lparl/idl/ucon/morrison/full_graph_gif.pro
[Previous] [Next]
NAME:
	full_graph_gif
PURPOSE:
	To plot the x and y error jitter plots into a gif file
OPTIONAL INPUTS:
	ff - file name with path
SAMPLE CALLING SEQUENCE:
	full_graph_gif
	full_graph_gif, filname
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], LOADCT, XMENU_SEL [1], XMENU_SEL [2], break_file [4]
	concat_dir [4], file_list [1], file_list [2], restgen [1], restgen [2]
	str_replace [1], str_replace [2], zbuff2file [1], zbuff2file [2]
HISTORY:
	Written 26-Mar-97 by S.Qwan


funct1 [1] $SSW/packages/spex/idl/original_spex/funct1.pro
[Previous] [Next]

 NAME: funct1


 PURPOSE: calculate function values and partial derivatives


 CATEGORY: spectral analysix


 CALLING SEQUENCE:
       funct1, f_model, x, a, f, pder, free=free

 CALLED BY:


 CALLS TO:
	none

 INPUTS:
       x - vector of independent variable
	a - function parameters
	f_model - function name, a string

 OPTIONAL INPUTS:

	free - vector of indices of free parameters for calculation of partial derivs.

 OUTPUTS:
       f - returned values of functions

 OPTIONAL OUTPUTS:
	pder- returned partial derivatives for free parameters

 CALLS: ***
	f_pder [1], f_pder [2]
 CALLED BY:
	SPEX_FCHISQR [1], SPEX_FCHISQR [2]
 MODIFICATION HISTORY:
	documented ras, 11-aug-94


funct1 [2] $SSW/packages/spex/pre2002/idl/funct1.pro
[Previous] [Next]

 NAME: funct1


 PURPOSE: calculate function values and partial derivatives


 CATEGORY: spectral analysix


 CALLING SEQUENCE:
       funct1, f_model, x, a, f, pder, free=free

 CALLED BY:


 CALLS TO:
	none

 INPUTS:
       x - vector of independent variable
	a - function parameters
	f_model - function name, a string

 OPTIONAL INPUTS:

	free - vector of indices of free parameters for calculation of partial derivs.

 OUTPUTS:
       f - returned values of functions

 OPTIONAL OUTPUTS:
	pder- returned partial derivatives for free parameters

 CALLS: ***
	f_pder [1], f_pder [2]
 CALLED BY:
	SPEX_FCHISQR [1], SPEX_FCHISQR [2]
 MODIFICATION HISTORY:
	documented ras, 11-aug-94


FUNCTION_COM $SSW/packages/xray/idl/function_com.pro
[Previous] [Next]
 Name:
	FUNCTION_COM
 CATEGORY: SPECTRA

FUNCTION_COM - Common and common source for information on fitting functions
 Restrictions:
	This is just an include block, not a procedure
 History:
	ras, circa 1990
	21-may-02, ras	changed a_cutoff default to 
	[1., 3.0], for keV and  spectral index


function_counts2photons $SSW/packages/xray/idl/inversion/function_counts2photons.pro
[Previous] [Next]
 PROJECT:
   RHESSI/INVERSION

 NAME:

   function_counts2photons

 PURPOSE:

   Inversion of count spectrum using regularisation + GSVD method
   to obtain model-independent photon spectrum

   Quick start with the inversion software
   http://www.astro.gla.ac.uk/users/eduard/rhessi/inversion/


  The observed count flux spectrum in the X-ray detectors
  C(eps) [counts/sec/cm^2/keV] can be written in matrix form

  C = DRM*F

  DRM - dynamic responce matrix of instrument

  We know C and DRM and want to find a photon flux F  [counts/sec/cm^2/keV].
  This problem is ill-conditioned
  and regularision (additional constraints) should be applied.

  The code finds the solution for the problem as a function of lambda

  ||DRM*F-C||^2+lambda*||L*(F-F0)||^2=min

   where

   ||...|| - L2 norm
   L       - constraint matrix
   F0      - a model of photon spectrum from SPEX/OSPEX
   lambda  - regularisation parameter found using descripancy principle


   ||A*F(lambda)-C||=reg_tweak*||dC||

   where
   dC  - 1 sigma uncertanty on count flux, [counts/sec/cm^2/keV]

   For details see:
   Kontar et al,2004,Sol Phys,225,293-309
   (http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=2004SoPh..225..293K )
   Kontar et al,2005,Sol Phys,226,317-325
   (http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=2005SoPh..226..317K )

 CATEGORY:
   HESSI, Spectra, Inversion

 CALLING SEQUENCE:

 function_COUNTS2PHOTONS,e_c2N,eph2N,drm,counts,ecounts,order=order,Npass=Npass,Guess=Guess,reg_tweak=reg_tweak,data_id=data_id,silent=silent

 CALLS: ***
	FCHECK, INV_REG_SOLUTION, INV_RESIDUALS, inv_confidence_interval, inv_gsvdcsq
	inv_make_constraint, inv_reg_parameter, inv_reg_resolution, inv_save_photons
 INPUTS:

 e_c2N  - 2D array, energy edges for counts, keV
 eph2N  - 2D array, energy edges for photons, keV
 drm    - drm matrix, [counts /sec/cm^2/keV /(photons /sec/cm^2/keV)]
 counts - count flux,       [counts /sec/cm^2/keV]
 ecounts- count flux errors,[counts /sec/cm^2/keV]


 OPTIONAL INPUTS:

   version   - string, version of the inversion code (currently only one version exist)
   order     - integer, regularization order. Can be 0 (default), 1, or 2.
   Npass     - integer, number of random noise realisations for the confidence strip.
                 Default is 30.
   Guess     - integer, 1 or 0 (default) - to use or NOT to use forward-fit in the constraint
   reg_tweak - float,  parameter to adjust the regularization parameter (default is 1).
   data_id   - string, to use as file identifier (for exampe data_id='flare_time')
                       default is 'my_data'
   silent    - 0 or 1, if silent=1 no screen output, default is 0

 OUTPUTS:

 F(e)       - regularised photon spectrum, [photons/sec/cm^2/keV]
 dF         - 1 sigma error, [photons/sec/cm^2/keV]
 FWHM       - energy resolution of the regularised solution [keV]


 The results of the inversion are returned as a structure


 OPTIONAL OUTPUTS:
   none

 KEYWORDS:
   none

 COMMON BLOCKS:
   none

 SIDE EFFECTS:


 RESTRICTIONS:


 MODIFICATION HISTORY:
   Version 1, eduard(at)astro.gla.ac.uk, 23 November, 2005
   returns a structure with resolution and errors