Varosi vlibm AstroContrib Library

This page is a listing of the entire contents of this library for IDL. This listing is the long version. Viewing the much more compact listing may be handier.

[Go Back to Main IDL Libraries Search Page]


Last modified: Thu Dec 21 21:18:28 2000.

List of Routines


Routine Descriptions

BLACK_BODY

[Next Routine] [List of Routines]
 NAME:
	Black_Body
 PURPOSE:
	Compute black body emission spectrum (Planck function)
	in units of Janskys/arcsec^2 at either an array of temperatures
	or array of wavelengths.
 CALLING:
	BB_spectrum = Black_Body( Temperature, dBdT, WAVELENGTH= )
 INPUTS:
	Temperature = scalar or array, degrees Kelvin.
 KEYWORDS:
	WAVELENGTH = wavelength in microns, array or scalar,
		(stored into common block for reusage).
 OUTPUTS:
	dBdT = optional output, derivative of Planck function respect to Temp.

	Function returns array of Planck spectrum in units of Janskys/arcsec^2.
	(Jansky = 1e-26 Watts/m^2/Hz)
 COMMON BLOCKS:
	common Black_Body, wavel	(keeps wavelength array for reuse).
 EXTERNAL CALLS:
	Assumes system variable !CV is defined
	(cgs constants defined in Varosi's idl_startup.pro).
 HISTORY:
	Written: Frank Varosi, NASA/GSFC, 1996.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/black_body.pro)


CHI_AUTO_CORR

[Previous Routine] [Next Routine] [List of Routines]
Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/chi_auto_corr.pro)


CHI_RESID_CORR

[Previous Routine] [Next Routine] [List of Routines]
 Used by procedure Max_Resid_Like,
 Based on:
	"Incorporation of Spatial Information in Bayesian Image Reconstruction:
			the Maximum Residual Likelihood (MRL) Criterion",
 by Robert Pina and Richard Puetter UCSD 1992.
 coded by Frank Varosi NASA/GSFC 1992.
 F.V. 1992, added new positivity constraint function as suggested by R.P.,
	so that final deconv image result = positivity( image_deconv ).

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/chi_resid_corr.pro)


DECONV_ANALYZE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	DeConv_Analyze
 PURPOSE:
	Analyze current deconvolution result by
	computing residuals and its auto-correlation,
	then display result with residuals, and print statistics. 
	Called by DeConv_Tool and DeConv_Review.
 CALLING:
	deconv_analyze, image_data, psf_obs, image_deconv, deconv_info, /INIT
 INPUTS:
	image_data = original observed image data.
	psf_obs = point spread function of observation.
	image_deconv = current deconvolution result.
	deconv_info = structure containing image/PSF info and deconv statistics.
 KEYWORDS:
	/INITIALIZE : must be set first call, creates windows and prints Labels.
	/NO_RESIDUALS : skips the computation & display of residual image.
	RE_CONVOL_IMAGE = optional input of image_deconv convolved with PSF,
		usually computed by deconv algorithms for next iteration,
		compared with image_data for goodness of fit.  If not supplied
		it will be computed (option is just to save time).
	FT_PSF = optional input of the Fourier transform of PSF (to save time),
		if not supplied it will be computed and passed on for next time.
 OUTPUTS:
	deconv_info = structure containing deconv statistics is updated.
 EXTERNAL CALLS:
	pro tvs
	function histo
	function convolve
	function get_window
	function positivity
	function deconv_struct
	function FullWid_HalfMax
 COMMON BLOCKS:
	common deconv_analyze, windc, winrh, winac
	common deconv_analyz1, magfim, ixsiz, iysiz, magfr, blankim, posxy
	common deconv_analyz2, min_rstd, max_rstd
	common deconv_analyz3, Log_im_fact
 HISTORY:
	Written: Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_analyze.pro)


DECONV_GET_IMAG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	deconv_get_imag
 PURPOSE:
	Function extracts a region from the input image, and adjusts for deconv.
 CALLING EXAMPLE:
	image = deconv_get_imag( image, image_stats )
 INPUTS:
	image
	image_stats
 KEYWORDS:
      /MENUS
      /TV_MONITOR
 OUTPUTS:
 RESULTS:
	Function returns the extracted region of input image.
 EXTERNAL CALLS:
	function extract_region
 PROCEDURE:
 HISTORY:
	Written, Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_get_imag.pro)


DECONV_GET_PSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	deconv_get_psf
 PURPOSE:
	Function extracts and models a PSF from the input image.
 CALLING EXAMPLE:
	psf = deconv_get_psf( image, psf_stats, /MENUS, /TV )
 INPUTS:
	image
 KEYWORDS:
      /MENUS : allow interactive processing options via menu queries,
		then other keywords need not be set.
      /SELECT_PSF : interactively select PSF data from supplied image,
			otherwise whole image is used as PSF.
      /MODEL_PSF : replace data with model (user selected) fit PSF function.
      /EXTRAPOLATE_PSF : replace wings of PSF (below noise level) by model.
      /TV_MONITOR : display images in windows.
	SIZE_PSF = optional 2 element array specifying the size to extract.
	NAME = optional string giving a name to the PSF
	NOISE_MODEL = optional string: "GAUSSIAN", "POISSON", "NONE"
 OUTPUTS:
	psf_stats = structure containing info/statistics about PSF.

	Function returns the PSF, extracted and modeled from the input image.

 EXTERNAL CALLS:
	function extract_region
	function im_stats
	function FullWid_HalfMax
	function psf_gaussian
	function psf_Lorentzian
	function psf_merge
	pro centroid
	pro show_psf
 PROCEDURE:
	Complicated, might as well look at the code.
 HISTORY:
	Written, Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_get_psf.pro)


DECONV_INIT

[Previous Routine] [Next Routine] [List of Routines]
 Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_init.pro)


DECONV_ITERATE

[Previous Routine] [Next Routine] [List of Routines]
 Apply one iteration of specified deconvolution method.
 Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_iterate.pro)


DECONV_RESTORE

[Previous Routine] [Next Routine] [List of Routines]
 Restore deconvolution results from files.
 Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_restore.pro)


DECONV_REVIEW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DeConv_Review
 PURPOSE:
	Review previously computed deconvolution results saved by Deconv_Tool.
	Routine prompts user for file/directory selection.
 CALLING EXAMPLE:
       deconv_review, deconv_result, deconv_infos, obs_image, obs_psf, /TV
 KEYWORDS:
       SAVE_NAME = file name (before ".") into which statistics and results
		were saved. If specified, these files will be restored
		and reviewed, otherwise directory will be searched and
		user can select from all files created by DeConv_Tool.
       DIRECTORY = sub-directory in which to look for files.
	WAIT_SECONDS = # seconds to wait between reviewing each saved iteration.
	/NO_RESIDUALS : do not bother computing/displaying residuals etc.
       /TV_MONITOR : display image results using tv (to bit-mapped display).
       /SHOW_PSF : display 2D images and 3D surface of PSF, and statistics.
 OUTPUTS:
       deconv_result = result of deconvolution, final, or whenever paused.
       deconv_info = structure array containing statistics
			about deconv results at all saved iterations.
       obs_image = the original observed image (the data).
       obs_psf = the point spread function used for deconvolution of data.
 EXTERNAL CALLS:
	pro find_files
	function find_dirs
       pro deconv_analyze
       pro show_psf
       pro zoomw
       pro zoomwp
       pro color_tables
       function positivity
       function get_cursor_win
 COMMON BLOCKS:
       common deconv_tool, winz	(the window to zoom)
 MODIFICATION HISTORY:
       Written, Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_review.pro)


DECONV_SAVE

[Previous Routine] [Next Routine] [List of Routines]
 Save current deconvolution results to file.
 Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_save.pro)


DECONV_SETUP

[Previous Routine] [Next Routine] [List of Routines]
 Select deconvolution options.
 Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_setup.pro)


DECONV_STRUCT

[Previous Routine] [Next Routine] [List of Routines]
Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_struct.pro)


DECONV_TOOL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       DeConv_Tool
 PURPOSE:
       Apply deconvolution algorithms to image data, monitor and save results.
 CALLING EXAMPLES:
  (first call)
       deconv_tool, image_deconv, deconv_info, IMAGE=data, PSF=psf, /TV,/MENU
  (or)
       deconv_tool, image_deconv, deconv_info, IMAGE=data, /TV,/MENU
  (further calls)
       deconv_tool, image_deconv, deconv_info,/TV,/MENU
 KEYWORD INPUTS:
       IMAGE_OBS = observed image (the data) to be deconvolved (deblurred),
                     need only be specified once, data image is then
                     stored in common block for further computations.
       PSF_OBS = point spread function, response of instrument to point source,
                     (e.g. an image containing an observation of a star).
              A subregion of image containing the actual PSF can be extracted
              by specifying /SELECT (or if /MENU was set, select the option).
              Observed PSF can be fit with analytic model by setting /MODEL.
              If PSF is not supplied, will automatically generate a model PSF
              and inquire the user for model profile parameters.
                     PSF need only be specified once, then it is stored
                     in common block for further computations.
       SIGMA_NOISE = optional Gaussian noise level (standard deviation),
                     otherwise sigma of noise is automatically determined.
       LOG10_MIN = scalar value > 0 at which to truncate image for Log display,
                     (e.g. /LOG10 cause display of Log10( images > 1 ) ).
       BASE_ITER = scalar, deconv results will be displayed at iterations
                     given by powers of base_iter (default = 2).
       MAXIT_POWER = integer, maximum # iterations = (base_iter)^maxit_power.
       NAME_IMAGE = string, for the record in deconv_info structure.
       NAME_PSF =  string, for the record in deconv_info structure.
       SAVE_NAME = file name into which result statistics are saved
              (and optionally the images) is constructed from this string.
              Otherwise a default name is constructed.
              Save is every (base_iter)^K iterations, K=0,1,2,..., by default.
       DIRECTORY = sub-directory name in which to save results.
       LAG_CHISQ = the maximum residual auto-correlation Lag to use in chi-sq.
       LAG_MIN =  the minimum residual auto-correlation Lag to use in chi-sq.
 KEYWORDS:
       /MENU : inquire for options using simple menus.
              otherwise specify method (see below, default method is MLP).
       /TV_MONITOR : display image results using tv (to bit-mapped display).
       /MLP : use Maximum Likelihood method, for Poisson statistics.
             (MLP = Lucy-Richardson algorithm, works also for Gaussian noise).
       /MLG : use Maximum Likelihood method, for Gaussian statistics.
       /MEM : use simple Maximum Entropy method, for Poisson statistics.
       /MRL : use Maximum Residual Likelihood method, for Gaussian statistics.
       /GAUSSIAN_NOISE : assume additive noise is Gaussian (default).
       /POISSON_NOISE : assume noise in data follows Poisson statistics.
       /SELECT_PSF : interactive extraction of PSF from the given image.
       /MODEL_PSF : fit the PSF with Gaussian or modified Lorentzian model,
                     or if PSF not given, will inquire for profile parameters.
       /SHOW_PSF : display 2D images and 3D surface of PSF, and statistics.
       /CONTINUE : continue with same method (as specified in deconv_info)
       /RESTART : use image_deconv as input and try new method.
       /NO_FT : default is to use FFT for convolutions,
              set /NO_FT to force the use of direct convolutions.
       /SAVE_IMAGES causes image data and deconvolution results to be saved
                     with statistics of progress (saved by default)
                     into default file name, unless SAVE_NAME= is given.
 OUTPUTS:
       image_deconv = result of deconvolution, else if /CONTINUE or /RESTART 
                     then taken as input from previous deconvolution.
       deconv_info = structure containing statistics about deconv result.
                     Taken as input if /CONTINUE or /RESTART is specified.
                     This structure variable is automatically saved
                     every (base_iter)^K iterations, K=0,1,2,....
 EXTERNAL CALLS:
       function deconv_get_imag
       function deconv_get_psf
       function im_stats
       function positivity
       function get_cursor_win
       pro deconv_init
       pro deconv_setup
       pro deconv_iterate
       pro deconv_analyze
       pro deconv_save
       pro show_psf
       pro zoomw
       pro zoomwp
       pro color_tables
 COMMON BLOCKS:
       common deconv_data, image_data, psf_image, psf_FT
       common deconv_stats, image_stats, psf_stats
       common deconv_tool, winz	(the window to zoom)
 MODIFICATION HISTORY:
       Written, Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/deconv_tool.pro)


DEF_MGEP

[Previous Routine] [Next Routine] [List of Routines]
 Define structures used in Mega-Grains Escape Probability (MGEP) model
  for which the code is in mg_ep_2phase.pro (pro MG_EP_2phase):

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/def_mgep.pro)


DEF_MGEP_ICM

[Previous Routine] [Next Routine] [List of Routines]
 Define structures used in Mega-Grains Escape Probability (MGEP) model
  for which the code is in mg_ep_2phase.pro (pro MG_EP_2phase):

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/def_mgep_icm.pro)


DTEMP_PROB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	dTemp_Prob
 PURPOSE:
	Compute the probabilities of given dust temperatures around a star,
	assuming a distribution of temperatures of power law form.
	Normalization is based on the range (min-max) of input temperatures.
	Based on optically thin theory of Luminosity vs. radius and
	temperature vs. absorbed Luminosity, coupled with density vs. radius.
 CALLING:
	probability = dTemp_Prob( Tgrid )
 INPUTS:
	Tgrid = array of dust temperatures of interest, degrees Kelvin.
		Note that Tmin and Tmax are obtained from this grid.
 KEYWORDS:
	EMISS_INDEX = one or two element array of emissivity power law indices.
		e.g. [2,1] for graphite or [2,0] for silicates, default = [2,1].
	TCUT = temperature at which dust emissivity index changes
		if 2 indices are specified, default = 100 K.
	DENS_INDEX = radial power law index of dust density variation,
		e.g. DENS_INDEX=1 implies density goes as 1/r, default = 0.
	LUMIN_INDEX = radial power law index of absorbed Luminosity, default=2.
		Note: the negative of all above power law indices are used,
			so normally specify indices as positive values.
	/AVERAGE : return instead the scalar average temperature of distrib.
		In this case you should pass Tgrid = [ Tmin, Tmax ].
 OUTPUTS:
	Function returns probabilities of input dust temperatures,
	normalized over the given range of temperatures.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/dtemp_prob.pro)


DUST_EMISSION

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	dust_emission
 PURPOSE:
	Compute dust temperature distributions and infrared emission spectrum
	from the absorbed Luminosities as computed by MGEP_RAD_TRANS.
	All input luminosities and output spectra are in solar units.

 CALLING:
	dust_IR_struct = dust_emission( Lumins, KAPPA_DUST= , ... )

 INPUT:
	Lumins = structure of all Luminosities in model,
		as computed and returned by procedure MGEP_Rad_Trans.

	   required tags are:	Lumins.Lum_dust: fltarr( ncomp, nphase )
				Lumins.dust_comp: strarr( ncomp )
				Lumins.dust_phase: strarr( nphase )

 KEYWORD INPUTS:

	KAPPA_DUST = structure variable with dust absorption/scattering coeffs.:
	KAPPA_ICM_DUST = optional, structure with ICM dust abs. & scat. coeffs.

	Required Structure Tags:
		Dust_Kappa.wavelen	(Nwave)  (wavelengths, in microns)
		Dust_Kappa.Kabs		(Nwave,Ncomp)	(absorption per gram)
		Dust_Kappa.Tmax		(Ncomp)  (sublimation temperatures)

	DUST_MASS = matrix (Ncomp,Nphase) of total dust mass
		for each component & phase of medium, in solar mass units.

	/PLOT : plot intermediate results.
	/VERBOSE : print informational messages about results.
	/FULL_STRUCT : return all infrared emission spectra in structure
		(default is to only return dust temperatures).

	POWER_LAW_TDIST = integer array of Nphase elements, giving power law
		flag for ICM and clumps in the case of a two-phase medium.
		Values of 0 : assume single dust temperature for that phase.
		Values of 1 : assume that the dust temperature follows
		an inverse power law distribution, like around a point source,
		and in such case the following indices will be used:

	DINDEX = radial inverse power law index of dust density variation,
		(e.g. DINDEX=2 implies density goes as 1/r^2, default = 0).
		Must be an array of Nphase elements, giving density index for
		ICM and clumps in the case of a two-phase medium.

	LINDEX = radial inverse power law index of absorbed luminosity,
		(default = 2, which is for optically thin dust).
		Must be vector of length Ncomponent, giving absorbed luminosity
		index for graphite and silicates, etc.

	EMISSINX = matrix of size (2,Ncomp) giving emissivity indices.
		default: [ [2.,1.], $  ;graphite emissivity indices < & > Tcut.
		           [2.,0.] ]   ;silicate emissivity indices < & > Tcut.

	TCUT = vector (Ncomp) of temperatures at which emissivity index
		transition occurs, default = 70K (graphite), 150K (silicates).

	TMAX = matrix (Ncomp,Nphase) of dust sublimation temperatures
		to use for the power law temperature distribution.
		(default is to use values from Dust_Kappa.Tmax).

 OUTPUTS:
	Function returns a structure containing following tags:
		Wavelen = wavelengths for spectra, in microns.
		Tdust = single dust temperature.
		Dspec1 = emission spectrum from dust at single temperature.
		Tdmin = minimum dust temperature of power-law distributions.
		Tdmax = maximum dust temperature of power-law distributions.
		Dspec_Td = emission spectrum from dust having
			 a power law distribution of temperatures.

	If FULL_STRUCT is negative then Dspec1 or Dspec_Td are replace by Dspec.

 COMMON BLOCKS:
	common dust_emit_spec, dust_spec   ;to get results of function Dust_Temp
	common dust_Tmin_spec, dtd_spec	   ;to get results of function Dust_Tmin
 EXTERNAL CALLS:
	function Dust_Temp
	function Dust_Tmin
	function Trapez
 PROCEDURE:
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.
	F.V. 1997, compute temperature of multi-phase medium: ICM and clumps.
	F.V. 1999, added keyword KAPPA_ICM_DUST for different dust in ICM.
	F.V. 2000, POWER_LAW_TD option now handles ICM and clumps seperately.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/dust_emission.pro)


DUST_SPECTRUM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Dust_Spectrum
 PURPOSE:
	Compute spectrum of emission from dust heated by point source(s)
	assuming a distribution of temperatures of power law form.
	Based on optically thin theory of Luminosity vs. radius and
	temperature vs. absorbed Luminosity, coupled with density vs. radius.
 CALLING:
	spectrum = Dust_Spectrum( Tmin, Tcut, Tmax )
 INPUTS:
	Tmin = minimun temperature of dust (default = 2.7 Kelvin).
	Tcut = turnover temperature between 2 emissivity indices (default=100).
	Tmax = maximum temperature of dust (default = 1500 Kelvin).
 KEYWORDS:
	EMISS_INDEX = emissivity power law index or 2 indices, default = [2,1].
	DENS_INDEX = optional, radial power law index of dust density variation,
		e.g. DENS_INDEX=1 implies density goes as 1/r, default = 0.
	LUMIN_INDEX = radial power law index of absorbed Luminosity, default=2.
		Note: the negative of all above power law indices are used,
			so normally specify indices as positive values.
	KABS = absorption cross-section of dust vs. wavelength (=emissivity).
	WAVELENS = wavelengths (microns) of dust cross-section.
	BBMATRIX = optional matrix of Planck spectra for distribution of
		temperatures (default is to compute and store in common).
	TGRID = optional temperature grid for distribution integration,
		or if scalar, # of elements in default temperature grid.
	/INIT : just load the keyword parameters into common block,
		setup/compute BB matrix, and return,0.
 OUTPUTS:
	Function returns spectrum (ergs/Angstrom/sec) of dust emission.
 COMMON BLOCKS:
	common Dust_Spectrum, Kemit, wvang, Tg, BBmat
 EXTERNAL CALLS:
	function dTemp_Prob
	function Planck
	function Trapow
 PROCEDURE:
	Temperature distribution is obtained from function dTemp_Prob.
	Carefully integrate over temperature distribution of Planck spectra.
	The usual factor of 4*!pi steradians for emission is just 4 since
	!pi is already included in Kemit = Kabs.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/dust_spectrum.pro)


DUST_TEMP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	dust_Temp
 PURPOSE:
	Compute the radiative equilibrium temperature of dust by matching
	absorbed luminosity and emission integrated over given wavelengths.
	The emision spectrum is placed in common dust_emit_spec for retrieval.
 CALLING:
	Temperature = dust_Temp( Lum_abs, wavel, kabs )
 INPUTS:
	Lum_abs = luminosity absorbed by the dust, in ergs.
	wavel = wavelengths in microns.
	kabs = absorption cross-section at wavelengths (=emissivity).
 KEYWORDS:
	RADIUS_SPHERE = radius (in cm) of homogenous sphere
		in which given Luminosity is absorbed,
		and then units are assumed to be solar luminosities,
		and kabs is assumed to be the radial optical depth of sphere.
		(this keyword is optional, just for a specific application)
	TOLERANCE = numerical tolerance for solution, default = 0.1.
	MINT = mininum T, default = 3.
	MAXT = maximum T, default = 2000.
 OUTPUTS:
	Function returns effective dust temperature in degrees kelvin.
 COMMON BLOCKS:
	common dust_emission, sigma, wavelang	;for internal purposes.
	common dust_emit_zero, Lum_emit
	common dust_emit_spec, dust_spec	;the resultant spectrum
 EXTERNAL CALLS:
	function Zbrent		(finds zero of a function)
	function Planck
	function Trapow
	function dust_emit_zero	(included in this file)
 PROCEDURE:
	Find zero of:  Lum_abs - 4 * Integral( kabs * Planck( Temperature ) )
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/dust_temp.pro)


DUST_TMIN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	dust_Tmin
 PURPOSE:
	Solve for the minimum Temperature of dust emitting over a distribution
	of temperatures, thus the emission spectrum is more realistic.
	The distribution of temperature is composed of two power laws
	(for low and high temps. resp.) and depends on dust emissivity indices
	(see function in file dust_spectrum.pro). The dust emission spectrum
	of solution is stored in: common dust_Tmin_spec, dtd_spec.
 CALLING:
	Tmin = dust_Tmin( Lumin, Tdust, Tcut, Tmax, $
			EM=emiss_indices, W=wave, K=Kemit )
 INPUTS:
	Lumin = the total Luminosity absorbed by the dust.
	Tdust = temperature obtained by assuming all dust emission is at
		single temperature (from function Dust_Temp).
	Tcut = temperature at which dust emissivity index changes
		(e.g. from 2 to 1 for graphite or 2 to 0 for silicates).
	Tmax = maximum allowed dust temperature of distribution.
 KEYWORDS:
	EMISS_INDEX = one or two element array of emissivity power law indices.
	DENS_INDEX = optional, radial power law index of dust density variation,
		e.g. DENS_INDEX=1 implies density goes as 1/r, default = 0.
	LUMIN_INDEX = radial power law index of absorbed Luminosity, default=2.
		Note: the negative of all above power law indices are used,
			so normally specify indices as positive values.
	KEMIT = dust emissivity (absorption cross-section).
	WAVE = wavelenths in microns corresponding to KEMIT.
	TOLERANCE = numerical tolerance for solution, default = 0.1.
 OUTPUTS:
	Function returns minimum dust temperature of power-law distribution.
 COMMON BLOCKS:
	common dust_Tmin_spec, dtd_spec		;resulting emission spectrum.
	common dust_Tmin, Lum, Tx, Tm, dindex, wvdang
 EXTERNAL CALLS:
	function Zbrent		(finds zero of a function)
	function Trapez
	function Dust_Spectrum
	function dust_Tmin_spec	(included in this file)
 PROCEDURE:
	Load common blocks, initialize function dust_spectrum, and solve
	by matching absorbed and emitted Luminosities using function Zbrent.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/dust_tmin.pro)


EP_HOMOG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	EP_homog
 PURPOSE:
	Approximate the radiative transfer of photons in a
	homogenous medium (dust & gas) of spherical/disk geometry, by
	calling EP_Rad_Trans, and then compute equilibrium dust temperatures
	and infrared emission using function Dust_Emission.
 CALLING:
	EP_homog, SED_wave, SED_emit, SED_esc, Lumins, dust_emiss
 INPUTS:
	SED_wave = array of SED wavelengths, in microns.

	SED_emit = emitted Spectral Energy Distribution (SED) vs. wavelength,
		in solar units (so that integral gives solar luminosities).
 OUTPUTS:
	SED_esc = escaping SED vs. wavelength (solar units).

	Lumins = structure variable accounting of all Luminosities emitted,
		escaped, and absorbed in dust/gas.

	dust_emiss = structure variable containing infrared emission spectra of
		and temperature distribution of each dust phase.

 KEYWORD INPUTS:

	KAPPA_DUST = structure variable with dust absorption/scattering coeffs.

	GEOMETRY = structure variable:
		geometry.R = radius of disk/cylinder.
		geometry.H = height of disk/cylinder.
		geometry.Reff = effective radius used for escape probability.

	MEDIUM = structure variable:

	SOURCE = string (upper or lowercase) indicating source of photons:
		"C" : do case of central source,
		"X" : do case of uniformly illuminating external source,
			default is "U": uniformly distributed internal source.

	/PLOT : plot intermediate results.
	/VERBOSE : print informational messages about results.
	/FULL_STRUCT : include all results in output structure variable "Lumins"

 EXTERNAL CALLS:
	pro EP_Rad_Trans
	function Dust_Emission
 PROCEDURE:
 HISTORY:
	Written: Frank Varosi, RSTX @ NASA/GSFC, 1997

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/ep_homog.pro)


EP_LYA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	EP_Lya
 PURPOSE:
	Compute escape probability of Lyman alpha in spheriod of gas & dust.
	The Lyman alpha emission is assumed to be uniformly distributed.
	The effects of resonant scattering in a dusty medium are approximated
	by computing an effective random walk path length thru the dust,
	thus increasing the effective optical depth of the dust, based on
	the parameter alpha indicating the amount of frequency redistribution
	occuring with the Lyman alpha resonant scattering.
 CALLING:
	ep = EP_Lya( ALPHA=, TGAS=, RADIUS=, GAS_DENS=, TAU=, ALBEDO= )
 KEYWORD INPUTS:
	ALPHA = index controlling frequency redistribution, default = 0.5 :
	alpha = 0.5 : complete freq-redistrib (Voigt profile) for scattering.
	alpha = 1 : scattering by thermal gas (partial coherent & f-redistrib),
	alpha = 2 : pure coherent scattering (line center, gas motion & T = 0).
	GAS_DENS = default = 1/cm^3.
	TGAS = default = 7000K.
	RADIUS = effective radius of spheriod medium.
	TAU_DUST = optical depth of dusty medium at Lyman alpha wavelength.
	ALBEDO = albedo of dusty medium at Lyman alpha wavelength.
	/VERBOSE : print parameters and the effective path-length.
 EXTERNAL CALLS:
	function escape_prob
	function scalar
	Uses system structure variable !cv (created by Varosi's idl_startup.pro)
 PROCEDURE:
	Compute Lya cross-section and effective path-length to get effective
	optical depth of dust, then used in Osterbrock-Lucy escape probability.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/ep_lya.pro)


EP_RAD_TRANS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	EP_Rad_Trans
 PURPOSE:
	Approximate the radiative transfer of photons emitted in or impacting
	a homogenous medium (dust & gas) of spherical/disk geometry,
	using escape/interaction probability formulae:
	Osterbrock-Lucy E.P. for uniformly distributed internal source,
	Varosi's interaction prob. for uniformly illuminating external source,
	or Varosi's E.P. approximation for central source.
	An approximation of absorption, ionization of gas, and resultant
	heating of dust by Lyman-alpha from gas is also attempted,
	but this needs more work.
 CALLING:
	EP_Rad_Trans, SED_wave, SED_emit, SED_esc, Lumins

 INPUTS:
	SED_wave = array of SED wavelengths, in microns.
		The dust abs. & scat. coeffs. (input from KAPPA_DUST keyword)
		are interpolated onto this SED wavelength grid.

	SED_emit = emitted Spectral Energy Distribution (SED) vs. wavelength,
		in solar luminosities per second per Angstrom.

 OUTPUTS:
	SED_esc = escaping spectral energy distribution vs. wavelength.

	Lumins = structure variable accounting of all Luminosities emitted,
		escaped, and absorbed in dust/gas.

 KEYWORD INPUTS:

	KAPPA_DUST = structure variable with dust absorption/scattering coeffs.
	DUST_MASS_DEN = array of dust mass densities for each component.
	GAS_DEN = density of atomic hydrogen, same units as RADIUS.
	RADIUS = effective radius of sphere/disk containing clumpy medium.

	SOURCE = string (upper or lowercase) indicating source of photons:
		"C" : do case of central source,
		"X" : do case of uniformly illuminating external source,
			default is "U": uniformly distributed internal source.

	/PLOT : plot intermediate results.
	/VERBOSE : print informational messages about results.
	/FULL_STRUCT : include all results in output structure variable "Lumins"

 OPTIONAL KEYWORD OUTPUTS:
	EPWAVE = computed photon escape probability vs. wavelength.
	EPLYA = escape probability of Lyman alpha accounting for resonant
		scattering in a dusty medium.
	TAU_EFF = the effective optical depth of medium at each wavelength.
	ALBEDO_EFF = the effective albedo of clumpy medium at each wavelength.
	FD = of the photons absorbed, the fractions going to each dust comp.
	FG = fraction of photons absorbed by the gas at each wavelength.
 EXTERNAL CALLS:
	function Finterpol
	function ismeuv
	function Tau_Eff_Scat
	function Escape_Prob
	function Pinteract
	function Trapez
	function ep_Lya
 PROCEDURE:
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/ep_rad_trans.pro)


ESCAPE_PROB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Escape_Prob

 PURPOSE:
	Compute the probability of escape for photons emitted uniformly
	in a homogenous sphere of absorbers, possibly with scattering.
	For no scattering (albedo = 0) the equation is exact (Osterbrock 1989).
	With scattering the accuracy of generalized formula (Lucy 1989)
	has been tested against Monte-Carlo simulations (Varosi 1995)
	and was found to depend also on the angular distribution of the
	scattering. For small optical depths ( < 1 ) the formual agrees with
	Monte-Carlo to better than 5% for scattering ranging from isotropic
	to slightly forward. As optical depth increases the formula
	over-estimates the escape probability for isotropic scattering, but
	agrees better with cases of progressively more forward scattering.
	Formula can also be applied to a homogenous disk/cylinder/ellipsoid
	by using effective tau = 3*tauZ * tauR / ( 2*tauZ + tauR ) where
	tauZ and tauR are the vertical and radial optical depths to the center
	of disk/cylinder/ellipsoid (Varosi 1995). Results are within 5% of
	Monte-Carlo simulations for cases of moderate forward scattering.

 CALLING:
	Pescape = Escape_Prob( tau, albedo )

 INPUTS:
	tau	= array of optical depths (radii, from center of sphere).
	albedo	= array of scattering albedos (ratios of scattering to total
		cross-sections), default = 0.

 KEYWORDS:
	/MATRIX : compute matrix of probabilities for all combinations
		of tau and albedo (also the case if # taus NE # albedos).

 OUTPUTS:
	Function returns vector of photon escape probabilities corresponding
	to the arrays of optical radii and albedos if equal in number.
	If tau and albedo arrays are different sizes or /MATRIX is set
	then a matrix of probabilities is returned, one element (i,j) for each
	combination of tau(i) and albedo(j).

 PROCEDURE:
	The zero albedo case (exact derivation for no scattering) is from
	Osterbrock, "Astrophysics of Gaseous Nebulae...", 1989, Appendix 2.
	The non-zero albedo case is from Lucy et al., in "Supernovae", 1989,
	edited by Woosley. Formula is stated with no derivation and is
	independent of the Osterbrock formula. However, with the assumption
	that scattering redistributes the photons uniformly,
	any zero albedo escape probability can be applied recursively,
	resulting in a geometric series which has a sum yielding the formula.

 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/escape_prob.pro)


FRACTAL_CLOUD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	FRACTAL_CLOUD
 PURPOSE:

	Generate a fractal cloud as a density distribution map,
	returning a 3D array (1D or 2D if requested). The density map
	is generated by binning points generated by a randomn recursive
	fractal algorithm, as described by Elmegreen, 1997, ApJ 477: 196-203.

 CALLING:

	dens_map = Fractal_Cloud( NDIM=, NLEVELS=, NP_FACTOR=, LSCALE=, $
					SIZE_MAP=, /VERBOSE, /DISPLAY )

 KEYWORD INPUTS:

	NDIM = dimension of space in which to embed fractal, default is 3.

	NLEVELS = number of LEVELS in fractal heiarchy, no default, must give.

	NP_FACTOR = integer factor (>1) setting the number of random points
		generated at each new level around and replacing each single
		point of previous level, default is 12.
		Total number of random points generated = NP_FACTOR^NLEVELS.

	LSCALE = the spatial scale divisor from one level to next.
		The spatial extent of new NP_FACTOR random points at next level
		is decreased by divisor LSCALE from previous level,
		thus spatial scale at level N = LSCALE^(-N).
		Can be scalar or vector with NDIM elements, except
		in case of spherical symmetry only scalar is used. Default=3.

	SIZE_MAP = dimensions (resolution in pixels) of output density map,
		default is [128,128,128].

	/SPHERICAL : generate points with spherical symmetry instead of cubic.

	RADIUS_EXP = exponent applied to random radii, for /SPHERICAL case only,
		default = 1/3 (for uniform in 3D sphere).

	/SAVE_RS : save the currently generated random number sequences into
		IDL/XDR save files (in current directory) which can then be
		later restored and used to obtain the same fractal realization
		with different dimension (by changing LSCALE) or resolution.

	DIR_SAVED_RS = optional string specifying directory containing IDL/XDR 
	    save files in which previously generated random numbers are stored.
		For UNIX, must use a "/" character at then end of dir string.

	RANGE_XYZ = float array of dimensions (2,NDIM) specifying min-max
		range of each dimension for binning the points. Default range
		is a sphere which contains all points.
		
	/VERBOSE
	/DISPLAY

 KEYWORD OUTPUTS:

	RANGE_XYZ = min-max range used for each dimension in binning the points.

	DHISTOGRAM = histogram of the density map.
	AVG_DENS = average density of the cloud pixels/voxels, excluding ICM.

 OUTPUT:
	Function returns density distribution map,
	an integer array of the requested dimension and size.

 EXTERNAL CALLS:
	function Bin3D
	function Bin2D
	function Histo
	function VarType
	function trapez
	pro get_window
	pro tvs
 PROCEDURE:
	Use the uniform random number generator to make points at each Level,
	which are rescaled in a descending heirarchy, a modified version of
	the algorithm described by Elmegreen, 1997, ApJ 477: 196-203.
	The final NP_FACTOR^NLEVEL points are binned into a density map array,
	but not all at once, just one group at a time, looping over NP_FACTOR.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1997.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/fractal_cloud.pro)


FRACTAL_SYNTH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	fractal_synth
 PURPOSE:
	Synthesize a fractal embedded in either 2-D (a fractal curve)
	or in 3-D (a fractal surface) using power-law spectral technique.
 CALLING:
	function fractal_synth, Hpar, ft
 INPUTS:
	Hpar = H parameter determining the theoretical fractal dimension D,
		should normally be in the range 0 to 1 so that D = E - H,
		where E = embedding dimension (2 or 3). The theoretical fractal
		dimension is approached as number of frequencies goes infinite.
		The power-law exponent of power spectral density = -(2*H+E-1).
		Statistically, the average variance of points on the fractal
		scales as the distance between the points to the power 2*H.
 KEYWORDS:
	EDIM = embedding dimension E, default=3, giving fractal surface (image).
	NFREQ = number of frequencies to use in spectral synthesis, default=64.
	STD = optional st.dev. of random noise added to amplitudes, default=0.
	PHASE = optional input/output, random phases between 0 and 2*!pi.
		Keyword can be used to keep the same phases while changing H.
 OUTPUTS:
	ft = optional, Fourier spectrum used to generate the synthesized image.

		Function returns a vector of size = 2 * NFREQ,
			or image of size = ( 2 * NFREQ, 2 * NFREQ ).
 EXAMPLES:
	display 128x128 image of dimension 2.5 :
		tvscl, fractal_synth()

	display 512x512 image of dim = 2.3 :
		tvscl, fractal_synth( 0.7, NF=256 )

	plot 512 pnt. curve of dim = 1.9 (and save phases into p) :
		plot, fractal_synth( 0.1, E=2, NF=256, PH=p )

	overplot curves with range of fractal dimensions from 1 to 2 :
		for i=0,10 do oplot, fractal_synth( i/10., E=2, NF=256, PH=p )
 
 EXTERNAL CALLS:
	function rfftinv	(inverse FFT giving a real-valued function).
 COMMON BLOCKS:
	common fractal_synth, su,sn   (internal use, seeds of randomu & randomn)
 PROCEDURE:
	Generate 1D/2D spectral amplitudes with power-law exponent -(2*H+E-1)/2
	and distribute the phases uniformly from 0 to 2*!pi, then inverse FFT.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/fractal_synth.pro)


INTERP_TAU_EFF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	interp_Tau_Eff
 PURPOSE:
	Compute effective optical depth of a sphere including scattering.
 EXPLANATION:
	Effective optical depth is estimated by interpolating a grid
	of Monte Carlo simulations stored in a structure in common.
	Inputs can be scalar or arrays, but must be all same dimensions.
 CALLING:
	Tau_Eff_scat = interp_Tau_Eff( gcos, albedos, taus )
 INPUTS:
	gcos = average < cos( scattering angle ) >
	albedos = scattering albedos.
	taus = optical depths (absorbtion + scattering cross-sections).
 OUTPUTS:
	Function returns scalar/array of effective optical depths
 EXTERNAL CALLS:
	function interleave
 COMMON BLOCKS:
	common interp_Tau_Eff, mcrt_gat    ;Monte Carlo rad. trans. simulations.
 PROCEDURE:
	Interleave the inputs into the Monte Carlo grids and then
	use the IDL intrinsic function interpolate.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1996.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/interp_tau_eff.pro)


IONFRAC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	ionfrac
 PURPOSE:
	Compute local ionization equilibrium, returning what fraction
	of hydrogen is ionized, given density of Lyman continuum photons.
 CALLING:
	fion = ionfrac( Dens_Lyc, DENS_H= )
 INPUTS:
	Dens_Lyc = density of Lyman continuum photons (#/cm^3),
		if a scalar, then we assume photons are all at Lyman edge.
 KEYWORDS:
	DENS_H = density of hydrogen (default = 1/cm^3).
	AION = ionization cross-section (default = 6.3e-18).
	AREC = recombination coefficient (default = 3e-13).
	FLUX_LYC = alternative way of specifying flux of Lyman continuum photons
			(#/cm^2/sec) instead of the density of photons.
 OUTPUTS:
	Function returns fraction of ionized gas.
 PROCEDURE:
	Solve quadratic equation of local ionization balance.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/ionfrac.pro)


IR_DUST_MODEL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	IR_dust_model
 PURPOSE:
	Model the infrared emission from dust in an image-spectrum data cube.
	Each line of sight is modeled independentaly (no scattering) by
	fitting a simple 1D radiative transfer model of single temperature
	dust emission and absorption to the spectrum at each image pixel.
	The user can modify the model control parameters with X-widget GUI
	that is automatically presented, or just accept the default values.
	Assumes that IDL/XDR save file "Dust_Kappa.idl" containing the dust
	absorption coefficients is in current directory.

 CALLING:
	specfits = IR_dust_model( wavelens, images )

 INPUTS:
	wavelens = array of wavelengths, in microns.

	images = 3D array (stack of images), one image for each wavelength,
		calibrated in Jansky's / arcsec^2.

 KEYWORDS:
	BOX_AVERAGE = radius of moving box of pixels to average over.
	/PLOT : plot the data & fit result at each pixel.

 OUTPUTS:
	Function returns array of structures (one for each image pixel)
	containing spectrum fit results: Temperature, mass of dust, etc...

 COMMON BLOCKS:
	common IR_spectrum_fit, fitparms, wghts

 EXTERNAL CALLS:
	pro X_Var_Edit
	function IR_spectrum_fit
 PROCEDURE:
	Call function IR_spectrum_fit in a double loop.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1996.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/ir_dust_model.pro)


IR_SPECTRUM_FIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	IR_spectrum_fit
 PURPOSE:
	Fit an infrared emission spectrum with a simple 1D radiative transfer
	model of single temperature dust emission from a homogenous source
	and line of sight absorption by colder dust.

 CALLING:
	specfit = IR_spectrum_fit( wvdat, fdat )

 INPUTS:
	wvdat = array of wavelengths, in microns.

	fdat = array of fluxes at each wavelength,
		calibrated in Jansky's / arcsec^2.

 KEYWORDS:
	DUST_KAPPA = structure containing the dust absorption coefficients.
	FIT_PARM_STRUCT = structure containing the fit control parameters,
		default is silicate dust at Galactic Center distance, with
		even mix of graphite & silicate dust in Line-of-sight (LOS).
	SOURCE_NAME = string, optional, name of source.
	BEAM_AREA = optional area of beam in arcsec^2,
		and this area factor is applied to computed luminosities.
	/PLOT : plot the data and overplot fitting result,
		PLOT=2 prints hardcopy.

 OUTPUTS:
	Function returns a structure with tags containing
	spectrum fit results: Temperature, mass of dust, etc...

 OPTIONAL OUTPUTS:
	wvf = wavelength array.
	flux_obs = flux (at wvf) of fit to (wvdat,fdat).
	flux_src = flux of source with no extinction.

 COMMON BLOCKS:
	common IR_spectrum_fit, fitparms, wghts
 EXTERNAL CALLS:
	pro match
	pro non_Lin_Lsq		(a version of IDL function curvefit)
	function finterpol
	function rad_trans_1D	(called by non_Lin_Lsq)
 PROCEDURE:
	Setup common blocks for function rad_trans_1D,
	call pro non_Lin_Lsq to fit spectrum, put results into structure.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1996.
	FV.1998: added option to keep extinction fixed.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/ir_spectrum_fit.pro)


MAX_ENTROPY

[Previous Routine] [Next Routine] [List of Routines]
PURPOSE:
	Deconvolution of data by Maximum Entropy analysis, given the
	instrument point spread response function (spatially invariant psf).
	Data can be an observed image or spectrum, result is always positive.
	Default is convolutions using FFT (faster when image size = power of 2).
CALLING:
	for i=1,Niter do begin
	Max_Entropy, image_data, psf, image_deconv, multipliers, FT_PSF=psf_ft
INPUTS:
	data = observed image or spectrum, should be mostly positive,
					with mean sky (background) near zero.
	psf = Point Spread Function of instrument (response to point source,
							must sum to unity).
	deconv = result of previous call to Max_Entropy,
	multipliers = the Lagrange multipliers of max.entropy theory
		(on first call, set = 0, giving flat first result).
OUTPUTS:
	deconv = deconvolution result of one more iteration by Max_Entropy.
	multipliers = the Lagrange multipliers saved for next iteration.
KEYWORDS:
	FT_PSF = passes (out/in) the Fourier transform of the PSF,
		so that it can be reused for the next time procedure is called,
      /NO_FT overrides the use of FFT, using the IDL function convol() instead.
      /LINEAR switches to Linear convergence mode, much slower than the
		default Logarithmic convergence mode.
	LOGMIN = minimum value constraint for taking Logarithms (default=1.e-9).
EXTERNAL CALLS:
	function convolve( image, psf ) for convolutions using FFT or otherwise.
METHOD:
	Iteration with PSF to maximize entropy of solution image with
	constraint that the solution convolved with PSF fits data image.
	Based on paper by Hollis, Dorband, Yusef-Zadeh, Ap.J. Feb.1992,
	which refers to Agmon, Alhassid, Levine, J.Comp.Phys. 1979.
HISTORY:  written by Frank Varosi at NASA/GSFC, 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/max_entropy.pro)


MAX_LIKELIHOOD

[Previous Routine] [Next Routine] [List of Routines]
PURPOSE:
	Deconvolution of an observed image (or spectrum), given the
	instrument point spread response function (spatially invariant psf).
	Performs iteration based on the Maximum Likelihood solution for
	the restoration of a blurred image (or spectrum) with additive noise.
	Maximum Likelihood formulation can assume Poisson noise statistics
	or Gaussian additive noise, yielding two types of iteration.
CALLING:
	for i=1,Niter do Max_Likelihood, data, psf, deconv, FT_PSF=psf_ft
INPUTS:
	data = observed image or spectrum, should be mostly positive,
				with mean sky (background) near zero.
	psf = Point Spread Function of the observing instrument,
				(response to a point source, must sum to unity).
INPUT and OUTPUT:
	deconv = as input: the result of previous call to Max_Likelihood,
		(initial guess on first call, default = average of data),
		as output: result of one more iteration by Max_Likelihood.
	Re_conv = (optional) the current deconv image reconvolved with PSF
		for use in next iteration and to check convergence.
KEYWORDS:
      /GAUSSIAN causes max-likelihood iteration for Gaussian additive noise
		to be used,  otherwise the default is Poisson statistics.
	FT_PSF = passes (out/in) the Fourier transform of the PSF,
		so that it can be reused for the next time procedure is called,
      /NO_FT overrides the use of FFT, using the IDL function convol() instead.
	POSITIVITY_EPS = value of epsilon passed to function positivity,
			default = -1 which means no action (identity).
	UNDERFLOW_ZERO = cutoff to consider as zero, if numbers less than this.
EXTERNAL CALLS:
	function convolve( image, psf ) for convolutions using FFT or otherwise.
	function positivity( image, EPS= ) to make image positive.
METHOD:
	Maximum Likelihood solution is a fixed point of an iterative eq.
	(derived by setting partial derivatives of Log(Likelihood) to zero).
	Poisson noise case was derived by Richardson(1972) & Lucy(1974).
	Gaussian noise case is similar with subtraction instead of division.
HISTORY:
	written: Frank Varosi at NASA/GSFC, 1992.
	F.V. 1993, added optional arg. Re_conv (to avoid doing it twice).

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/max_likelihood.pro)


MAX_RESID_LIKE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Max_Resid_Like
 PURPOSE:
 CALLING EXAMPLE:
 INPUTS:
 KEYWORDS:
 OUTPUTS:
 EXTERNAL CALLS:
 COMMON BLOCKS:
 PROCEDURE:
	Uses conjugate-gradient method to minimize
	the chi-square of residual auto-correlation,
	as computed by function chi_Resid_Corr( image_deconv, gradient ).
	The chi_sq is minimized until close to most probable value (mode),
	and then the difference (chi_sq - mode)^2 is further minimized
	(phase2 of algorithm).
 Based on:
	"Incorporation of Spatial Information in Bayesian Image Reconstruction:
			the Maximum Residual Likelihood (MRL) Criterion",
	by Robert Pina and Richard Puetter UCSD 1992.
 MODIFICATION HISTORY:
	Written, Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/max_resid_like.pro)


MEGA_GRAINS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Mega_Grains
 PURPOSE:
	Approximate the effective absorption and scattering properties
	of a two-phase clumpy medium of dust by considering the randomly
	located spherical clumps as large grains:  "mega-grains".
	Assumes that clumps are uniformly distributed, all of same radius
	and same density relative to the inter-clump medium (ICM).
	Based on the theory of Hobson & Padman 1993, MNRAS, 264, 161-164,
	and extended to the case when the filling factor of the clumps > 0.3.
	Effective albedo of the clumps (albedo_CL) is estimated using the
	Osterbrock-Lucy escape probability instead of Hobson & Padman eq.,
	thereby improving agreement with Monte Carlo simulations.
	Includes new approximation for effective scattering asymmetry parameter
	(see Varosi and Dwek, 1999 ApJ 523, 265 for all equations).
	Optionally, the optical properties of dust in the ICM can be specified
	with ICM_* keywords, if different than dust in clumps.
 CALLING:
	Mega_Grains, kabscat_MG, kabscat_ICM, albedo_EFF, g_EFF

 KEYWORD INPUTS:

	XSEC_DUST = total (absorption + scattering) cross-section of dust.
	ALBEDO_DUST = dust scattering albedo (default = 0).
	GP_DUST = scattering asymmetry parameter of dust.

	ICM_XSEC = optional, Xsec for dust in the ICM if different than clumps.
	ICM_ALBEDO = scattering albedo for dust in the ICM (optional).
	ICM_GP = scatt. asymmetry param. for dust in the ICM (optional).

	DENS_HOMOG = desired equivalent homogenous (average) density (default=1)
	FILL_FACT = volume filling factor of clumps.
	RADIUS_CLUMP = radius of a spherical clump (same units as XSEC & DENS).
	RATIO_ICM_CL = ratio of ICM to clump densities.
	DRATIO_CL_ICM = ratio of clump to ICM densities (overrides RATIO_ICM_CL)

	GAMMA_F = exponent used in extended MG approx: (1-ff)^gamma_f
		which is the clump radii renormalization factor.
		Default = 1, so default renorm factor is just (1-ff).

	Note: any one input keyword can be a vector (so outputs are vectors),
		then other inputs should be scalar or vector of same size.

	/NORMAL_CLUMPS : flag to use full clump optical depth instead of
		the default due to just the overdensity.
		This option is invoked by function mega_grain_abs.

	/HP_MG : set this to use original Hobson & Padman mega-grains approx.
	/HP_ALBEDO : set to use original Hobson & Padman approx. clump albedo,
		default is to use Osterbrock-Lucy escape probability from clump.
 OUTPUTS:
	kabscat_MG = effective absorption + scattering coefficient per unit
			length in medium of the clumps only.

	kabscat_ICM = absorption + scattering coefficient of inter-clump medium,
			again per unit length.

	albedo_EFF = effective scattering albedo of the medium: clumps and ICM.

	g_EFF = effective scattering asymmetry parameter of the clumpy medium.

 KEYWORD OUTPUTS (optional):
	ACLUMP = equivalent scattering albedo of each clump.
	GCLUMP = equivalent scattering asymmetry parameter of each clump.
	TAU_CL = optical depth of each clump.

 EXAMPLE OF USING OUTPUT:
	Effective optical depth of sphere:
		tau_eff = radius * ( kabscat_MG + kabscat_ICM )
	With scattering:
		tau_effsc = tau_eff_scat( g_EFF, albedo_EFF, tau_eff )
	Escape probabilities:
		central source:		ep = exp( -tau_effsc )
		uniform source:		ep = escape_prob( tau_eff, albedo_EFF )
 EXTERNAL CALLS:
	function Pinteract
	function escape_prob
 PROCEDURE:
	Based on theory of Hobson & Padman 1993, MNRAS, 264, 161-164,
	"Radiative transfer in a clumpy medium - II:
	 The mega-grains approximation for two-phase models".
	Extended to filling factors > 0.3 by decreasing the effective
	clump radii by (1-f) yielding more and smaller clumps.
	Extended approximation to ICM/Clump density ratios > 1 (cavities) by
	simply reversing the roles of clumps and ICM.
	Improved approximation for effective scattering albedo.
	Introduced new approximation for effective scattering asymmetry param.
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1996.
	FV 1998, added code for g_EFF and keywords GAMMA_F= , /NORMAL_CLUMPS.
	FV 1999, added keywords ICM_XSEC, ICM_ALBEDO, ICM_GP and related code.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/mega_grains.pro)


MEGA_GRAIN_ABS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Mega_Grain_Abs
 PURPOSE:
	Compute fraction of photons absorbed by the inter-clump medium (ICM)
	for the case of photons emitted uniformly/centrally in a spheriod/disk.
	Returns what fraction of the photons absorbed in the two-phase
	clumpy medium are actually absorbed by the inter-clump medium (ICM).
	Uses a variation of the Mega-Grains approximation (see mega_grains.pro)
	but this theory is NOT in the original paper by Hobson & Padman 1993.
	The clumps are treated totally separate from ICM (not just overdensity).
	(See Varosi and Dwek, 1999 ApJ 523, 265 for all equations).
 CALLING:
	frac_abs_ICM = Mega_Grain_Abs( FILL_FACT=,... )

 KEYWORD INPUTS:

	XSEC_DUST = total (absorption + scattering) cross-section(s) of dust.
	ALBEDO_DUST = dust scattering albedo(s).
	GP_DUST = scattering asymmetry parameter(s).

	ICM_XSEC = optional, Xsec for dust in the ICM if different than clumps.
	ICM_ALBEDO = scattering albedo for dust in the ICM (optional).
	ICM_GP = scatt. asymmetry param. for dust in the ICM (optional).

	DENS_HOMOG = desired equivalent homogenous (average) density (default=1)
	RADIUS_EFF = effective radius of sphere enclosing the clumps.

	FILL_FACT = volume filling factor of clumps.
	RADIUS_CLUMP = radius of a spherical clump (same units as XSEC & DENS).
	RATIO_ICM_CL = ratio of ICM to clump densities.
	DRATIO_CL_ICM = ratio of clump to ICM densities (overrides RATIO_ICM_CL)

	SOURCE_TYPE = string (upper or lowercase) indicating source of photons:
		"C" : case of central point source,
		"X" : case of uniformly illuminating external source,
		"U" = uniformly distributed internal sources (default case).
		"MC" : central source only in clumps (no emission in ICM),
		"MU" : uniform source only in clumps (no emission in ICM).

	/CLUMPS : return instead fraction absorbed by clumps ( = 1 - f_ICM ).
 OUTPUTS:
	Function returns the fraction of photons absorbed by ICM,
	for the case of central or uniformly distributed emission.

 EXTERNAL CALLS:
	pro Mega_Grains,/NORMAL_CLUMPS
	function escape_prob
	function Tau_Eff_Scat
 PROCEDURE:
	Approximate the effects of scattering by function Tau_Eff_Scat.
	Then compute ICM fraction based on ratio of k_ICM/(k_MG+k_ICM).
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1996-97.
	F.V. 2000, added source types "MC" and "MU" (source just in clumps).

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/mega_grain_abs.pro)


MGEP_RAD_TRANS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	MGEP_Rad_Trans
 PURPOSE:
	Approximate the radiative transfer of photons emitted in or impacting
	a two-phase clumpy medium (dust & gas) of spherical/disk geometry,
	using the Mega-Grains approximation of Hobson & Padman,
	combined with the escape/interaction probability formulae:
	Osterbrock-Lucy E.P. for uniformly distributed internal source,
	Varosi's interaction prob. for uniformly illuminating external source,
	or Varosi's E.P. approximation for central source.
	See Varosi & Dwek 1999, ApJ 523, 265 for complete discussion.
	An approximation for the ionization of Hydrogen, and resultant
	heating of dust by Lyman-alpha photons is also attempted.
	See keyword SOURCE for the 5 types of photon sources modeled,
	(3 standard types and 2 special for sources only in clumps).
 CALLING:
	MGEP_Rad_Trans, SED_wave, SED_source, SED_esc, Lumins

 INPUTS:
	SED_wave = array of SED wavelengths, in microns.
		The dust abs. & scat. coeffs. (input from KAPPA_DUST keyword)
		are interpolated onto this SED wavelength grid.

	SED_source = Spectral Energy Distribution (SED) of source emission
		vs. wavelength, in solar luminosities per Angstrom (Lsun/A).

 OUTPUTS:
	SED_esc = escaping spectral energy distribution vs. wavelength (Lsun/A).

	Lumins = structure variable accounting of all Luminosities emitted,
		escaped, and absorbed in dust/gas.

 KEYWORD INPUTS:	(ICM = interclump medium)

	KAPPA_DUST = structure variable with dust absorption/scattering coeffs.
	KAPPA_ICM_DUST = optional, structure with ICM dust abs. & scat. coeffs.

	DUST_MASS_DEN = equivalent homogeneous mass density of dust (gm/cm^3).
	DUST_FRAC = mass fraction of each component of the dust.
	DUST_ICM_FRAC = optional, dust component fractions in the ICM.

	GAS_DEN = homogeneous density (n(H)/cm^3) of atomic hydrogen.
	GAS_TEMP = temperature (K) of atomic hydrogen.
	RADIUS = effective radius of sphere/disk containing clumpy medium.

	FILL_FACT = volume filling factore of spherical clumps,
	CLUMP_RADIUS = radius of a spherical clump, same units as RADIUS.
	RATIO_DICM_DCL = ratio of ICM density to clump density.

	SOURCE = string (upper or lowercase) indicating source of photons:
		"C" : case of central point source,
		"X" : case of uniformly illuminating external source,
		"U" = uniformly distributed internal sources (default case).
		"MC" : central source only in clumps (no emission in ICM),
		"MU" : uniform source only in clumps (no emission in ICM).

	/PLOT : plot intermediate results.
	/VERBOSE : print informational messages about results.
	/FULL_STRUCT : include all results in output structure variable "Lumins"

 OPTIONAL KEYWORD OUTPUTS:
	EPWAVE = computed photon escape probability vs. wavelength.
	EPLYA = escape probability of Lyman alpha accounting for resonant
		scattering in a dusty medium.
	TAU_EFF = the effective optical depth of medium at each wavelength.
	ALBEDO_EFF = the effective albedo of clumpy medium at each wavelength.
	FDUST = fractions of photons absorbed by each dust component and phase.
	FGAS = fractions of photons absorbed by each gas phase at each wavelen.
 EXTERNAL CALLS:
	pro Mega_Grains
	function Mega_Grain_Abs
	function Finterpol
	function ismeuv
	function Tau_Eff_Scat
	function Escape_Prob
	function Pinteract
	function Trapez
	function ep_Lya
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995
	F.V. 1997, account for absorbtion by both ICM and clumps.
	F.V. 1999, added keyword options for different dust in ICM.
	F.V. 2000, added source types "MC" and "MU" (source just in clumps).

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/mgep_rad_trans.pro)


MG_EP_2PHASE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	MG_EP_2phase
 PURPOSE:
	Approximate the radiative transfer of photons in a
	two-phase clumpy medium (dust & gas) of spherical/disk geometry, by
	calling MGEP_Rad_Trans, and then compute equilibrium dust temperatures
	and infrared emission using function Dust_Emission.
	Can optionally model an environment where the SED of stars in clumps
	is different that stars in ICM (see keywords SED_CLUMPS and SRC_CLUMPS),
	or case of the dust in ICM different than in clumps (KAPPA_ICM_DUST).
 CALLING:
	MG_EP_2phase, SED_wave, SED_source, SED_esc, Lumins, dust_emiss
 INPUTS:
	SED_wave = array of SED wavelengths, in microns.

	SED_source = Spectral Energy Distribution (SED) of source emission
		vs. wavelength, in solar luminosities per Angstrom (Lsun/A).
 OUTPUTS:
	SED_esc = escaping SED vs. wavelength (Lsun/A).

	Lumins = structure variable accounting of all Luminosities emitted,
		escaped, and absorbed in dust (tag LUM_DUST) or gas.

	dust_emiss = structure variable containing the temperature of dust
		in each phase, and optionally the infrared emission spectra.

 KEYWORD INPUTS:

	KAPPA_DUST = structure variable with dust absorption/scattering coeffs.
	KAPPA_ICM_DUST = optional, structure with ICM dust abs. & scat. coeffs.

	Required Structure Tags:
		Dust_Kappa.wavelen	(Nwave)  (wavelengths, in microns)
		Dust_Kappa.Kabs		(Nwave,Ncomp)	(absorption per mass)
		Dust_Kappa.Ksca		(Nwave,Ncomp)	(scattering per mass)
		Dust_Kappa.gcos		(Nwave,Ncomp)	(asymmetry params)
		Dust_Kappa.dust_comp	(Ncomp)  (eg. ["graphite","silicates"])
		Dust_Kappa.Tmax		(Ncomp)  (sublimation temperatures)

  (note: the following 3 structures are defined by IDL> @def_mgep)

	GEOMETRY = structure variable:
		geometry.R = radius of sphere/disk/cylinder (in pc).
		geometry.H = height of disk/cylinder (if H=0 then sphere).

	CLUMPY = structure variable:
		clumpy.fill_fact	(filling factor of clumps)
		clumpy.Clump_ICM_Ratio	(clump/ICM density ratio)
		clumpy.Rcl		(radius of clumps, in pc)

	MEDIUM = structure variable, specify:
 		medium.fsil		(ratio of silicates to total dust mass)
		medium.Dust_Mass_Dens   (gm/cm^3)
		medium.gas_dens		(n(H)/cm^3)

	SOURCE = string (upper or lowercase) indicating type of photon source:
		"C" = central point source,
		"X" = uniformly illuminating external source,
		"U" = uniformly distributed internal sources (default case).

	SED_CLUMPS = optional SED of stellar emission in clumps,
		and then input array SED_source is for stars in the ICM.
		Output array SED_esc and structure Lumins is then the
		sum of effects from SED_source and SED_clumps.

	SRC_CLUMPS = string indicating type of source emission in clumps:
		"C" = central point source,
		"U" = uniformly distributed sources (default case).
		Must specify SED_CLUMPS and then SOURCE=type of emission in ICM.

	/PLOT : plot intermediate results.
	/VERBOSE : print informational messages about results.
	/FULL_STRUCT : include all results in output structure variable "Lumins"

 KEYWORD OUTPUTS (optional):

	SED_ABS_DUST = 3D matrix of flux vs. wavelength absorbed by each
		component and phase of the dust: (Nwave,Ncomp,Nphase) (Lsun/A).
	SED_ESC_CL = escaping flux from source just in clumps.
	LUM_CLUMPS = absorbed luminosities (structure) from source in clumps.

 EXTERNAL CALLS:
	pro MGEP_Rad_Trans
	pro add_struct
	function Dust_Emission
 HISTORY:
	Written: Frank Varosi, RSTX @ NASA/GSFC, 1997
	F.V. 1999, added keyword KAPPA_ICM_DUST for different dust in ICM.
	F.V. 2000, added option for separate SED for stars in clumps.
	F.V. 2000, added keyword output SED_ABS_DUST.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/mg_ep_2phase.pro)


PINTERACT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Pinteract

 PURPOSE:
	Compute and return the probability that a photon entering a sphere
	of absorbers and/or scatterers (e.g. dust or gas) at a random angle
	will interact with an absorber/scatterer. In otherwords, it gives
	the interacting fraction of a collection of randomly impacting photons.
	If the scattering albedo is given, then the actual absorbed fraction is
	computed approximately. When scattering is specified to be purely
	forward then an exact formula used.

 CALLING:
	Pint = Pinteract( tau )

 INPUTS:
	tau = optical radius of sphere (absorption and/or scattering).

	albedo = scattering albedo (optional), if specified then the eventual
		escape of photons due to scattering is accounted for approx.,
		in which case Pinteract returns the actual absorbed fraction.
		If scattering is purely forward then exact formula is used.
 KEYWORDS:
	/FORWARD : indicates purely forward scattering (when albedo > 0).
 OUTPUTS:
	Returns probability of interaction, same dimensions as input.
 PROCEDURE:
	Exact formula is derived by averaging transmission over all
	impact parameters. Formula was given in Neufeld, ApJL., 1991, and
	Hobson & Padman, MNRAS, 1993.
	Exact formula for purely forward scattering is using tau*(1-albedo),
	approx formula for non-forward is by using escape probability function.
 EXTERNAL CALLS:
	function Pinteract	(recursively)
	function escape_prob	(when scattering albedo is specified).
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1997.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/pinteract.pro)


PLOT_DCINFO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	plot_dcinfo
 PURPOSE:
 CALLING EXAMPLE:
 INPUTS:
 KEYWORDS:
 OUTPUTS:
 EXTERNAL CALLS:
 COMMON BLOCKS:
 PROCEDURE:
 MODIFICATION HISTORY:
	Written, Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/plot_dcinfo.pro)


POSITIVITY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Positivity
 PURPOSE:
	For use in nonlinear functional fitting or minimization
	that require a positivity constraint on solution parameters.
	Take unconstrained parameter array x (usually an image),
	and map it uniquely and smoothly into positive values.
	Negative values of x get mapped to interval ( 0, sqrt( EPSILON )/2 ],
	positive values go to ( sqrt( EPSILON )/2, oo )
	with derivative approaching unity. Derivative is always 1/2 at x=0.
	Derivative is used by the MRL deconvolution algorithm.
	If EPSILON=0 then mapping reduces to truncation > 0.
	If EPSILON LT 0 then mapping reduces to identity (no change).
 CALLING:
	px = positivity( x [, EPS=1, /DERIV ] )
 INPUTS:
	x = any numerical scalar or array.
 KEYWORDS:
	EPSILON = scalar parameter, small positive number (default = 1.e-8).
	/DERIVATIVE : causes derivative at x to be computed and returned.
 OUTPUTS:
	Function returns variable of same type and size as input.
 PROCEDURE:
	Use function ( x + sqrt( x^2 + EPSILON ) )/2, a rotated hyperbola.
 HISTORY:
	written: F.Varosi NASA/GSFC 1992, as suggested by R.Pina UCSD.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/positivity.pro)


PSF_MERGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	psf_merge
 PURPOSE:
	Merge two psf matrices together by smoothly splicing/glueing.
 CALLING EXAMPLE:
	psf_combo = psf_merge( psf_inner, psf_outer, RADIUS=7 )
 INPUTS:
	psf_inner = will be used inside (at the peak).
	psf_outer = will be spliced to outside (this one must be centered)
 KEYWORDS:
	LEVEL_SPLICE = magnitude at which psf_outer is spliced with psf_inner,
			overrides and determines RADIUS_SPLICE.
	RADIUS_SPLICE = radius at which splicing occurs (default = 3*FWHM).
	FACTOR_SPLICE = control steepness of glueing function (default = 2).
 OUTPUT:
	Function returns matrix of new spliced PSF.
 EXTERNAL CALLS:
	function dist
	function FullWid_HalfMax (if RADIUS_SPLICE not specified)
 PROCEDURE:
	Use the function 1/(1+exp(x)) to smoothly glue psf_outer to psf_inner.
 HISTORY:
	Written, Frank Varosi NASA/GSFC 1993.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/psf_merge.pro)


RAD_STROMGREN

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Rad_Stromgren
 PURPOSE:
	Compute Stromgren radius of an idealized spherical HII region
	with central source of ionizing photons.

 CALLING:
	radius = Rad_Stromgren( Log_N_Lyc, DENSITY_H = )

 INPUTS:
	Log_N_Lyc = Log base 10 of number of Lyman continuum ionizing photons.

 KEYWORDS:
	DENSITY_H = density of Hydrogen atoms per cubic cm,  default=1.

	RECOMBINATION = recombination rate coefficient, default = 3e-13.

 OUTPUTS:
	Function returns Stromgren radius of HII region in parsecs.

 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1995.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/rad_stromgren.pro)


RAD_TRANS_1D

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	Rad_Trans_1D
 PURPOSE:
	Compute single temperature dust emission/absorption spectrum
	with line of sight (LOS) absorption, in Janskys/arcsec^2.
	If third argument is present, compute partial derivatives for fitting.
 CALLING:
	IR_spec = Rad_Trans_1D( wvd, Params, Pder )
 INPUTS:
	wvd = wavelength array, in microns.
	Params = [ cLOS, T1, csrc1, T2, csrc2 ]
	Pder = matrix of partial derivatives of parameters at wavelengths.
 KEYWORDS:
	/FULL_SPECTRUM : use full resoltuion wavelength array in common block.
	EXTINCT = array of LOS extinction factor vs. wavelength (returned).
	/JANSKYS : return IR intensity in Jy/arcsec^2, otherwise
		default is pure energy [nu.I(nu)]: W/m^2/arcsec^2.
 OUTPUTS:
	Returns the IR intensity in W/m^2 or Janskys, per arcsec^2.

	I(w)=  B(w,T1)*(1-exp[-TAU_src1])*exp[-TAU_LOS] 
	     + B(w,T2)*(1-exp[-TAU_src2])*exp[-TAU_LOS]
 COMMON BLOCKS:
	common IR_spectrum_comp, Fsil_LOS, Fsil_src1, Fsil_src2
	common kappa_interp, wki, kigrf, kisil
	common kappa_full, wkf, kgrf, ksil
	common Rad_Trans_1D, cLOS
 EXTERNAL CALLS:
	pro match
 PROCEDURE:

 HISTORY:
	Written: Frank Varosi & Eli Dwek, NASA/GSFC, 1996.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/rad_trans_1d.pro)


SETUP_MLG

[Previous Routine] [Next Routine] [List of Routines]
Frank Varosi NASA/GSFC 1992.

	Lag = round_off( deconv_info.psf_stats.fwhm ) > 1
	text=""
	read," select residual auto-correlation Lag range  (default=" + $
					strtrim( Lag,2 ) + " to 2) ",text
	if strlen( text ) GT 0 then Lag = fix( get_words( text ) ) > 0
	deconv_info.Lag_chisq = Lag(0)
	if N_elements( Lag ) GT 1 then deconv_info.Lag_min = Lag(1) $
				  else deconv_info.Lag_min = 2
	deconv_info.Lag_chisq = deconv_info.Lag_chisq > deconv_info.Lag_min
	print," auto-correlation Lag range (max,min) =", $
				deconv_info.Lag_chisq, deconv_info.Lag_min

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/setup_mlg.pro)


SETUP_MLP

[Previous Routine] [Next Routine] [List of Routines]
Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/setup_mlp.pro)


SETUP_MRL

[Previous Routine] [Next Routine] [List of Routines]
Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/setup_mrl.pro)


SHOW_PSF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	show_psf
 PURPOSE:
	Display the PSF (image) in pseudo-color with Linear and Log-10 scale,
	and as surface (Log-10) with contours (SHOW3).
	Centroid is determined and marked, and optionally
	the FWHM and other parameters are determined and printed.
 CALLING:
	show_psf, psf, NAME=name, /PRINT_INFO, INFO_PARMS=pinfo
 INPUTS:
	psf = 2D array (image) giving point-spread-function (peaked source).
 KEYWORDS (in):
	NAME = string, name of PSF to use in titles.
	XSIZ_3D, YSIZ_3D = window size for 3D surface plot (def = 512 by 378 ).
	NPOWER_10 = # of powers of 10 to show on 3D surface.
	/NO_3D : skip the 3D surface plot.
	/PRINT_INFO
	/GET_PARMS
 KEYWORDS (out):
	INFO_PARMS = all parameters of PSF (if /PRINT_INFO)
	LORENTZIAN_PARAMS = parameters of PSF (if /PRINT_INFO or /GET_PARMS)
	GAUSSIAN_PARAMS = parameters of PSF (if /PRINT_INFO or /GET_PARMS)
 EXTERNAL CALLS:
	pro tvs
	pro show3
	pro centroid
	pro get_window
	function nint
	function fullwid_halfmax
 COMMON BLOCKS:
	common show_psf, winpsf2, winpsf3
 HISTORY:
	Written, Frank Varosi NASA/GSFC 1992.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/show_psf.pro)


SIGMA_CLEAN

[Previous Routine] [Next Routine] [List of Routines]
Frank Varosi NASA/GSFC 1992.
(still in code development stage...)
 using W.C.Keel, Proc.Astro.Soc.Pacific, July 1991.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/sigma_clean.pro)


TAU_EFF_SCAT

[Previous Routine] [List of Routines]
 NAME:
	tau_eff_scat
 PURPOSE:
	Compute effective optical depth of a sphere including scattering.
 EXPLANATION:
	Effective optical depth is estimated by interpolating between
	approximate solutions at large optical depths and small optical depths.
	Inputs can be scalar or arrays, but must be all same dimensions.
 CALLING:
	tau_eff = tau_eff_scat( gcos, albedos, taus )
 INPUTS:
	gcos = average < cos( scattering angle ) >
	albedos = scattering albedos.
	taus = optical depths (absorbtion + scattering cross-sections).
 OUTPUTS:
	Function returns scalar/array of effective optical depths
 HISTORY:
	Written: Frank Varosi, HSTX @ NASA/GSFC, 1998.

(See /host/bluemoon/usr2/idllib/astron/contrib/varosi/vlibm/allpro/tau_eff_scat.pro)