safetag $SSW/packages/ztools/util/safetag.pro
[Previous] [Next]
 SAFETAG - Return a tag value from a structure, safely

 USAGE: tag = safetag( structure, tag)
	 ok = safetag(structure,/check)

 RETURNS: The tag value, or the null string if the tag is undefined;
	OR tells whether the tag is defined or no.

 CALLS:
 CALLED BY
	CALC_LOI_ROLL, COORD [1], COORD [2], ZGRID, ZGUESS_LOCATION, ZHDRUNIT, ZLASCO_SUM
	datify, fixinate_eit, fixinate_lasco, fixinate_mdi, fixinate_trace, mdialign
	struct_eq, zcheck_hdr, zdeheliographinize, zhelio2xy, zintervals, zprfits
	zradialize, zwritefits, zxy2helio


SET_FUNCTION_COM $SSW/packages/xray/idl/set_function_com.pro
[Previous] [Next]
 NAME:
	SET_FUNCTION_COM

 PURPOSE:
	Sets and changes the values of the parameters in the common block
	FUNCTION_COM

 CATEGORY:
	SPEX (spectroscopic analysis), fitting

 CALLING SEQUENCE:
	SET_FUNCTION_COM, F_MODEL_IN=F_MODEL_IN, EPIVOT_IN=EPIVOT_IN, $
	A_CUTOFF_IN = A_CUTOFF_IN

 KEYWORD PARAMETERS:
	F_MODEL_IN: string with name of fitting model function available in
		    SPEX, e.g. 'F_VTH_BPOW'
	EPIVOT_IN:  cutoff energy in current units, frequently keV
		    defaults to 50.0
	A_CUTOFF_IN: a two element vector with the low-energy power-law
		     cutoff parameters, the break energy and negative power-law
		     defaults are 10.0 keV and 1.5
 OUTPUTS:
	No explicit outputs but changes the values in the common block.

 OPTIONAL OUTPUTS:
	Describe optional outputs here.  If the routine doesn't have any, 
	just delete this section.

 CALLS: ***
	FCHECK
 COMMON BLOCKS:
	FUNCTION_COM

 EXAMPLE:
	SET_FUNCTION_COM, F_MODEL_IN = 'F_3POW'

 MODIFICATION HISTORY:
 	Written by:	ras, 12-dec-1995


SETUP_ELEMENTS $SSW/packages/chianti/idl/low_level/setup_elements.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:
	SETUP_ELEMENTS


 PURPOSE:  read in ionization equilibrium and abundances
           not for general user use


 CALLING SEQUENCE:

       SETUP_ELEMENTS


 INPUTS:

	None	

 OUTPUTS:  reads data into common block


 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], READ_ABUND, READ_IONEQ
	concat_dir [4]
 CALLED BY:
	FB_RAD_LOSS, FF_RAD_LOSS, RAD_LOSS [1], RAD_LOSS [2], SUTHERLAND, TWO_PHOTON, ZETA_0
	bb_rad_loss, freebound, freefree, itoh
 COMMON BLOCKS:

	common elements,abund,abund_ref,ioneq,ioneq_logt,ioneq_ref



 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	Feb.  2000:     Version 1.0 for CHIANTI version 3
       V. 2, 21-May-2002, Giulio Del Zanna (GDZ):
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       V. 3, 16-Apr-2003, Peter Young
                   I had to use expand_path for DIR in order for the paths to be 
                   recognised in Windows.

 VERSION     :   3, 16-Apr-2003 


SETUP_ION $SSW/packages/chianti/idl/low_level/setup_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:
	SETUP_ION

 PURPOSE:

	Several of the CHIANTI routines require the atomic data for ions 
       to be read into common blocks, and so this routine performs this 
       task for individual ions.

       Note that the inputs WVLMIN and WVLMAX merely serve to check 
       whether the ion has lines lying in this wavelength range. If yes, 
       then the common blocks are filled with the data; if no, then the 
       common blocks are left empty. 

       An important point to note is that the 
       wgfa and upsilon common blocks contain their data in 2-D array 
       form, suitable for solving the level balance equations. When 
       dealing with dielectronic files, there will be some transitions 
       which will have two A-values, one representing autoionisation 
       rather than radiative decay. For the level balance equations, 
       these two A-values need to be summed together. However, for 
       computing the line emissivity, one needs to only use the radiative 
       decay A-value. For this purpose, the routine outputs the 1-D 
       arrays read by READ_WGFA2 which contain the two separate A-values, 
       allowing other routines to pick out just the radiative decay 
       A-value. These outputs are listed below (LVL1, LVL2, etc.).


 CALLING SEQUENCE:

       SETUP_ION,Ion,Wvlmin,Wvlmax,Wvltst,Lvl1,Lvl2,Wvl1,Gf1,A_value1


 INPUTS

	ION     String specifying ion, e.g., 'c_2'
       
       WVLMIN  Minimum wavelength of interest (angstroms). If there are 
               no lines with wavelengths between WVLMIN and WVLMAX, then 
               no data is read into the common blocks. If both WVLMIN 
               and WVLMAX are set to -1, then no checks are made on the 
               wavelengths (i.e., the common blocks will be filled).

       WVLMAX  Maximum wavelength of interest (angstroms). See above.
	
 OPTIONAL INPUT

       PATH    Can be used to specify a different directory to !xuvtop 
               for the location of the data files. E.g., 
               path='/data/user/chianti/o_4'

 KEYWORDS

       NOPROT  Switches off the inclusion of proton rates.

       ALL     By default the routine only looks for wavelengths which 
               are positive when checking if they lie in the wavelength 
               range. By setting /ALL then negative wavelengths are also 
               included.

 OUTPUTS:

	WVLTST  The number of transitions lying between WVLMIN and WVLMAX. 
               If WVLMIN and WVLMAX are both -1, then WVLTST will 
               be the total number of transitions in the .wgfa file 
               (including any with zero wavelength).

       LVL1    Number of final level of transition (1-D array)

       LVL2    Number of initial level of transition (1-D array)

       WVL1    Wavelenths (in angstroms) of spectral lines formed by this 
               ion (1-D array)

       GF1     Oscillator strength (1-D array)

       A_VALUE1 Radiative transition probability (1-D array)

 OPTIONAL OUTPUTS

       ANYLINES Contains the indices of the elements of lvl1, lvl2, wvl1, 
                gf1, a_value1 arrays for which the wavelengths lie in 
                specified wavelength range.

 CALLED BY:
	EMISS_CALC, POP_PROCESSES, RATE_COEFF, SHOW_POPS, TWO_PHOTON, bb_rad_loss
 EXAMPLE:

    IDL> setup_ion,'c_2',1000.,1500.,wvltst,Lvl1,Lvl2,Wvl1,Gf1,A_value1
    IDL> print,wvltst
          17
    IDL> setup_ion,'c_2',-1,-1,wvltst,Lvl1,Lvl2,Wvl1,Gf1,A_value1
    IDL> print,wvltst
          43
    IDL> setup_ion,'c_2',-1,0,wvltst,Lvl1,Lvl2,Wvl1,Gf1,A_value1
    IDL> print,wvltst
           0

 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], READ_ELVLC, READ_IONREC
	READ_SPLUPS, READ_WGFA2, concat_dir [4], ion2filename
 COMMON BLOCKS:

	common elvlc,l1a,term,conf,ss,ll,jj,ecm,eryd,ecmth,erydth,eref
       common wgfa, wvl,gf,a_value
       common upsilon,t_type,deu,c_ups,splups

 CALLS

    READ_WGFA2, READ_SPLUPS, READ_ELVLC, ION2FILENAME


 MODIFICATION HISTORY:

       Ver.1, Sep-99, Ken Dere
       Ver.2, 10-Oct-00, Peter Young
                Allowed wvlmin and wvlmax to take -1 values.
                Removed elements common block.
                Removed for-loop.
                Added PATH.
       Ver.3, 12-Nov-01, Peter Young
                Added proton common block and /noprot keyword
       Ver.4, 11-Dec-01, Peter Young
                Added keyword /all.

       V.5, Giulio Del Zanna (GDZ)
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       V.6, 25-Feb-2004, Enrico Landi (EL)
                   Added call to read_ionrec.pro to read ionization 
                   and recombination files.

 VERSION     :   6, 25-Feb-2004, EL 


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

 NAME:
	setup_params

 PURPOSE:
       intialize parameters and command strings for SPEX

 CATEGORY:
       initializations

 CALLING SEQUENCE:
   	setup_params, params, fam_info

 CALLED BY:
       SPEX

 INPUTS:
       none

 OUTPUTS:
       params - parameter structures with family, type, initial value, range info
	fam_info - structure which allocates command strings to FAMILY menus

 CALLS: ***
	ATIME [1], ATIME [2], CREATE_FAMILY [1], CREATE_FAMILY [2], CREATE_PARAM [1]
	CREATE_PARAM [2], GET_UTC, JULDAY, chk_batse_env [1], chk_batse_env [2]
	printx [1], printx [2]
 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 MODIFICATION HISTORY:
	akt
	ras, 19-may-94 added command string 'reset_event' and parameter nback
	ras, 03-aug-94 added command string 'restore_event','save_event'
	ras, 25-aug-94 added command string 'pspreview'
	RAS, 4-mar-95, added test_drm option
	RAS, 14-mar-95, added cont_pendleton option
	RAS, 28-mar-95, added controls for recalibration
	ras, 2-nov-95, changed defaults to test_drm,2 and cont_pendleton,1
	Version 2, ras, 8-April-1996, changed str name to parm_structure2
	Version 10, ras, 30-apr-1997, changed back_order max to 3
	Version 11, richard.schwartz@gsfc.nasa.gov, 21-aug-1997, default
	on cont edges in set_pendleton is 2, Preece mod of Lestrade!
	Version 12, richard.schwartz@gsfc.nasa.gov, 1-oct-1997,
	removed @flare_catalog
	PB, 21-Jun-00, added call to chk_batse_env and error checking to allow start-
		up to proceed without calls to read_flare, etc.


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

 NAME:
	setup_params

 PURPOSE:
       intialize parameters and command strings for SPEX

 CATEGORY:
       initializations

 CALLING SEQUENCE:
   	setup_params, params, fam_info

 CALLED BY:
       SPEX

 INPUTS:
       none

 OUTPUTS:
       params - parameter structures with family, type, initial value, range info
	fam_info - structure which allocates command strings to FAMILY menus

 CALLS: ***
	ATIME [1], ATIME [2], CREATE_FAMILY [1], CREATE_FAMILY [2], CREATE_PARAM [1]
	CREATE_PARAM [2], GET_UTC, JULDAY, chk_batse_env [1], chk_batse_env [2]
	printx [1], printx [2]
 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 MODIFICATION HISTORY:
	akt
	ras, 19-may-94 added command string 'reset_event' and parameter nback
	ras, 03-aug-94 added command string 'restore_event','save_event'
	ras, 25-aug-94 added command string 'pspreview'
	RAS, 4-mar-95, added test_drm option
	RAS, 14-mar-95, added cont_pendleton option
	RAS, 28-mar-95, added controls for recalibration
	ras, 2-nov-95, changed defaults to test_drm,2 and cont_pendleton,1
	Version 2, ras, 8-April-1996, changed str name to parm_structure2
	Version 10, ras, 30-apr-1997, changed back_order max to 3
	Version 11, richard.schwartz@gsfc.nasa.gov, 21-aug-1997, default
	on cont edges in set_pendleton is 2, Preece mod of Lestrade!
	Version 12, richard.schwartz@gsfc.nasa.gov, 1-oct-1997,
	removed @flare_catalog
	PB, 21-Jun-00, added call to chk_batse_env and error checking to allow start-
		up to proceed without calls to read_flare, etc.


setup_spex [1] $SSW/packages/spex/idl/original_spex/setup_spex.pro
[Previous] [Next]
 PROJECT:
 SDAC
 NAME:
 setup_spex
 PURPOSE:
 Initialize parameters and variables for spex.pro
 CALLING SEQUENCE:
 setup_spex, com_stack, style_sel, need, prompt, comments, $
   script_opt1, script_opt2, standard_types, bdata, $
   dir_queue, edg_units, last_found, last_read, wtitles, gaction, $
   gdaction, goaction,  plotbuffer, bang_enter, setup_sys, merge_list=merge_list, $
   nowidget=nowidget, last_plot=last_plot, handles=handles

 CATEGORY:
 SPEX, analysis
 INPUTS:

 OUTPUTS:
 com_stack,
 style_sel,
 need,
 prompt,
 comments,
 script_opt1,
 script_opt2,
 standard_types, A string arrays whose entries determine the valid
     spacecraft and instruments recognized by SPEX
 bdata,
 dir_queue,
 edg_units,
 last_found,
 last_read,
 wtitles,
 gaction,
 gdaction,
 goaction,
 plotbuffer,
 bang_enter,
 setup_sys,
 KEYWORDS
 merge_list
 nowidget,
 last_plot
 handles
 OPTIONAL INPUTS:

 OPTIONAL OUTPUTS:

 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 PROCEDURE:

 CALLS: ***
	CHECKVAR [1], CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FCHECK, FILE_EXIST [2], F_USE_WIDGET, LOC_FILE [1], LOC_FILE [2]
	LOC_FILE [3], OS_FAMILY, PATH_DIR, POINT [1], RD_TEXT, SET_UTLABEL
	SPEX_HANDLES_STR [1], SPEX_HANDLES_STR [2], WINUP [5], XDEVICE, checkvar [2]
	concat_dir [4], file_exist [1], file_exist [3], get_logenv [1], get_logenv [2]
	hxrbs_format, linecolors [1], linecolors [2], point [2], winup [1], winup [2]
	winup [3], winup [4], wsetshow [1], wsetshow [2]
 RESTRICTIONS:

 MODIFICATION HISTORY:
 ras, 22-apr-94
 ras, 5-may-94, incorporate need structure and Yohkoh sxs changes
 ras, 17-may-94, update site specific setup
 ras, 15-jun-94, enable widget menus
       ras, 14-oct-94, add spex_remote
 ras, 10-apr-95, changed data directory on umbra
 ras, 23-aug-95, changed data directory on umbra
 RAS, 13-jan-96, isas installation modified
 Version 2, ras, 8-apr-1996, align structure boundaries
   added last_plot and handles initialization
 ras, 15-apr-1996, added stte to standard types
 ras, 16-may-1996, added near pin to standard types
 ras, 16-may-1996, added WIND TGRS to standard types
 ras, 14-aug-1996, made the comments section more robust
 ras, 21-oct-1996, added BATSE DISCSP_CONT to standard types
 ras, 2-dec-1996, replace RD_ASCII with RD_TEXT with LOC_FILE
 Version 16,
 ras, 26-mar-1997, added SMM GRS detectors, Spectrometer and Xray detectors merged
 Version 17,
 ras, 7-Jul-1997, changed dir_queue for ibdb files at sdac and umbra
 Version 18,
 richard.schwartz@gsfc.nasa.gov, 26-sep-1997 added BATSE DISCLA.
 Version 19,
 richard.schwartz@gsfc.nasa.gov, 14-nov-1997, place txt help files in
 ssw distribution and use path_dir to locate.
 Version 21,
 richard.schwartz@gsfc.nasa.gov, 3-feb-1998, modified DIR_QUEUE to use
 BATSE_DATABASE.
 richard.schwartz@gsfc.nasa.gov, 27-may-1998, revised to support WIN and MACos
 richard.schwartz@gsfc.nasa.gov, 19-march-1999, for unknown site, root db 
 directories
 for BATSE to BATSE_DATABASE
 1-June-2000 Paul Bilodeau added HXRS instrument and SHLD,NSHLD, and TOTAL
 formats
 18-FEB-2001 richard.schwartz@gsfc.nasa.gov, 18-feb-2001, added HESSI
 FRONT,REAR, ALLSEG
 20-March-2002, Paul Bilodeau - use free window id numbers from winup
 common block, no longer 0 / 1.  Call to wsetshow for initialization.
 Use WIN_NAME keyword in call to wsetshow to select windows.


setup_spex [2] $SSW/packages/spex/pre2002/idl/setup_spex.pro
[Previous] [Next]
 PROJECT:
 SDAC
 NAME:
 setup_spex
 PURPOSE:
 Initialize parameters and variables for spex.pro
 CALLING SEQUENCE:
 setup_spex, com_stack, style_sel, need, prompt, comments, $
   script_opt1, script_opt2, standard_types, bdata, $
   dir_queue, edg_units, last_found, last_read, wtitles, gaction, $
   gdaction, goaction,  plotbuffer, bang_enter, setup_sys, merge_list=merge_list, $
   nowidget=nowidget, last_plot=last_plot, handles=handles

 CATEGORY:
 SPEX, analysis
 INPUTS:

 OUTPUTS:
 com_stack,
 style_sel,
 need,
 prompt,
 comments,
 script_opt1,
 script_opt2,
 standard_types, A string arrays whose entries determine the valid
     spacecraft and instruments recognized by SPEX
 bdata,
 dir_queue,
 edg_units,
 last_found,
 last_read,
 wtitles,
 gaction,
 gdaction,
 goaction,
 plotbuffer,
 bang_enter,
 setup_sys,
 KEYWORDS
 merge_list
 nowidget,
 last_plot
 handles
 OPTIONAL INPUTS:

 OPTIONAL OUTPUTS:

 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 PROCEDURE:

 CALLS: ***
	CHECKVAR [1], CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FCHECK, FILE_EXIST [2], F_USE_WIDGET, LOC_FILE [1], LOC_FILE [2]
	LOC_FILE [3], OS_FAMILY, PATH_DIR, POINT [1], RD_TEXT, SET_UTLABEL
	SPEX_HANDLES_STR [1], SPEX_HANDLES_STR [2], WINUP [5], XDEVICE, checkvar [2]
	concat_dir [4], file_exist [1], file_exist [3], get_logenv [1], get_logenv [2]
	hxrbs_format, linecolors [1], linecolors [2], point [2], winup [1], winup [2]
	winup [3], winup [4], wsetshow [1], wsetshow [2]
 RESTRICTIONS:

 MODIFICATION HISTORY:
 ras, 22-apr-94
 ras, 5-may-94, incorporate need structure and Yohkoh sxs changes
 ras, 17-may-94, update site specific setup
 ras, 15-jun-94, enable widget menus
       ras, 14-oct-94, add spex_remote
 ras, 10-apr-95, changed data directory on umbra
 ras, 23-aug-95, changed data directory on umbra
 RAS, 13-jan-96, isas installation modified
 Version 2, ras, 8-apr-1996, align structure boundaries
   added last_plot and handles initialization
 ras, 15-apr-1996, added stte to standard types
 ras, 16-may-1996, added near pin to standard types
 ras, 16-may-1996, added WIND TGRS to standard types
 ras, 14-aug-1996, made the comments section more robust
 ras, 21-oct-1996, added BATSE DISCSP_CONT to standard types
 ras, 2-dec-1996, replace RD_ASCII with RD_TEXT with LOC_FILE
 Version 16,
 ras, 26-mar-1997, added SMM GRS detectors, Spectrometer and Xray detectors merged
 Version 17,
 ras, 7-Jul-1997, changed dir_queue for ibdb files at sdac and umbra
 Version 18,
 richard.schwartz@gsfc.nasa.gov, 26-sep-1997 added BATSE DISCLA.
 Version 19,
 richard.schwartz@gsfc.nasa.gov, 14-nov-1997, place txt help files in
 ssw distribution and use path_dir to locate.
 Version 21,
 richard.schwartz@gsfc.nasa.gov, 3-feb-1998, modified DIR_QUEUE to use
 BATSE_DATABASE.
 richard.schwartz@gsfc.nasa.gov, 27-may-1998, revised to support WIN and MACos
 richard.schwartz@gsfc.nasa.gov, 19-march-1999, for unknown site, root db 
 directories
 for BATSE to BATSE_DATABASE
 1-June-2000 Paul Bilodeau added HXRS instrument and SHLD,NSHLD, and TOTAL
 formats
 18-FEB-2001 richard.schwartz@gsfc.nasa.gov, 18-feb-2001, added HESSI
 FRONT,REAR, ALLSEG
 20-March-2002, Paul Bilodeau - use free window id numbers from winup
 common block, no longer 0 / 1.  Call to wsetshow for initialization.
 Use WIN_NAME keyword in call to wsetshow to select windows.


sgn [2] $SSW/packages/lparl/idl/ucon/morrison/sgn.pro
[Previous] [Next]
 NAME: sgn

 PURPOSE: Return the sign of the argument. 
	   If the argument is zero, return zero.

 CALLING SEQUENCE:  out=sgn(in)

 PARAMETERS:
		in	input number
		out	-/0/+

 RETURN TYPE: INTEGER                               

 CALLED BY:
	XCROP_CUBE, bcs_spec, fovc2corn_cmd, mdipdist, mk_sfd [1], mk_sfd [2], mk_sfd [3]
	mk_sfd [4]
 HISTORY: Drafted by A.McAllister, Feb. 1993.


SHOW_POPS $SSW/packages/chianti/idl/extra/show_pops.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: SHOW_POPS
       
 PURPOSE:

	To display populations of significant levels in a CHIANTI ion 
	model

 CATEGORY:

       Scientific analysis

 EXPLANATION:

	Displays percentage level populations and level IDs for all levels 
	in the specified ion with populations greater than 0.01%. If the 
	temperature is not specified, then it is taken to be where the 
	maximum of the ionisation fraction is.

       If the keyword /ALL is set, the output populations are relative 
       values and not percentages. All levels are shown.

 CALLING SEQUENCE:

	SHOW_POPS, IZ, ION [, POPSTR, DENS= , TEMP= , /NOPROT,
                           RADTEMP= , RPHOT= , /ALL, /DIEL, PATH=,
                           IONEQ_FILE= , ABUND_FILE= ]

 EXAMPLES:

	show_pops,26,13,popstr
	show_pops,26,13,dens=7.5,temp=6.0,rphot=1.2

 INPUTS:

	IZ	The atomic number of the ion

	ION	The spectroscopic number of the ion (e.g., 12 = XII)

 OPTIONAL INPUTS:

	DENS	Logarithm of electron density

	TEMP	Logarithm of electron temperature. If not specified, then
               T_max of the ion is used

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

	PATH	Directly specify the path where the ion data is contained, 
		e.g., path='/home/other_data/fe_13'

       N_LEVELS  The size of the ion model is automatically determined 
                 from the information in the CHIANTI data files. Setting 
                 this keyword allows the number of levels in the model to 
                 be reduced. E.g., N_LEVELS=14 reduces the model to the 
                 first 14 levels given in the .ELVLC file.

       IONEQ_FILE To include proton rates in the level balance equations 
                  requires the number of density of protons to be known, 
                  and this requires an ion balance file and an abundance 
                  file to be specified, which are done through the 
                  IONEQ_FILE and ABUND_FILE keywords. If they are not set 
                  then the default files specified by !ioneq_file and 
                  !abund_file are used.

       ABUND_FILE See IONEQ_FILE.

       SUM_MWL_COEFFS  An array of coefficients of the same length as 
                       the array of temperatures. Electron and proton rate 
                       coefficients will be calculated at each temperature 
                       and then a weighted sum of the coefficients is 
                       performed using SUM_MWL_COEFFS. This allows 
                       non-Maxwellian energy distributions to be 
                       incorporated into the level balance equations.
                       If this keyword is set for an ion that has ionization
                       and recombination included in the level balance, then
                       these processes will be switched off for the
                       calculation since their rates implicitly assume a
                       single Maxwellian to describe the ion fractions of
                       the neighbouring ions.

       LEVEL   Allows the control of which level populations are displayed
               to the screen. If set to a positive scalar or array, then
               only those levels are printed. If it is set to a negative
               scalar (-n), then all level populations up to level n are
               printed. E.g., LEVEL=20 (only level 20); LEVEL=[5,7,20]
               (levels 5, 7 and 20); LEVEL=-20 (all levels up to level 20).

       RADFUNC         The name of a user-defined function that will generate
                       a radiation spectrum as a function of temperature. 
                       This radiation field will replace the black-body that
                       is assumed when using the RADTEMP keyword in the call
                       to pop_solver.

; OPTIONAL OUTPUTS

       POPSTR  Send level population information to a structure. POPSTR has 
               the tags:
               .dens    Density (cm^-3)
               .temp    Temperature (K). Can be an array if SUM_MWL_COEFFS=
                        is used.
               .radtemp RADTEMP. Set to -1 if RADTEMP not 
                        set.
               .rphot   RPHOT value. Set to -1 if RPHOT not set.
               .proton  String set to 'yes' if proton rates included, 'no' 
                        otherwise
               .version CHIANTI version used to derive populations.
               .date    Date and time at which structure created.
               .level   Structure containing level information. Tags are:
                  .index   CHIANTI level index
                  .term    String containing level identifier.
                  .pop     Population of level
               .sumtst  Set to 1 if the SUM_MWL_COEFFS keyword has been used.
                        Set to 0 otherwise.
               .sum_mwl_coeffs Contains SUM_MWL_COEFFS. Set to -1 if sumtst=0.

 KEYWORDS:

	ALL	Show populations for all levels.
               the output populations are relative 
               values and not percentages.

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.

       DIEL    Use the dielectronic recombination files. E.g., for Fe XXII, 
               the routine will read in the fe_22d.* files instead of the 
               fe_22.* files.

 COMMON BLOCKS:

	ELVLC, WGFA, UPSILON, RADIATIVE, PROTON, ELEMENTS

 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2], POP_SOLVER
	PROTON_DENS, R2W, READ_ABUND, READ_IONEQ, SETUP_ION, ZION2FILENAME, concat_dir [4]
	file_exist [1], file_exist [3]
 HISTORY:

	Ver 1, PRY 22-Sep-97
	Ver.2, PRY 5-Sep-98  - added call to choose_ioneq
	Ver.3, PRY 23-Apr-99 - calls pop_solver now; added DENS keyword
	Ver.4, PRY 18-Dec-99 - added deu to upsilon common block to be 
			consistent with main Chianti routines.
       Ver.5, PRY 7-Aug-00  - added /DIEL keyword to allow populations of 
                       the dielectronic recombination files to be studied.
                       Also changed elvlc common block to match new 
                       version of pop_solver.
       Ver 6, PRY 10-Oct-00 - now calls setup_ion to read ion data
       Ver 7, PRY 12-Nov-01 - modified for proton rates, photoexcitation,
                       and 9 pt splines.
       Ver 8, PRY 9-Dec-01  - completed modifications for v4 of CHIANTI.

       V.  9, 25-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 
                   Now we only call zion2filename

       V. 10, 9-Aug-2002, Peter Young
                   corrected !ioneq_file problem

       V. 11, 12-Aug-2002, Peter Young
                   added POPSTR output, and tidied up header.

       V. 12, 4-Oct-2003, GDZ
                  modified the input to POP_SOLVER, now it is dealt with an
                  input structure.

       V 13, 4-May-2005, Enrico Landi (EL)
                  Modified in order to include ionization and recombination
                  data in the input to POP_SOLVER

       V.14, 26-May-2005, Peter Young (implemented by GDZ)
                  added SUM_MWL_COEFFS optional input for allowing
                  non-Maxwellian distributions to be considered.

                  added LEVEL= optional input to only print the populations of
                  a few levels.

       V.15, 5-Jul-2005, Peter Young
                  added RADFUNC= and /QUIET keywords

       V.16, 14-Sept-2005 Giulio Del Zanna 
              modified header.

       v.17, 12-Dec-2005, Peter Young
              routine now performs check on existence of .splups file
              instead of .elvlc since with v.5 some ions have a .elvlc
              file but nothing else (fe_3, fe_4)

 VERSION     :   17, 12-Dec-2005


solar_hdr $SSW/packages/ztools/images/xforms/solar_hdr.pro
[Previous] [Next]
 SOLAR_HDR

 PURPOSE:
 Returns a skeleton fits header structure that just contains 
 alignment information for the SoHO "standard solar co-ordinate"
 system:  N = up; co-ordinates are arc seconds from disk center
 in the (W, N) direction.

 USAGE:
	a = solar_hdr()

 OPTIONAL KEYWORDS:
	ARCSEC - if set, return value in arc seconds (default)
	ARCMIN - if set, return value in arc minutes 
	RADII  - if set, return value in solar radii
	SOLAR_RADII - if set, return value in solar radii

 CALLS: ***
	zcheck_hdr
 CALLED BY:
	COORD [1], V42PIX, ZCONTAINS, hao_hdr, make_radius_map
 HISTORY: 
	Written in the dim past, C. DeForest
	Modified to use correct CRPIX values (1.0) and to take
	SOLAR_RADII keyword, 1-Sep-98
	Added INSTRUME to keep track of instrument name in ZCOORD
		(location kludge)
 


SOXS_CZT_DRM $SSW/packages/spex/idl/object_spex/soxs_czt_drm.pro
[Previous] [Next]
 PROJECT:
	SOXS
 NAME:
	SOXS_CZT_DRM

 PURPOSE:
	This function constructs and returns the DRM for SOXS czt detector

 CATEGORY:
	Spectral Analysis

 CALLING SEQUENCE:
	soxs_czt_drm, efficiency_file=efficiency_file, $
		transmission_file=transmission_file, $
	    fwhm=fwhm, edges_file=edges_file, path=path, $
	    ein2 = ein2, $
	    area = area, $ ;nominal geometric area
	    error = error


 INPUTS:

		fwhm - constant, uses 2.0 keV
		not implemented - offset - empirical channel offset to fix apparent gain not implemented,


 OUTPUTS:
		Returns DRM as 256 x 256 array
			for a photon spectrum in photons/cm2/sec input
			(i.e. integrated over photon energy bins), the output
			is in units of cnts/cm2/s/keV
			count_flux = drm # (photon_spectrum * DE)
			where photon_spectrum is in units of photons/cm2/sec/keV
			and DE is the input energy bin width in keV
       EIN2 - edges in 2 x 256 array
		AREA - nominal area, 0.25 cm^2



 CALLS: ***
	AVG [1], AVG [2], Energy_res [1], Energy_res [2], GET_EDGES, INTERPOL, LAST_ITEM
	REVERSE, soxs_czt_photopeak
 CALLED BY:
	read_soxs_4_ospex
 RESTRICTIONS:
	none

 PROCEDURE:
	Reads efficiency, transmission, and edge files provided by
	SOXS team.  Energy calibration is fit and uses, efficiency and transmission
	are read and smoothed to energy edge midpoints.

 MODIFICATION HISTORY:
	7-dec-2006, richard.schwartz@gsfc.nasa.gov


soxs_czt_photopeak $SSW/packages/spex/idl/object_spex/soxs_czt_photopeak.pro
[Previous] [Next]
Procedure for determining photopeak response of SOXS czt detector
Based on discussions at PRL with R Jain and KJ Shah
;
 the response is computed from the exposed geometric area thru the
 collimator circle, the absorption from the Be, Al, and Kapton and then
 the prob of single pe detection in czt. A correction to the photopeak
 efficiency was obtained by a second order fit of the detector efficiency
 data which included the Be window of 11 mil.  We therefore group the be
 window with the detector and treat the Al and Kapton separately as absorbers


 CALLS:
 CALLED BY
	SOXS_CZT_DRM


SOXS_DRM $SSW/packages/spex/idl/object_spex/soxs_drm.pro
[Previous] [Next]
 PROJECT:
	SOXS
 NAME:
	SOXS_DRM

 PURPOSE:
	This function constructs and returns the DRM for SOXS.

 CATEGORY:
	Spectral Analysis

 CALLING SEQUENCE:
	soxs_drm, efficiency_file=efficiency_file, $
		transmission_file=transmission_file, $
	    fwhm=fwhm, edges_file=edges_file, path=path, $
	    ein2 = ein2, $
	    area = area, $ ;nominal geometric area
	    error = error


 INPUTS:

       Efficiency_file - defaults to 'effi_si.txt'
		Transmission_file - defaults to 'efsi80150.txt'
		Edges_file - defaults to 'corr_si_180_140804_054312.txt'
		fwhm - constant, uses 0.70 keV
		offset - empirical channel offset to fix apparent gain
		OLD - if set use original discredited method for determining
			photopeak response

 OUTPUTS:
		Returns DRM as 256 x 256 array
			for a photon spectrum in photons/cm2/sec input
			(i.e. integrated over photon energy bins), the output
			is in units of cnts/cm2/s/keV
			count_flux = drm # (photon_spectrum * DE)
			where photon_spectrum is in units of photons/cm2/sec/keV
			and DE is the input energy bin width in keV
       EIN2 - edges in 2 x 256 array
		AREA - nominal area, 0.06 cm^2



 CALLS: ***
	AVG [1], AVG [2], DEFAULT, Energy_res [1], Energy_res [2], GET_EDGES, POLY, POLY_FIT
	is_number [1], is_number [2], soxs_photopeak
 CALLED BY:
	read_soxs_4_ospex, soxs_off_fwhm
 RESTRICTIONS:
	none

 PROCEDURE:
	Reads efficiency, transmission, and edge files provided by
	SOXS team.  Energy calibration is fit and uses, efficiency and transmission
	are read and smoothed to energy edge midpoints.

 MODIFICATION HISTORY:
	6-jul-2006, richard.schwartz@gsfc.nasa.gov
	10-Aug-2006, Kim.  Changed default for offset from 1.25 to 2.07
	31-Aug-2006, Kim.  Use fwhm keyword


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

 Purpose: Modify the energy gain offset and FWHM used to calculate the
   SOXS DRM, replace the modified DRM in the spex drm object, insert
   the new energy edges in the spex object, and tell the spex_drm that it
   needs to reprocess next time it's needed.
   This allows the user to find the best value of the offset and fwhm
   by fitting the data using the current drm, adjusting the offset
   and/or the fwhm, and fitting again, and determining which drm produces the
   the best spectrum.

 CALLS: ***
	SOXS_DRM, TRIM
 Example:
   Start ospex by
     obj = ospex()
   and read in an input data file.  You can plot the data, and do fits at
   this point if you want.  The default values for offset and fwhm are:
     offset = 2.07   (in channels)
     fwhm = .7 (in keV)
   If you don't call soxs_off_fwhm, those are the values that are used.
   To change the offset to 3. and the fwhm to .8 type the following:
     soxs_off_fwhm, obj, offset=3., fwhm=.8
   Now you can fit again using the new DRM.

   Note: if you prefer to start ospex using an ospex script, be sure to return
   the object reference in the variable obj, e.g.  ospex_script_18_Jul_2006, obj=obj

 Calling arguments:
   obj - the ospex object reference
 Input keywords:
   offset - the new energy gain offset value in channels
   fwhm - the new fwhm in keV


soxs_photopeak $SSW/packages/spex/idl/object_spex/soxs_photopeak.pro
[Previous] [Next]
Procedure for determining photopeak response of SOXS si detector
Based on discussions at PRL with R Jain and KJ Shah
Old method based on efficiency and transmission file was flawed in
interpretation by RA Schwartz because efficiency file was computed using
the wrong cross-section for silicon, czt cross section was used instead.

 Now the response is computed from the exposed geometric area thru the
 collimator circle, the absorption from the Be, Al, and Kapton and then
 the prob of single pe detection in Si. A correction to the photopeak
 efficiency was obtained by a second order fit of the detector efficiency
 data which included the Be window of 1 mil.  We therefore group the be
 window with the detector and treat the Al and Kapton separately as absorbers


 CALLS:
 CALLED BY
	SOXS_DRM


soxs_readfile $SSW/packages/spex/idl/object_spex/soxs_readfile.pro
[Previous] [Next]

 PROJECT:
 RHESSI

 NAME:
 soxs_readfile

 PURPOSE: Read SOXS data file

 PREVIOUSLY (before 8-nov-2006):
 Read a single .out soxs file and return data and time array
 The soxs files are text files containing a bunch of rows that look like:
 record counter, hour, min, sec, msec, 256 energy channels
 We're rejected the first two and last two energy bins (Rajmal's instructions)
 We're taking the time to be the start of the accumulation.  There are two
 accumulation modes - 3s and .1s, but we found times that are not spaced by
 3 or .1 s, so we've eliminated those data points.

 AFTER 8-Nov-2006:
 Read the SOXS .les binary file.  Code to read this binary file was supplied by PRL.
 Files are named either soxs_dd-mmm-yyyy.les (or sometimes on their web site, just
 dd-mmm-yyyy.les) for the Si detector, and  cztsoxs_dd-mmm-yyyy.les for the CZT
 detector.  The first time in the file is used as a base time, and
 subsequent times are generated by adding 3 s or 100 msec depending on the mode of the
 data (given by b(3)).  As before, reject first 2 and last 2 energy bins.

 The energy bin edges are not contained in the input file.  Later we call soxs_drm and
 that returns the energy edges.

 CATEGORY:
 SPEX

 CALLING SEQUENCE:
 soxs_readfile, file, data, ut_edges, timeshift=timeshift, $
	err_code=err_code, _extra=_extra

 INPUTS:
 FILE - Name of file to read (with path)

 Input keywords:
 timeshift - number of seconds to shift data array by

 OUTPUTS:
 data - data array (nenergy x ntime)
 ut_edges - time array (2 x ntime) in seconds since 79/1/1

 OUTPUT KEYWORDS:
 detector - string containing 'Si' or 'CZT' for detector
 err_code - 0/1 indicates success / failure

 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CHECKVAR [1], GET_EDGES, LAST_ITEM
	anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], break_file [4]
	checkvar [2], ssw_strsplit
 CALLED BY:
	read_soxs_4_ospex
 EXAMPLE:
 soxs_readfile, f, data, ut, timeshift=90.

 Written: Kim Tolbert, June 2006

 Modification History:
	21-Aug-2006, Kim.  Use break_file instead of file_basename for <IDL 6.0 use.
	31-Oct-2006, K.J.Shah  and A.B. Shah - Read .les file directly instead of
	  ASCII .out file.  This will handle both Si and CZT files.
	2-Nov-2006, Kim.  Skip writing .out file and reading it back in.
	3-Nov-2006, Kim.  Replace a few do loops with vector operations,
	  use previous value of b(3) to decide whether to add 3 s or 100 msec.
	6-Nov-2006, Kim.  Added detector output keyword


spatial_filter $SSW/packages/lparl/idl/ucon/tarbell/spatial_filter.pro
[Previous] [Next]
NAME:
       spatial_filter
PURPOSE:
	This takes a byte, float, or int (2d or 3d) array, smooths it, and
	returns the result in the original format.
SAMPLE CALLING SEQUENCE:
       spatial_filter, array_thats_3d, .25
PARAMETERS
	The array to be smoothed, and the resolution of the output
DETAILS:
	This works best when NX and NY have prime factors of only 2,3, and 5

	Resolution is the HWHM in spatial frequency of a Gaussian filter, in 
	units of cycles per pixel.  Larger values mean less noise filtering 
	and more spatial resolution in the output.  In these units the Nyquist
	frequency is 0.5.
 CALLS: ***
	GETHELP, REVERSE
HISTORY:
	Smoother Code 7-Jul-97 T.Tarbell
       Created 8-Jul-97 by J.Abrehamson
	Modified 16-Jul-97 (Accepts NX or NY odd)
	Mod 26-Nov-97 (TDT) - Fixed bug for non-square images


spec_plot [1] $SSW/packages/spex/idl/original_spex/spec_plot.pro
[Previous] [Next]
	add a line to the subtitle of the spectral plots
	more_info must be set to display this
 CALLS:


spec_plot [2] $SSW/packages/spex/idl/original_spex/spec_plot.pro
[Previous] [Next]

 NAME: spec_plot

 PURPOSE: Plot an observed energy spectrum and its model

 CATEGORY: SPEX, GRAPHICS


 CALLING SEQUENCE:
	spec_plot, edges=edges, drm=drm, e_in=e_in, apar=apar, $
	conversion=conversion, pconv=pconv, cflux=cflux, ecflux=ecflux, units=units,$
	set=set, xtype=xtype, ytype=ytype, colors=colors, uncert=uncert, cal_test=cal_test
 CALLS TO: Fcount_rate
	

 KEYWORD INPUTS:
       edges:  2 x Num_channels energy edges
	drm:    Detector Response defining relationship between input model and output response
		DRM is Num_channels x Num_photon
	e_in:   Input energy edges for photon spectrum, 2 X Num_photon bins
	apar:	Parameters of model
	sigmaa:  Uncertainties on model parameters
	cflux:   Counting rate flux, counts/uflux, often counts/cm2/s/keV, Num_channels long.
	ecflux:  Uncertainties on cflux
	bflux:   Background flux
	ebflux:  Uncertainty on bflux
	units:   Units of cflux, expressed as needed for figure, often' s!u-1!n cm!u-2!n keV!u-1!n'
	set:  	if set then interactively select fitting parameters
	interval: Interval number used to reference a series of fits.
	Trange:  Time range covered by observation, for subtitle.
	Chisqr:  Value of reduced chi-square for this fit.

	cal_test 1, scaled plot comparing net source count/rate and model count/rate
	 In the cal_test mode we are trying to highlight the correspondance between
	 the details of the predicted model spectrum and the observed spectrum looking
	 for any obvious systematic problems in the gain/detector-response.
	 Therefore, we plot the net source count rate spectrum over the range
	 indicated by edges(*,wuse) and overplot with the predicted source count rate.
	 Furthermore if a linear plot is desired then the plot is autoscaled by
	 multiplying by a power-law which will best flatten the plot and the yrange
	 is selected from extrema of the product of the observed and the power-law over the
	 the channels in wuse.
	Title	-Title used on figure, string. 
	xtype	-If set log xaxis, otherwise linear
	ytype	-If set log yaxis, otherwise linear
	Colors  - Vector of colors to use, referenced to Linecolors.pro
		Nominally [5,9,3,4,7] for 
		linecolor 5 (yellow) source counts
		linecolor 9 (sky blue) folded model counts, 
		linecolor 3 (scarlet) total continuous model,
		linecolor 4 (orange)  background counts,
		linecolor 7 (green) continuous model components.
	group=group
		The new edges are the low edge of the first channel in each group and the low
		edge of the second channel.
	uncert - minimum fractional uncertainty on background subtracted flux
       pconv - pileup correction to conversion factor, optional, see run_curvefit
	OVERPLOT - If set, overplot new spectrum
	RESIDUALS - If set, plot residuals.
 OUTPUTS:
	conversion

 OPTIONAL OUTPUTS:
	none

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2]
	CHECKVAR [1], DATPLOT, EMENU, EPLOT, FCHECK, FCOLOR [1], F_DIV, F_USE_WIDGET
	GRAPHICS_PAGE, LIMITS, MINMAX [1], MINMAX [2], MORE_SUBTITLE, Model_components [1]
	Model_components [2], RESPOND_WIDG, TIMESTAMP, checkvar [2], countsmod_plot [1]
	countsmod_plot [2], edge_products, fcolor [2], get_conversion [1]
	get_conversion [2], option_changer [1], option_changer [2], printx [1]
	printx [2]
 COMMON BLOCKS:
	Function_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	If 'COUNTS' appears in units, flux is displayed with no additional scaling,
	and the bflux is also plotted. Otherwise, the (cflux-bflux) is divided by the 
	conversion factor (see GET_CONVERSION.PRO) computed from the
	drm and model function found in function_com.

 MODIFICATION HISTORY:
	ras, 1994
	ras, 9-Mar-1995, only 6 parameters per line in the subtitle
	ras, 22-mar-95, added cal_test keyword
	ras, 5-apr-95, fixed bug in energy bin averaging, creating gmatrix
	rasm 24-jan-96, added residuals plot 


spec_plot [3] $SSW/packages/spex/pre2002/idl/spec_plot.pro
[Previous] [Next]
	add a line to the subtitle of the spectral plots
	more_info must be set to display this
 CALLS:


spec_plot [4] $SSW/packages/spex/pre2002/idl/spec_plot.pro
[Previous] [Next]

 NAME: spec_plot

 PURPOSE: Plot an observed energy spectrum and its model

 CATEGORY: SPEX, GRAPHICS


 CALLING SEQUENCE:
	spec_plot, edges=edges, drm=drm, e_in=e_in, apar=apar, $
	conversion=conversion, pconv=pconv, cflux=cflux, ecflux=ecflux, units=units,$
	set=set, xtype=xtype, ytype=ytype, colors=colors, uncert=uncert, cal_test=cal_test
 CALLS TO: Fcount_rate
	

 KEYWORD INPUTS:
       edges:  2 x Num_channels energy edges
	drm:    Detector Response defining relationship between input model and output response
		DRM is Num_channels x Num_photon
	e_in:   Input energy edges for photon spectrum, 2 X Num_photon bins
	apar:	Parameters of model
	sigmaa:  Uncertainties on model parameters
	cflux:   Counting rate flux, counts/uflux, often counts/cm2/s/keV, Num_channels long.
	ecflux:  Uncertainties on cflux
	bflux:   Background flux
	ebflux:  Uncertainty on bflux
	units:   Units of cflux, expressed as needed for figure, often' s!u-1!n cm!u-2!n keV!u-1!n'
	set:  	if set then interactively select fitting parameters
	interval: Interval number used to reference a series of fits.
	Trange:  Time range covered by observation, for subtitle.
	Chisqr:  Value of reduced chi-square for this fit.

	cal_test 1, scaled plot comparing net source count/rate and model count/rate
	 In the cal_test mode we are trying to highlight the correspondance between
	 the details of the predicted model spectrum and the observed spectrum looking
	 for any obvious systematic problems in the gain/detector-response.
	 Therefore, we plot the net source count rate spectrum over the range
	 indicated by edges(*,wuse) and overplot with the predicted source count rate.
	 Furthermore if a linear plot is desired then the plot is autoscaled by
	 multiplying by a power-law which will best flatten the plot and the yrange
	 is selected from extrema of the product of the observed and the power-law over the
	 the channels in wuse.
	Title	-Title used on figure, string. 
	xtype	-If set log xaxis, otherwise linear
	ytype	-If set log yaxis, otherwise linear
	Colors  - Vector of colors to use, referenced to Linecolors.pro
		Nominally [5,9,3,4,7] for 
		linecolor 5 (yellow) source counts
		linecolor 9 (sky blue) folded model counts, 
		linecolor 3 (scarlet) total continuous model,
		linecolor 4 (orange)  background counts,
		linecolor 7 (green) continuous model components.
	group=group
		The new edges are the low edge of the first channel in each group and the low
		edge of the second channel.
	uncert - minimum fractional uncertainty on background subtracted flux
       pconv - pileup correction to conversion factor, optional, see run_curvefit
	OVERPLOT - If set, overplot new spectrum
	RESIDUALS - If set, plot residuals.
 OUTPUTS:
	conversion

 OPTIONAL OUTPUTS:
	none

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2]
	CHECKVAR [1], DATPLOT, EMENU, EPLOT, FCHECK, FCOLOR [1], F_DIV, F_USE_WIDGET
	GRAPHICS_PAGE, LIMITS, MINMAX [1], MINMAX [2], MORE_SUBTITLE, Model_components [1]
	Model_components [2], RESPOND_WIDG, TIMESTAMP, checkvar [2], countsmod_plot [1]
	countsmod_plot [2], edge_products, fcolor [2], get_conversion [1]
	get_conversion [2], option_changer [1], option_changer [2], printx [1]
	printx [2]
 COMMON BLOCKS:
	Function_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	If 'COUNTS' appears in units, flux is displayed with no additional scaling,
	and the bflux is also plotted. Otherwise, the (cflux-bflux) is divided by the 
	conversion factor (see GET_CONVERSION.PRO) computed from the
	drm and model function found in function_com.

 MODIFICATION HISTORY:
	ras, 1994
	ras, 9-Mar-1995, only 6 parameters per line in the subtitle
	ras, 22-mar-95, added cal_test keyword
	ras, 5-apr-95, fixed bug in energy bin averaging, creating gmatrix
	rasm 24-jan-96, added residuals plot 


spectral_ratio [1] $SSW/packages/spex/idl/original_spex/spectral_ratio.pro
[Previous] [Next]
 PROJECT:
	SDAC
 
 NAME: spectral_ratio
	
 PURPOSE: Find estimates to fitting functions by using
	ratios of count rates and detector response functions.
	
 CALLING SEQUENCE:
	result = SPECTRAL_RATIO( Cflux, DRM=DRM, APAR_IN=APAR_IN, $
	PHOTON_EDGES=PHOTON_EDGES, [WUSE=WUSE, MODEL=MODEL, $
	NBIN=NBIN, MRATIO=MRATIO, PAR_OUT=PAR_OUT]
 INPUTS:
	Cflux - Count rate in output units of DRM.  Frequently both
	are in cts/cm2/sec/keV.  Dimensioned Channels X Time-Bins.
	Frequently Time-Bins but may be spatial, too, for which DRM is constant.
	
 OUTPUTS:	
	returns the normalization and non-linear parameter for
	the input count rate and model function for each pair
	of channels requested in succession, i.e. 0:1, 1:2, 2:3, ...

 CATEGORY: SPEX

 KEYWORD INPUTS:
 Required:
	DRM: detector response matrix expressed as counts/chan per photon/cm2
	PHOTON_EDGES: photon energy edges (keV) used as inputs for cdrm
	APAR_IN: Input parameters.  2XN.  There may be an arbitrary number
	of parameters, but there is only 1 which will be interpolated on
	and the range of interpolation is given by the two values at the ith
	position.  Its normalization parameter must immediately precede it in
	the call.  All of the other parameters must have duplicated values and
	the normalization parameter must be set to 1.0.
	ECFLUX: one sigma deviations on cflux., dimensioned identically to cflux.
 Optional:
	MODEL:
		String of function name model to use. Default is
		a single power-law.  May be any parametric
		model, such as F_VTH, in the software tree.
	NBIN: Number of interpolation bins, 50 default.
 KEYWORD OUTPUTS:
	MRATIO: Channel ratios for interpolation grid.
	PAR_OUT: Interpolation parameter vector.	
	EPAR: Propagated deviations on the return values. Two sets of values 
	for each return value, for positive and negative excursions of the calculated
	channel ratio.
 CALLED BY:
	MAP_DISCLA2CONT, RUN_CURVEFIT [1], RUN_CURVEFIT [2]
 PROCEDURE:
	creates a grid of ratios for model spectra and interpolates

 CALLS: ***
	CHECKVAR [1], CHKARG, DATATYPE [1], DATATYPE [2], DATATYPE [3], EXIST, F_DIV, INTERPOL
	MATCH_STRUCT, MORE [1], MORE [2], checkvar [2], edge_products, fcount_rate [1]
	fcount_rate [2]
 COMMON BLOCKS:
	SPECTRAL_RATIO_COM

 RESTRICTIONS:
	none:
	
 MODIFICATION HISTORY:
	
	Version 1	RAS March 8, 1996	
	Version 2       RAS 25-July-1996, added vector DRM test
	Version 3, richard.schwartz@gsfc.nasa.gov, 28-jan-1998, cleaned some.
		Added common block with saved ratios and checks to eliminate recalculating
		interpolation grid when not needed on successive calls.  Added error propagation.


spectral_ratio [2] $SSW/packages/spex/pre2002/idl/spectral_ratio.pro
[Previous] [Next]
 PROJECT:
	SDAC
 
 NAME: spectral_ratio
	
 PURPOSE: Find estimates to fitting functions by using
	ratios of count rates and detector response functions.
	
 CALLING SEQUENCE:
	result = SPECTRAL_RATIO( Cflux, DRM=DRM, APAR_IN=APAR_IN, $
	PHOTON_EDGES=PHOTON_EDGES, [WUSE=WUSE, MODEL=MODEL, $
	NBIN=NBIN, MRATIO=MRATIO, PAR_OUT=PAR_OUT]
 INPUTS:
	Cflux - Count rate in output units of DRM.  Frequently both
	are in cts/cm2/sec/keV.  Dimensioned Channels X Time-Bins.
	Frequently Time-Bins but may be spatial, too, for which DRM is constant.
	
 OUTPUTS:	
	returns the normalization and non-linear parameter for
	the input count rate and model function for each pair
	of channels requested in succession, i.e. 0:1, 1:2, 2:3, ...

 CATEGORY: SPEX

 KEYWORD INPUTS:
 Required:
	DRM: detector response matrix expressed as counts/chan per photon/cm2
	PHOTON_EDGES: photon energy edges (keV) used as inputs for cdrm
	APAR_IN: Input parameters.  2XN.  There may be an arbitrary number
	of parameters, but there is only 1 which will be interpolated on
	and the range of interpolation is given by the two values at the ith
	position.  Its normalization parameter must immediately precede it in
	the call.  All of the other parameters must have duplicated values and
	the normalization parameter must be set to 1.0.
	ECFLUX: one sigma deviations on cflux., dimensioned identically to cflux.
 Optional:
	MODEL:
		String of function name model to use. Default is
		a single power-law.  May be any parametric
		model, such as F_VTH, in the software tree.
	NBIN: Number of interpolation bins, 50 default.
 KEYWORD OUTPUTS:
	MRATIO: Channel ratios for interpolation grid.
	PAR_OUT: Interpolation parameter vector.	
	EPAR: Propagated deviations on the return values. Two sets of values 
	for each return value, for positive and negative excursions of the calculated
	channel ratio.
 CALLED BY:
	MAP_DISCLA2CONT, RUN_CURVEFIT [1], RUN_CURVEFIT [2]
 PROCEDURE:
	creates a grid of ratios for model spectra and interpolates

 CALLS: ***
	CHECKVAR [1], CHKARG, DATATYPE [1], DATATYPE [2], DATATYPE [3], EXIST, F_DIV, INTERPOL
	MATCH_STRUCT, MORE [1], MORE [2], checkvar [2], edge_products, fcount_rate [1]
	fcount_rate [2]
 COMMON BLOCKS:
	SPECTRAL_RATIO_COM

 RESTRICTIONS:
	none:
	
 MODIFICATION HISTORY:
	
	Version 1	RAS March 8, 1996	
	Version 2       RAS 25-July-1996, added vector DRM test
	Version 3, richard.schwartz@gsfc.nasa.gov, 28-jan-1998, cleaned some.
		Added common block with saved ratios and checks to eliminate recalculating
		interpolation grid when not needed on successive calls.  Added error propagation.


SPECTROSCOPIC2ION $SSW/packages/chianti/idl/low_level/spectroscopic2ion.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:
	SPECTROSCOPIC2ION

 PURPOSE:
	provide identification string

 CATEGORY:

	database.

 CALLING SEQUENCE:

       SPECTROSCOPIC2ION,  snote, Ion, dielectronic=dielectronic

 INPUTS:

	snote:  the spectroscopic notation for the ion, i.e. 'C II'

 OPTIONAL INPUTS: none

 KEYWORD PARAMETERS:
              
 OUTPUTS:
       Ion:   CHIANTI notation for an ion, i.e., 'c_2' for C II	

 OPTIONAL OUTPUTS:  dielectronic (0/1)

 CALLS: ***
	STR_SEP, TRIM
 CALLED BY:
	CH_LINE_LIST, ch_ss
 EXAMPLE:
             > spectroscopic2ion, 'O VI d', ion,dielectronic=dielectronic
             > help, ion, dielectronic
             > ION             STRING    = 'o_6d'
             > DIELECTRONIC    INT       =        1

 WRITTEN     : 
       Version 1, Written by: Giulio Del Zanna (GDZ) 25-May-2002

 MODIFICATION HISTORY:

       V.2, 12-Aug-02, GDZ 
           Corrected a typo concerning XXII.

 VERSION     :   2, 12-Aug-02


spex [1] $SSW/packages/spex/idl/original_spex/spex.pro
[Previous] [Next]
 Main program for SPEX - Spectral Analysis Executive

	mod, ras, 12-apr-1997, change call from PS to SPS for
	graphics.
 Paul Bilodeau, 3-April-2002, changed calls to wsetshow to use
   TIMEHISTORY and SPECTRAl keywords.


spex [2] $SSW/packages/spex/pre2002/idl/spex.pro
[Previous] [Next]
 Main program for SPEX - Spectral Analysis Executive

	mod, ras, 12-apr-1997, change call from PS to SPS for
	graphics.
 Paul Bilodeau, 3-April-2002, changed calls to wsetshow to use
   TIMEHISTORY and SPECTRAl keywords.


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

 Purpose: Main OSPEX object

 Category: OSPEX

 Written: 2003, Kim Tolbert
 Modifications:
   22-Jun-2004, Kim.  Replaced spex_interval_range with spex_intervals_tofit
   15-Jul-2004, Kim.  Added _extra to fitsummary and setupsummary so now they can
     pass that to text_output (for /print and /file_text for printing and sending to file)
   16-Jul-2004, Kim.  Moved preview stuff out of here and into spex_data and spex_drm - just
     call those from this preview
   20-Jul-2004, Kim.  Added filter info to fitsummary and setupsummary output.
   09-Aug-2004, Sandhia,  Added a method setParams to allow user to set parameters for OSPEX manually.
   26-Aug-2004, Sandhia,  Modified savefit to write fit parameters to a FITS file or IDL save
                          file based on a keyword value.
   08-Sep-2004, Sandhia,  implemented code to write the spex_summ structure to a fits file in
                             the format compatible with a RATE FITS file.  The new fits file will
                             now have three extensions - primary, rate and ebounds.
   09-Sep-2004, Sandhia,  restorefit (from FITS file option) will now call spex_read_fit_results routine
                             to copy the FITS results in OSPEX_summ structure.
   12-Sep-2004, Kim.  writescript wasn't writing bk_time_interval if bk_sep=1. Fixed.
   17-Sep-2004, Kim.  Added writing bk_rate and bk_error to FITS file
   19-Sep-2004, Kim.  Added 4 background things to plot in plot_summ, and
     2 bk things to calc in calc_summ.
   20-Sep-2004, Kim.  Added an extension to fit results FITS file for OSPEX control params
   24-Sep-2004, Sandhia, Filled mjdref, timezero, tstarti, tstopi, tstartf and tstopf, poisserr,
                              timesys, clockcor, observer and version fields of
                              rate_struct before calling mk_rate_hdr.  Deleted code to write these
                              parameters to fits file from add_rate_keywords routine.
   5-Oct-2004, Kim.  Changed writescript to write a procedure instead of a script that is @'ed.
   5-Oct-2004, Kim.  Added runscript method to set params from a script with option to init first.
   5-Oct-2004, Kim.  Added adjust_intervals method to force fit intervals to data boundaries
   20-Oct-2004, Sandhia,  Separated the code to handle writing fits files (data or
                              fit results) in a new file spex__fitswrite
   2-Dec-2004, Kim.  Added chisq_full item to calculate in calc_summ method.
   11-Apr-2005, Kim.  In intervals, use plot_time,/data instead of plot, class=spex_data, and
     added /show_filter on time plot
   23-Jun-2005, Kim. Changed file filter for pickfile to include .dat, .fits for data, .rmf for srm
	10-Aug-2005, Kim.  Added area to fitresults display, added current date to default name for
	  script, and added some comments at the beginning of the script written to explain how to
	  use it.  And added a ' READING...' while reading the input file.
	Sep-2005, Kim.  Use xmessage for preview and fitsheader instead of prstr
	30-Sep-2005, Kim.  Added roi, roi_config, and save_roi methods - just so you can call
	  those spex_image methods from a spex object.  Just passes through.
	  Also, in writescript, if obj is using an image cube, then temporary obj used to
	  get default params must have strategy set to an image also, or params aren't there.
	7-Oct-2005, Kim.  Added list_roi method, so can call spex_image::list_roi from a spex obj.
	9-Feb-2006, Kim.  Added set method - allows us to trap when a new input file is set, so we
	  can reset key parameters to defaults.
	  Added albedo info to setupsummary
	  get_script_params method renamed to get_param_names, and added new_input keyword (also added
	    an 'N' flag to param list in ospex_script_params.txt to indicate which params should be
	    reset when input changes, and now read that file with rd_tfile to parse it)
	  clearall method renamed to init_params, and added new_input keyword.
	  Added is_image_input method to test if input file is an image cube and use it in the roi methods.
	15-Mar-2006, Kim.  Added epsilon=1.e-5 to call to find_contig_ranges
	7-Apr-2006, Kim.  Added call to func_comp_kw in fitsummary, added list_function method,
	  and call it in setupsummary.
	9-May-2006, Kim.  Disabled option to write fit results in save (genx) file
   23-Jun-2006, Kim. Set default for source_xy whenever a new input file is set (in set method)
	2-Jul-2006, Kim.  Added tband to intervals method.
	17-Jul-2006, Kim.  To enable SOXS data:
		In set_file, added .out as acceptable file name extension
		In fitsheader, check if file is a FITS file before calling mrdfits
	3-Aug-2006, Kim.  Added nodialog keyword to restorefits method
	18-Sep-2006, Kim.  Added bk_ratio info to setupsummary output
	19-Oct-2006, ABShah Change *.out to *.LES for SOXS instrument.

 CALLS:


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

 Purpose: Provides methods to create a FITS file for OSPEX.

 Calling Sequence
 fitswrite, outfile=outfile, fits=fit_results, bksub=bksub, origint=origint

 INPUTS:

 INPUT KEYWORDS:
 /FIT_RESULTS -  Specify this keyword to create FITS file containing OSPEX fit results
 /BKSUB -  Specify this keyword to create a Background-subtracted RATES
 /ORIGINT - Specify this keyword to create an unbinned RATES

********************************************************************************************
 *** NOTE ***
 FIT_RESULTS keyword cannot be used in combination with BKSUB and/or ORIGINT keywords.
********************************************************************************************
 This procedure can be called in one of the following ways:
   fitswrite, outfile=outfile   ; Creates a RATE file containing binned count data (and
                                      background, if available in the input file)
   fitswrite, outfile=outfile, /bksub   ; Creates a RATE file containing binned background-
                                              subtracted data
   fitswrite, outfile=outfile, /bksub, /origint   ; Creates a RATE file containing unbinned
                                                        background subtracted data
   fitswrite, outfile=outfile, /origint   ; Creates a RATE file containing unbinned
                                                count (and background data, if applicable)
   fitswrite, outfile=outfile, /fit_results   ; Creates a file containing FIT results


 OUTPUTS:
 OUTFILE - Name of the output file


 Category: OSPEX

 Written: Oct. 22, 2004  Sandhia Bansal
 Modifications:
 Sandhia Bansal - 12/08/04 - renamed three procedures: createRateExt to fit_results_write,
             getRates to fit_results and createControlExt to fit_results_control_ext.
 Sandhia Bansal - 12/20/04 - Modified defineRateKeys to set telescope to "unknonwn" and
                                chantype to a blank string when the instrument is not "HESSI"
                                or "XSM".
 Kim.  15-Aug-2005.  Changed catch in fitswrite method to check debug level, and
   print more info, changed getRateFilename to use break_file, changed getRateFilename
   filetype argument to not include '.', and Andre made changes to use his new fitswrite obj.
 Kim, 7-Apr-2006. added new spex_summ params (spectrum, model, chianti_version,
   abun_table) in fit_results method.  New version of fit results FITS file is 1.1 (was 1.00)
!!!!!!!!!!!!!!!!!!!!!!!
 NOTE from Kim, 7-apr-2006:  fit_results method here and spex_read_fit_results should
 be changed to use the original names in the spex_summ structure instead of
 changing the names to shorter names to write the binary extension, and then
 repopulating the spex_summ structure with each name.  That requires manually moving
 each piece of info in spex_summ, instead of just using the whole structure.
  Should just use the spex_summ structure and add
 whatever's necessary to it before calling mwrfits.  I think.  I think Sandhia did it this
 way so that each interval has a structure (replicated with same tags)?   But is it worth it?
!!!!!!!!!!!!!!!!!

 29-May-2006, Kim.  Made sure func_spectrum and func_model aren't '' when the structure
   containing them is being set up to write to a FITS file.  There's a bug in the FITS writer.


spex__xbk $SSW/packages/spex/idl/object_spex/spex__xbk.pro
[Previous] [Next]
 Name: spex__xbk
 Purpose: Widget interface to background selection in OSPEX

 Written, Kim Tolbert 2002
 Modifications:
   11-Apr-2005, Kim.  Use plot_time,/data instead of plot, class=spex_data, and
     added /show_filter on time plots
	15-Mar-2006, Kim. added gui_label to put on title bar of spex widget interfaces
	18-Sep-2006, Kim. Added bk_ratio option with smoothing width


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

 PROJECT:
	SDAC
 NAME:
	SPEX_BACKGROUND

 PURPOSE:
	controls the determination of background rate within the SPEX environment.

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	SPEX_BACKGROUND, Ut, Flux, Eflux, Rate, Erate, Back, Eback, Ltime, $
	Tb, Wback, Com_param, Check_defaults, Command

 INPUTS:
 	Ut - time array in seconds relative to utbase ( utbase=getutbase() )
	for displayed light curve
 	Flux - count rate flux, current units of displayed plot.
        background to be determined for each energy channel and
        time interval of flux    
 	Flux- uncertainties on flux    
 	Ltime- live time in each time bin
 	Check_defaults - if set ask for background input

 OPTIONAL INPUTS:
 	Com_param- command parameter from op_com
            used for passing in CLEAR command 
            and channels for selective background
            Use 'null' to set background to zero for background subtracted data
	
 KEYWORD PARAMETERS:
 	BACK_ORDER - optional keyword, polynomial order of background fit, 
              5 values, one for each band and all channel default
 	ENERGY_BANDS - 2x4 energy intervals referenced to edges
 	EDGES      - nominal energy of output bands
	USE_BAND - set to 0,1,2,3 to use data in energy_bands(use_band)
             set to -1 to use a single background interval and fit order

 OUTPUTS:
 	Rate - background subtracted count rate (also input)
 	Erate- uncertainty on rate
 	Back - background model for each channel and time bin
 	Eback- uncertainty on back
 	Wback- indices of time intervals used for background

 OPTIONAL OUTPUTS:
 	Command- tells spex where to go after subtraction

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], Arr2Str [2], CHECKVAR [1], CRANGE
	FCOLOR [1], FIT_BACKGRND, F_DIV, F_USE_WIDGET, GETUTBASE [1], GETUTBASE [2]
	GRAPHICS_PAGE, LIMITS, RESPOND_WIDG, SPEX_THISTORY [1], SPEX_THISTORY [2]
	checkvar [2], fcolor [2], printx [1], printx [2], spex_current [1]
	spex_current [2], spex_intervals [1], spex_intervals [2]
 CALLED BY:
	MAP_DISCLA2CONT, SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1]
	SPEX_PROC [2]
 COMMON BLOCKS:
	BLOCK1: common spex_background, t_out_range

 SIDE EFFECTS:
	Describe "side effects" here.  There aren't any?  Well, just delete
	this entry.

 RESTRICTIONS:
	Describe any "restrictions" here.  Delete this section if there are
	no important restrictions.

 PROCEDURE:
         Assumes event light curve is currently plotted in the active window
         Background is calculated over all of ut according to
         polynomial model of order back_order(def=1) using
         polyfitw over each energy channel in turn.  Weighting is
         according to ltime, the livetime of the detector for
         each time bin.  
         Can be used to clear background, "background, clear" in SPEX
         or can use existing background array, "background, old" in SPEX.
         After first fitting the background over the whole energy range,
         the background can be computed independently for any of the energy
         ranges specifed by energy bands in SPEX.  That band is replotted alone
         without any background subtraction, and the current intervals are shown and
         the new intervals are requested and the fit is calculated according to
         the current value of back_order as usual for that energy range.
         The variable need_nw_back is not set to 1 until some background has
         been calculated for the whole energy range!

 EXAMPLE:
	Not to be used directly.  Called from with SPEX, e.g.
	  spex_background, ut, flux, eflux, rate, erate, back, eback, ltime, $
	   tb, wback, com_param, check_defaults, command, $
	   back_order=back_order, title=title, def_tb=def_tb, $;
	   use_band= use_band, need = need, energy_bands=energy_bands, edges = edges

 MODIFICATION HISTORY: 
 	ras 14-apr-94
       ras, 17-may-94, allows use of "old" background, already in SPEX 
       ras, 23-july-94, integrated discrete energy band capability
       ras, 1-sep-94, fixed direct input problem
       ras, 27-sep-94, allow for no background subtraction with Null command
	ras, 20-oct-94, change to allow multi-channel ltime
	ras, pass eflux on to background fitter, 30-aug-95
	Version 2, ras, 23-Mar-1996, tidied documentation header
	Version 3, ras, 27-Oct-1996, changed definition of nchan to match spex_intervals.pro


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

 PROJECT:
	SDAC
 NAME:
	SPEX_BACKGROUND

 PURPOSE:
	controls the determination of background rate within the SPEX environment.

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	SPEX_BACKGROUND, Ut, Flux, Eflux, Rate, Erate, Back, Eback, Ltime, $
	Tb, Wback, Com_param, Check_defaults, Command

 INPUTS:
 	Ut - time array in seconds relative to utbase ( utbase=getutbase() )
	for displayed light curve
 	Flux - count rate flux, current units of displayed plot.
        background to be determined for each energy channel and
        time interval of flux    
 	Flux- uncertainties on flux    
 	Ltime- live time in each time bin
 	Check_defaults - if set ask for background input

 OPTIONAL INPUTS:
 	Com_param- command parameter from op_com
            used for passing in CLEAR command 
            and channels for selective background
            Use 'null' to set background to zero for background subtracted data
	
 KEYWORD PARAMETERS:
 	BACK_ORDER - optional keyword, polynomial order of background fit, 
              5 values, one for each band and all channel default
 	ENERGY_BANDS - 2x4 energy intervals referenced to edges
 	EDGES      - nominal energy of output bands
	USE_BAND - set to 0,1,2,3 to use data in energy_bands(use_band)
             set to -1 to use a single background interval and fit order

 OUTPUTS:
 	Rate - background subtracted count rate (also input)
 	Erate- uncertainty on rate
 	Back - background model for each channel and time bin
 	Eback- uncertainty on back
 	Wback- indices of time intervals used for background

 OPTIONAL OUTPUTS:
 	Command- tells spex where to go after subtraction

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], Arr2Str [2], CHECKVAR [1], CRANGE
	FCOLOR [1], FIT_BACKGRND, F_DIV, F_USE_WIDGET, GETUTBASE [1], GETUTBASE [2]
	GRAPHICS_PAGE, LIMITS, RESPOND_WIDG, SPEX_THISTORY [1], SPEX_THISTORY [2]
	checkvar [2], fcolor [2], printx [1], printx [2], spex_current [1]
	spex_current [2], spex_intervals [1], spex_intervals [2]
 CALLED BY:
	MAP_DISCLA2CONT, SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1]
	SPEX_PROC [2]
 COMMON BLOCKS:
	BLOCK1: common spex_background, t_out_range

 SIDE EFFECTS:
	Describe "side effects" here.  There aren't any?  Well, just delete
	this entry.

 RESTRICTIONS:
	Describe any "restrictions" here.  Delete this section if there are
	no important restrictions.

 PROCEDURE:
         Assumes event light curve is currently plotted in the active window
         Background is calculated over all of ut according to
         polynomial model of order back_order(def=1) using
         polyfitw over each energy channel in turn.  Weighting is
         according to ltime, the livetime of the detector for
         each time bin.  
         Can be used to clear background, "background, clear" in SPEX
         or can use existing background array, "background, old" in SPEX.
         After first fitting the background over the whole energy range,
         the background can be computed independently for any of the energy
         ranges specifed by energy bands in SPEX.  That band is replotted alone
         without any background subtraction, and the current intervals are shown and
         the new intervals are requested and the fit is calculated according to
         the current value of back_order as usual for that energy range.
         The variable need_nw_back is not set to 1 until some background has
         been calculated for the whole energy range!

 EXAMPLE:
	Not to be used directly.  Called from with SPEX, e.g.
	  spex_background, ut, flux, eflux, rate, erate, back, eback, ltime, $
	   tb, wback, com_param, check_defaults, command, $
	   back_order=back_order, title=title, def_tb=def_tb, $;
	   use_band= use_band, need = need, energy_bands=energy_bands, edges = edges

 MODIFICATION HISTORY: 
 	ras 14-apr-94
       ras, 17-may-94, allows use of "old" background, already in SPEX 
       ras, 23-july-94, integrated discrete energy band capability
       ras, 1-sep-94, fixed direct input problem
       ras, 27-sep-94, allow for no background subtraction with Null command
	ras, 20-oct-94, change to allow multi-channel ltime
	ras, pass eflux on to background fitter, 30-aug-95
	Version 2, ras, 23-Mar-1996, tidied documentation header
	Version 3, ras, 27-Oct-1996, changed definition of nchan to match spex_intervals.pro


spex_batse_preview [1] $SSW/packages/spex/idl/original_spex/spex_batse_preview.pro
[Previous] [Next]
 PROJECT:
	SDAC
 NAME: 
	spex_batse_preview	
 PURPOSE:
	find file names and display energy range and aspect info
	in preparation for file reading in SPEX of BATSE data.
 CALLING SEQUENCE:
	spex_batse_preview, data_tipe, flare, det_id, in_files, in_directory, ;Inputs
		      dir_path=dir_path, files, det_cosines, dsel, last_found, command              ;Outputs
 CATEGORY:
	SPEX, BATSE, CGRO
 INPUTS:
	data_tipe - instrument and data format, gets set to upper case
	flare     - event number for BATSE
	det_id    - detector id 
	in_files  - 2 input file names to search for
	in_directory - possible directory for data files
	dir_queue - set of data directories to search including
		    wildcards
	standard_types - data formats integrated into SPEX environment	
	source_radec - ra and dec of cosmic source, used if ra or dec non-zero
	event_time - If flare isn't given for BATSE data, then event_time must be
 OUTPUTS:
	files       - found filenames
	det_cosines - detector aspects for event
	dsel        - selected detectors (BATSE)
	last_found  - structure with dataa_tipe, det_id, flare of found files
	command     - string which directs output path in spex
		      set to '' if no file found satisfying condition
	text_out    - block of text reporting success of preview
 KEYWORDS:
	BATSE_BURST - optional reference to BATSE database, if non-zero may override Flare
 OPTIONAL OUTPUTS:

 PROCEDURE: uses findfile to find standard file names in directories
		given in dir_queue.  

 CALLS: ***
	ATIME [1], ATIME [2], AVG [1], AVG [2], CHECKVAR [1], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], DET_COSINES, DISCLA_EDGES, DISCSP_EDGES, FCHECK, GRO_POINT
	MERGE_BATSE, READ_FLARE, READ_SHER, READ_SHERB, READ_STTE, batse_file_search [1]
	batse_file_search [2], bits [1], bits [2], checkvar [2], concat_dir [4]
	spex_current [1], spex_current [2]
 RESTRICTIONS: Defaults set for BATSE data, 14-apr-94. More to come.
 
 MODIFICATION HISTORY: 
	richard.schwartz@gsfc.nasa.gov, 29-sep-1997 from SPEX_PREVIEW
	richard.schwartz@gsfc.nasa.gov, 2-oct-1997 files(0) set to '' on sher_only set. 


spex_batse_preview [2] $SSW/packages/spex/pre2002/idl/spex_batse_preview.pro
[Previous] [Next]
 PROJECT:
	SDAC
 NAME: 
	spex_batse_preview	
 PURPOSE:
	find file names and display energy range and aspect info
	in preparation for file reading in SPEX of BATSE data.
 CALLING SEQUENCE:
	spex_batse_preview, data_tipe, flare, det_id, in_files, in_directory, ;Inputs
		      dir_path=dir_path, files, det_cosines, dsel, last_found, command              ;Outputs
 CATEGORY:
	SPEX, BATSE, CGRO
 INPUTS:
	data_tipe - instrument and data format, gets set to upper case
	flare     - event number for BATSE
	det_id    - detector id 
	in_files  - 2 input file names to search for
	in_directory - possible directory for data files
	dir_queue - set of data directories to search including
		    wildcards
	standard_types - data formats integrated into SPEX environment	
	source_radec - ra and dec of cosmic source, used if ra or dec non-zero
	event_time - If flare isn't given for BATSE data, then event_time must be
 OUTPUTS:
	files       - found filenames
	det_cosines - detector aspects for event
	dsel        - selected detectors (BATSE)
	last_found  - structure with dataa_tipe, det_id, flare of found files
	command     - string which directs output path in spex
		      set to '' if no file found satisfying condition
	text_out    - block of text reporting success of preview
 KEYWORDS:
	BATSE_BURST - optional reference to BATSE database, if non-zero may override Flare
 OPTIONAL OUTPUTS:

 PROCEDURE: uses findfile to find standard file names in directories
		given in dir_queue.  

 CALLS: ***
	ATIME [1], ATIME [2], AVG [1], AVG [2], CHECKVAR [1], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], DET_COSINES, DISCLA_EDGES, DISCSP_EDGES, FCHECK, GRO_POINT
	MERGE_BATSE, READ_FLARE, READ_SHER, READ_SHERB, READ_STTE, batse_file_search [1]
	batse_file_search [2], bits [1], bits [2], checkvar [2], concat_dir [4]
	spex_current [1], spex_current [2]
 RESTRICTIONS: Defaults set for BATSE data, 14-apr-94. More to come.
 
 MODIFICATION HISTORY: 
	richard.schwartz@gsfc.nasa.gov, 29-sep-1997 from SPEX_PREVIEW
	richard.schwartz@gsfc.nasa.gov, 2-oct-1997 files(0) set to '' on sher_only set. 


spex_bk__define $SSW/packages/spex/idl/object_spex/spex_bk__define.pro
[Previous] [Next]
 Modifications:
 9-Sep-2004, Kim.  Modified edata calc - previously summed error in counts and sigma in
   quadrature.  Wrong.  Now just use sigma as error.
 16-Sep-2004, Kim.  Added show_err option in plot_setup method.
 10-Oct-2004, Kim.  In process, check if data is structure before using it.
 09-Aug-2005, Kim.  In get, found needs to be param name, not 1
 13-Feb-2006, Kim.  In plot_setup, call get_plot_title to get title
 13-Sep-2006, Kim.  In plot_setup, call spex_apply_eff for errors too if photons
 18-Sep-2006, Kim.  Lots of changes in process method to implement bk_ratio method.
 CALLS:


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

 Purpose: Initialize control params for spex_bk class

 Modifications:
 9-sep-2006,Kim.  Added spex_bk_ratio and spex_bk_sm_width
 CALLED BY
	spex_bk__define


spex_bk_control__define $SSW/packages/spex/idl/object_spex/spex_bk_control__define.pro
[Previous] [Next]
 5-Sep-2006, Kim.  Added spex_bk_ratio and spex_bk_sm_width


spex_bkgrd t_d rate trange1 trange2 order sigmasigma [1] $SSW/packages/spex/idl/original_spex/spex_bkgrd.pro
[Previous] [Next]
FUNCTION: spex_bkgrd, t_d, rate, trange1, trange2, order, sigma=sigma, $
	selected=selected, ltime=ltime

PURPOSE: Fit the count rate, RATE, to a polynomial of order, ORDER, over
the background intervals specified by the limits in TRANGE1 and TRANGE2.
Return the value of the fit over the time range, T_D.
Inputs:

	t_d - time array, n  or (2 x n) where n is the number of time bins.
		if t_d is dimensioned 2xn, then the first column is the
		start times and the second column is the end times.
		if t_d is dimensioned n, then intervals are uniform and
		t_d is the center of each interval. t_d is monotonic.

	rate - count rate vector, n elements.
	ltime - livetime of each interval in rate, used for weighting

	selected - indices of selected points in t_d and rate to use in fit
	or 
	trange1 - 2 points on the range covered by t_d.  Should be prior
		to the event (flare).
	trange2 - 2 points after the event along t_d.

	order - polynomial to fit over the ranges specified by 
		trange1 and trange2
If it is 
Keyword SIGMA is the average standard deviation in the fit

Default ORDER =1
Uses POLY and POLY_FIT

RAS, 92/1/27
17-oct-93, modified to take time arrays with start and stop edges
 CALLS:


spex_bkgrd t_d rate trange1 trange2 order sigmasigma [2] $SSW/packages/spex/pre2002/idl/spex_bkgrd.pro
[Previous] [Next]
FUNCTION: spex_bkgrd, t_d, rate, trange1, trange2, order, sigma=sigma, $
	selected=selected, ltime=ltime

PURPOSE: Fit the count rate, RATE, to a polynomial of order, ORDER, over
the background intervals specified by the limits in TRANGE1 and TRANGE2.
Return the value of the fit over the time range, T_D.
Inputs:

	t_d - time array, n  or (2 x n) where n is the number of time bins.
		if t_d is dimensioned 2xn, then the first column is the
		start times and the second column is the end times.
		if t_d is dimensioned n, then intervals are uniform and
		t_d is the center of each interval. t_d is monotonic.

	rate - count rate vector, n elements.
	ltime - livetime of each interval in rate, used for weighting

	selected - indices of selected points in t_d and rate to use in fit
	or 
	trange1 - 2 points on the range covered by t_d.  Should be prior
		to the event (flare).
	trange2 - 2 points after the event along t_d.

	order - polynomial to fit over the ranges specified by 
		trange1 and trange2
If it is 
Keyword SIGMA is the average standard deviation in the fit

Default ORDER =1
Uses POLY and POLY_FIT

RAS, 92/1/27
17-oct-93, modified to take time arrays with start and stop edges
 CALLS:


spex_bkint__define $SSW/packages/spex/idl/object_spex/spex_bkint__define.pro
[Previous] [Next]
 Modifications:
 10-Oct-2004, Kim.  In process, abort if data isn't a structure
 11-Apr-2005, Kim.  In intervals_pre_hook, use plot_time,/data instead of plot, class=spex_data, and
   added /show_filter on time plot
 09-Aug-2005, Kim.  In get, found needs to be param name, not 1
 29-Sep-2005, Kim.  In set, /need_update was causing it to re-read the raw data file.  Use
   /this_class_only to limit to this class.  (not sure why we need to set need_update, but
   I think it has something to do with framework not finding this_xxx param)
 13-Feb-2006, Kim.  In plot_setup, call get_plot_title to get title
 CALLS:


spex_bksub__define $SSW/packages/spex/idl/object_spex/spex_bksub__define.pro
[Previous] [Next]
 Modifications:
 16-Sep-2004, Kim.  Added show_err option in plot_setup method.
 13-Feb-2006, Kim.  In plot_setup, call get_plot_title to get title
 13-Sep-2006, Kim.  In plot_setup, call spex_apply_drm for errors too if photons

 CALLS:


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

 NAME:
	SPEX_COMMONS

 PURPOSE:
	Data and Option storage common blocks for SPEX

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	Not a procedure, code to be included using "@spex_commons"

 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	SPEX_PROC_COM - Input and Processed Data Arrays
	SPEX_SETUP_COM- Control Options
	SPEX_HOLD_COM - Used for merging data input streams

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	Common blocks only, used in SPEX_PROC, SPEX_CURRENT, SPEX_SAVE
				    SPEX_SAVE_DATA, SPEX_CURRENT, SPEX
				    OPTION_CHANGER, SPEX_SOURCE, HELP_MERGE
				    SPEX_DELETE, SPEX_MERGE, SPEX_HOLD

 MODIFICATION HISTORY:
	Documented ras, April 1996
	Version 2, ras, Added HANDLES, 3 April 1996, last_plot

	Version 3, ras, Added HANDLES, 15 May 1996, added p_read_data and
	moved p_drm_reader
	Version 4, ras, 18-Jul-1997, added erange and flare
	19-mar-02, ras, pyb, added spex_debug, spex_obj to
		support catch and objects
	21-may-02, ras, added function_com


SPEX_COMMONS [2] $SSW/packages/spex/idl/original_spex/spex_proc.pro
[Previous] [Next]

 NAME:
	SPEX_COMMONS

 PURPOSE:
	Data and Option storage common blocks for SPEX

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	Not a procedure, code to be included using "@spex_commons"

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], ATIME [1], ATIME [2], AVG [1], AVG [2]
	Accum [1], Accum [2], Arr2Str [2], BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3]
	CHECKVAR [1], CHKLOG [1], CHKLOG [2], CLEANPLOT [1], CLEANPLOT [2], CLEANPLOT [3]
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], CRANGE, FCHECK, FCOLOR [1]
	FORM_FILENAME [1], FORM_FILENAME [2], F_DIV, GETUT [1], GETUT [2], GETUTBASE [1]
	GETUTBASE [2], GRAPHICS_PAGE, Help_spex [1], Help_spex [2], LIMITS, LOC_FILE [1]
	LOC_FILE [2], LOC_FILE [3], Model_components [1], Model_components [2]
	OP_COM [1], OP_COM [2], PARSE_COMLINE, PSPLOT [1], PSPLOT [2], READ_SEQFILE
	RUN_CURVEFIT [1], RUN_CURVEFIT [2], SETUT [1], SETUT [2], SETUTBASE [1]
	SETUTBASE [2], SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_FLASH [1]
	SPEX_FLASH [2], SPEX_PROC [1], SPEX_PROC [2], SPEX_SUMMARY [1], SPEX_SUMMARY [2]
	SPEX_THISTORY [1], SPEX_THISTORY [2], UNIQ [1], UNIQ [2], UNIQ [3], UTIME [1]
	UTIME [2], WRITE_GIF, XDEVICE, anytim [1], anytim [2], anytim [3], anytim [4]
	anytim [5], apar_check [1], apar_check [2], break_file [4], checkvar [2]
	concat_dir [4], curdir [1], curdir [2], drm_4_spex [1], drm_4_spex [2]
	edge_products, fcolor [2], get_logenv [1], get_logenv [2], printx [1], printx [2]
	read_4_spex [1], read_4_spex [2], setup_params [1], setup_params [2]
	setup_spex [1], setup_spex [2], spex_energy_ranges [1], spex_energy_ranges [2]
	spex_intervals [1], spex_intervals [2], spex_merge_control [1]
	spex_merge_control [2], spex_preview [1], spex_preview [2], spex_spec_plot [1]
	spex_spec_plot [2], spex_spec_plot [3], spex_spec_plot [4], wsetshow [1]
	wsetshow [2], xps [1], xps [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	SPEX_PROC_COM - Input and Processed Data Arrays
	SPEX_SETUP_COM- Control Options
	SPEX_HOLD_COM - Used for merging data input streams

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	Common blocks only, used in SPEX_PROC, SPEX_CURRENT, SPEX_SAVE
				    SPEX_SAVE_DATA, SPEX_CURRENT, SPEX
				    OPTION_CHANGER, SPEX_SOURCE, HELP_MERGE
				    SPEX_DELETE, SPEX_MERGE, SPEX_HOLD

 MODIFICATION HISTORY:
	Documented ras, April 1996
	Version 2, ras, Added HANDLES, 3 April 1996, last_plot

	Version 3, ras, Added HANDLES, 15 May 1996, added p_read_data and
	moved p_drm_reader
	Version 4, ras, 18-Jul-1997, added erange and flare
	19-mar-02, ras, pyb, added spex_debug, spex_obj to
		support catch and objects
       17-sep-2002, PB, changed SPEX_DEBUG to Boolean flag.


SPEX_COMMONS [3] $SSW/packages/spex/pre2002/idl/spex_commons.pro
[Previous] [Next]

 NAME:
	SPEX_COMMONS

 PURPOSE:
	Data and Option storage common blocks for SPEX

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	Not a procedure, code to be included using "@spex_commons"

 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	SPEX_PROC_COM - Input and Processed Data Arrays
	SPEX_SETUP_COM- Control Options
	SPEX_HOLD_COM - Used for merging data input streams

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	Common blocks only, used in SPEX_PROC, SPEX_CURRENT, SPEX_SAVE
				    SPEX_SAVE_DATA, SPEX_CURRENT, SPEX
				    OPTION_CHANGER, SPEX_SOURCE, HELP_MERGE
				    SPEX_DELETE, SPEX_MERGE, SPEX_HOLD

 MODIFICATION HISTORY:
	Documented ras, April 1996
	Version 2, ras, Added HANDLES, 3 April 1996, last_plot

	Version 3, ras, Added HANDLES, 15 May 1996, added p_read_data and
	moved p_drm_reader
	Version 4, ras, 18-Jul-1997, added erange and flare
	19-mar-02, ras, pyb, added spex_debug, spex_obj to
		support catch and objects
	21-may-02, ras, added function_com


SPEX_COMMONS [4] $SSW/packages/spex/pre2002/idl/spex_proc.pro
[Previous] [Next]

 NAME:
	SPEX_COMMONS

 PURPOSE:
	Data and Option storage common blocks for SPEX

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	Not a procedure, code to be included using "@spex_commons"

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], ATIME [1], ATIME [2], AVG [1], AVG [2]
	Accum [1], Accum [2], Arr2Str [2], BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3]
	CHECKVAR [1], CHKLOG [1], CHKLOG [2], CLEANPLOT [1], CLEANPLOT [2], CLEANPLOT [3]
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], CRANGE, FCHECK, FCOLOR [1]
	FORM_FILENAME [1], FORM_FILENAME [2], F_DIV, GETUT [1], GETUT [2], GETUTBASE [1]
	GETUTBASE [2], GRAPHICS_PAGE, Help_spex [1], Help_spex [2], LIMITS, LOC_FILE [1]
	LOC_FILE [2], LOC_FILE [3], Model_components [1], Model_components [2]
	OP_COM [1], OP_COM [2], PARSE_COMLINE, PSPLOT [1], PSPLOT [2], READ_SEQFILE
	RUN_CURVEFIT [1], RUN_CURVEFIT [2], SETUT [1], SETUT [2], SETUTBASE [1]
	SETUTBASE [2], SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_FLASH [1]
	SPEX_FLASH [2], SPEX_PROC [1], SPEX_PROC [2], SPEX_SUMMARY [1], SPEX_SUMMARY [2]
	SPEX_THISTORY [1], SPEX_THISTORY [2], UNIQ [1], UNIQ [2], UNIQ [3], UTIME [1]
	UTIME [2], WRITE_GIF, XDEVICE, anytim [1], anytim [2], anytim [3], anytim [4]
	anytim [5], apar_check [1], apar_check [2], break_file [4], checkvar [2]
	concat_dir [4], curdir [1], curdir [2], drm_4_spex [1], drm_4_spex [2]
	edge_products, fcolor [2], get_logenv [1], get_logenv [2], printx [1], printx [2]
	read_4_spex [1], read_4_spex [2], setup_params [1], setup_params [2]
	setup_spex [1], setup_spex [2], spex_energy_ranges [1], spex_energy_ranges [2]
	spex_intervals [1], spex_intervals [2], spex_merge_control [1]
	spex_merge_control [2], spex_preview [1], spex_preview [2], spex_spec_plot [1]
	spex_spec_plot [2], spex_spec_plot [3], spex_spec_plot [4], wsetshow [1]
	wsetshow [2], xps [1], xps [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	SPEX_PROC_COM - Input and Processed Data Arrays
	SPEX_SETUP_COM- Control Options
	SPEX_HOLD_COM - Used for merging data input streams

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	Common blocks only, used in SPEX_PROC, SPEX_CURRENT, SPEX_SAVE
				    SPEX_SAVE_DATA, SPEX_CURRENT, SPEX
				    OPTION_CHANGER, SPEX_SOURCE, HELP_MERGE
				    SPEX_DELETE, SPEX_MERGE, SPEX_HOLD

 MODIFICATION HISTORY:
	Documented ras, April 1996
	Version 2, ras, Added HANDLES, 3 April 1996, last_plot

	Version 3, ras, Added HANDLES, 15 May 1996, added p_read_data and
	moved p_drm_reader
	Version 4, ras, 18-Jul-1997, added erange and flare
	19-mar-02, ras, pyb, added spex_debug, spex_obj to
		support catch and objects
       17-sep-2002, PB, changed SPEX_DEBUG to Boolean flag.


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

 Purpose: Convert structure from ospex results file from Version 1. to current version.

 Input:
  primhdr - primary header from OSPEX results FITS file
  rates_table - structure from rates table extension of FITS file
  rates_hdr - header of rates table extension of FITS file
  ebounds_table - structure from ebounds table extension of FITS file
  ebounds_hdr - header of ebounds table extension of FITS file

 Output:
  Each of the input variable is changed as needed and returned.

 Method:
 Changes need to convert from Version 1. to 1.1:
   All changes are in rates_table structure:
   1. vth functions (vth, multi_therm_pow, multi_therm_exp) now have an extra parameter
     (abundance).  Need to add an extra element in the correct place in all arrays that
     are dimensioned by nparams and set to default values.
   2. func_spectrum, func_model need to be added to structure, and set to -1 for non-thermal
      functions, and 'full', 'mewe' for any thermal function
   3. chianti_version, abun_table need to be added to structure.
      since we only had mewe before this, abun_table should be set mewe_solar

 Written: Kim Tolbert 1-May-2006
 15-May-2006, Kim.  Replace any vth_noline components with vth and set their
   corresponding func_spectrum value to 'continuum'
 CALLS:
 CALLED BY
	SPEX_READ_FIT_RESULTS


spex_convert_results [2] $SSW/packages/spex/idl/object_spex/spex_convert_results_geny.pro
[Previous] [Next]
 Name: spex_convert_results

 Purpose: Convert structure from ospex results geny file from Version 1. to 1.1.
  Same function as spex_convert_results, except conveniently, the tag names are different, so
  couldn't call that.  Plan to phase out geny files, so conversion from 1.0 to 1.1 hopefully
  will be the only conversion necessary for geny files.

 Input:
  struct - structure of OSPEX results from gen file

 Output:
  Each of the input variable is changed as needed and returned.

 Method:
 Changes need to convert from Version 1. to 1.1:
   1. vth functions (vth, multi_therm_pow, multi_therm_exp) now have an extra parameter
     (abundance).  Need to add an extra element in the correct place in all arrays that
     are dimensioned by nparams and set to default values.
   2. func_spectrum, func_model need to be added to structure, and set to -1 for non-thermal
      functions, and 'full', 'mewe' for any thermal function
   3. chianti_version, abun_table need to be added to structure.
      since we only had mewe before this, abun_table should be set mewe_solar

 Written: Kim Tolbert 1-May-2006
 15-May-2006, Kim.  Replace any vth_noline components with vth and set their
   corresponding func_spectrum value to 'continuum'
 CALLS:
 CALLED BY
	SPEX_READ_FIT_RESULTS


spex_current [1] $SSW/packages/spex/idl/original_spex/spex_current.pro
[Previous] [Next]
 NAME: spex_current
	
 PURPOSE: return current value of SPEX variable from common or parameters
	
 CALLING SEQUENCE: value = spex_current( spex_name, incommon=[0,1])
	
 INPUTS:
	spex_name - string with name of variable in common or option list 
 OPTIONAL INPUTS:
	/incommon - this variable is in the spex_commons.pro common blocks
	input       - if defined, put this value into the variable, return 1 for success
	/by_tag   - if set, then convert the tag name values into SPEX variables
		    used on input only
	/SAVE      - if set, then argument is interpreted as a common separated list of
		    variables to be written to spex.sav or the given
		    FILENAME
	/RESTORE   - if set then restore spex.sav or the given filename.
 OUTPUTS:
	returns the value of the variable for output or 1/0 for success/fail on input

 OPTIONAL OUTPUTS:

 CALLED BY:
	BUILD_DRM_MER_CONT, F_CONVERSION [1], F_CONVERSION [2], GAIN_COR, HESSI_SPEX [1]
	HESSI_SPEX [2], Load_Main [1], Load_Main [2], ROUTINE_NAME [4], ROUTINE_NAME [7]
	RUN_BATSE, SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_DATA_GENX [1]
	SPEX_DATA_GENX [2], SPEX_DATA_OUT [1], SPEX_DATA_OUT [2], SPEX_HANDLES [1]
	SPEX_HANDLES [2], SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
	SPEX_RUN_CURVEFIT [1], SPEX_RUN_CURVEFIT [2], SPEX_SAVE [1], SPEX_SAVE [2]
	SPEX_SAVE_DATA [1], SPEX_SAVE_DATA [2], SPEX_SUMMARY [1], SPEX_SUMMARY [2]
	countsmod_plot [1], countsmod_plot [2], drm_4_spex [1], drm_4_spex [2]
	fcount_rate [1], fcount_rate [2], help_merge [1], help_merge [2]
	inv_counts2photons, inv_get_data_spex [2], inv_get_f_thin_spex
	option_changer [1], option_changer [2], spex_batse_preview [1]
	spex_batse_preview [2], spex_delete [1], spex_delete [2]
	spex_energy_ranges [1], spex_energy_ranges [2], spex_hold [1], spex_hold [2]
	spex_merge [1], spex_merge [2], spex_merge_control [1], spex_merge_control [2]
	spex_source [1], spex_source [2]
 PROCEDURE:

 CALLS: ***
	CHECKVAR [1], DATATYPE [1], DATATYPE [2], DATATYPE [3], FCHECK, checkvar [2]
 COMMON BLOCKS:
	those in spex_commons.pro and dep150_com 

 RESTRICTIONS:
	should not be used where round-off error from string conversion will be a problem

 MODIFICATION HISTORY:
	


 

 value = spex_current( spex_name, incommon=[0,1])

 Avoids including common block in every procedure which needs to access
 main level spex variables.  Also extracts variable values from the fields
 in prm_spex, the option structures.
 
 Mod:
	ras, jul-94
	ras, mar-95, now it won't crash if you forget /incommon for variables
		in the common block
	ras, 30-mar-95, added input capability    
	ras, 12-oct-95, added by_tag
	ras, 4-april-1996, added save and restore and filename


spex_current [2] $SSW/packages/spex/pre2002/idl/spex_current.pro
[Previous] [Next]
 NAME: spex_current
	
 PURPOSE: return current value of SPEX variable from common or parameters
	
 CALLING SEQUENCE: value = spex_current( spex_name, incommon=[0,1])
	
 INPUTS:
	spex_name - string with name of variable in common or option list 
 OPTIONAL INPUTS:
	/incommon - this variable is in the spex_commons.pro common blocks
	input       - if defined, put this value into the variable, return 1 for success
	/by_tag   - if set, then convert the tag name values into SPEX variables
		    used on input only
	/SAVE      - if set, then argument is interpreted as a common separated list of
		    variables to be written to spex.sav or the given
		    FILENAME
	/RESTORE   - if set then restore spex.sav or the given filename.
 OUTPUTS:
	returns the value of the variable for output or 1/0 for success/fail on input

 OPTIONAL OUTPUTS:

 CALLED BY:
	BUILD_DRM_MER_CONT, F_CONVERSION [1], F_CONVERSION [2], GAIN_COR, HESSI_SPEX [1]
	HESSI_SPEX [2], Load_Main [1], Load_Main [2], ROUTINE_NAME [4], ROUTINE_NAME [7]
	RUN_BATSE, SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_DATA_GENX [1]
	SPEX_DATA_GENX [2], SPEX_DATA_OUT [1], SPEX_DATA_OUT [2], SPEX_HANDLES [1]
	SPEX_HANDLES [2], SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
	SPEX_RUN_CURVEFIT [1], SPEX_RUN_CURVEFIT [2], SPEX_SAVE [1], SPEX_SAVE [2]
	SPEX_SAVE_DATA [1], SPEX_SAVE_DATA [2], SPEX_SUMMARY [1], SPEX_SUMMARY [2]
	countsmod_plot [1], countsmod_plot [2], drm_4_spex [1], drm_4_spex [2]
	fcount_rate [1], fcount_rate [2], help_merge [1], help_merge [2]
	inv_counts2photons, inv_get_data_spex [2], inv_get_f_thin_spex
	option_changer [1], option_changer [2], spex_batse_preview [1]
	spex_batse_preview [2], spex_delete [1], spex_delete [2]
	spex_energy_ranges [1], spex_energy_ranges [2], spex_hold [1], spex_hold [2]
	spex_merge [1], spex_merge [2], spex_merge_control [1], spex_merge_control [2]
	spex_source [1], spex_source [2]
 PROCEDURE:

 CALLS: ***
	CHECKVAR [1], DATATYPE [1], DATATYPE [2], DATATYPE [3], FCHECK, checkvar [2]
 COMMON BLOCKS:
	those in spex_commons.pro and dep150_com 

 RESTRICTIONS:
	should not be used where round-off error from string conversion will be a problem

 MODIFICATION HISTORY:
	


 

 value = spex_current( spex_name, incommon=[0,1])

 Avoids including common block in every procedure which needs to access
 main level spex variables.  Also extracts variable values from the fields
 in prm_spex, the option structures.
 
 Mod:
	ras, jul-94
	ras, mar-95, now it won't crash if you forget /incommon for variables
		in the common block
	ras, 30-mar-95, added input capability    
	ras, 12-oct-95, added by_tag
	ras, 4-april-1996, added save and restore and filename


spex_customplot [1] $SSW/packages/spex/idl/original_spex/spex_customplot.pro
[Previous] [Next]
 PROJECT:
	SPEX
 NAME:


 PURPOSE:
	This is a hacked wrapper to spex_spec_plot to support spectrum plotting without
	the subtitles, titles, or timestamp.

 CATEGORY:


 CALLING SEQUENCE:


 CALLS: ***
	CHECKVAR [1], checkvar [2], spex_spec_plot [1], spex_spec_plot [2]
	spex_spec_plot [3], spex_spec_plot [4], wsetshow [1], wsetshow [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, richard.schwartz@gsfc.nasa.gov
	27-jun-02


spex_customplot [2] $SSW/packages/spex/pre2002/idl/spex_customplot.pro
[Previous] [Next]
 PROJECT:
	SPEX
 NAME:


 PURPOSE:
	This is a hacked wrapper to spex_spec_plot to support spectrum plotting without
	the subtitles, titles, or timestamp.

 CATEGORY:


 CALLING SEQUENCE:


 CALLS: ***
	CHECKVAR [1], checkvar [2], spex_spec_plot [1], spex_spec_plot [2]
	spex_spec_plot [3], spex_spec_plot [4], wsetshow [1], wsetshow [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, richard.schwartz@gsfc.nasa.gov
	27-jun-02


spex_data__define $SSW/packages/spex/idl/object_spex/spex_data__define.pro
[Previous] [Next]

 Modifications:
   19-Jul-2004, Kim.  Moved preview method out of spex__define to here
   11-Aug-2004, Kim.  In plot_setup, check if # energy bins is 1, and if so,
     don't try to plot spectrum or spectrogram.
   16-Sep-2004, Kim.  Added show_err option in plot_setup method.
   18-Nov-2004, Sandhia.  Added code to manage XSM-specific data.
   17_Aug-2005, Kim.  Added spex_deconvolved, spex_pseudo_livetime to preview args.
   13-Feb-2006, Kim.  In set method, handle invalid FITS files - use status keyword in
     getpar call and print error message for bad or not found files
     In plot_setup, call get_plot_title to get title
	26-May-2006, Kim.  Added spex_data_pos to args.
	23-Jun-2006, Kim.  Added get_source_pos method
	30-Jun-2006, Kim.  Added tband (in set and intervals pre and post hook methods)
	Jun 2006,    Kim.  Added SPEX_SOXS_SPECFILE strategy, Changed preview to do a getdata
	  and get the info from the obj (previously tried to keep preview separate, not putting
	  the data in the obj, but it's not worth it).  Made dim1_sum=0 the default for time plots.
	13-Sep-2006, Kim.  In plot_setup, call spex_apply_drm for errors too if photons
	31-Oct-2006 A.B. Shah - New SOXS .les identified by 'soxs' or 'corr' in file name
 CALLS:


SPEX_DATA_GENX [1] $SSW/packages/spex/idl/original_spex/spex_data_genx.pro
[Previous] [Next]
 Project     : SDAC

 Name        : SPEX_DATA_GENX

 Purpose     : This procedure loads the flux from a genx file into SPEX variables.

 Category    : SPEX, I/O

 Explanation : The flux and it's uncertainties are extracted from a genx file after
		having been previously prepared.

 Syntax      : spex_data_genx, files=files, flux=flux, eflux=eflux, ut=ut, units=units,
	area=area, ltime=ltime, edges=edges

 Examples    :

 Inputs      :

 Opt. Inputs :

 Opt. Outputs:

 Keywords    :
 files       - file or files with the data to be read
 start_time  -
 end_time    -
               optional, read file between start_time and end_time, defaults
               are the start and end of the files, must be readable by ANYITM

 Keyword Outputs:

 flux        - fltarr(nchan,nbins) - counts/cm2/sec/keV, overflow and livetime corrected
 eflux       - fltarr(nchan,nbins) - sqrt(counts)/cm2/sec/keV
 ut          - dblarr(2,nbins), seconds referenced to 79/1/1
 units       - e.g. 'cm!u-2!n s!u-1!n keV!u-1!n'
 area        - detector area in cm2
 ltime       - fltarr(1,nbins)  accumulation live time in interval, seconds
               changed to fltarr(nchan,nbins) - 20-oct-94
 edges       - fltarr(2,nchan)  lo and hi edges in keV
 delta_light - fltarr(nchan), e.g. for BATSE SHER, channel width in pulse height
               see cal_sher and calibrate, and Band 1992 on SLED problem for
               discussion.  This allows channel widths for normalization (counts/keV)
		to be different from channel edges.
 id_use      - actual detector id, to reference drm
 title       - title string referencing instrument, data
 mode        - special output for YOHKOH, mode=0 for non-flare, 1 for flare
 wchan       - indices of allowed channels
 AUTO        - further instructions to SPEX, e.g. "read_drm", may also be used for input
 COMMAND_OUT - Command text array or scalar passed back to SPEX command processor.

 Calls	      : ***
	DATATYPE [1], DATATYPE [2], DATATYPE [3], FCHECK, FIND_IX, F_DIV, LOC_FILE [1]
	LOC_FILE [2], LOC_FILE [3], anytim [1], anytim [2], anytim [3], anytim [4]
	anytim [5], curdir [1], curdir [2], edge_products, gt_tagval [1], gt_tagval [2]
	restgen [1], restgen [2], spex_current [1], spex_current [2], wc_where [1]
	wc_where [2]
 Common      :

 Restrictions:

 Side effects: P_DRM_READER, a string with a procedure name for building the DRM, may
	be set if the tag P_DRM exists in the structure of the first arg. of the genx
	file in files(0).

 History     : Version 1, RAS, 11-Jul-1997

 Contact     : Richard.Schwartz@gsfc.nasa.gov


SPEX_DATA_GENX [2] $SSW/packages/spex/pre2002/idl/spex_data_genx.pro
[Previous] [Next]
 Project     : SDAC

 Name        : SPEX_DATA_GENX

 Purpose     : This procedure loads the flux from a genx file into SPEX variables.

 Category    : SPEX, I/O

 Explanation : The flux and it's uncertainties are extracted from a genx file after
		having been previously prepared.

 Syntax      : spex_data_genx, files=files, flux=flux, eflux=eflux, ut=ut, units=units,
	area=area, ltime=ltime, edges=edges

 Examples    :

 Inputs      :

 Opt. Inputs :

 Opt. Outputs:

 Keywords    :
 files       - file or files with the data to be read
 start_time  -
 end_time    -
               optional, read file between start_time and end_time, defaults
               are the start and end of the files, must be readable by ANYITM

 Keyword Outputs:

 flux        - fltarr(nchan,nbins) - counts/cm2/sec/keV, overflow and livetime corrected
 eflux       - fltarr(nchan,nbins) - sqrt(counts)/cm2/sec/keV
 ut          - dblarr(2,nbins), seconds referenced to 79/1/1
 units       - e.g. 'cm!u-2!n s!u-1!n keV!u-1!n'
 area        - detector area in cm2
 ltime       - fltarr(1,nbins)  accumulation live time in interval, seconds
               changed to fltarr(nchan,nbins) - 20-oct-94
 edges       - fltarr(2,nchan)  lo and hi edges in keV
 delta_light - fltarr(nchan), e.g. for BATSE SHER, channel width in pulse height
               see cal_sher and calibrate, and Band 1992 on SLED problem for
               discussion.  This allows channel widths for normalization (counts/keV)
		to be different from channel edges.
 id_use      - actual detector id, to reference drm
 title       - title string referencing instrument, data
 mode        - special output for YOHKOH, mode=0 for non-flare, 1 for flare
 wchan       - indices of allowed channels
 AUTO        - further instructions to SPEX, e.g. "read_drm", may also be used for input
 COMMAND_OUT - Command text array or scalar passed back to SPEX command processor.

 Calls	      : ***
	DATATYPE [1], DATATYPE [2], DATATYPE [3], FCHECK, FIND_IX, F_DIV, LOC_FILE [1]
	LOC_FILE [2], LOC_FILE [3], anytim [1], anytim [2], anytim [3], anytim [4]
	anytim [5], curdir [1], curdir [2], edge_products, gt_tagval [1], gt_tagval [2]
	restgen [1], restgen [2], spex_current [1], spex_current [2], wc_where [1]
	wc_where [2]
 Common      :

 Restrictions:

 Side effects: P_DRM_READER, a string with a procedure name for building the DRM, may
	be set if the tag P_DRM exists in the structure of the first arg. of the genx
	file in files(0).

 History     : Version 1, RAS, 11-Jul-1997

 Contact     : Richard.Schwartz@gsfc.nasa.gov


SPEX_DATA_OUT [1] $SSW/packages/spex/idl/original_spex/spex_data_out.pro
[Previous] [Next]
 Project     : SDAC

 Name        : SPEX_DATA_OUT

 Purpose     : This function extracts variable from the SPEX common blocks into a structure.

 Category    : SPEX, I/O


 Syntax      : data_str = spex_data_out( /arg1, /arg2, ...)


 Examples    :
IDL> out=spex_data_out(/obsi,/backi,/apar,/convi,/edges)
IDL> help,out,/st
** Structure <4485588>, 5 tags, length=1864, data length=1864, refs=1:
   APAR            FLOAT     Array[6]
   BACKI           FLOAT     Array[92]
   CONVI           FLOAT     Array[92]
   EDGES           FLOAT     Array[2, 92]
   OBSI            FLOAT     Array[92]


 Inputs      :

 Opt. Inputs :

 Opt. Outputs: Returns a structure.  See example above.  There is one tag in the structure
	for every valid argument.

 Keyword Inputs    :
 	Arg1 - Variables from spex_commons to extract.  See spex_commons.pro and spex_current.pro
		Some examples are FLUX, RATE, OBSI, BACKI, EDGES
		Any and all of the variables may be selected. The full variable name must
		be used.
 Calls	      : ***
	ADD_TAG [1], ADD_TAG [2], spex_current [1], spex_current [2]
 Common      :

 Restrictions:



 History     : Version 1, RAS, 21-FEB-2003

 Contact     : Richard.Schwartz@gsfc.nasa.gov


SPEX_DATA_OUT [2] $SSW/packages/spex/pre2002/idl/spex_data_out.pro
[Previous] [Next]
 Project     : SDAC

 Name        : SPEX_DATA_OUT

 Purpose     : This function extracts variable from the SPEX common blocks into a structure.

 Category    : SPEX, I/O


 Syntax      : data_str = spex_data_out( /arg1, /arg2, ...)


 Examples    :
IDL> out=spex_data_out(/obsi,/backi,/apar,/convi,/edges)
IDL> help,out,/st
** Structure <4485588>, 5 tags, length=1864, data length=1864, refs=1:
   APAR            FLOAT     Array[6]
   BACKI           FLOAT     Array[92]
   CONVI           FLOAT     Array[92]
   EDGES           FLOAT     Array[2, 92]
   OBSI            FLOAT     Array[92]


 Inputs      :

 Opt. Inputs :

 Opt. Outputs: Returns a structure.  See example above.  There is one tag in the structure
	for every valid argument.

 Keyword Inputs    :
 	Arg1 - Variables from spex_commons to extract.  See spex_commons.pro and spex_current.pro
		Some examples are FLUX, RATE, OBSI, BACKI, EDGES
		Any and all of the variables may be selected. The full variable name must
		be used.
 Calls	      : ***
	ADD_TAG [1], ADD_TAG [2], spex_current [1], spex_current [2]
 Common      :

 Restrictions:



 History     : Version 1, RAS, 21-FEB-2003

 Contact     : Richard.Schwartz@gsfc.nasa.gov


spex_data_strategy__define $SSW/packages/spex/idl/object_spex/spex_data_strategy__define.pro
[Previous] [Next]
 Time-stamp: <Tue Jul 26 2005 17:05:25 csillag tounesol.gsfc.nasa.gov>
 Modifications:
  15-Jul-2004, Kim.  Added spex_interval_filter
  24-Nov-2004, Sandhia.  Added a new field called spex_data_name to the argument
                           list for read_data (which is instrument-specific).
                           It will return the name of the instrument.
	21-Jul-2005, Kim.  Added /this_class in setunits and getunits for speed
	17-Aug-2005, Kim.  Added spex_deconvolved and spex_pseudo_livetime to calling args for
		read_data, preview, get_spectra, and setinfoparams
	Aug-2005 - Kim, Andre.  Lots of changes to accommodate image cube spectra in process,
	    setinfoparams, setspectra methods.
	26-May-2006, Kim.  Added spex_data_pos to args.
	23-Jun-2006, Kim.  Added get_source_pos method
	30-Jul-2006, Kim.  Got rid of preview method.  Initialize spex_tband to time range
	  divided into 5 intervals.  Added GET method so we could apply spex_ut_offset to
	  spex_ut_edges whenever we get them.
	2-Aug-2006, Kim.  In process method, read file only if force or filename changed.
	  Otherwise, apply timeshift and save spex_ut_edges, and set_last_update flag
	8-Aug-2006, Kim.  If data has fewer than 10 time or energy intervals, set
	  spex_tband and spex_eband to the raw intervals.
	30-Aug-2006, Kim. Corrected test for eband inside edg in setinfoparams method
	20-Nov-2006, Kim. In process, if spectrum undefined after reading, throw exception

 CALLS:


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

 Purpose: Defines info structure for spex_data_strategy object

 Category: OSPEX

 Modifications:
	15-Jul-2004, Kim.  Added spex_interval_filter
	17-Aug-2005, Kim.  Added spex_deconvolved and spex_pseudo_livetime
	26-May-2006, Kim.  Added spex_data_xyoffset
	30-Jun-2006, Kim.  Added spex_tband


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

 NAME:    spex_delete


 PURPOSE:   remove channels from output spectra


 CATEGORY: spex, spectral analysis


 CALLING SEQUENCE:  spex_delete, chan_2_delete[, wchan=wchan]

 CALLED BY:


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FCHECK, F_DIV, GETUTBASE [1], GETUTBASE [2]
	checkvar [2], delvarx [5], edge_products, help_merge [1], help_merge [2]
	printx [1], printx [2], spex_current [1], spex_current [2], spex_hold [1]
	spex_hold [2], spex_merge [1], spex_merge [2], spex_source [1], spex_source [2]
 INPUTS:
       chan_2_delete - indices of channels to delete
	
 OPTIONAL INPUTS:
	wchan - as an alternative to chan_2_delete, the channels to use may
	        be given as indices in wchan

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	help_merge [1], help_merge [2], spex_hold [1], spex_hold [2], spex_merge [1]
	spex_merge [2], spex_source [1], spex_source [2]
 COMMON BLOCKS:
	common spex_proc_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:

 MODIFICATION HISTORY:
	ras, 20-oct-94


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

 NAME:    spex_delete


 PURPOSE:   remove channels from output spectra


 CATEGORY: spex, spectral analysis


 CALLING SEQUENCE:  spex_delete, chan_2_delete[, wchan=wchan]

 CALLED BY:


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FCHECK, F_DIV, GETUTBASE [1], GETUTBASE [2]
	checkvar [2], delvarx [5], edge_products, help_merge [1], help_merge [2]
	printx [1], printx [2], spex_current [1], spex_current [2], spex_hold [1]
	spex_hold [2], spex_merge [1], spex_merge [2], spex_source [1], spex_source [2]
 INPUTS:
       chan_2_delete - indices of channels to delete
	
 OPTIONAL INPUTS:
	wchan - as an alternative to chan_2_delete, the channels to use may
	        be given as indices in wchan

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	help_merge [1], help_merge [2], spex_hold [1], spex_hold [2], spex_merge [1]
	spex_merge [2], spex_source [1], spex_source [2]
 COMMON BLOCKS:
	common spex_proc_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:

 MODIFICATION HISTORY:
	ras, 20-oct-94


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

 Purpose: Draw bars across the top of plots in ospex to show filter states

 Method:  When /show_filter is set on call to plot_time, the utplot object
   contains addplot_name='spex_draw_bars', and addplot_arg = a structure
   containing the values for the keyword arguments needed here.
   The bar for time periods with the same label are drawn at the same y value,
     different labels are shifted downward in y.

 Input Keywords:
   stime - array of start times
   etime - array of end times
   label - array of labels corresponding to those start/end times

 Written: Kim Tolbert 10-Apr-2005.  Extracted from spex_gen__filter_bars so
   that it could be used with the addplot... stuff in utplot
 Modifications:

 CALLS:


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

 Purpose: This object manages the Detector Response Matrix for OSPEX.

 Category: OSPEX

 Written: 2003, Kim Tolbert
 Modifications:
   15-Jul-2004, Kim.  Handle DRM files with multiple filter states
   16-Jul-2004, Kim.  Move preview method here from spex__define.
   23-Aug-2004, Kim.  Added albedo correction stuff
   10-Oct-2004, Kim.  In get_diagonal, check for drm[0]=-1 before using
   19-Nov-2004, Kim.  In read_drm, if xsm data, call xsm drm reader.  Also changed name of hessi
     drm reader to spex_hessi_fits2drm.
   6-Jun-2005, Kim.  Changed solar radius in ::set angle calculation from 916 to 960 arcsec.
	19-Sep-2005, Kim.  For imagecubes, process wasn't getting called again when the imagecube file
	  and therefore respinfo was changed (because respinfo is an info parameter of spex_data.
	  spex_data doesn't know anything about spex_drm, so it can't set a control parameter here.)
	  So save value of respinfo in self, and if it changes, then set need_update.
	9-Feb-2006, Kim.  Added ability to calculate drm if data is rhessi and spex_image_full_srm
	  is set (for image cube, this flags made input spectrum counts instead of photons, and then
	  calculates full drm to convert to photons.)
	  Added need_update method, so can set need_update if respinfo or image_full_srm change,
	  even though they aren't control parameters of drm.
	  Rewrote process method to use a file, array, or build method and added array_drm and
	  build_drm methods.
	  Modified preview method to handle the build method.
	  Only allow albedo correction if drm was read from file.
	7-Apr-2006, Kim.  changed get_diagonal args.  Previously passed in func name and array of
	  params, now pass in fit function object with everything already set in it.  This is better
	  now that we have keywords to set in function as well as params.
	27-Jun-2006, Kim.  Added func_obj to args to apply_drm and call to apply_drm in get_diagonal to
	  accomodate new drm_mod function for RHESSI (to fine-tune detector params in DRM).  When one
     of the functions used is 'drm_mod', then calls the hsi_drm_mod obj to compute drm instead of
     using the one stored.
	10-july-2006, used this_filter or info param to pass correct
		atten_state into hsi_drm_mod object
	14-Jul-2006, Kim.  Use data_name from units structure to assign data name for drm in
		array_drm
	18-Jul-2006, Kim.  Set atten_state into hsi_drm_mod each time, not just when obj is created.
	06-Oct-2006, Kim.  Added pileup_mod changes in apply_drm. pileup_mod is another pseudo
		function (like drm_mod) that lets us add in pileup effects to the expected spectrum.
	11-Oct-2006, Kim.  Added 3rd parameter (smoothing) in call to pileup_mod
	15-Oct-2006, Kim.  Added 4th parameter (mult. factor) for pileup_mod
	17-Oct-2006, Kim.  Pileup was returning ctr rate as double, and this was
		causing mcurvefit to crash when only fitting one variable (IDL bug!)- so
		make pileup_mod output a float.
	30-Oct-2006, Kim.  Changed calls to hsi_drm_mod because of changes in hsi_drm_mod
	14-Nov-2006, Kim.  When drm input file changes, set need_update in spex_drm_mod_obj

 CALLS:


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

 Purpose: Defines control structure for spex_drm object

 Category: OSPEX

 Modifications:
	15-Jul-2004, Kim.  Added spex_drm_filter
	23-Aug-2004, Kim.  Added spex_albedo_correct, spex_anisotropy,
	  spex_source_angle, and spex_source_xy


SPEX_DRM_GENX [1] $SSW/packages/spex/idl/original_spex/spex_drm_genx.pro
[Previous] [Next]
 Project     : SDAC

 Name        : SPEX_DRM_GENX

 Purpose     : This procedure loads the DRM from a genx file.

 Category    : SPEX, I/O

 Explanation : The drm is extracted from a genx file after
				having been previously prepared.
				It will be read by the drm reader through this call:

			call_procedure, p_drm_reader, file=drm_to_read, sfile=scatter_to_read, $
			edges_out=edges_out_drm, edges_in=e_in, area=area, drm=drm

 Syntax      :
				Spex_drm_genx, $
					FILE=file, $
					DRM=drm, $
					EDGES_IN=edges_in, $
					EDGES_OUT=edges_out, $
					AREA=area,  $
					SFILE=sfile

 CALLED BY:
	rd_hessi_drm_4_spex [1], rd_hessi_drm_4_spex [2]
 Examples    :

 Inputs      :

 Opt. Inputs :

 Opt. Outputs:

 Keywords    :
 files       - file or files with the data to be read
 start_time  -
 end_time    -
               optional, read file between start_time and end_time, defaults
               are the start and end of the files, must be readable by ANYITM

 Keyword Outputs:

 flux        - fltarr(nchan,nbins) - counts/cm2/sec/keV, overflow and livetime corrected
 eflux       - fltarr(nchan,nbins) - sqrt(counts)/cm2/sec/keV
 ut          - dblarr(2,nbins), seconds referenced to 79/1/1
 units       - e.g. 'cm!u-2!n s!u-1!n keV!u-1!n'
 area        - detector area in cm2
 ltime       - fltarr(1,nbins)  accumulation live time in interval, seconds
               changed to fltarr(nchan,nbins) - 20-oct-94
 edges       - fltarr(2,nchan)  lo and hi edges in keV
 delta_light - fltarr(nchan), e.g. for BATSE SHER, channel width in pulse height
               see cal_sher and calibrate, and Band 1992 on SLED problem for
               discussion.  This allows channel widths for normalization (counts/keV)
		to be different from channel edges.
 id_use      - actual detector id, to reference drm
 title       - title string referencing instrument, data
 mode        - special output for YOHKOH, mode=0 for non-flare, 1 for flare
 wchan       - indices of allowed channels
 AUTO        - further instructions to SPEX, e.g. "read_drm", may also be used for input

 Calls	      : ***
	GET_TAG_VALUE, LOC_FILE [1], LOC_FILE [2], LOC_FILE [3], curdir [1], curdir [2]
	edge_products, restgen [1], restgen [2]
 Common      :

 Restrictions:

 Side effects: P_DRM_READER, a string with a procedure name for building the DRM, may
	be set if the tag P_DRM exists in the structure of the first arg. of the genx
	file in files(0).

 History     : Version 1, RAS, 11-Jul-1997

 Contact     : Richard.Schwartz@gsfc.nasa.gov


SPEX_DRM_GENX [2] $SSW/packages/spex/pre2002/idl/spex_drm_genx.pro
[Previous] [Next]
 Project     : SDAC

 Name        : SPEX_DRM_GENX

 Purpose     : This procedure loads the DRM from a genx file.

 Category    : SPEX, I/O

 Explanation : The drm is extracted from a genx file after
				having been previously prepared.
				It will be read by the drm reader through this call:

			call_procedure, p_drm_reader, file=drm_to_read, sfile=scatter_to_read, $
			edges_out=edges_out_drm, edges_in=e_in, area=area, drm=drm

 Syntax      :
				Spex_drm_genx, $
					FILE=file, $
					DRM=drm, $
					EDGES_IN=edges_in, $
					EDGES_OUT=edges_out, $
					AREA=area,  $
					SFILE=sfile

 CALLED BY:
	rd_hessi_drm_4_spex [1], rd_hessi_drm_4_spex [2]
 Examples    :

 Inputs      :

 Opt. Inputs :

 Opt. Outputs:

 Keywords    :
 files       - file or files with the data to be read
 start_time  -
 end_time    -
               optional, read file between start_time and end_time, defaults
               are the start and end of the files, must be readable by ANYITM

 Keyword Outputs:

 flux        - fltarr(nchan,nbins) - counts/cm2/sec/keV, overflow and livetime corrected
 eflux       - fltarr(nchan,nbins) - sqrt(counts)/cm2/sec/keV
 ut          - dblarr(2,nbins), seconds referenced to 79/1/1
 units       - e.g. 'cm!u-2!n s!u-1!n keV!u-1!n'
 area        - detector area in cm2
 ltime       - fltarr(1,nbins)  accumulation live time in interval, seconds
               changed to fltarr(nchan,nbins) - 20-oct-94
 edges       - fltarr(2,nchan)  lo and hi edges in keV
 delta_light - fltarr(nchan), e.g. for BATSE SHER, channel width in pulse height
               see cal_sher and calibrate, and Band 1992 on SLED problem for
               discussion.  This allows channel widths for normalization (counts/keV)
		to be different from channel edges.
 id_use      - actual detector id, to reference drm
 title       - title string referencing instrument, data
 mode        - special output for YOHKOH, mode=0 for non-flare, 1 for flare
 wchan       - indices of allowed channels
 AUTO        - further instructions to SPEX, e.g. "read_drm", may also be used for input

 Calls	      : ***
	GET_TAG_VALUE, LOC_FILE [1], LOC_FILE [2], LOC_FILE [3], curdir [1], curdir [2]
	edge_products, restgen [1], restgen [2]
 Common      :

 Restrictions:

 Side effects: P_DRM_READER, a string with a procedure name for building the DRM, may
	be set if the tag P_DRM exists in the structure of the first arg. of the genx
	file in files(0).

 History     : Version 1, RAS, 11-Jul-1997

 Contact     : Richard.Schwartz@gsfc.nasa.gov


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

 Purpose: Defines info structure for spex_drm object

 Category: OSPEX

 Modifications:
	15-Jul-2004, Kim.  Added spex_drm_filter
	9-Feb-2006, Kim.  Added spex_drm_method
   27-Jun-2006, Kim.  Added spex_drm_mod_obj


spex_energy_ranges [1] $SSW/packages/spex/idl/original_spex/spex_energy_ranges.pro
[Previous] [Next]
 PROJECT:
	SPEX
 NAME:


 PURPOSE:
	This procedure converts a set of energy intervals into
	the wuse array in SPEX. Indices in wuse indicate the data bins
	used in fitting.

 CATEGORY:


 CALLING SEQUENCE:
 Call from inside SPEX
	IDL,spex_energy_ranges, energy_ranges

	or outside SPEX

	spex_energy_ranges, energy_ranges

 CALLS: ***
	LAST_ITEM, SINCE_VERSION [1], SINCE_VERSION [2], UNIQ [1], UNIQ [2], UNIQ [3]
	spex_current [1], spex_current [2]
 INPUTS:
       energy_ranges - An array of paired energies used to
		select data bins used in model fitting in SPEX.

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, richard.schwartz@gsfc.nasa.gov
	ras, 7-nov-02


spex_energy_ranges [2] $SSW/packages/spex/pre2002/idl/spex_energy_ranges.pro
[Previous] [Next]
 PROJECT:
	SPEX
 NAME:


 PURPOSE:
	This procedure converts a set of energy intervals into
	the wuse array in SPEX. Indices in wuse indicate the data bins
	used in fitting.

 CATEGORY:


 CALLING SEQUENCE:
 Call from inside SPEX
	IDL,spex_energy_ranges, energy_ranges

	or outside SPEX

	spex_energy_ranges, energy_ranges

 CALLS: ***
	LAST_ITEM, SINCE_VERSION [1], SINCE_VERSION [2], UNIQ [1], UNIQ [2], UNIQ [3]
	spex_current [1], spex_current [2]
 INPUTS:
       energy_ranges - An array of paired energies used to
		select data bins used in model fitting in SPEX.

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, richard.schwartz@gsfc.nasa.gov
	ras, 7-nov-02


spex_env [1] $SSW/packages/spex/idl/original_spex/spex_database.pro
[Previous] [Next]
 NAME: spex_env
	
 PURPOSE: install the SPEX environmentals and path at ISAS
	Two software directories needed are installed at the top of the path.	
 CALLING SEQUENCE:
	spex_env [,old_path=old_path]

 MODIFICATION HISTORY:
	ras, 21-apr-94	


SPEX_ENV [2] $SSW/packages/spex/idl/original_spex/spex_env.pro
[Previous] [Next]
 PROJECT: SDAC

 NAME: SPEX_ENV
	
 PURPOSE: install the SPEX environmentals and path locally, 
	Two software directories needed are installed at the top of the path.	
 CALLING SEQUENCE:
	Spex_env [,old_path=old_path]

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FCHECK, STR_SEP, concat_dir [4]
 MODIFICATION HISTORY:
	ras, 21-apr-94
	RAS, 14-OCT-94	
	ras, 13-jan-96, installation at ISAS
	RAS, 15-jan-96, support ISAS and SSL from same script
	RAS, 16-May-1997, change SSL paths.  Soon to be obsolete, use SSW site setups!


spex_env [3] $SSW/packages/spex/pre2002/idl/spex_database.pro
[Previous] [Next]
 NAME: spex_env
	
 PURPOSE: install the SPEX environmentals and path at ISAS
	Two software directories needed are installed at the top of the path.	
 CALLING SEQUENCE:
	spex_env [,old_path=old_path]

 MODIFICATION HISTORY:
	ras, 21-apr-94	


SPEX_ENV [4] $SSW/packages/spex/pre2002/idl/spex_env.pro
[Previous] [Next]
 PROJECT: SDAC

 NAME: SPEX_ENV
	
 PURPOSE: install the SPEX environmentals and path locally, 
	Two software directories needed are installed at the top of the path.	
 CALLING SEQUENCE:
	Spex_env [,old_path=old_path]

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FCHECK, STR_SEP, concat_dir [4]
 MODIFICATION HISTORY:
	ras, 21-apr-94
	RAS, 14-OCT-94	
	ras, 13-jan-96, installation at ISAS
	RAS, 15-jan-96, support ISAS and SSL from same script
	RAS, 16-May-1997, change SSL paths.  Soon to be obsolete, use SSW site setups!


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

 PURPOSE: Provide a widget interface to select data events for SPEX.
	plot HXRBS flare time profiles.

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHOOSE_FL, FCHECK, READ_MINICAT, SPEX_EVNT_EVENT, TWIDGET
	UTIME [1], UTIME [2], WIDGET_FLASH, WIDG_TYPE, XMANAGER, anytim [1], anytim [2]
	anytim [3], anytim [4], anytim [5], batse_read_cat
 MODIFICATION HISTORY: Written by ras, 23-aug-94
	based on HXRBS widget program by Kim Tolbert 6/92
 


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

 PURPOSE: Provide a widget interface to select data events for SPEX.
	plot HXRBS flare time profiles.

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHOOSE_FL, FCHECK, READ_MINICAT, SPEX_EVNT_EVENT, TWIDGET
	UTIME [1], UTIME [2], WIDGET_FLASH, WIDG_TYPE, XMANAGER, anytim [1], anytim [2]
	anytim [3], anytim [4], anytim [5], batse_read_cat
 MODIFICATION HISTORY: Written by ras, 23-aug-94
	based on HXRBS widget program by Kim Tolbert 6/92
 


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

PURPOSE  - This function returns the structure with the description of the fitting
	    function and the meaning of the free parameters needed for the 
           model selection and the legend printed by the plotting routines.
	     
	     
	     
            

Inputs: FUNCTION_NAME - a string expression of the selected fitting model such as
		   F_VTH_BPOW.
	

Outputs:
		A structure, PAR_LIST, containing the needed description of
		the fitting function.
	

Usage:  label = F_label( Function_name)
Restrictions:
	Implemented for 
	F_VTH_BPOW, F_BPOW, F_VTH	14-APR-1996	

History:
	Written by RAS 92/10/1 as f_label.pro
	Version 2, ras, 14-april-1996


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

PURPOSE  - This function returns the structure with the description of the fitting
	    function and the meaning of the free parameters needed for the 
           model selection and the legend printed by the plotting routines.
	     
	     
	     
            

Inputs: FUNCTION_NAME - a string expression of the selected fitting model such as
		   F_VTH_BPOW.
	

Outputs:
		A structure, PAR_LIST, containing the needed description of
		the fitting function.
	

Usage:  label = F_label( Function_name)
Restrictions:
	Implemented for 
	F_VTH_BPOW, F_BPOW, F_VTH	14-APR-1996	

History:
	Written by RAS 92/10/1 as f_label.pro
	Version 2, ras, 14-april-1996


SPEX_FCHISQR [1] $SSW/packages/spex/idl/original_spex/spex_fchisqr.pro
[Previous] [Next]
 NAME:
	SPEX_FCHISQR
 PURPOSE:
	Compute statistic of total Chisqr for a function (FUNCTION_NAME),
	a set of parameters A, independent variables X, dependent variables Y,
	and weighting factors, W.  Also evaluates the function at X for A as
	well as the partial derivatives wrt the parameters if requested.
 CATEGORY:
	E2 - Curve and Surface Fitting
 CALLING SEQUENCE:
	CHISQR = SPEX_FCHISQR(X,Y,W,Function_Name,A,YFIT,PDER) 
 INPUTS:
	X = Row vector of independent variables.
	Y = Row vector of dependent variable, same length as x.
	W = Row vector of weights, same length as x and y.
		For no weighting
		w(i) = 1., instrumental weighting w(i) =
		1./y(i), etc.
	Function_name - Name of function (string) with X and A as arguments.
	A = Vector of nterms length of parameters for each parameter.  
	If A is double precision, calculations are performed in double 
	precision, otherwise in single prec.

 Optional:
	free - vector of indices of free parameters for which derivs are needed
 OUTPUTS:
;	Function result = YFIT = Vector of calculated
		values.
 OPTIONAL OUTPUT PARAMETERS:
	Partial Derivatives = PDER
	
 CALLS: ***
	funct1 [1], funct1 [2]
 CALLED BY:
	CURVFIT [1], CURVFIT [2]
 COMMON BLOCKS:
	NONE.
 SIDE EFFECTS:
	See details in CURVEFIT.
 RESTRICTIONS:
	NONE.
 PROCEDURE:
	Copied from "CURFIT", least squares fit to a non-linear
	function, pages 237-239, Bevington, Data Reduction and Error
	Analysis for the Physical Sciences.


SPEX_FCHISQR [2] $SSW/packages/spex/pre2002/idl/spex_fchisqr.pro
[Previous] [Next]
 NAME:
	SPEX_FCHISQR
 PURPOSE:
	Compute statistic of total Chisqr for a function (FUNCTION_NAME),
	a set of parameters A, independent variables X, dependent variables Y,
	and weighting factors, W.  Also evaluates the function at X for A as
	well as the partial derivatives wrt the parameters if requested.
 CATEGORY:
	E2 - Curve and Surface Fitting
 CALLING SEQUENCE:
	CHISQR = SPEX_FCHISQR(X,Y,W,Function_Name,A,YFIT,PDER) 
 INPUTS:
	X = Row vector of independent variables.
	Y = Row vector of dependent variable, same length as x.
	W = Row vector of weights, same length as x and y.
		For no weighting
		w(i) = 1., instrumental weighting w(i) =
		1./y(i), etc.
	Function_name - Name of function (string) with X and A as arguments.
	A = Vector of nterms length of parameters for each parameter.  
	If A is double precision, calculations are performed in double 
	precision, otherwise in single prec.

 Optional:
	free - vector of indices of free parameters for which derivs are needed
 OUTPUTS:
;	Function result = YFIT = Vector of calculated
		values.
 OPTIONAL OUTPUT PARAMETERS:
	Partial Derivatives = PDER
	
 CALLS: ***
	funct1 [1], funct1 [2]
 CALLED BY:
	CURVFIT [1], CURVFIT [2]
 COMMON BLOCKS:
	NONE.
 SIDE EFFECTS:
	See details in CURVEFIT.
 RESTRICTIONS:
	NONE.
 PROCEDURE:
	Copied from "CURFIT", least squares fit to a non-linear
	function, pages 237-239, Bevington, Data Reduction and Error
	Analysis for the Physical Sciences.


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

 Purpose: This object manages the Fitting for OSPEX

 Category: OSPEX

 Written: 2003, Kim Tolbert
 Modifications:
   21-Jun-2004, Kim. Switched to using progressbar object (from progbar and showprogress object)
     because it wasn't trapping the 'cancel' clicks.
   22-Jun-2004, Kim.  Removed spex_interval_range parameter from control parameters, and
     added spex_intervals_tofit.  Now can specify non-contiguous intervals to fit.
   20-Jul-2004, Kim.  Added spex_summ_filter to fit results structure
   09-Sep-2004, Sandhia.  Moved definition of spex_summ structure to a separate routine
                                  spex_summ_define_str.  This is to avoid duplication of definition.
   17-Sep-2004, Kim.  Added bk_rate and bk_error to spex_summ structure
	5-Oct-2004, Kim.  In process, call getdata for fitint class at start, so bad intervals will be
	  removed immediately, then adjust intervals_tofit accordingly.  Also use spex_fit_time_used
	  instead of spex_fit_time_interval for summary data since it will show exact times used (since
	  spex_fit_time_interval might not be on data boundaries)
	29-Jun-2005, Kim. Position progbar at lower left of screen
	25-Aug-2005, Kim.  Added class= to calls to get wherever possible to speed things up
	  Since get(/fit_comp,class='fit_comp_manager') no longer include fit_comp_sigmas in structure,
	  get sigmas directly with a get.
	15-Mar-2006, Kim.  Added epsilon=1.e-5 to call to find_contig_ranges
	15-Mar-2006, Kim.  In process, add _extra to call to xfit_comp to pass through gui_label
	7-Apr-2006, Kim.  Changes for addition of spectrum,model keywords:  Added setting
	  corresponding new spex_summ params. Added ncomp arg in call to spex_summ_define_str
	8-Aug-2006, Kim.  Change object chain structure.  Previously spex_fitalg was the source here.
	  Now fitrange is first source and fitalg is second source.  Set the spex_fit obj reference (self)
	  into the fitalg object so it can get to everything.  This fixes the problem of every set into
	  a lower level object being done twice.
	30-Oct-2006,Kim.  Do heap_gc after every fit.  Use this_class_only when
	  saving spex_summ params in obj.  Both help with running out of memory issue.
	  Also, before starting fit loop, find bad intervals and skip over them during loop.
	8-Nov-2006, Kim.  Allow users to change fit function while fitting.  Added check_func method.
	  Adds and removes elements from fit information arrays in spex_summ structure for new or
	  deleted components.
	  Also, don't replot interval if status is 2 (already did fit in fit_comp widget)
 CALLS:


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

 Purpose: Method of spex_fit object to allow users to select fit components and parameters
	through a widget interface

 Category: FITTING, SPEX

 Input:
	group - widget id of parent widget, if any

 Written: Kim Tolbert, March, 2003
 Modifications:
	13-Aug-2004, Kim.  Now 'accept' button has two options - accept and continue as before,
	  or just accept these parameters, but don't continue looping, and don't save fit
	  results.  Also, on cancel was resetting the fit comp stuff, but not the erange, uncert,
	  or itmax to original - fixed.
	31-May-2005, Kim.  Previously called xmanager with cleanup= a routine that would get the
	  uvalue and then re-sensitize the main Fit widget (state.xfit_widget_id).  On Linux, (this
	  never happened on Windows), this was causing IDL to hang intermittently with:
	     % X windows protocol error: BadFont (invalid Font parameter).
	     Xlib: unexpected async reply (sequence 0xdb70)!
	  or if it didn't crash, often got this error:
	     % X windows protocol error: BadFont (invalid Font parameter).
	     Xlib: sequence lost (0xf9fd9 > 0xea003) in reply type 0x0!
	  Got rid of the cleanup routine (I think the problem was in trying to get the uvalue out of
	  the widget that it was killing) and just resensitize the fit widget after we pass through
	  xmanager to the end of the routine.
	28-Jun-2005, Kim.  After fitting, call plot_spectrum with show_chi
	22-Aug-2005, Kim.  Use new units_widget gen method to handle units.
	25-Aug-2005, Kim.  Added class= to calls to get wherever possible to speed things up
	16-Feb-2006, Kim.  Add 0. to dropdown list for systematic uncertainty
	15-Mar-2006, Kim. added gui_label to put on title bar of spex widget interfaces
	7-Apr-2006, Kim.  Changes for addition of spectrum,model keywords
	26-Apr-2006, Kim. Save table values as strings in tables[ii].vals pointer to check what's changed
	29-May-2006, Kim.  Use trim when checking func_spectrum and func_model in case they = '  '
	26-Jul-2006, Kim.  Added /force in call to getdata(class='spex_fitalg') to ensure that a fit
		is done, even if didn't change any parameters
	9-Aug-2006, Kim.   Added a catch in event handler.  Added a kill for wxmessage at the exit
		in case it's still alive (because of routing through the catch).  Also in 'fit' event,
		check if data is a structure before using it.
	31-Oct-2006, Kim.  Rearranged widgets to make widget narrower


spex_fit_info__define $SSW/packages/spex/idl/object_spex/spex_fit_info__define.pro
[Previous] [Next]
 Modifications:
 16-Sep-2004, Kim.  Added spex_autoplot_show_err
 17-Sep-2004, Kim.  Added bk_rate, bk_error
 7-Apr-2006, Kim.  Added func_spectrum func_model, chianti_version, spex_summ_abun_table


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

 Purpose: This object manages the fit algorithms for OSPEX.

 Category: OSPEX

 Calling sequence:

 Modifications:
   15-Jul-2004, Kim.  Set spex_drm_current_filter before starting fits. And in process
      method, change ->getdata to ->framework::getdata
	6-Oct-2004, Kim.  Change process method to use spex_fit_time_used instead of
	   spex_fit_time_interval
	18-Jul-2006, Kim.  Fixed error in process method when calculating errors to use for weighting
		in fit.  In process, when spex_error_use_expected is set, calc error based
		on initial params, then loop to iterate, using params after each fit to calculate new
		errors.
	31-Jul-2006, Kim. Moved message about re-entering fit procedure with new errors
	8-Aug-2006, Kim.  Added spex_fit_obj property, and set and get methods so we can
	  set and get it.  Now fitrange...down to data are not in object chain, so wherever
	  we were using self before to get at something in that area, now use spex_fit_obj.
	  Also, use f_div when dividing by ltime in process.
	  Also, pass loop_index to process_hook in process.

 CALLS:


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

 Purpose: Defines info structure for spex_fitalg_mcurvefit object

 Category: OSPEX

 Modifications:
  23-Jun-2004. Kim.  Added mcurvefit_free_mask


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

 Purpose: This object manages the Fit Intervals for OSPEX

 Category: OSPEX

 Written: 2003, Kim Tolbert
 Modifications:
   15-Jul-2004, Kim.  In process, if no data returned for an interval delete
	  that interval (with printed warning to user)
	16-Jul-2004, Kim.  Got rid of extra stuff in plot_setup (like overlaying
	  background and fits - should use the gen plot_spectrum method for that.
	19-Jul-2004, Kim.  Added spex_fitint_filter parameter
	20-Jul-2004, Kim.  Added rm_bad_intervals method - calls process, so first
	  gets rid of intervals with no data.  Then delete any intervals whose
	  filter state is unknown (with printed warning to user)
	12-Aug-2004, Kim.  Changed rm_bad_intervals method to find_bad_interval, with
	  keyword option /remove.
	5-Oct-2004, Kim.  Added spex_fit_time_used - in process, store newedges there.
	10-Oct-2004, Kim.  Init spex_fit_time_used to -1
   11-Apr-2005, Kim.  In intervals_pre_hook, use plot_time,/bk_data instead of plot, class=spex_bksub, and
     added /show_filter on time plot
	21-Jul-2005, Kim.  Added /this_class in setunits for speed
	13-Feb-2006, Kim.  In plot_setup, call get_plot_title to get title
 CALLS:


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

 Purpose: Defines info structure for spex_fitint object

 Category: OSPEX

 Modifications:
	15-Jul-2004, Kim.  Added spex_fitint_filter
	5-Oct-2004, Kim.  Added spex_fit_time_used


SPEX_FLASH [1] $SSW/packages/spex/idl/original_spex/spex_flash.pro
[Previous] [Next]
 Project: SDAC

 Name: SPEX_FLASH
	
 Purpose: This procedure highlights the current time interval being fit on
	the time history plot.
 
 Inputs:
	IX - index of current interval
	Select_int - position array of intervals on x axis, 2XN.
 Keyword Inputs:
	OFF- Turn the highlighting off.
	ON - Turn the highlighting on.
 History
	ras, 19-jan-1996, change variable xselct to select_int to
	avoid conflicts
	richard.schwartz@gsfc.nasa.gov, 27-may-1998, support all
	windowing os
       Paul Bilodeau, 3-April-2002, changed wsetshow calls to use
       TIMEHISTORY and SPECTRAL keywords.
 CALLS:
 CALLED BY
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]


SPEX_FLASH [2] $SSW/packages/spex/pre2002/idl/spex_flash.pro
[Previous] [Next]
 Project: SDAC

 Name: SPEX_FLASH
	
 Purpose: This procedure highlights the current time interval being fit on
	the time history plot.
 
 Inputs:
	IX - index of current interval
	Select_int - position array of intervals on x axis, 2XN.
 Keyword Inputs:
	OFF- Turn the highlighting off.
	ON - Turn the highlighting on.
 History
	ras, 19-jan-1996, change variable xselct to select_int to
	avoid conflicts
	richard.schwartz@gsfc.nasa.gov, 27-may-1998, support all
	windowing os
       Paul Bilodeau, 3-April-2002, changed wsetshow calls to use
       TIMEHISTORY and SPECTRAL keywords.
 CALLS:
 CALLED BY
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]


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

 PURPOSE:
	Returns a matrix of flux values, 1 for each energy and each set of model parameters
	within the applicable energy range.
 CATEGORY:
	SPEX, Modeling

 CALLING SEQUENCE:

	SPEX_FLUX_TIME, Model, Energy, Dummy_pars, Ipar, Edges, Model_pars, Values

 INPUTS:
	Model	: Name of model function, e.g. 'F_vth_bpow'
	Energy	: Vector of first argument to Model function.  Usually a vector
		energies in keV. Monotonically increasing.
	Dummy_pars: Dummy parameters into which the variable Model_pars parameters are inserted
	Ipar	: Insert the Model_pars into this position of Dummy_pars
	Edges	: Energy edges of each channel.  Gives the range of applicability for
		  Each Model_pars. 2 x #channels	
	Model_pars:
		  An array of model parameters, e.g. a set for each fit interval.
		  2 x #edges(0,*) #intervals. 
	
 OPTIONAL INPUTS:
	
 KEYWORD PARAMETERS:

 OUTPUTS:
	Values	: Array of returns from Model, #Energy x #Intervals.

 OPTIONAL OUTPUTS:

 COMMON BLOCKS:

 SIDE EFFECTS:

 CALLS: ***
	edge_products
 RESTRICTIONS:

 PROCEDURE:
	Loops over each set of parameters to save the user the grief of a visible loop.

 EXAMPLE:
	
   SPEX_FLUX_TIME, Model, Energy, Dummy_pars, Ipar, Edges, Model_pars, Values

 MODIFICATION HISTORY:
 	Written by:	RAS, 23-March-1996
	Version 1


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

 PURPOSE:
	Returns a matrix of flux values, 1 for each energy and each set of model parameters
	within the applicable energy range.
 CATEGORY:
	SPEX, Modeling

 CALLING SEQUENCE:

	SPEX_FLUX_TIME, Model, Energy, Dummy_pars, Ipar, Edges, Model_pars, Values

 INPUTS:
	Model	: Name of model function, e.g. 'F_vth_bpow'
	Energy	: Vector of first argument to Model function.  Usually a vector
		energies in keV. Monotonically increasing.
	Dummy_pars: Dummy parameters into which the variable Model_pars parameters are inserted
	Ipar	: Insert the Model_pars into this position of Dummy_pars
	Edges	: Energy edges of each channel.  Gives the range of applicability for
		  Each Model_pars. 2 x #channels	
	Model_pars:
		  An array of model parameters, e.g. a set for each fit interval.
		  2 x #edges(0,*) #intervals. 
	
 OPTIONAL INPUTS:
	
 KEYWORD PARAMETERS:

 OUTPUTS:
	Values	: Array of returns from Model, #Energy x #Intervals.

 OPTIONAL OUTPUTS:

 COMMON BLOCKS:

 SIDE EFFECTS:

 CALLS: ***
	edge_products
 RESTRICTIONS:

 PROCEDURE:
	Loops over each set of parameters to save the user the grief of a visible loop.

 EXAMPLE:
	
   SPEX_FLUX_TIME, Model, Energy, Dummy_pars, Ipar, Edges, Model_pars, Values

 MODIFICATION HISTORY:
 	Written by:	RAS, 23-March-1996
	Version 1


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

 Purpose: This abstract class is inherited by some of the OSPEX objects to
	handle general functions.

 Category: OSPEX

 Written: 2003, Kim Tolbert
 Modifications:
   15-Jul-2004, Kim.  bad_interval keyword added to edges2index and bindata
	16-Jul-2004, Kim.  Got rid of extra stuff in plot_setup (like overlaying
	  background and fits - should use the gen plot_spectrum method for that.
	19-Jul-2004, Kim.  Added filter specification in convert_fitfunc_units and get_drm_eff
	   and added get_fitint_filter method.
	20-Jul-2004, Kim.  Added show_filter option to plot_time
	10-Aug-2004, Kim.  Added use_fitted keyword to get_fitint_filter
	11-Aug-2004, Kim.  In bin_data, don't transpose data array if binning over energy and there's
	   only one energy bin.
	6-Oct-2004, Kim.  In valid_summ_params, use spex_fit_time_used instead of
	   spex_fit_time_interval, and check max of absolute value of diff, not max of diff
	10-Oct-2004, Kim.  In plot_spectrum, even though we're not actually using spex_fitint obj, do
	   getdata on it so that info params will be set. And use spex_fit_time_used intervals.
	17-Nov-2004, Kim.  In plot_spectrum, when overlaying fit, was showing last erange used
	   instead of getting the erange from the spex_summ params when it could.  If multiple
	   intervals are plotted, gets erange from first interval selected.
	11-Apr-2005, Kim.  In plot_time, plot filter bars by adding to plotman properties,so
		they'll still appear on zooms, prints, etc.
	7-Jun-2005, Kim.  Added fit_color to make_fitplot_obj method so we can pass in colors for the
		fit component overlays even if we're not using plotman
	28-Jun-2005, Kim.  Added show_chi keyword to make_fitplot_obj method
	17-Aug-2005, Kim. In convert_units, use spex_deconvolved to choose 'photons' or 'counts'. Added
		allint keyword to plot_spectrum method.  Added units_widget method.
	25-Aug-2005, Kim.  Added class= to calls to get wherever possible to speed things up/  Also
		use f_div in do_binning in case iwidth is 0.  Also, plot_spectrum and plot_time, added
		region numbers to labels for imagecube data.
	12-Oct-2005, Kim.  In units_widget, put droplist in a base so can store uvalues in base -
		otherwise crashes in 5.6
	9-Feb-2006, Kim.  Added full srm indication to label in plot_spectrum if /photon set.
	  Added get_plot_title function to consolidate what plot for each data type was doing.
	  Also, remove the /replace flag on new_panel call so we keep all panels even if they have same name
	15-Mar-2006, Kim.  Added epsilon=1.e-5 to call to find_contig_ranges
	7-Apr-2006, Kim. Changes for addition of spectrum,model keywords:
	  In get_drm_eff, make fit func obj and pass that to get_diagonal instead of passing
	  func and params.  Added make_func_obj method.  In make_fitplot_obj, call make_func_obj
     to create and set up fit function, instead of doing it in make_fitplot_obj,
     and added short summary of keyword values to plot label for fit functions
	27-Jun-2006, Kim.  Added func_obj to call to apply_drm (in convert_fitfunc_units) to
	  accommodate new drm_mod function for RHESSI (to fine-tune detector params in DRM)
	2-Jul-2006, Kim.  Added option to plot_spectrum method to bin in spex_tband time intervals
	30-Jul-2006, Kim.  If want allint, but there are > 100, don't plot them separately - too many - bin
	  into a single bin containing from min to max of all times.
	1-Aug-2006, Kim.  In valid_summ_params, corrected bug - use interval[i] not i in loop
	1-Sep-2006, Kim.  Define linestyles for fitplot obj even if using plotman (for b/w)
 CALLS:


spex_gen__get_filter_bars $SSW/packages/spex/idl/object_spex/spex_gen__get_filter_bars.pro
[Previous] [Next]
 ospex function method to get the structure containing the info for showing the filter states
 at the top of the plot.  In caller need to know how many bars will be displayed
 so can adjust the legend down by that amount.  Then call spex_draw_bars with this structure
 (or add the bars to plotman via addplot_name, addplot_arg properties) to plot the bars
 on the current plot.

 Written: 20-Jul-2004, Kim
 Modifications:
	8-Apr-2005, Kim.  Previously this method returned str, and/or plotted the bars. Now just
	  return str, and use spex_draw_bars routine as an addplot_name in xyplot to replot the
	  filter bars every time plotman redraws the plot (previously only plotted once, and then
	  were lost, since plotman didn't know about them.)
	6-Feb-2006, Kim.  Finding start/end times didn't work right when intervals weren't
	  contiguous.  Fixed.


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

 Purpose:  This is similar to the RHESSI strategy holder tools, except that here
  we are adding unknown numbers (max=50) of instances of one object (passed to init in
  strategy_object keyword), whereas in the other strategy holder, there is a pre-defined
  set of unique strategies, and only one (or none) of each is instantiated.
  This routine handles both cases - if self.strategy_object is just a blank string, then
  just falls through to the regular strategy holder.
  Here since we'll have multiple strategies of the same class, we need to create a unique
  identifier for each - done in getnewname method.
  Also different because here, we want to control the creation of the strategy objects
  by only creating them when createstrategy is called.

 Modifications:
 CALLS:


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

 Project: HESSI

 Purpose: Return the current debug level (from SPEX_DEBUG env. var.)

 Calling sequence:  debug = spex_get_debug()

 Written: Kim Tolbert 2-Jun-2003
 Modifications:
 CALLED BY
	SPEX_DRM__DEFINE, SPEX_FITALG_GEN__DEFINE, SPEX_FITINT__DEFINE
	SPEX_FIT__DEFINE, SPEX_GEN__DEFINE, SPEX__DEFINE, fit_comp__define
	spex_bk__define, spex_bkint__define, spex_bksub__define, spex_data__define


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

 Purpose: Return filter values grouped by index.  If any filter in the group
   is -99 (unknown state) or the the filter changes within a group, return a -99
   for that group.

 Category: OSPEX

 Calling sequence:  fil = spex_get_filter (filters, index)

 Input:
   filters - array of filters (normally one for every raw time interval)
   index - array of start/end indices to group filters by

 CALLED BY:
	SPEX_FITINT__DEFINE
 Example:
   filters = [0,0,-99,1,1,1,0,0,0,3,3,3]
   index = [0,1] returns 0
   index = [0,2] returns -99
   index = [[6,8],[9,11]] returns 0,3
   index = [6,10] returns -99

 Written: 19-Jul-2004, Kim
 Modifications:


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

 Project: HESSI

 Purpose: Return the current debug level (from SPEX_NOINTERACTIVE env. var.)

 Calling sequence:  nointeractive = spex_get_nointeractive()

 KEYWORDS:
	MESSAGE - if set, and nointeractive is true then print message saying so.

 Written: Kim Tolbert 2-Jun-2003
 Modifications:
 CALLED BY
	SPEX_DRM__DEFINE, SPEX_FIT__DEFINE, SPEX_GEN__DEFINE, SPEX__DEFINE
	read_xsm_4_ospex, spex_data__define


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

 NAME: 
	SPEX_HANDLES

 PURPOSE:
	Global data handling in SPEX.

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	SPEX_HANDLES, Search_str

 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], AVG [1], AVG [2], Arr2Str [2], CHECKVAR [1]
	DATATYPE [1], DATATYPE [2], DATATYPE [3], FCHECK, GETUTBASE [1], GETUTBASE [2]
	SPEX_HANDLES_FIND [1], SPEX_HANDLES_FIND [2], SPEX_HANDLES_STR [1]
	SPEX_HANDLES_STR [2], STR_SEP, UTIME [1], UTIME [2], checkvar [2], printx [1]
	printx [2], spex_current [1], spex_current [2]
 INPUTS:
	none

 OPTIONAL INPUTS:
	Search_str -  A SPEX_HANDLES structure to look search for, data under this
	handle is placed into SPEX_COMMONS.  If you want the newly written
	Top_handle and Top_handle_id use '' for Search_str

 OUTPUTS:
       Top_handle    - Returns the TOP_HANDLE structure when it finds it.
	Top_handle_id - handle id of TOP_HANDLE variable
 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	TYPE	- 'INPUT', 'DRM', or 'FIT' indicating type of data to place into
	handle storage
	README  - a string with information about the data set, input or output.
	SELECT_ID- a number to identify multiple data sets, as in fitting or
	changed edges or drm's, this is a returned value
	EVENT_ID - a string which uniquely identifies the initial dataset, '3030' or 
	the elements in the array FILES	or the midpoint time of the dataset.
	ERROR   - returns 1 if SEARCH_STR can't be found.

 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	Watch out.  Data storage could get huge.

 PROCEDURE:
	This procedure causes the data values in spex_commons to be swapped between
	the common area and the handle area.

 MODIFICATION HISTORY:
	ras, 3 april 1996


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

 NAME: 
	SPEX_HANDLES

 PURPOSE:
	Global data handling in SPEX.

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	SPEX_HANDLES, Search_str

 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], AVG [1], AVG [2], Arr2Str [2], CHECKVAR [1]
	DATATYPE [1], DATATYPE [2], DATATYPE [3], FCHECK, GETUTBASE [1], GETUTBASE [2]
	SPEX_HANDLES_FIND [1], SPEX_HANDLES_FIND [2], SPEX_HANDLES_STR [1]
	SPEX_HANDLES_STR [2], STR_SEP, UTIME [1], UTIME [2], checkvar [2], printx [1]
	printx [2], spex_current [1], spex_current [2]
 INPUTS:
	none

 OPTIONAL INPUTS:
	Search_str -  A SPEX_HANDLES structure to look search for, data under this
	handle is placed into SPEX_COMMONS.  If you want the newly written
	Top_handle and Top_handle_id use '' for Search_str

 OUTPUTS:
       Top_handle    - Returns the TOP_HANDLE structure when it finds it.
	Top_handle_id - handle id of TOP_HANDLE variable
 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	TYPE	- 'INPUT', 'DRM', or 'FIT' indicating type of data to place into
	handle storage
	README  - a string with information about the data set, input or output.
	SELECT_ID- a number to identify multiple data sets, as in fitting or
	changed edges or drm's, this is a returned value
	EVENT_ID - a string which uniquely identifies the initial dataset, '3030' or 
	the elements in the array FILES	or the midpoint time of the dataset.
	ERROR   - returns 1 if SEARCH_STR can't be found.

 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	Watch out.  Data storage could get huge.

 PROCEDURE:
	This procedure causes the data values in spex_commons to be swapped between
	the common area and the handle area.

 MODIFICATION HISTORY:
	ras, 3 april 1996


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

 NAME: 
	SPEX_HANDLES_FIND

 PURPOSE:
	This function returns the top handle id for the requested data structure.

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	Match_ids = SPEX_HANDLES_FIND( Search_struct )

 CALLS: ***
	DATATYPE [1], DATATYPE [2], DATATYPE [3], SPEX_HANDLES_STR [1]
	SPEX_HANDLES_STR [2]
 INPUTS:
       Search_str - A structure used to pattern match existing handle structures
	used in SPEX.  

 OPTIONAL INPUTS:
	none

 OUTPUTS:
	Match_ids - Output of this function. 
	The ids that match the Search_struct in DATA_TIPE, DET_ID, and TYPE (INPUT, DRM, or FIT)
       Children - If 1 unique match is found to the search structure, then
	the child ids are returned starting at the first child with the siblings in order.

 OPTIONAL OUTPUTS:

 KEYWORDS:
	SELECT_ID - If this value is set, it is used to find the exact dataset from
	otherwise identical datasets in data_tipe, det_id, and type.
	TOP_HANDLES - Matching SPEX_HANDLES structures corresponding
	to returned IDs
 CALLED BY:
	SPEX_HANDLES [1], SPEX_HANDLES [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	This is not a stand-alone routine, but is internal to the SPEX handle routines.
	Assumes that there are no more than 10,000 handles
 PROCEDURE:
	This function looks for the top handles that have the name
	spex_handles and then matches it to the Search_str and returns
	its id.  If no Search_str which is a SPEX_HANDLES structure, then all the 
	handle ids for all the SPEX_HANDLES structures are returned, and TOP_HANDLES
	is an array of all the SPEX_HANDLES structures.

 MODIFICATION HISTORY:
	ras, 5-Apr-1996


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

 NAME: 
	SPEX_HANDLES_FIND

 PURPOSE:
	This function returns the top handle id for the requested data structure.

 CATEGORY:
	SPEX

 CALLING SEQUENCE:
	Match_ids = SPEX_HANDLES_FIND( Search_struct )

 CALLS: ***
	DATATYPE [1], DATATYPE [2], DATATYPE [3], SPEX_HANDLES_STR [1]
	SPEX_HANDLES_STR [2]
 INPUTS:
       Search_str - A structure used to pattern match existing handle structures
	used in SPEX.  

 OPTIONAL INPUTS:
	none

 OUTPUTS:
	Match_ids - Output of this function. 
	The ids that match the Search_struct in DATA_TIPE, DET_ID, and TYPE (INPUT, DRM, or FIT)
       Children - If 1 unique match is found to the search structure, then
	the child ids are returned starting at the first child with the siblings in order.

 OPTIONAL OUTPUTS:

 KEYWORDS:
	SELECT_ID - If this value is set, it is used to find the exact dataset from
	otherwise identical datasets in data_tipe, det_id, and type.
	TOP_HANDLES - Matching SPEX_HANDLES structures corresponding
	to returned IDs
 CALLED BY:
	SPEX_HANDLES [1], SPEX_HANDLES [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	This is not a stand-alone routine, but is internal to the SPEX handle routines.
	Assumes that there are no more than 10,000 handles
 PROCEDURE:
	This function looks for the top handles that have the name
	spex_handles and then matches it to the Search_str and returns
	its id.  If no Search_str which is a SPEX_HANDLES structure, then all the 
	handle ids for all the SPEX_HANDLES structures are returned, and TOP_HANDLES
	is an array of all the SPEX_HANDLES structures.

 MODIFICATION HISTORY:
	ras, 5-Apr-1996


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

 NAME: 
	SPEX_HANDLES_STR

 PURPOSE:
	This procedure creates the structure used in the SPEX_HANDLES* procedures.
	It also loads the tags with the input values.

 CATEGORY:
	SPEX, HANDLES

 CALLING SEQUENCE:
	Result = SPEX_HANDLES_STR( Data_tipe, Det_id, Type, Select_id, README=README, $
	EVENT_ID=EVENT_ID)

 CALLS: ***
	CHECKVAR [1], checkvar [2]
 INPUTS:
       Data_tipe: SPEX data_tipe option, e.g. ['BATSE','SHERS']
	Det_id: Detector ID, 0 if not-applicable
	Type: 'INPUT', 'DRM', or 'FIT'
	Select_id: Numerical ID of similar handle data sets, 0 is first, such
	as 3 for the fourth version of 'FIT'
	
 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	README: A string with more information about the data set
	EVENT_ID: A unique string identifier when used with DATA_TIPE and DET_ID, e.g.
		'Flare=3030' or 'Files=continuous_ibdb_1674.fits' 
 CALLED BY:
	SPEX_HANDLES [1], SPEX_HANDLES [2], SPEX_HANDLES_FIND [1]
	SPEX_HANDLES_FIND [2], setup_spex [1], setup_spex [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 7-april-1996


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

 NAME: 
	SPEX_HANDLES_STR

 PURPOSE:
	This procedure creates the structure used in the SPEX_HANDLES* procedures.
	It also loads the tags with the input values.

 CATEGORY:
	SPEX, HANDLES

 CALLING SEQUENCE:
	Result = SPEX_HANDLES_STR( Data_tipe, Det_id, Type, Select_id, README=README, $
	EVENT_ID=EVENT_ID)

 CALLS: ***
	CHECKVAR [1], checkvar [2]
 INPUTS:
       Data_tipe: SPEX data_tipe option, e.g. ['BATSE','SHERS']
	Det_id: Detector ID, 0 if not-applicable
	Type: 'INPUT', 'DRM', or 'FIT'
	Select_id: Numerical ID of similar handle data sets, 0 is first, such
	as 3 for the fourth version of 'FIT'
	
 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	README: A string with more information about the data set
	EVENT_ID: A unique string identifier when used with DATA_TIPE and DET_ID, e.g.
		'Flare=3030' or 'Files=continuous_ibdb_1674.fits' 
 CALLED BY:
	SPEX_HANDLES [1], SPEX_HANDLES [2], SPEX_HANDLES_FIND [1]
	SPEX_HANDLES_FIND [2], setup_spex [1], setup_spex [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 7-april-1996


spex_hessi_fits2drm $SSW/packages/spex/idl/object_spex/spex_hessi_fits2drm.pro
[Previous] [Next]

 NAME:
	spex_hessi_fits2drm

 PURPOSE:
   Read a HESSI response matrix from a FITS file and return information of
 	interest to OSPEX.


 CATEGORY:
       SPECTRAL FITTING, SPEX - HESSI

 CALLING SEQUENCE:

 CALLS: ***
	FITS_INFO [1], FITS_INFO [2], FXPAR [1], FXPAR [2], MRDFITS [1], MRDFITS [2]
	TAG_EXIST [1], TAG_EXIST [2], fits2rm, st2num, str_replace [1], str_replace [2]
 INPUTS:

 OUTPUTS:

 INPUT KEYWORDS:
 	FILE - name of FITS file to read.
 	SFILE - not used.  Included for Spex comptability.

 OUTPUT KEYWORDS:
 	drm_str - structure with drm info
     If there are multiple attenuator states, the DRM and ATTEN_STATE items
     in the structure are dimensioned to the # of atten states.

 CALLED BY:
	SPEX_DRM__DEFINE
 PROCEDURE:

 Written 25-May-2001 Paul Bilodeau, RITSS/NASA-GSFC

 Modification History:
   06-Mar-2003, Paul Bilodeau - change sumflag to sepdets for
     correct header keyword that determines if the matrix is the sum
     or individual detector responses.
   1-Jul-2004, Kim.  Handle files with extensions for drms for multiple
     attenuator states.
	19-Nov-2004, Kim.  Changed name from hessi_fits2drm_ospex.
	20-Nov-2006, Kim. Abort if sum_flag=0


spex_hessi_image__define $SSW/packages/spex/idl/object_spex/spex_hessi_image__define.pro
[Previous] [Next]
 Modifications:
 August-2005, Andre, Kim.  Lots of changes.  Inherits spex_image now.
 10-Nov-2005, Kim.  If total in roi is negative then set spectrum and error for
	that image to 0.  Also use max(abs(...)) for max noise and max signal.
 9-Feb-2006, Kim.  Added spex_image_full_srm option.  Gets diagonal drm
   and converts spectrum to counts instead of photons.  Added get_diag method.
   Set spex_interval_filter from image_atten_state instead of just 0s since
     we'll need filter states for srm if full_srm is set.
   And moved ptr_valid(self.boxes) check out of loops over time and energy.
 2-Mar-2006, Kim.  In compute_spectra corrected area used to convert to phot/sec
 5-Apr-2006, Kim.  Corrected error in compute_spectra - was using midpoints for
   image axes instead of start (left/bottom) for each pixel.  Also adjusted boxes
   for limitation of polyfillv - it doesn't include a pixel unless center is to
   right of boundary
 26-May-2006, Kim.  Added spex_data_pos to args.
 8-Aug-2006, Kim.  In read_data: Older imagecube files return a scalar
   image_atten_state. We want one per time interval so rebin if necessary.
 3-Nov-2006, Kim.  Fixed bug in compute_spectra setting ibox_start (Thanks to Pascal!)
 CALLS:


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

 NAME: spex_hold


 PURPOSE: save the current spectrum in common to allow merging of spectra


 CATEGORY: spectral analysis


 CALLING SEQUENCE:  spex_hold


 CALLED BY:    spex


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FCHECK, F_DIV, GETUTBASE [1], GETUTBASE [2]
	checkvar [2], delvarx [5], edge_products, help_merge [1], help_merge [2]
	printx [1], printx [2], spex_current [1], spex_current [2], spex_delete [1]
	spex_delete [2], spex_merge [1], spex_merge [2], spex_source [1]
	spex_source [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	help_merge [1], help_merge [2], spex_delete [1], spex_delete [2], spex_merge [1]
	spex_merge [2], spex_source [1], spex_source [2]
 COMMON BLOCKS:
	spex_hold_com
       spex_setup_com
       spex_proc_com
 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 19-oct-94


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

 NAME: spex_hold


 PURPOSE: save the current spectrum in common to allow merging of spectra


 CATEGORY: spectral analysis


 CALLING SEQUENCE:  spex_hold


 CALLED BY:    spex


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FCHECK, F_DIV, GETUTBASE [1], GETUTBASE [2]
	checkvar [2], delvarx [5], edge_products, help_merge [1], help_merge [2]
	printx [1], printx [2], spex_current [1], spex_current [2], spex_delete [1]
	spex_delete [2], spex_merge [1], spex_merge [2], spex_source [1]
	spex_source [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	help_merge [1], help_merge [2], spex_delete [1], spex_delete [2], spex_merge [1]
	spex_merge [2], spex_source [1], spex_source [2]
 COMMON BLOCKS:
	spex_hold_com
       spex_setup_com
       spex_proc_com
 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 19-oct-94


spex_image__define $SSW/packages/spex/idl/object_spex/spex_image__define.pro
[Previous] [Next]
 Time-stamp: <Tue Jul 26 2005 16:47:20 csillag tounesol.gsfc.nasa.gov>
 Name: spex_image__define

 Purpose:  This class is inherited by any spex image data class (like spex_hessi_image)

 Written, Kim and Andre, August 2005
 Modifications:
 9-Feb-2006, Kim.  spex_deconvolved now depends on spex_image_full_srm value.  And added
   no_dialog and done keywords to save_roi.
 26-May-2006, Kim.  Added spex_data_pos to args.
 30-Jul-2006, Kim.  Got rid of preview method.
 3-Aug-2006, Kim.  Since put specfile property in spex_data_strategy structure, remove it from here.

 CALLS:


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

 Purpose:  ROI method presents user with a panel display showing all the images in an image cube.
 The user can click on single or multiple (click and drag) images.  A list of options pops up
 to choose what to define regions for, or what to display.

 Written, Kim, August 2005
 Modifications:
   7-Oct-2005, Kim.  Added panel_size, colortable keywords to roi method.
   27-Jan-2006, Kim.  When first called, call self->getdata just in case it hasn't
     been done yet, since this expects some data info parameters to be set (ut,energy)


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

 Purpose:  Initialize variables in control structure for spex_image

 Kim Tolbert Aug 2005
 Modifications:
 17-Feb-2006, Kim.  Added variables initialized by spex_data_strategy_control()

 CALLS:
 CALLED BY
	spex_image__define


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

 Purpose:  Define control structure for spex_image

 Kim Tolbert Aug 2005
 Modifications:
	8-Feb-2006, Kim.  Added spex_image_full_srm
	  Also, make flags integer not byte.  If strategy isn't image, then
	  framework returns an integer -1 for these params, so when checking values
	  better if they're the same type.


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

 Purpose:  Initialize variables in info structure for spex_image
 (some of these info params are really used as admin params)

 Kim Tolbert Aug 2005
 Modifications:

 CALLS:
 CALLED BY
	spex_image__define


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

 Purpose:  Define info structure for spex_image

 Kim Tolbert Aug 2005
 Modifications:


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

 Project: HESSI

 Purpose: Insert error handlers in SPEX objects.

 Method:
 This code should be inserted (via @) into any SPEX GETDATA or GET method in which
 we want to establish an error handler. It should be placed at the beginning of the
 method.  @ must be used (rather than making this a procedure) so that the catch will
 actually be IN the routine we want to stop in.  The added line should look like:
   @spex_insert_catch

 Any exception that occurs in any routine called by GETDATA or GET will jump back
 to the nearest error handler (looking up the traceback backward).  Exceptions are
 caused in two ways and are handled differently in the catch:

   If the exception was caused by a MESSAGE statement, the message is printed.
   If the exception was caused by an error in the code, the error message and
   traceback are printed.

 If the error handler is within a series of calls to framework get or getdata, then
 it is assumed that there is another error handler further up the chain, and this
 error handler generates another exception via the MESSAGE routine which will bubble
 up to the next error handler.
 If the error handler is not nested inside SPEX object calls, then this error handler
 prints a message that it's aborting, and returns a -1.

 Since this error handler returns a -1, it can only be inserted in a function. (We
 can make another version if we need to insert it into a procedure.)

 In routines that encounter error conditions that should cause an abort of the current
 operation, there should be a call to SPEX_MESSAGE (or MESSAGE without a /CONTINUE or /INFO)

 For programmers who want to debug without the catch:
 If $OSPEX_DEBUG is not zero, then catch is NOT set to trap errors.
 In that case, errors will cause normal failures (instead of jumping to the nearest catch)
 and programmers can debug normally.

 See SPEX_MESSAGE also.

 Written: Kim Tolbert, 20-Aug-2002
 Modifications:


spex_intervals [1] $SSW/packages/spex/idl/original_spex/spex_intervals.pro
[Previous] [Next]
 PRJECT: 
	SDAC
 NAME: spex_intervals


 PURPOSE: Graphically select a set of intervals from an X array.
	   The X, Y plot is already displayed.  SPEX_INTERVALS is the driver
	   for INTERVALS, the interval selection routine in SPEX.

 CATEGORY: Graphics, Fitting


 CALLING SEQUENCE: 
	spex_intervals(xdisplay, xselect ,xwidth=xwidth [,xinput=xinput] [,iselect=iselect] $
		 [,style=style] [,color=color])
                
 CALLS TO: point, intervals

 INPUTS:
	xdisplay - array of displayed abscissae
		if xdisplay is 2xn, then the two vectors are assumed
		to be the hi and lo edge of the data point, and 
		xwidth is calculated
	xwidth   - the width of each x bin, xdisplay taken at the center
 Optional inputs:
	style    - options
		 'contiguous'  The intervals are all contiguous.
		 'discrete'    The interval boundaries are chosen individually
		 'boundary'     Two limit boundaries are chosen.  
		 'regular'     Data are grouped into intervals according to SAMPAV
			       between two limit boundaries.
                 'inputvariable' - xinputStyle is not used on direct input
	v_styles - strarr of valid styles, each style may be abbreviated with its
		   first letter: 'contiguous','discrete','regular' or 'boundaries'
	/query   - if set, then query user for style either in session window or using
		   widgets if possible.  If query is set to 0, then selection must come
		   via xinput or an error condition is generated.
	message  - string, used to inform user about interval selection if /query

	xinput   - for direct input of x edges, non-graphic
		     Non-graphic selection, a vector of 2xN time bins
		     are passed.  No display feedback.  For input times, 
		     the discrete mode is used although if a boundary is within 1% of an 
		     interval width it is chosen even if it violates the leading 
		     trailing edge rules for discrete selection
	input_variable - string containing name of variable to be used for non-graphic input
			       
	color    - can be used with routine linecolors
	sampav   - number of sub-intervals to be grouped together if a single interval
		   is selected for any style, including input.  If a positive integer,
		   this number is used, but the user is queried for an input of -1.
	xoffset  - array of xoffsets for respond_widg in point.pro
	yoffset  - array of yoffsets for respond_widg in point.pro
 
 OUTPUTS:
	xselect - the value of the boundaries for each interval selected 
		  2 x number of intervals
	iselect - the index of each boundary relative to xdisplay
		  for j=iselect(0,i) and k=iselect(1,i) the channels are
		  j through k-1, inclusive
		  For example, if the selected interval only includes time bin 77,
		  then iselect will be [77,78].
	error   - set to 0 on normal return. Set to 1 if input conditions are
		  irreconcilable.

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], CHECKVAR [1], CRANGE, DATATYPE [1], DATATYPE [2]
	DATATYPE [3], EMENU, FCHECK, FCOLOR [1], F_DIV, F_USE_WIDGET, GRAPHICS_PAGE
	MINMAX [1], MINMAX [2], POINT [1], RESPOND_WIDG, XDEVICE, checkvar [2]
	edge_products, fcolor [2], option_changer [1], option_changer [2], point [2]
	printx [1], printx [2], uniqo [1], uniqo [2]
 CALLED BY:
	CAL_SHER, SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_COMMONS [2]
	SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2], SPEX_THISTORY [1]
	SPEX_THISTORY [2], rd_sxs_pha [1], rd_sxs_pha [2], read_yohkoh_4_spex [1]
	read_yohkoh_4_spex [2]
 RESTRICTIONS: If selected points are not within the elements of xdisplay,
	then the element of xdisplay less than the selected value is chosen.
	Returns 0 if called by with device set to non-interactive and graphic
	input is required.

 PROCEDURE: Calls for a set of points to be input graphically or passed.  For graphical
	selection mode, lines are
	drawn showing each bin selected. Intervals may be chosen contiguously
	or individually.  Default is individual points. When specifying points
	interactively, the start and end of an interval defaults to the leading edge of
	the selected bin for a stream of contiguous intervals, and to the trailing edge
	for the last bin selected.

 MODIFICATION HISTORY:
	ras, 24-jun-94
	ras, 1-sep-94, protected user against double selection problem with mouse
	Version 2
	ras, 12-apr-1996, ras, added some protection against oplot without 1st plotting.
	ras, 14-may-1996, check before calling f_use_widget
	RAS, 26-Aug-1996, change interval selection endpoints
	RAS, 30-apr-1997, fixed logic in doubles rejection


spex_intervals [2] $SSW/packages/spex/pre2002/idl/spex_intervals.pro
[Previous] [Next]
 PRJECT: 
	SDAC
 NAME: spex_intervals


 PURPOSE: Graphically select a set of intervals from an X array.
	   The X, Y plot is already displayed.  SPEX_INTERVALS is the driver
	   for INTERVALS, the interval selection routine in SPEX.

 CATEGORY: Graphics, Fitting


 CALLING SEQUENCE: 
	spex_intervals(xdisplay, xselect ,xwidth=xwidth [,xinput=xinput] [,iselect=iselect] $
		 [,style=style] [,color=color])
                
 CALLS TO: point, intervals

 INPUTS:
	xdisplay - array of displayed abscissae
		if xdisplay is 2xn, then the two vectors are assumed
		to be the hi and lo edge of the data point, and 
		xwidth is calculated
	xwidth   - the width of each x bin, xdisplay taken at the center
 Optional inputs:
	style    - options
		 'contiguous'  The intervals are all contiguous.
		 'discrete'    The interval boundaries are chosen individually
		 'boundary'     Two limit boundaries are chosen.  
		 'regular'     Data are grouped into intervals according to SAMPAV
			       between two limit boundaries.
                 'inputvariable' - xinputStyle is not used on direct input
	v_styles - strarr of valid styles, each style may be abbreviated with its
		   first letter: 'contiguous','discrete','regular' or 'boundaries'
	/query   - if set, then query user for style either in session window or using
		   widgets if possible.  If query is set to 0, then selection must come
		   via xinput or an error condition is generated.
	message  - string, used to inform user about interval selection if /query

	xinput   - for direct input of x edges, non-graphic
		     Non-graphic selection, a vector of 2xN time bins
		     are passed.  No display feedback.  For input times, 
		     the discrete mode is used although if a boundary is within 1% of an 
		     interval width it is chosen even if it violates the leading 
		     trailing edge rules for discrete selection
	input_variable - string containing name of variable to be used for non-graphic input
			       
	color    - can be used with routine linecolors
	sampav   - number of sub-intervals to be grouped together if a single interval
		   is selected for any style, including input.  If a positive integer,
		   this number is used, but the user is queried for an input of -1.
	xoffset  - array of xoffsets for respond_widg in point.pro
	yoffset  - array of yoffsets for respond_widg in point.pro
 
 OUTPUTS:
	xselect - the value of the boundaries for each interval selected 
		  2 x number of intervals
	iselect - the index of each boundary relative to xdisplay
		  for j=iselect(0,i) and k=iselect(1,i) the channels are
		  j through k-1, inclusive
		  For example, if the selected interval only includes time bin 77,
		  then iselect will be [77,78].
	error   - set to 0 on normal return. Set to 1 if input conditions are
		  irreconcilable.

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], CHECKVAR [1], CRANGE, DATATYPE [1], DATATYPE [2]
	DATATYPE [3], EMENU, FCHECK, FCOLOR [1], F_DIV, F_USE_WIDGET, GRAPHICS_PAGE
	MINMAX [1], MINMAX [2], POINT [1], RESPOND_WIDG, XDEVICE, checkvar [2]
	edge_products, fcolor [2], option_changer [1], option_changer [2], point [2]
	printx [1], printx [2], uniqo [1], uniqo [2]
 CALLED BY:
	CAL_SHER, SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_COMMONS [2]
	SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2], SPEX_THISTORY [1]
	SPEX_THISTORY [2], rd_sxs_pha [1], rd_sxs_pha [2], read_yohkoh_4_spex [1]
	read_yohkoh_4_spex [2]
 RESTRICTIONS: If selected points are not within the elements of xdisplay,
	then the element of xdisplay less than the selected value is chosen.
	Returns 0 if called by with device set to non-interactive and graphic
	input is required.

 PROCEDURE: Calls for a set of points to be input graphically or passed.  For graphical
	selection mode, lines are
	drawn showing each bin selected. Intervals may be chosen contiguously
	or individually.  Default is individual points. When specifying points
	interactively, the start and end of an interval defaults to the leading edge of
	the selected bin for a stream of contiguous intervals, and to the trailing edge
	for the last bin selected.

 MODIFICATION HISTORY:
	ras, 24-jun-94
	ras, 1-sep-94, protected user against double selection problem with mouse
	Version 2
	ras, 12-apr-1996, ras, added some protection against oplot without 1st plotting.
	ras, 14-may-1996, check before calling f_use_widget
	RAS, 26-Aug-1996, change interval selection endpoints
	RAS, 30-apr-1997, fixed logic in doubles rejection


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

 NAME: spex_merge


 PURPOSE: merge the current spectrum and drm with the ones in the spex_hold_com


 CATEGORY: spectral analysis, SPEX


 CALLING SEQUENCE: spex_merge


 CALLED BY: spex


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FCHECK, F_DIV, GETUTBASE [1], GETUTBASE [2]
	checkvar [2], delvarx [5], edge_products, help_merge [1], help_merge [2]
	printx [1], printx [2], spex_current [1], spex_current [2], spex_delete [1]
	spex_delete [2], spex_hold [1], spex_hold [2], spex_source [1], spex_source [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	help_merge [1], help_merge [2], spex_delete [1], spex_delete [2], spex_hold [1]
	spex_hold [2], spex_source [1], spex_source [2]
 COMMON BLOCKS:
	spex_hold_com
       spex_setup_com
       spex_proc_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	flux in hold and current areas are defined on the same time range

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 19-oct-94


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

 NAME: spex_merge


 PURPOSE: merge the current spectrum and drm with the ones in the spex_hold_com


 CATEGORY: spectral analysis, SPEX


 CALLING SEQUENCE: spex_merge


 CALLED BY: spex


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FCHECK, F_DIV, GETUTBASE [1], GETUTBASE [2]
	checkvar [2], delvarx [5], edge_products, help_merge [1], help_merge [2]
	printx [1], printx [2], spex_current [1], spex_current [2], spex_delete [1]
	spex_delete [2], spex_hold [1], spex_hold [2], spex_source [1], spex_source [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	help_merge [1], help_merge [2], spex_delete [1], spex_delete [2], spex_hold [1]
	spex_hold [2], spex_source [1], spex_source [2]
 COMMON BLOCKS:
	spex_hold_com
       spex_setup_com
       spex_proc_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	flux in hold and current areas are defined on the same time range

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 19-oct-94


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

 NAME: spex_merge_control


 PURPOSE: process the creation, editing, and processing
	of the merging of database files within SPEX


 CATEGORY: SPEX


 CALLING SEQUENCE:  
	spex_merge_control, com_param, merge_list, input_line, mscript

 CALLED BY: SPEX


 CALLS: ***
	ARR2STR [1], Arr2Str [2], DATATYPE [1], DATATYPE [2], DATATYPE [3], FCHECK
	F_USE_WIDGET, Modify_Merge_list [1], Modify_Merge_list [2], printx [1]
	printx [2], spex_current [1], spex_current [2]
 INPUTS:
       com_param - command modifier from SPEX input
		    Values with meaning:
		    '' - create merge_list, mscript and input_line to run
		         based on the current values of the flare
		    'CURRENT' - create mscript and input_line based on the
			        current values of merge_list 
		    'NORUN'   - create merge_list based on the current values
			        of the flare
		    'EDIT'    - edit merge_list
		    			

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       merge_list - structure with database specifications
	input_line - control instructions for SPEX, string
	mscript    - created from merge_list, a string array
		     with consecutive instructions for SPEX

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	As of 16-oct-1995, only BATSE CONT and BATSE DISCSP have automatic merging.
	Data files really must cover exactly the same time intervals.
 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 16-oct-1995
	ras, 21-oct-1996, changed to use merge_batse


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

 NAME: spex_merge_control


 PURPOSE: process the creation, editing, and processing
	of the merging of database files within SPEX


 CATEGORY: SPEX


 CALLING SEQUENCE:  
	spex_merge_control, com_param, merge_list, input_line, mscript

 CALLED BY: SPEX


 CALLS: ***
	ARR2STR [1], Arr2Str [2], DATATYPE [1], DATATYPE [2], DATATYPE [3], FCHECK
	F_USE_WIDGET, Modify_Merge_list [1], Modify_Merge_list [2], printx [1]
	printx [2], spex_current [1], spex_current [2]
 INPUTS:
       com_param - command modifier from SPEX input
		    Values with meaning:
		    '' - create merge_list, mscript and input_line to run
		         based on the current values of the flare
		    'CURRENT' - create mscript and input_line based on the
			        current values of merge_list 
		    'NORUN'   - create merge_list based on the current values
			        of the flare
		    'EDIT'    - edit merge_list
		    			

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       merge_list - structure with database specifications
	input_line - control instructions for SPEX, string
	mscript    - created from merge_list, a string array
		     with consecutive instructions for SPEX

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	As of 16-oct-1995, only BATSE CONT and BATSE DISCSP have automatic merging.
	Data files really must cover exactly the same time intervals.
 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 16-oct-1995
	ras, 21-oct-1996, changed to use merge_batse


spex_merge_plots $SSW/packages/spex/idl/object_spex/spex_merge_plots.pro
[Previous] [Next]
 Modifications:
 16-Sep-2004, Kim. Added merging edata if in both structures.
 CALLS:
 CALLED BY
	SPEX_GEN__DEFINE


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

 Project: HESSI

 Purpose: Generate MESSAGE exception.  HSI_MESSAGE decides whether to use
   /CONTINUE on MESSAGE call depending on debug level.

 Method:  Some GET and GETDATA object methods establish a CATCH error
  handler.  HSI_MESSAGE is called by routines further down the processing
  chain from the GET and GETDATA calls to generate an exception that will
  cause the program flow to abort and jump to the nearest error handler.

  However, in debugging mode, we don't want to change the program flow.
  We want to continue and let the error condition cause a crash.
  When the debug level is not 0, then the error handler
  is NOT set in the objects (see HSI_INSERT_CATCH) and HSI_MESSAGE
  calls MESSAGE with /CONTINUE.

  This is not a procedure.  It should be inserted into your code via
  @spex_message after setting the variable msg to your error message string.
  The reason for this is that in case there is no catch and continue is
  not set here (based on debug level), then it will stop, so we want it to
  stop in the routine itself, not in a routine called spex_message.

 Calling sequence:
  Put your error text in a variable called msg
  @spex_message

 Example:
   msg = 'No lookup table.  Aborting.'
   @spex_message

 Written: Kim Tolbert 22-Oct-2002
 Modifications:


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

 PURPOSE:
	Returns a matrix of flux values, 1 for each energy and each set of model parameters.

 CATEGORY:
	SPEX, Modeling

 CALLING SEQUENCE:

	SPEX_MODEL_ARRAY, Model, Energy, Model_pars, Values

 INPUTS:
	Model	: Name of model function, e.g. 'F_vth_bpow'
	Energy	: Vector of first argument to Model function.  Usually a vector
		energies in keV. May also be 2x N_channels
	Model_pars:
		  An array of model parameters, e.g. a set for each fit interval.
		  #pars x #intervals.
	
 OPTIONAL INPUTS:
	
 KEYWORD PARAMETERS:

 OUTPUTS:
	Values	: Array of returns from Model, #Energy x #Intervals.

 OPTIONAL OUTPUTS:

 CALLED BY:
	SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
 COMMON BLOCKS:

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:
	Loops over each set of parameters to save the user the grief of a visible loop.

 EXAMPLE:
	
		SPEX_MODEL_ARRAY, 'F_VTH_BPOW', findgen(100)+10., Apar_arr, Fit_flux

 MODIFICATION HISTORY:
 	Written by:	RAS, 22-March-1996
	Version 1
	Version 2	ras, 13-april-1996, made energy input more robust


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

 PURPOSE:
	Returns a matrix of flux values, 1 for each energy and each set of model parameters.

 CATEGORY:
	SPEX, Modeling

 CALLING SEQUENCE:

	SPEX_MODEL_ARRAY, Model, Energy, Model_pars, Values

 INPUTS:
	Model	: Name of model function, e.g. 'F_vth_bpow'
	Energy	: Vector of first argument to Model function.  Usually a vector
		energies in keV. May also be 2x N_channels
	Model_pars:
		  An array of model parameters, e.g. a set for each fit interval.
		  #pars x #intervals.
	
 OPTIONAL INPUTS:
	
 KEYWORD PARAMETERS:

 OUTPUTS:
	Values	: Array of returns from Model, #Energy x #Intervals.

 OPTIONAL OUTPUTS:

 CALLED BY:
	SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
 COMMON BLOCKS:

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:
	Loops over each set of parameters to save the user the grief of a visible loop.

 EXAMPLE:
	
		SPEX_MODEL_ARRAY, 'F_VTH_BPOW', findgen(100)+10., Apar_arr, Fit_flux

 MODIFICATION HISTORY:
 	Written by:	RAS, 22-March-1996
	Version 1
	Version 2	ras, 13-april-1996, made energy input more robust


spex_nontherm_energy $SSW/packages/spex/idl/object_spex/spex_nontherm_energy.pro
[Previous] [Next]

 NAME: spex_nontherm_energy.pro


 PURPOSE:
               Compute  the nonthermal electron energy based on the spectral fitting results for MULTIPLE time intervals
               The spectral  models must include a bremsstrahlung thick-target model.

 CATEGORY:
       SPECTRA, XRAYS

 CALLING SEQUENCE:
        spex_nontherm_energy, 'xxxxxx.fits',  model_para, timearr, engarr, indexstart = indexstart

 CALLS: ***
	GET_EDGES, SPEX_READ_FIT_RESULTS, brmthick_power
 INPUTS:
                  ospexfile:  name of the fits file from OSPEX
                  indexstart: the index for the first thick-target fitting parameter parameter (see details in brm_bremthick.pro)
 OUTPUT:
               return fitting parameters, mean time,  nonthermal energy for each time interval,

               model_para:  fitting model parameters for those spectra with a nonthermal component
               time:         mean value of each time interval (in seconds since 79/1/1, 00:00)
               energy:          nonthermal energy input (in ergs) at each time interval

               PRINT  the summation of the nonthermal energy at all time intervals

 History:
               Linhui Sui (linhui.sui@gsfc.nasa.gov), 09/2005


SPEX_PLOT_SAVED [1] $SSW/packages/spex/idl/original_spex/spex_plot_saved.pro
[Previous] [Next]
 Name: 	
	SPEX_PLOT_SAVED
               
 Purpose: 
	This procedure provides a simple interface for plotting the results of analysis
	in SPEX.
               
 Category: 
	SPEX               
 Explanation: 
	This procedure restores a save file then plots out the requested interval.               
 Use: 
    	SPEX_PLOT_SAVED, Filename, Interval
 Inputs: 
	Filename - Fully qualified filename of IDL XDR save file.
	Interval   - Fitting Interval to plot or overplot               
 Opt. Inputs: None
               
 Outputs: None

 Opt. Outputs: None
               
 Keywords: 
	UNITS - Two cases:
	  For Spectral Plots the  Default is
	  'Photons'+uflux or  UNITS+uflux

         For Time-History it can be Counts/sec or Counts/sec/cm2/keV controlled
	  by the value of 'T_hist_mode' restored into common.  If UNITS are 'PHOTONS'
	  for th plots, then background subtracted accumulations, (OBSI-BACKI)/CONVI will
	  be used with photons in the labels and photons used for integrating over bands.
	  PH_MODEL - If set, then the model photon fits will be used to construct
	  the time history plots.

	OVERPLOT - Overplot these values.
	RESIDUALS- Show residual plot, too.
	EXTRA - Provide keyword inheritance into SPEX_SPEC_PLOT
	The following keywords have their usual meaning in Plot.
	XRANGE
	YRANGE
	XMARGIN
	YMARGIN
	CHARSIZE
	SUBTITLE -  Pass this subtitle onto time (not implemented) or spectral plot.
	Can be used to plot time-histories too by use of the following keyword:
	TIME_HISTORY: A string with value 'TIME_HISTORY' or 'GRAPH'
	for TIME_HISTORY an integrate light curve is plotted, while for
	GRAPH the variable ENERGY_BANDS gives the 4 band ranges.
	NEW_EBANDS: OVERRIDES ENERGY_BANDS in spex_commons, only used when PH_MODEL is set
	BAND_DENSITY: Only used with NEW_EBANDS, the number of sub-bins per NEW_EBAND,
	logarithmic scaling.
	NEW_SCALE: Overrides scale_bands in save files, set scaling on multi-traces
 Calls: ***
	CHECKVAR [1], EXIST, FCHECK, F_DIV, Model_components [1], Model_components [2]
	SETUTBASE [1], SETUTBASE [2], SPEX_MODEL_ARRAY [1], SPEX_MODEL_ARRAY [2]
	SPEX_SAVE_DATA [1], SPEX_SAVE_DATA [2], SPEX_THISTORY [1], SPEX_THISTORY [2]
	STR_SEP, checkvar [2], linecolors [1], linecolors [2], spex_current [1]
	spex_current [2], spex_spec_plot [1], spex_spec_plot [2], spex_spec_plot [3]
	spex_spec_plot [4]
 Common Blocks:
	spex_plot_saved
 Restrictions: 
 	              
 Side effects: 
	!p.charsize, !x.margin, and !y.margin are set within this procedure               
 Prev. Hist  :
	Based on the plotting interface with SPEX.PRO
 Modified    : 
	Version 1, RAS, 10-April-1996
	Version 2, RAS, 31-May-1996, changes to new_scale and trange


SPEX_PLOT_SAVED [2] $SSW/packages/spex/pre2002/idl/spex_plot_saved.pro
[Previous] [Next]
 Name: 	
	SPEX_PLOT_SAVED
               
 Purpose: 
	This procedure provides a simple interface for plotting the results of analysis
	in SPEX.
               
 Category: 
	SPEX               
 Explanation: 
	This procedure restores a save file then plots out the requested interval.               
 Use: 
    	SPEX_PLOT_SAVED, Filename, Interval
 Inputs: 
	Filename - Fully qualified filename of IDL XDR save file.
	Interval   - Fitting Interval to plot or overplot               
 Opt. Inputs: None
               
 Outputs: None

 Opt. Outputs: None
               
 Keywords: 
	UNITS - Two cases:
	  For Spectral Plots the  Default is
	  'Photons'+uflux or  UNITS+uflux

         For Time-History it can be Counts/sec or Counts/sec/cm2/keV controlled
	  by the value of 'T_hist_mode' restored into common.  If UNITS are 'PHOTONS'
	  for th plots, then background subtracted accumulations, (OBSI-BACKI)/CONVI will
	  be used with photons in the labels and photons used for integrating over bands.
	  PH_MODEL - If set, then the model photon fits will be used to construct
	  the time history plots.

	OVERPLOT - Overplot these values.
	RESIDUALS- Show residual plot, too.
	EXTRA - Provide keyword inheritance into SPEX_SPEC_PLOT
	The following keywords have their usual meaning in Plot.
	XRANGE
	YRANGE
	XMARGIN
	YMARGIN
	CHARSIZE
	SUBTITLE -  Pass this subtitle onto time (not implemented) or spectral plot.
	Can be used to plot time-histories too by use of the following keyword:
	TIME_HISTORY: A string with value 'TIME_HISTORY' or 'GRAPH'
	for TIME_HISTORY an integrate light curve is plotted, while for
	GRAPH the variable ENERGY_BANDS gives the 4 band ranges.
	NEW_EBANDS: OVERRIDES ENERGY_BANDS in spex_commons, only used when PH_MODEL is set
	BAND_DENSITY: Only used with NEW_EBANDS, the number of sub-bins per NEW_EBAND,
	logarithmic scaling.
	NEW_SCALE: Overrides scale_bands in save files, set scaling on multi-traces
 Calls: ***
	CHECKVAR [1], EXIST, FCHECK, F_DIV, Model_components [1], Model_components [2]
	SETUTBASE [1], SETUTBASE [2], SPEX_MODEL_ARRAY [1], SPEX_MODEL_ARRAY [2]
	SPEX_SAVE_DATA [1], SPEX_SAVE_DATA [2], SPEX_THISTORY [1], SPEX_THISTORY [2]
	STR_SEP, checkvar [2], linecolors [1], linecolors [2], spex_current [1]
	spex_current [2], spex_spec_plot [1], spex_spec_plot [2], spex_spec_plot [3]
	spex_spec_plot [4]
 Common Blocks:
	spex_plot_saved
 Restrictions: 
 	              
 Side effects: 
	!p.charsize, !x.margin, and !y.margin are set within this procedure               
 Prev. Hist  :
	Based on the plotting interface with SPEX.PRO
 Modified    : 
	Version 1, RAS, 10-April-1996
	Version 2, RAS, 31-May-1996, changes to new_scale and trange


spex_preview [1] $SSW/packages/spex/idl/original_spex/spex_preview.pro
[Previous] [Next]
 PROJECT:
	SDAC
 NAME:
	spex_preview
 PURPOSE:
	find file names and display energy range and aspect info
	in preparation for file reading in SPEX
 CALLING SEQUENCE:
	spex_preview, data_tipe, flare, det_id, in_files, in_directory, ;Inputs
		      dir_path=dir_path, files, det_cosines, dsel, last_found, command              ;Outputs

 INPUTS:
	data_tipe - instrument and data format, gets set to upper case
	flare     - event number for BATSE
	det_id    - detector id
	in_files  - 2 input file names to search for
	in_directory - possible directory for data files
	dir_queue - set of data directories to search including
		    wildcards
	standard_types - data formats integrated into SPEX environment
	source_radec - ra and dec of cosmic source, used if ra or dec non-zero
	event_time - If flare isn't given for BATSE data, then event_time must be
 OUTPUTS:
	files       - found filenames
	det_cosines - detector aspects for event
	dsel        - selected detectors (BATSE)
	last_found  - structure with dataa_tipe, det_id, flare of found files
	command     - string which directs output path in spex
		      set to '' if no file found satisfying condition
	text_out    - block of text reporting success of preview
 KEYWORDS:
	BATSE_BURST - optional reference to BATSE database, if non-zero may override Flare
 OPTIONAL OUTPUTS:

 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 PROCEDURE: uses findfile to find standard file names in directories
		given in dir_queue.

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHECKVAR [1], CHKARG, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], HAVE_WINDOWS [1], HAVE_WINDOWS [2], LOC_FILE [1], LOC_FILE [2]
	LOC_FILE [3], Run_FILE_SEARCH [1], Run_FILE_SEARCH [2], SINCE_VERSION [1]
	SINCE_VERSION [2], SSW_PICKFILE, checkvar [2], concat_dir [4], curdir [1]
	curdir [2], get_logenv [1], get_logenv [2]
 RESTRICTIONS: Defaults set for BATSE data, 14-apr-94. More to come.

 MODIFICATION HISTORY:
	ras, 14-apr-94
	ras, 5-may-94, yohkoh hxt and sxs update
	RAS, 25-MAY-94, YOHKOH HXS AND GRS
	ras, 22-aug-94, text is passed out to calling program
	and not printed here
	ras, 26-aug-94 adding smm hxrbs
	ras, 18-oct-94, adding batse discsp
	ras, 6-mar-95, integrated data_paths() with dir_queue for Yohkoh
	ras, 20-sep-95, allowed sher_only or no sherb file condition
	ras, 13-oct-95, searches current directory as a default
	ras, 15-apr-96, added source_radec
	ras, 14-nove-1996, passing event_time to run_file_search
	ras, 18-jul-1997, replaced findfile, break_file mess with loc_file for non-standard
	richard.schwartz@gsfc.nasa.gov, 26-sep-1997 added BATSE DISCLA.
	Version 15
	richard.schwartz@gsfc.nasa.gov, 29-sep-1997, moved all non-spex
	calls to call_procedure.
	richard.schwartz@gsfc.nasa.gov, 29-nov-2000 changed keyword test_dir
		to spex_test_dir in calls to run_file_search
 	1-June-2000 Paul Bilodeau added HXRS capability
 	25-May-2001 Paul Bilodeau added HESSI capability


spex_preview [2] $SSW/packages/spex/pre2002/idl/spex_preview.pro
[Previous] [Next]
 PROJECT:
	SDAC
 NAME:
	spex_preview
 PURPOSE:
	find file names and display energy range and aspect info
	in preparation for file reading in SPEX
 CALLING SEQUENCE:
	spex_preview, data_tipe, flare, det_id, in_files, in_directory, ;Inputs
		      dir_path=dir_path, files, det_cosines, dsel, last_found, command              ;Outputs

 INPUTS:
	data_tipe - instrument and data format, gets set to upper case
	flare     - event number for BATSE
	det_id    - detector id
	in_files  - 2 input file names to search for
	in_directory - possible directory for data files
	dir_queue - set of data directories to search including
		    wildcards
	standard_types - data formats integrated into SPEX environment
	source_radec - ra and dec of cosmic source, used if ra or dec non-zero
	event_time - If flare isn't given for BATSE data, then event_time must be
 OUTPUTS:
	files       - found filenames
	det_cosines - detector aspects for event
	dsel        - selected detectors (BATSE)
	last_found  - structure with dataa_tipe, det_id, flare of found files
	command     - string which directs output path in spex
		      set to '' if no file found satisfying condition
	text_out    - block of text reporting success of preview
 KEYWORDS:
	BATSE_BURST - optional reference to BATSE database, if non-zero may override Flare
 OPTIONAL OUTPUTS:

 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 PROCEDURE: uses findfile to find standard file names in directories
		given in dir_queue.

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHECKVAR [1], CHKARG, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], HAVE_WINDOWS [1], HAVE_WINDOWS [2], LOC_FILE [1], LOC_FILE [2]
	LOC_FILE [3], Run_FILE_SEARCH [1], Run_FILE_SEARCH [2], SINCE_VERSION [1]
	SINCE_VERSION [2], SSW_PICKFILE, checkvar [2], concat_dir [4], curdir [1]
	curdir [2], get_logenv [1], get_logenv [2]
 RESTRICTIONS: Defaults set for BATSE data, 14-apr-94. More to come.

 MODIFICATION HISTORY:
	ras, 14-apr-94
	ras, 5-may-94, yohkoh hxt and sxs update
	RAS, 25-MAY-94, YOHKOH HXS AND GRS
	ras, 22-aug-94, text is passed out to calling program
	and not printed here
	ras, 26-aug-94 adding smm hxrbs
	ras, 18-oct-94, adding batse discsp
	ras, 6-mar-95, integrated data_paths() with dir_queue for Yohkoh
	ras, 20-sep-95, allowed sher_only or no sherb file condition
	ras, 13-oct-95, searches current directory as a default
	ras, 15-apr-96, added source_radec
	ras, 14-nove-1996, passing event_time to run_file_search
	ras, 18-jul-1997, replaced findfile, break_file mess with loc_file for non-standard
	richard.schwartz@gsfc.nasa.gov, 26-sep-1997 added BATSE DISCLA.
	Version 15
	richard.schwartz@gsfc.nasa.gov, 29-sep-1997, moved all non-spex
	calls to call_procedure.
	richard.schwartz@gsfc.nasa.gov, 29-nov-2000 changed keyword test_dir
		to spex_test_dir in calls to run_file_search
 	1-June-2000 Paul Bilodeau added HXRS capability
 	25-May-2001 Paul Bilodeau added HESSI capability


SPEX_PROC [1] $SSW/packages/spex/idl/original_spex/spex_proc.pro
[Previous] [Next]
 NAME:
   SPEX_PROC
 PURPOSE:
   Run the SPEX spectral analysis package as a procedure
 CALLING SEQUENCE:
spex_proc, command=command, script_commands=script_commands, $
  prm_spex=prm_spex, prm_spex_info=prm_spex_info, cosine=cosine, $
  ut=ut, flux=flux, eflux=eflux, ltime=ltime, rate=rate, erate=erate, back_order=back_order, $
  backgrnd=back, eback=eback, tb=tb, $
  edges=edges , e_in=e_in, drm=drm,  obsi=obsi, convi=convi, eobsi=eobsi, backi=backi, ebacki=ebacki, $
  live=live, in_start=in_start, in_end = in_end, iegroup=iegroup, $
  need_accum=need_accum, need_nw_bck=need_nw_bck, uncert=uncert, $
  dir_queue=dir_queue, files=files, _extra=_extra

 input and output
   These are all of the important input and output variables in
   the SPEX environment:
 Parameters::::::
   These are the parameters:
   QUIET CHECK_DEFAULTS DFLTS_FILE DATA_TIPE _1FILE _2FILE DIRECTORY FLARE
   DET_ID PSSTYLE UTS UTE T_HIST_MODE
   ENERGY_BANDS SCALE_BANDS EPLOTS TH_YTYPE TH_YRANGE IAVG F_MODEL APAR
   FREE UNCERT IFIRST ILAST RANGE_LO
   RANGE_HI ERANGE SUMFIT SP_XTYPE SP_YTYPE SPXRANGE SPYRANGE MORE_INFO
   DDIRECTORY DFILE SFILE HIGH_DRM
 APAR           Fit Model Initial Parameters, referenced to FIT_MODEL,
                the model function
 DATA_TIPE      Data_tipe(0) - Instrument, e.g. 'BATSE'
        Data_tipe(1) - Data Mode   e.g. 'CONT', 'SHERS', 'HERS'
 DET_ID     Detector ID, for BATSE 0-7
 DFLTS_FILE     File with defaults for parameters from LIST command.
 ENERGY_BANDS   Energy bands (keV) for display in GRAPH command.  Grouped by twos.
 EPLOTS         Logical.  If set, then display error bars in GRAPH command.
 ERANGE         Energy interval used for fitting.
 FLARE          BATSE archive flare number.
 FREE           Logical array.  Set to 0 or 1 corresponding APAR parameter in F_MODEL is
        fixed(0) or free(1).
 F_MODEL    Name of function used in fitting.
 HIGH_DRM       Logical.  If set, then the high energy versions of the DRMs are used in the
            BUILD_DRM command.
 IAVG           Interval averaging parameter.  Used under SELECT_INTERVAL.  IAVG consecutive intervals
        are grouped together when using REGULAR style.
 IFIRST         First accumulation to use for fitting and PHOTON_SPECTRUM display.
 ILAST          Last accumulation to use for fitting.
 QUIET          If set, it reduces the reporting during fitting.
 RANGE_HI       High boundaries for fitting parameters, apar, RANGE(*,1)
 RANGE_LO       Low boundaries, RANGE(*,0)
 SCALE_BANDS    Multiplicative factors applied to light curve bands in GRAPH.
        Referenced to ENERGY_BANDS or first four channels in CHAN_MASK
 SPXRANGE       If non-zero, this is the xrange used in spectral plotting.
 SPYRANGE       If non-zero, this is the yrange used in spectral plotting.
 SUMFIT         If not set, then initial fit parameters are taken from the
        previous interval, apar_arr(*,i-1).  If set, then the initial fit
        parameters are taken from the previous fit to the ith interval
        in apar_last(*,i).
 T_HIST_MODE    TIME_HISTORY and GRAPH display mode.
        FLUX for counts/s/cm2/keV
        COUNTS for counts/s
 UTE            Timerange upper bound in string format. Normally set with Zoom command.
 UTS            Timerange lower bound.
 Variables not contained in PRM_SPEX but found in SPEX_COMMONS.
 These next 4 variables span the entire data set as read in:
 The data are dimensioned in Number_Energy_bin X Number_Time_bin

 FLUX      Input count rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 EFLUX     1-sigma uncertainty on FLUX, same units, includes uncertainty from
       background algorithm and Poisson statistics
 RATE      Background subtracted count rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 ERATE     1-sigma uncertainty on RATE, same units, includes uncertainty from
       background algorithm and Poisson statistics
 BACK      Background count rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 EBACK     1-sigma uncertainty on BACK, same units, includes uncertainty from
       background algorithm and Poisson statistics

 The next set of variables apply globally to the input data set
 EDGES     PHA energy edges, low and high edges in keV, dimensioned 2 xNumber_energy_bins
 UT        Dimensioned 2 x Time_bin, the start and stop of each interval in seconds
       measured from 1-Jan-1979
       (really 86400.*number_days from 1-jan-1979+seconds_of_day).
 AREA      Geometric detector area, a fixed scalar regardless of angle or energy
 DELTA_LIGHT   PHA energy width for each energy_bin, in this case it is edges(1,*)-edges(0,*)
 COUNT_2_FLUX  a vector, DELTA_LIGHT * AREA
 DRM           Detector response matrix, PHA_energy_bins x number_input_photon_energies.
       The input_photon_energies are in E_IN, and should not be confuse with EDGES.
       Defined as the counts/cm2/keV per incident photon/cm2 for each cell.
 DET_ID    The detector ID, a number ranging from 0-7 for BATSE
 FILES     The data files used in the session.

 The next 7 variables span the data selected for spectral fitting.
 The data are dimensioned in Energy_bin X Accumulation_interval

 OBSI      Average count rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 EOBSI     Uncertainty on OBSI, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 BACKI     Average background rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction

 EBACKI    Uncertainty on BACKI, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 CONVI     Conversion factor, dimensionless ratio, the pseudo-effective area,
       defined for the fitted model spectrum as the ratio of
       the expected_count_rate to the photon_flux integrated over each
       energy_bin.

 PHOTONS   defined as (OBSI-BACKI)/CONVI
 EPHOTONS  the 1-sigma uncertainty on PHOTONS

 The next two variables also are generated by selecting fitting time intervals

 APAR_ARR      Fit Model Initial Parameters, referenced to FIT_MODEL,
               the model function dimensioned Number_parameters X Accumulation_interval
 XSELECT   The time in seconds from the start of the day(at the start of the data)
       for each accumulation interval, dimensioned 2 x Accumulation_interval

 COMMAND
 SCRIPT_COMMANDS
 BACK_ORDER     Polynomial order for background construction

 IEAVG          Spectral interval averaging parameter.  For display purposes only at present.  Used
        under SPEC_BANDS command.
 ITER           Number of outside loops on Curvefit where conversion factors are recomputed.
 NITER          Number of loops inside of Curvefit.
 UNCERT         Minimum uncertainty in FLUX bin as a fraction of FLUX.

 PRM_SPEX       Structure with display and control parameters
 IN_START   Start reading data file at in_start, e.g. 30-jun-91 02:55:00
 IN_END     Read file until in_end.
 Need_accum     if set, then use iselect to integrate over time to create OBSI, EOBSI, etc
 Need_nw_bck    if set, background subtraction is needed
 DIR_QUEUE      Hierarchical selection of directories to search for data files, including wildcards
        e.g. ['????? /usr5/com/schwartz/db_?????/', '/usr6/com/schwartz/db_?????/']
 APAR_LAST      Fit Model parameters for last fit to each interval.
 COSINE         Cosine of the angle between the detector normal and the photon source.
 E_IN           Incident energies defined for DRM.
 IEGROUP    Channel number boundaries of spectral channels grouped together.
 ISELECT        Index of interval boundaries (referenced to FLUX) of accumulation intervals.
        The ith interval starts at the leading edge of ISELECT(0,i) and ends at the leading
        edge of ISELECT(1,i).
 LIVE           Live time in seconds of each accumulation interval.
 LTIME          Live time in seconds of each FLUX observation interval
 TB             Boundaries of background intervals with same reference
        as UT (sec)
 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], ATIME [1], ATIME [2], AVG [1], AVG [2]
	Accum [1], Accum [2], Arr2Str [2], BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3]
	CHECKVAR [1], CHKLOG [1], CHKLOG [2], CLEANPLOT [1], CLEANPLOT [2], CLEANPLOT [3]
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], CRANGE, FCHECK, FCOLOR [1]
	FORM_FILENAME [1], FORM_FILENAME [2], F_DIV, GETUT [1], GETUT [2], GETUTBASE [1]
	GETUTBASE [2], GRAPHICS_PAGE, Help_spex [1], Help_spex [2], LIMITS, LOC_FILE [1]
	LOC_FILE [2], LOC_FILE [3], Model_components [1], Model_components [2]
	OP_COM [1], OP_COM [2], PARSE_COMLINE, PSPLOT [1], PSPLOT [2], READ_SEQFILE
	RUN_CURVEFIT [1], RUN_CURVEFIT [2], SETUT [1], SETUT [2], SETUTBASE [1]
	SETUTBASE [2], SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_FLASH [1]
	SPEX_FLASH [2], SPEX_SUMMARY [1], SPEX_SUMMARY [2], SPEX_THISTORY [1]
	SPEX_THISTORY [2], UNIQ [1], UNIQ [2], UNIQ [3], UTIME [1], UTIME [2], WRITE_GIF
	XDEVICE, anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], apar_check [1]
	apar_check [2], break_file [4], checkvar [2], concat_dir [4], curdir [1]
	curdir [2], drm_4_spex [1], drm_4_spex [2], edge_products, fcolor [2]
	get_logenv [1], get_logenv [2], printx [1], printx [2], read_4_spex [1]
	read_4_spex [2], setup_params [1], setup_params [2], setup_spex [1]
	setup_spex [2], spex_energy_ranges [1], spex_energy_ranges [2]
	spex_intervals [1], spex_intervals [2], spex_merge_control [1]
	spex_merge_control [2], spex_preview [1], spex_preview [2], spex_spec_plot [1]
	spex_spec_plot [2], spex_spec_plot [3], spex_spec_plot [4], wsetshow [1]
	wsetshow [2], xps [1], xps [2]
 CALLED BY:
	BUILD_DRM_MER_CONT, HESSI_SPEX [1], HESSI_SPEX [2], ROUTINE_NAME [3]
	ROUTINE_NAME [4], ROUTINE_NAME [6], ROUTINE_NAME [7], RUN_BATSE
	SPEX_COMMONS [2], SPEX_COMMONS [4], option_changer [1], option_changer [2]
 MODIFICATION HISTORY:
   ras, 15-apr-94
   ras, 18-sep-95, changed to @spex.pro from @spex to help idl find it.


SPEX_PROC [2] $SSW/packages/spex/pre2002/idl/spex_proc.pro
[Previous] [Next]
 NAME:
   SPEX_PROC
 PURPOSE:
   Run the SPEX spectral analysis package as a procedure
 CALLING SEQUENCE:
spex_proc, command=command, script_commands=script_commands, $
  prm_spex=prm_spex, prm_spex_info=prm_spex_info, cosine=cosine, $
  ut=ut, flux=flux, eflux=eflux, ltime=ltime, rate=rate, erate=erate, back_order=back_order, $
  backgrnd=back, eback=eback, tb=tb, $
  edges=edges , e_in=e_in, drm=drm,  obsi=obsi, convi=convi, eobsi=eobsi, backi=backi, ebacki=ebacki, $
  live=live, in_start=in_start, in_end = in_end, iegroup=iegroup, $
  need_accum=need_accum, need_nw_bck=need_nw_bck, uncert=uncert, $
  dir_queue=dir_queue, files=files, _extra=_extra

 input and output
   These are all of the important input and output variables in
   the SPEX environment:
 Parameters::::::
   These are the parameters:
   QUIET CHECK_DEFAULTS DFLTS_FILE DATA_TIPE _1FILE _2FILE DIRECTORY FLARE
   DET_ID PSSTYLE UTS UTE T_HIST_MODE
   ENERGY_BANDS SCALE_BANDS EPLOTS TH_YTYPE TH_YRANGE IAVG F_MODEL APAR
   FREE UNCERT IFIRST ILAST RANGE_LO
   RANGE_HI ERANGE SUMFIT SP_XTYPE SP_YTYPE SPXRANGE SPYRANGE MORE_INFO
   DDIRECTORY DFILE SFILE HIGH_DRM
 APAR           Fit Model Initial Parameters, referenced to FIT_MODEL,
                the model function
 DATA_TIPE      Data_tipe(0) - Instrument, e.g. 'BATSE'
        Data_tipe(1) - Data Mode   e.g. 'CONT', 'SHERS', 'HERS'
 DET_ID     Detector ID, for BATSE 0-7
 DFLTS_FILE     File with defaults for parameters from LIST command.
 ENERGY_BANDS   Energy bands (keV) for display in GRAPH command.  Grouped by twos.
 EPLOTS         Logical.  If set, then display error bars in GRAPH command.
 ERANGE         Energy interval used for fitting.
 FLARE          BATSE archive flare number.
 FREE           Logical array.  Set to 0 or 1 corresponding APAR parameter in F_MODEL is
        fixed(0) or free(1).
 F_MODEL    Name of function used in fitting.
 HIGH_DRM       Logical.  If set, then the high energy versions of the DRMs are used in the
            BUILD_DRM command.
 IAVG           Interval averaging parameter.  Used under SELECT_INTERVAL.  IAVG consecutive intervals
        are grouped together when using REGULAR style.
 IFIRST         First accumulation to use for fitting and PHOTON_SPECTRUM display.
 ILAST          Last accumulation to use for fitting.
 QUIET          If set, it reduces the reporting during fitting.
 RANGE_HI       High boundaries for fitting parameters, apar, RANGE(*,1)
 RANGE_LO       Low boundaries, RANGE(*,0)
 SCALE_BANDS    Multiplicative factors applied to light curve bands in GRAPH.
        Referenced to ENERGY_BANDS or first four channels in CHAN_MASK
 SPXRANGE       If non-zero, this is the xrange used in spectral plotting.
 SPYRANGE       If non-zero, this is the yrange used in spectral plotting.
 SUMFIT         If not set, then initial fit parameters are taken from the
        previous interval, apar_arr(*,i-1).  If set, then the initial fit
        parameters are taken from the previous fit to the ith interval
        in apar_last(*,i).
 T_HIST_MODE    TIME_HISTORY and GRAPH display mode.
        FLUX for counts/s/cm2/keV
        COUNTS for counts/s
 UTE            Timerange upper bound in string format. Normally set with Zoom command.
 UTS            Timerange lower bound.
 Variables not contained in PRM_SPEX but found in SPEX_COMMONS.
 These next 4 variables span the entire data set as read in:
 The data are dimensioned in Number_Energy_bin X Number_Time_bin

 FLUX      Input count rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 EFLUX     1-sigma uncertainty on FLUX, same units, includes uncertainty from
       background algorithm and Poisson statistics
 RATE      Background subtracted count rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 ERATE     1-sigma uncertainty on RATE, same units, includes uncertainty from
       background algorithm and Poisson statistics
 BACK      Background count rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 EBACK     1-sigma uncertainty on BACK, same units, includes uncertainty from
       background algorithm and Poisson statistics

 The next set of variables apply globally to the input data set
 EDGES     PHA energy edges, low and high edges in keV, dimensioned 2 xNumber_energy_bins
 UT        Dimensioned 2 x Time_bin, the start and stop of each interval in seconds
       measured from 1-Jan-1979
       (really 86400.*number_days from 1-jan-1979+seconds_of_day).
 AREA      Geometric detector area, a fixed scalar regardless of angle or energy
 DELTA_LIGHT   PHA energy width for each energy_bin, in this case it is edges(1,*)-edges(0,*)
 COUNT_2_FLUX  a vector, DELTA_LIGHT * AREA
 DRM           Detector response matrix, PHA_energy_bins x number_input_photon_energies.
       The input_photon_energies are in E_IN, and should not be confuse with EDGES.
       Defined as the counts/cm2/keV per incident photon/cm2 for each cell.
 DET_ID    The detector ID, a number ranging from 0-7 for BATSE
 FILES     The data files used in the session.

 The next 7 variables span the data selected for spectral fitting.
 The data are dimensioned in Energy_bin X Accumulation_interval

 OBSI      Average count rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 EOBSI     Uncertainty on OBSI, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 BACKI     Average background rate, channels by intervals, in counts/s/keV/cm2
       including livetime correction

 EBACKI    Uncertainty on BACKI, channels by intervals, in counts/s/keV/cm2
       including livetime correction
 CONVI     Conversion factor, dimensionless ratio, the pseudo-effective area,
       defined for the fitted model spectrum as the ratio of
       the expected_count_rate to the photon_flux integrated over each
       energy_bin.

 PHOTONS   defined as (OBSI-BACKI)/CONVI
 EPHOTONS  the 1-sigma uncertainty on PHOTONS

 The next two variables also are generated by selecting fitting time intervals

 APAR_ARR      Fit Model Initial Parameters, referenced to FIT_MODEL,
               the model function dimensioned Number_parameters X Accumulation_interval
 XSELECT   The time in seconds from the start of the day(at the start of the data)
       for each accumulation interval, dimensioned 2 x Accumulation_interval

 COMMAND
 SCRIPT_COMMANDS
 BACK_ORDER     Polynomial order for background construction

 IEAVG          Spectral interval averaging parameter.  For display purposes only at present.  Used
        under SPEC_BANDS command.
 ITER           Number of outside loops on Curvefit where conversion factors are recomputed.
 NITER          Number of loops inside of Curvefit.
 UNCERT         Minimum uncertainty in FLUX bin as a fraction of FLUX.

 PRM_SPEX       Structure with display and control parameters
 IN_START   Start reading data file at in_start, e.g. 30-jun-91 02:55:00
 IN_END     Read file until in_end.
 Need_accum     if set, then use iselect to integrate over time to create OBSI, EOBSI, etc
 Need_nw_bck    if set, background subtraction is needed
 DIR_QUEUE      Hierarchical selection of directories to search for data files, including wildcards
        e.g. ['????? /usr5/com/schwartz/db_?????/', '/usr6/com/schwartz/db_?????/']
 APAR_LAST      Fit Model parameters for last fit to each interval.
 COSINE         Cosine of the angle between the detector normal and the photon source.
 E_IN           Incident energies defined for DRM.
 IEGROUP    Channel number boundaries of spectral channels grouped together.
 ISELECT        Index of interval boundaries (referenced to FLUX) of accumulation intervals.
        The ith interval starts at the leading edge of ISELECT(0,i) and ends at the leading
        edge of ISELECT(1,i).
 LIVE           Live time in seconds of each accumulation interval.
 LTIME          Live time in seconds of each FLUX observation interval
 TB             Boundaries of background intervals with same reference
        as UT (sec)
 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], ATIME [1], ATIME [2], AVG [1], AVG [2]
	Accum [1], Accum [2], Arr2Str [2], BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3]
	CHECKVAR [1], CHKLOG [1], CHKLOG [2], CLEANPLOT [1], CLEANPLOT [2], CLEANPLOT [3]
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], CRANGE, FCHECK, FCOLOR [1]
	FORM_FILENAME [1], FORM_FILENAME [2], F_DIV, GETUT [1], GETUT [2], GETUTBASE [1]
	GETUTBASE [2], GRAPHICS_PAGE, Help_spex [1], Help_spex [2], LIMITS, LOC_FILE [1]
	LOC_FILE [2], LOC_FILE [3], Model_components [1], Model_components [2]
	OP_COM [1], OP_COM [2], PARSE_COMLINE, PSPLOT [1], PSPLOT [2], READ_SEQFILE
	RUN_CURVEFIT [1], RUN_CURVEFIT [2], SETUT [1], SETUT [2], SETUTBASE [1]
	SETUTBASE [2], SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_FLASH [1]
	SPEX_FLASH [2], SPEX_SUMMARY [1], SPEX_SUMMARY [2], SPEX_THISTORY [1]
	SPEX_THISTORY [2], UNIQ [1], UNIQ [2], UNIQ [3], UTIME [1], UTIME [2], WRITE_GIF
	XDEVICE, anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], apar_check [1]
	apar_check [2], break_file [4], checkvar [2], concat_dir [4], curdir [1]
	curdir [2], drm_4_spex [1], drm_4_spex [2], edge_products, fcolor [2]
	get_logenv [1], get_logenv [2], printx [1], printx [2], read_4_spex [1]
	read_4_spex [2], setup_params [1], setup_params [2], setup_spex [1]
	setup_spex [2], spex_energy_ranges [1], spex_energy_ranges [2]
	spex_intervals [1], spex_intervals [2], spex_merge_control [1]
	spex_merge_control [2], spex_preview [1], spex_preview [2], spex_spec_plot [1]
	spex_spec_plot [2], spex_spec_plot [3], spex_spec_plot [4], wsetshow [1]
	wsetshow [2], xps [1], xps [2]
 CALLED BY:
	BUILD_DRM_MER_CONT, HESSI_SPEX [1], HESSI_SPEX [2], ROUTINE_NAME [3]
	ROUTINE_NAME [4], ROUTINE_NAME [6], ROUTINE_NAME [7], RUN_BATSE
	SPEX_COMMONS [2], SPEX_COMMONS [4], option_changer [1], option_changer [2]
 MODIFICATION HISTORY:
   ras, 15-apr-94
   ras, 18-sep-95, changed to @spex.pro from @spex to help idl find it.


SPEX_READ_FIT_RESULTS $SSW/packages/spex/idl/object_spex/spex_read_fit_results.pro
[Previous] [Next]
 PROJECT:
       HESSI

 NAME:
       SPEX_READ_FIT_RESULTS

 PURPOSE:
       Reads the FITS or geny file that contains fit results and copies them to
                a ospex_summ structure.

 CATEGORY:
       gen/fits

 CONSTRUCTION:
       fit_results = spex_read_fit_results(filename)

 SEE ALSO
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], FILE_EXIST [2]
	FIT_FUNCTION_QUERY, FXPAR [1], FXPAR [2], MJD2ANY, MRDFITS [1], MRDFITS [2]
	SPEX_CONVERT_RESULTS_GENY, TRIM, break_file [4], curdir [1], curdir [2]
	file_exist [1], file_exist [3], get_fits_extno, restgenx
	spex_convert_results [1], spex_convert_results [2], spex_summ_define_str
 CALLED BY:
	SPEX__DEFINE, hsi_qlook_spectrum, spex_nontherm_energy
 HISTORY:
       Sep-2004: created - Sandhia Bansal
		25-Sep-2004, Kim.  If filename not passed in, open dialog_pickfile
		29-Sep-2004, Kim.  For geny files, add any tags that weren't defined when
		  file was created, and fill with zeros.  For FITS files, this is already taken
		  care of since we call spex_summ_define_str which gets current struct def, and
		  then fills in what it gets from the FITS file.
		7-Apr-2006, Kim.  Added ncomp to spex_summ_define_str args and added spectrum,
		  model to fields to retrieve from file.  Also spex_summ_abun_table
		  SEE NOTE IN SPEX__FITSWRITE header)


SPEX_RUN_CURVEFIT [1] $SSW/packages/spex/idl/original_spex/spex_run_curvefit.pro
[Previous] [Next]
Project:
	SSW/HESSI
Name:
	SPEX_RUN_CURVEFIT

Usage
	SPEX_run_curvefit, interval, apar_in, niter, iter, FREE=FREE

How to use;
	First obtain accumulation intervals and initial fits on a spectrum
	using SPEX.  Then exit SPEX and begin using this procedure to
	easily change the fitting parameters for any accumulation interval without
	having to use the SPEX interface. You may obtain the resultant values by
	using the spex_commons common blocks directly or query them using
	spex_current (e.g. chi = spex_current('chi'))

	To save all of the variables in the common blocks use
	(idl,)spex_save_data, filename, /all

	[ (idl,) is needed if running from the SPEX prompt ]

	Then in a later sswidl session you can restore using
	spex_save_data, filename, /restore and continue using this routine,
	spex_run_curvefit


PURPOSE:
	 This procedure provides a modular interface to the
	fitting routine within SPEX.  It includes most of the SPEX
   variables via the common blocks in SPEX (see spex_commons.pro)


Category:
	SPEX, ANALYSIS, FITTING

Inputs:
	APAR_IN - Parameters used in call to F_MODEL.

	ITER - Number of times in outside loop where conversion factors are
		recomputed.
	       If ITER is set to 0, then fitting is done in count rate space,
	       and there are no conversion factors used. default 0
	NITER - Number of times in loop inside Curvefit where parameter
		increments are calculated, default 5

KEYWORD INPUT:
	FREE - A bytarr for each parameter in the model function.
	set (1) if parameter is free to vary, reset (0) if it is fixed.


Explanation:
	This procedure controls the input to the functional minimization
	     program, usually CURVFIT. In the standard technique there is
	     an inner and outer loop.  In the outer loop the conversion
	     factors are recompute with the new values of the parameters
	     obtained from CURVFIT.  The inner loop counter is used within
	     CURVFIT.
	If there are no degrees of freedom for two free parameters and two
	data values, and one of the free parameters is a normalization parameter,
	while the other is a shape parameter directly after it,
	the procedure, SPECTRAL_RATIO, is used to obtain the "fitted" values.


In the SPEX_COMMON_BLOCK OR IN THE SPEX PARAMETER STRUCTURE
	 - SHOULD BE CHANGED OR QUERIED USING SPEX_CURRENT()
	E_IN - Mean of m input energy bins, geometric mean is best normally, or 2Xm edges
	W_IN - Width of input energy bins.
	COUNT_2_FLUX - conversion vector from incident counts to count flux
		     for hard x-ray data normally the product of energy bin width and area
	LIVE - Livetime of observing interval in seconds (or unit of choice)
	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.
	F_MODEL - Name of functional model (string)
	OBSERVE (OBS) - Source counting rate spectrum
	EOBSERVE (EOBS) - Uncertainties on OBS calculated from Gaussian stat. on observed
	USE_MOD_SIG     - If set, use Gaussian statistics on expected rate
	BACKGROUND (BACK)  - Backgrount counting rate spectrum
	EBACK (EBACK) - Uncertainties on BCK
	UNCERT_MIN  - minimum relative uncertainty used to calculate weighting
	E_OUT - Mean of n output energy bins, or 2XN edges.
	W_USE - Indices to use in E_OUT and OBS
	RANGE - Min and Max values allowed for each of APAR,
		dimensioned 2,n where n is the number of parameters
	QUIET - If set then informational print statements are suppressed.
	NOLAMBDA - see curvfit
	PCONV - pileup conversion factor if set, the ratio of a single photon pulse-ht
		spectrum divided by the pileup pulse height spectrum
		These corrections can be obtained using [sdac.spex]convolve.pro
	NOFIT - Make all computations but don't run curvefit if set.
	APAR - Input parameter values are adjusted to new values in CURVEFIT
	SIGMAA - Uncertainties on the APAR from CURVEFIT, somewhat crude
	NRESID - Residuals on fitted points normalized by uncertainties used, same
		 length as wuse
CALLS: ***
	CHECKVAR [1], DEFAULT, FCHECK, RUN_CURVEFIT [1], RUN_CURVEFIT [2], checkvar [2]
	spex_current [1], spex_current [2]
History:
	Written by richard.schwartz@gsfc.nasa.gov 17-apr-03
	5-may-2003, force chi to be float, ras
	6-may-2003, propagate UNCERT into fitting alg., ras


SPEX_RUN_CURVEFIT [2] $SSW/packages/spex/pre2002/idl/spex_run_curvefit.pro
[Previous] [Next]
Project:
	SSW/HESSI
Name:
	SPEX_RUN_CURVEFIT

Usage
	SPEX_run_curvefit, interval, apar_in, niter, iter, FREE=FREE

How to use;
	First obtain accumulation intervals and initial fits on a spectrum
	using SPEX.  Then exit SPEX and begin using this procedure to
	easily change the fitting parameters for any accumulation interval without
	having to use the SPEX interface. You may obtain the resultant values by
	using the spex_commons common blocks directly or query them using
	spex_current (e.g. chi = spex_current('chi'))

	To save all of the variables in the common blocks use
	(idl,)spex_save_data, filename, /all

	[ (idl,) is needed if running from the SPEX prompt ]

	Then in a later sswidl session you can restore using
	spex_save_data, filename, /restore and continue using this routine,
	spex_run_curvefit


PURPOSE:
	 This procedure provides a modular interface to the
	fitting routine within SPEX.  It includes most of the SPEX
   variables via the common blocks in SPEX (see spex_commons.pro)


Category:
	SPEX, ANALYSIS, FITTING

Inputs:
	APAR_IN - Parameters used in call to F_MODEL.

	ITER - Number of times in outside loop where conversion factors are
		recomputed.
	       If ITER is set to 0, then fitting is done in count rate space,
	       and there are no conversion factors used. default 0
	NITER - Number of times in loop inside Curvefit where parameter
		increments are calculated, default 5

KEYWORD INPUT:
	FREE - A bytarr for each parameter in the model function.
	set (1) if parameter is free to vary, reset (0) if it is fixed.


Explanation:
	This procedure controls the input to the functional minimization
	     program, usually CURVFIT. In the standard technique there is
	     an inner and outer loop.  In the outer loop the conversion
	     factors are recompute with the new values of the parameters
	     obtained from CURVFIT.  The inner loop counter is used within
	     CURVFIT.
	If there are no degrees of freedom for two free parameters and two
	data values, and one of the free parameters is a normalization parameter,
	while the other is a shape parameter directly after it,
	the procedure, SPECTRAL_RATIO, is used to obtain the "fitted" values.


In the SPEX_COMMON_BLOCK OR IN THE SPEX PARAMETER STRUCTURE
	 - SHOULD BE CHANGED OR QUERIED USING SPEX_CURRENT()
	E_IN - Mean of m input energy bins, geometric mean is best normally, or 2Xm edges
	W_IN - Width of input energy bins.
	COUNT_2_FLUX - conversion vector from incident counts to count flux
		     for hard x-ray data normally the product of energy bin width and area
	LIVE - Livetime of observing interval in seconds (or unit of choice)
	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.
	F_MODEL - Name of functional model (string)
	OBSERVE (OBS) - Source counting rate spectrum
	EOBSERVE (EOBS) - Uncertainties on OBS calculated from Gaussian stat. on observed
	USE_MOD_SIG     - If set, use Gaussian statistics on expected rate
	BACKGROUND (BACK)  - Backgrount counting rate spectrum
	EBACK (EBACK) - Uncertainties on BCK
	UNCERT_MIN  - minimum relative uncertainty used to calculate weighting
	E_OUT - Mean of n output energy bins, or 2XN edges.
	W_USE - Indices to use in E_OUT and OBS
	RANGE - Min and Max values allowed for each of APAR,
		dimensioned 2,n where n is the number of parameters
	QUIET - If set then informational print statements are suppressed.
	NOLAMBDA - see curvfit
	PCONV - pileup conversion factor if set, the ratio of a single photon pulse-ht
		spectrum divided by the pileup pulse height spectrum
		These corrections can be obtained using [sdac.spex]convolve.pro
	NOFIT - Make all computations but don't run curvefit if set.
	APAR - Input parameter values are adjusted to new values in CURVEFIT
	SIGMAA - Uncertainties on the APAR from CURVEFIT, somewhat crude
	NRESID - Residuals on fitted points normalized by uncertainties used, same
		 length as wuse
CALLS: ***
	CHECKVAR [1], DEFAULT, FCHECK, RUN_CURVEFIT [1], RUN_CURVEFIT [2], checkvar [2]
	spex_current [1], spex_current [2]
History:
	Written by richard.schwartz@gsfc.nasa.gov 17-apr-03
	5-may-2003, force chi to be float, ras
	6-may-2003, propagate UNCERT into fitting alg., ras


SPEX_SAVE [1] $SSW/packages/spex/idl/original_spex/spex_save.pro
[Previous] [Next]
 NAME: 
	SPEX_SAVE
 PURPOSE: 
	To save and restore variables defined in a SPEX session	
 CATEGORY: 
	I/O
 CALLING SEQUENCE:
	spex_save
 PROCEDURE:
    
    Extract variables from SPEX_COMMONS and write to a save file
	Key variables:
	apar_arr, backi,convi,delta_light,drm, $
	edges, live, obsi, ut, wuse, xselect, e_in

 INPUTS:
	None 
 OUTPUTS:                                                   
	None direct, an IDL XDR save file is written into the current directory

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHECKVAR [1], GETUTBASE [1], GETUTBASE [2], anytim [1]
	anytim [2], anytim [3], anytim [4], anytim [5], checkvar [2], printx [1], printx [2]
	spex_current [1], spex_current [2]
 COMMON BLOCKS:
	 in spex_commons.pro

 SIDE EFFECTS:
	
 RESTRICTIONS:
	None.

 MODIFICATION HISTORY:
 Under development, ras, 30-may-1995
 	Version 2, ras, 25-oct-1996, include flare number in filename


SPEX_SAVE [2] $SSW/packages/spex/pre2002/idl/spex_save.pro
[Previous] [Next]
 NAME: 
	SPEX_SAVE
 PURPOSE: 
	To save and restore variables defined in a SPEX session	
 CATEGORY: 
	I/O
 CALLING SEQUENCE:
	spex_save
 PROCEDURE:
    
    Extract variables from SPEX_COMMONS and write to a save file
	Key variables:
	apar_arr, backi,convi,delta_light,drm, $
	edges, live, obsi, ut, wuse, xselect, e_in

 INPUTS:
	None 
 OUTPUTS:                                                   
	None direct, an IDL XDR save file is written into the current directory

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHECKVAR [1], GETUTBASE [1], GETUTBASE [2], anytim [1]
	anytim [2], anytim [3], anytim [4], anytim [5], checkvar [2], printx [1], printx [2]
	spex_current [1], spex_current [2]
 COMMON BLOCKS:
	 in spex_commons.pro

 SIDE EFFECTS:
	
 RESTRICTIONS:
	None.

 MODIFICATION HISTORY:
 Under development, ras, 30-may-1995
 	Version 2, ras, 25-oct-1996, include flare number in filename


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

 NAME:   SPEX_SAVE_DATA


 PURPOSE: Write current spex input data to a save file.  Rates


 CATEGORY:  SPEX, Spectral Analysis


 CALLING SEQUENCE:  SPEX_SAVE_DATA [, Filename]


 CALLED BY:


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], CHKARG, EMENU, EXIST
	F_DIV, F_USE_WIDGET, GETUTBASE [1], GETUTBASE [2], PICKFILE, SINCE_VERSION [1]
	SINCE_VERSION [2], STR_SEP, checkvar [2], select_widg, spex_current [1]
	spex_current [2]
 INPUTS:
       none explicit

 OPTIONAL INPUTS:
	Filename - Name of file to write to.
	ALL: If set, then save all of the defined data in SPEX_COMMONS
	RESTORE: If set, then restore Filename, may use findfile wildcards
	or enter a null string.
 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
            Version 1, RAS July 1996
 Version 4, ras, 6-nov-2002, enable up to 200 parameters in spex after 5.1


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

 NAME:   SPEX_SAVE_DATA


 PURPOSE: Write current spex input data to a save file.  Rates


 CATEGORY:  SPEX, Spectral Analysis


 CALLING SEQUENCE:  SPEX_SAVE_DATA [, Filename]


 CALLED BY:


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], CHKARG, EMENU, EXIST
	F_DIV, F_USE_WIDGET, GETUTBASE [1], GETUTBASE [2], PICKFILE, SINCE_VERSION [1]
	SINCE_VERSION [2], STR_SEP, checkvar [2], select_widg, spex_current [1]
	spex_current [2]
 INPUTS:
       none explicit

 OPTIONAL INPUTS:
	Filename - Name of file to write to.
	ALL: If set, then save all of the defined data in SPEX_COMMONS
	RESTORE: If set, then restore Filename, may use findfile wildcards
	or enter a null string.
 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
            Version 1, RAS July 1996
 Version 4, ras, 6-nov-2002, enable up to 200 parameters in spex after 5.1


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

 NAME: spex_source


 PURPOSE: initialize source array in spex_hold_com


 CATEGORY: spex, spectral analysis


 CALLING SEQUENCE:spex_source_ident


 CALLED BY:


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FCHECK, F_DIV, GETUTBASE [1], GETUTBASE [2]
	checkvar [2], delvarx [5], edge_products, help_merge [1], help_merge [2]
	printx [1], printx [2], spex_current [1], spex_current [2], spex_delete [1]
	spex_delete [2], spex_hold [1], spex_hold [2], spex_merge [1], spex_merge [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	help_merge [1], help_merge [2], spex_delete [1], spex_delete [2], spex_hold [1]
	spex_hold [2], spex_merge [1], spex_merge [2]
 COMMON BLOCKS:
	spex_hold_com
       spex_setup_com
       spex_proc_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 20-oct-94


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

 NAME: spex_source


 PURPOSE: initialize source array in spex_hold_com


 CATEGORY: spex, spectral analysis


 CALLING SEQUENCE:spex_source_ident


 CALLED BY:


 CALLS: ***
	ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2], CHECKVAR [1], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FCHECK, F_DIV, GETUTBASE [1], GETUTBASE [2]
	checkvar [2], delvarx [5], edge_products, help_merge [1], help_merge [2]
	printx [1], printx [2], spex_current [1], spex_current [2], spex_delete [1]
	spex_delete [2], spex_hold [1], spex_hold [2], spex_merge [1], spex_merge [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	help_merge [1], help_merge [2], spex_delete [1], spex_delete [2], spex_hold [1]
	spex_hold [2], spex_merge [1], spex_merge [2]
 COMMON BLOCKS:
	spex_hold_com
       spex_setup_com
       spex_proc_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 20-oct-94


spex_soxs_specfile__define $SSW/packages/spex/idl/object_spex/spex_soxs_specfile__define.pro
[Previous] [Next]

 NAME:
   spex_soxs_specfile__define

 PURPOSE:
   Provides read_data method for the soxs instrument.
   NOTE: This procedure is based on spex_hessi_specfile__define.


 CATEGORY:
       SPECTRAL FITTING, SPEX - SOXS

 CALLING SEQUENCE:

 CALLS: ***
	SPEX_SOXS_SPECFILE::READ_DATA, SPEX_SOXS_SPECFILE_TEST, UTIME [1], UTIME [2]
	read_soxs_4_ospex
 INPUTS:

 OUTPUTS:

 INPUT KEYWORDS:

 OUTPUT KEYWORDS:

 PROCEDURE:

 Written 23-Nov-2004  - Sandhia Bansal

 Modification History:
 Sandhia Bansal - 12/08/04 - Specified a SOXS file in the test routine.


spex_spec_plot [1] $SSW/packages/spex/idl/original_spex/spex_spec_plot.pro
[Previous] [Next]
	add a line to the subtitle of the spectral plots
	more_info must be set to display this
 CALLS:
 CALLED BY
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
	SPEX_PROC [1], SPEX_PROC [2], spex_customplot [1], spex_customplot [2]


spex_spec_plot [2] $SSW/packages/spex/idl/original_spex/spex_spec_plot.pro
[Previous] [Next]

 NAME: spex_spec_plot

 PURPOSE: Plot an observed energy spectrum and its model

 CATEGORY: SPEX, GRAPHICS


 CALLING SEQUENCE:
	spex_spec_plot, plotted, edges=edges, drm=drm, e_in=e_in, apar=apar, cflux=cflux

 CALLS TO: Fcount_rate, Model_components, fcheck, fcolors, checkvar, $
	edge_products, datplot, countsmod_plot, eplot, graphics_page,alpha_page,
	option_changer, printx, timestamp, arr2str, atime, chklog, emenu, exist,
	f_div, f_use_widget, limits, respond_widg


REQUIRED KEYWORD INPUTS:
	Required:
	EDGES:  2 x Num_channels energy edges
	DRM:    Detector Response defining relationship between input model and output response
		DRM is Num_channels x Num_photon
	E_IN:   Input energy edges for photon spectrum, 2 X Num_photon bins
	APAR:	Parameters of model, If SET is set, then the values of APAR may be changed
	by a popup menu.
	CFLUX:   Counting rate flux, counts/uflux, often counts/cm2/s/keV, Num_channels long.

Optional Keywords:
	ECFLUX:  Uncertainties on cflux, defaults to [0.*cflux]
	SIGMAA:  Uncertainties on model parameters
	BFLUX:   Background flux, defaults to [0.*cflux]
	EBFLUX:  Uncertainty on bflux, defaults to [0.*bflux]
	UNITS:   Units of cflux, expressed as needed for figure, often' s!u-1!n cm!u-2!n keV!u-1!n'
	SET:  	if set then interactively select fitting parameters
	INTERVAL: Interval number used to reference a series of fits. default: [0]
	TRANGE:  Time range covered by observation, for subtitle.
	CHISQR:  Value of reduced chi-square for this fit.  Appears in subtitle if at all.
	SUBTITLE: Subtitle of plot.  Overrides TRANGE if used.
	EPLOT: If set, plot uncertainties
	CAL_TEST: An option for experts only.
	 If set, scaled plot comparing net source count/rate and model count/rate
	 In the cal_test mode we are trying to highlight the correspondance between
	 the details of the predicted model spectrum and the observed spectrum looking
	 for any obvious systematic problems in the gain/detector-response.
	 Therefore, we plot the net source count rate spectrum over the range
	 indicated by edges(*,wuse) and overplot with the predicted source count rate.
	 Furthermore if a linear plot is desired then the plot is autoscaled by
	 multiplying by a power-law which will best flatten the plot and the yrange
	 is selected from extrema of the product of the observed and the power-law over the
	 the channels in wuse.
	TITLE: Title used on figure, string.
	XTYPE: If set log xaxis, otherwise linear
	YTYPE: If set log yaxis, otherwise linear
	COLORS: Vector of colors to use, referenced to Linecolors.pro
		Nominally the indices used are [5,9,3,4,7] for
		linecolor 5 (yellow) for source counts
		linecolor 9 (sky blue) for  folded model counts,
		linecolor 3 (scarlet) for continuous model summed over the components,
		linecolor 4 (orange) for background counts,
		linecolor 7 (green) for the continuous model components.
	GROUP:  This array controls the grouping (binning together) of the instrument energy
		channels.
		The new edges are the low edge of the first channel in each group and the low
		edge of the second channel.
	DELTA_LIGHT: If GROUP is used, then DELTA_LIGHT is mandatory.  Gives the channel widths
		of the individual channels and may be different from the widths implied by
		edges.  This still needs some testing, 11 April 1996, RAS
	UNCERT:  minimum fractional uncertainty on background subtracted flux, def 0.0
 	PCONV: Additional scaling between counts and photons.  A multiplicative factor
	applied to the conversion factors calculated in GET_CONVERSION.PRO where the conversion
	factor is given by the counts/photons.  It may be used to test modifications from
	considerations such as pileup.
	OVERPLOT: If set, overplot new spectrum
	RESIDUALS:  If set, plot residuals.
	THICK: thick keyword for plotting horizontal bars
 OUTPUTS:
	no direct outputs other than apar described above.

 OPTIONAL OUTPUTS:
	Plotted - An anonymous structure with the the plotted data points, ordinates and abscissae

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2]
	CHECKVAR [1], CRANGE, DATPLOT, EMENU, EXIST, FCHECK, FCOLOR [1], F_DIV, F_USE_WIDGET
	GRAPHICS_PAGE, LIMITS, MINMAX [1], MINMAX [2], MORE_SUBTITLE, Model_components [1]
	Model_components [2], RESET_XY [1], RESET_XY [2], RESPOND_WIDG, STR_SEP, TIMESTAMP
	checkvar [2], edge_products, fcolor [2], get_conversion [1], get_conversion [2]
	option_changer [1], option_changer [2], printx [1], printx [2]
 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
	SPEX_PROC [1], SPEX_PROC [2], spex_customplot [1], spex_customplot [2]
 COMMON BLOCKS:
	Function_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	If 'COUNTS' appears in units, flux is displayed with no additional scaling,
	and the bflux is also plotted. Otherwise, the (cflux-bflux) is divided by the
	conversion factor (see GET_CONVERSION.PRO) computed from the
	drm and model function found in function_com.

 MODIFICATION HISTORY:
	ras, 1994
	ras, 9-Mar-1995, only 6 parameters per line in the subtitle
	ras, 22-mar-95, added cal_test keyword
	ras, 5-apr-95, fixed bug in energy bin averaging, creating gmatrix
	rasm 24-jan-96, added residuals plot
	Version 2, ras, 11-April-1996, cleaned documentation, added overplot.
	Version 3, ras, 31-May-1996, added subtitle keyword
	Version 4, ras, 27-aug-1996, fixed for new meaning of group
	added thick keyword
	Version 5, ras, 24-sep-1996, e_in given default definition of ecflux
	Version 6, ras, use call_procedure for batse specific routine, countsmod_plot.
	Version 7, ras, set_graphics used to overwrite colors in window system, 11-sep-1997
	Version 8, ras, used execute for set_graphics call to device, 4-nov-1997
	27-jun-02, ras, added notimestamp keyword


spex_spec_plot [3] $SSW/packages/spex/pre2002/idl/spex_spec_plot.pro
[Previous] [Next]
	add a line to the subtitle of the spectral plots
	more_info must be set to display this
 CALLS:
 CALLED BY
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
	SPEX_PROC [1], SPEX_PROC [2], spex_customplot [1], spex_customplot [2]


spex_spec_plot [4] $SSW/packages/spex/pre2002/idl/spex_spec_plot.pro
[Previous] [Next]

 NAME: spex_spec_plot

 PURPOSE: Plot an observed energy spectrum and its model

 CATEGORY: SPEX, GRAPHICS


 CALLING SEQUENCE:
	spex_spec_plot, plotted, edges=edges, drm=drm, e_in=e_in, apar=apar, cflux=cflux

 CALLS TO: Fcount_rate, Model_components, fcheck, fcolors, checkvar, $
	edge_products, datplot, countsmod_plot, eplot, graphics_page,alpha_page,
	option_changer, printx, timestamp, arr2str, atime, chklog, emenu, exist,
	f_div, f_use_widget, limits, respond_widg


REQUIRED KEYWORD INPUTS:
	Required:
	EDGES:  2 x Num_channels energy edges
	DRM:    Detector Response defining relationship between input model and output response
		DRM is Num_channels x Num_photon
	E_IN:   Input energy edges for photon spectrum, 2 X Num_photon bins
	APAR:	Parameters of model, If SET is set, then the values of APAR may be changed
	by a popup menu.
	CFLUX:   Counting rate flux, counts/uflux, often counts/cm2/s/keV, Num_channels long.

Optional Keywords:
	ECFLUX:  Uncertainties on cflux, defaults to [0.*cflux]
	SIGMAA:  Uncertainties on model parameters
	BFLUX:   Background flux, defaults to [0.*cflux]
	EBFLUX:  Uncertainty on bflux, defaults to [0.*bflux]
	UNITS:   Units of cflux, expressed as needed for figure, often' s!u-1!n cm!u-2!n keV!u-1!n'
	SET:  	if set then interactively select fitting parameters
	INTERVAL: Interval number used to reference a series of fits. default: [0]
	TRANGE:  Time range covered by observation, for subtitle.
	CHISQR:  Value of reduced chi-square for this fit.  Appears in subtitle if at all.
	SUBTITLE: Subtitle of plot.  Overrides TRANGE if used.
	EPLOT: If set, plot uncertainties
	CAL_TEST: An option for experts only.
	 If set, scaled plot comparing net source count/rate and model count/rate
	 In the cal_test mode we are trying to highlight the correspondance between
	 the details of the predicted model spectrum and the observed spectrum looking
	 for any obvious systematic problems in the gain/detector-response.
	 Therefore, we plot the net source count rate spectrum over the range
	 indicated by edges(*,wuse) and overplot with the predicted source count rate.
	 Furthermore if a linear plot is desired then the plot is autoscaled by
	 multiplying by a power-law which will best flatten the plot and the yrange
	 is selected from extrema of the product of the observed and the power-law over the
	 the channels in wuse.
	TITLE: Title used on figure, string.
	XTYPE: If set log xaxis, otherwise linear
	YTYPE: If set log yaxis, otherwise linear
	COLORS: Vector of colors to use, referenced to Linecolors.pro
		Nominally the indices used are [5,9,3,4,7] for
		linecolor 5 (yellow) for source counts
		linecolor 9 (sky blue) for  folded model counts,
		linecolor 3 (scarlet) for continuous model summed over the components,
		linecolor 4 (orange) for background counts,
		linecolor 7 (green) for the continuous model components.
	GROUP:  This array controls the grouping (binning together) of the instrument energy
		channels.
		The new edges are the low edge of the first channel in each group and the low
		edge of the second channel.
	DELTA_LIGHT: If GROUP is used, then DELTA_LIGHT is mandatory.  Gives the channel widths
		of the individual channels and may be different from the widths implied by
		edges.  This still needs some testing, 11 April 1996, RAS
	UNCERT:  minimum fractional uncertainty on background subtracted flux, def 0.0
 	PCONV: Additional scaling between counts and photons.  A multiplicative factor
	applied to the conversion factors calculated in GET_CONVERSION.PRO where the conversion
	factor is given by the counts/photons.  It may be used to test modifications from
	considerations such as pileup.
	OVERPLOT: If set, overplot new spectrum
	RESIDUALS:  If set, plot residuals.
	THICK: thick keyword for plotting horizontal bars
 OUTPUTS:
	no direct outputs other than apar described above.

 OPTIONAL OUTPUTS:
	Plotted - An anonymous structure with the the plotted data points, ordinates and abscissae

 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ARR2STR [1], ATIME [1], ATIME [2], Arr2Str [2]
	CHECKVAR [1], CRANGE, DATPLOT, EMENU, EXIST, FCHECK, FCOLOR [1], F_DIV, F_USE_WIDGET
	GRAPHICS_PAGE, LIMITS, MINMAX [1], MINMAX [2], MORE_SUBTITLE, Model_components [1]
	Model_components [2], RESET_XY [1], RESET_XY [2], RESPOND_WIDG, STR_SEP, TIMESTAMP
	checkvar [2], edge_products, fcolor [2], get_conversion [1], get_conversion [2]
	option_changer [1], option_changer [2], printx [1], printx [2]
 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2]
	SPEX_PROC [1], SPEX_PROC [2], spex_customplot [1], spex_customplot [2]
 COMMON BLOCKS:
	Function_com

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	If 'COUNTS' appears in units, flux is displayed with no additional scaling,
	and the bflux is also plotted. Otherwise, the (cflux-bflux) is divided by the
	conversion factor (see GET_CONVERSION.PRO) computed from the
	drm and model function found in function_com.

 MODIFICATION HISTORY:
	ras, 1994
	ras, 9-Mar-1995, only 6 parameters per line in the subtitle
	ras, 22-mar-95, added cal_test keyword
	ras, 5-apr-95, fixed bug in energy bin averaging, creating gmatrix
	rasm 24-jan-96, added residuals plot
	Version 2, ras, 11-April-1996, cleaned documentation, added overplot.
	Version 3, ras, 31-May-1996, added subtitle keyword
	Version 4, ras, 27-aug-1996, fixed for new meaning of group
	added thick keyword
	Version 5, ras, 24-sep-1996, e_in given default definition of ecflux
	Version 6, ras, use call_procedure for batse specific routine, countsmod_plot.
	Version 7, ras, set_graphics used to overwrite colors in window system, 11-sep-1997
	Version 8, ras, used execute for set_graphics call to device, 4-nov-1997
	27-jun-02, ras, added notimestamp keyword


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

 Purpose:  Put up a splash screen on initial window in spex GUI

 Call:  spex_splash

 Kim Tolbert, 14-Apr-2003
 CALLS:


SPEX_STARTUP [1] $SSW/packages/spex/idl/original_spex/spex_startup.pro
[Previous] [Next]
 NAME:   
      SPEX_STARTUP
 PURPOSE:
      setup path and start spex as a subroutine
      important variables available in common block
      Runs spex through command line mode.
 CATEGORY:
      SPEX utility
 CALLING SEQUENCE:
	@[richard.spex.new]spex_startup
 INPUTS:
      none
 OUTPUTS:
      none
 RESTRICTIONS:
	must be run in the interactive mode, or spex_commons won't be
	found until [richard.spex.new] is included in the path 
     
 PROCEDURE:

 MODIFICATION HISTORY:
      ras, 20-aug-94


SPEX_STARTUP [2] $SSW/packages/spex/pre2002/idl/spex_startup.pro
[Previous] [Next]
 NAME:   
      SPEX_STARTUP
 PURPOSE:
      setup path and start spex as a subroutine
      important variables available in common block
      Runs spex through command line mode.
 CATEGORY:
      SPEX utility
 CALLING SEQUENCE:
	@[richard.spex.new]spex_startup
 INPUTS:
      none
 OUTPUTS:
      none
 RESTRICTIONS:
	must be run in the interactive mode, or spex_commons won't be
	found until [richard.spex.new] is included in the path 
     
 PROCEDURE:

 MODIFICATION HISTORY:
      ras, 20-aug-94


spex_summ_define_str $SSW/packages/spex/idl/object_spex/spex_summ_define_str.pro
[Previous] [Next]
 PROJECT:
       HESSI

 NAME:
       spex_summ_define_str

 PURPOSE:
       Defines the structure that contains spex_summ parameters

 Calling arguments:
       nintervals - number of time intervals
       nenergies - number of energy bins
       nparams - total number of parameters for combined function
       ncomp - number of function components in combined function

 CATEGORY:
       gen/fits

 CONSTRUCTION:
       o = spex_summ_define_str(nintervals, nenergies, nparams, ncomp)

 SEE ALSO
 CALLED BY:
	SPEX_FIT__DEFINE, SPEX_READ_FIT_RESULTS
 HISTORY:
       Sep-2004: created - Sandhia Bansal
 Modifications:
 17-Sep-2004, Kim.  Added bk_rate and bk_error
 29-Sep-2004, Kim.  Init spex_summ_filter to -1
 20-Mar-2006, Kim.  Added ncomp arg and spex_summ_func_spectrum, spex_summ_func_model,
   and spex_summ_chianti_version and spex_summ_abun_table


SPEX_SUMMARY [1] $SSW/packages/spex/idl/original_spex/spex_summary.pro
[Previous] [Next]
 NAME:
	SPEX_SUMMARY
 PURPOSE:
	To save and restore variables defined in a SPEX session
 CATEGORY:
	I/O
 CALLING SEQUENCE:
	spex_summary,sumfile,data_tipe,flare,dflts_file,$
	apar_last=apar_last,chi=chi,xselect=xselect,iselect=iselect,tb=tb, $
	prm_spex=prm_spex,style_sel=style_sel,$
	input_line=input_line,check_defaults=check_defaults,/save
 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 PROCEDURE:
    Set sumfile and dflts_file so that they have the same root name
	    with the appropriate suffixes
    Save:
    	if a paramter to be saved isn't defined define it
	save parameters
	run RESTORE_DFLTS using INPUT_LINE
    Restore:
	restore SumFile
	check to see whether background and interval selection
	    have been done
	run SAVE_DFLTS and other commands to set up data using INPUT_LINE

 INPUTS:
   Inputs used to name IDL save file
    SUMFILE     Name of file in which to store parameters
		 Basis of name for save file used here.
    DATA_TIPE   Data_tipe(0) - Instrument, e.g. 'BATSE'
                Data_tipe(1) - Data Mode   e.g. 'CONT', 'SHERS', 'HERS'
    FLARE       flare number.
 OUTPUTS:
    DFLTS_FILE  Name of file in which to store defaults (save_dflts)
 KEYWORDS:
    Parameters to be saved/restored:
    APAR_LAST      Fit Model parameters for last fit to each interval.
    CHI	    Chi-squared vaules
    XSELECT        Time boundaries on accumulation intervals referenced to the
		    same base as UT
    ISELECT        Index of interval boundaries (referenced to FLUX) of
		    accumulation intervals.
    TB             Boundaries of background intervals with same reference
                   time given by ATIME( getutbase(0))
    PRM_SPEX       Structure with display and control parameters
    Other:
    SAVE           Save Parameters (with save_event)
    RESTORE        Restore Paramters (with restore_event)
    INPUT_LINE     Output - commands to be performed after spex_summary
    CHECK_DEFAULTS Given so that it can be reset to original value
    STYLE_SEL      If spectral intervals are in the file this is set to
			'discrete'

 CALLS: ***
	ARR2STR [1], Arr2Str [2], BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3]
	CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], EXIST
	LOC_FILE [1], LOC_FILE [2], LOC_FILE [3], SINCE_VERSION [1], SINCE_VERSION [2]
	break_file [4], concat_dir [4], curdir [1], curdir [2], printx [1], printx [2]
	spex_current [1], spex_current [2]
 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	Changes name of dflts_file so that it has a .dflt extension

 RESTRICTIONS:
	None.

 MODIFICATION HISTORY:
	Written: TAK, September, 1994
	mod, ras, oct 1994
	Version 3, richard.schwartz@gsfc.nasa.gov, made file finding more robust.
	11-jan-2001. Added code to support up to 60 values in a parameter field.
; Version 4, ras, 6-nov-2002, enable up to 200 parameters in spex after 5.1


SPEX_SUMMARY [2] $SSW/packages/spex/pre2002/idl/spex_summary.pro
[Previous] [Next]
 NAME:
	SPEX_SUMMARY
 PURPOSE:
	To save and restore variables defined in a SPEX session
 CATEGORY:
	I/O
 CALLING SEQUENCE:
	spex_summary,sumfile,data_tipe,flare,dflts_file,$
	apar_last=apar_last,chi=chi,xselect=xselect,iselect=iselect,tb=tb, $
	prm_spex=prm_spex,style_sel=style_sel,$
	input_line=input_line,check_defaults=check_defaults,/save
 CALLED BY:
	SPEX_COMMONS [2], SPEX_COMMONS [4], SPEX_PROC [1], SPEX_PROC [2]
 PROCEDURE:
    Set sumfile and dflts_file so that they have the same root name
	    with the appropriate suffixes
    Save:
    	if a paramter to be saved isn't defined define it
	save parameters
	run RESTORE_DFLTS using INPUT_LINE
    Restore:
	restore SumFile
	check to see whether background and interval selection
	    have been done
	run SAVE_DFLTS and other commands to set up data using INPUT_LINE

 INPUTS:
   Inputs used to name IDL save file
    SUMFILE     Name of file in which to store parameters
		 Basis of name for save file used here.
    DATA_TIPE   Data_tipe(0) - Instrument, e.g. 'BATSE'
                Data_tipe(1) - Data Mode   e.g. 'CONT', 'SHERS', 'HERS'
    FLARE       flare number.
 OUTPUTS:
    DFLTS_FILE  Name of file in which to store defaults (save_dflts)
 KEYWORDS:
    Parameters to be saved/restored:
    APAR_LAST      Fit Model parameters for last fit to each interval.
    CHI	    Chi-squared vaules
    XSELECT        Time boundaries on accumulation intervals referenced to the
		    same base as UT
    ISELECT        Index of interval boundaries (referenced to FLUX) of
		    accumulation intervals.
    TB             Boundaries of background intervals with same reference
                   time given by ATIME( getutbase(0))
    PRM_SPEX       Structure with display and control parameters
    Other:
    SAVE           Save Parameters (with save_event)
    RESTORE        Restore Paramters (with restore_event)
    INPUT_LINE     Output - commands to be performed after spex_summary
    CHECK_DEFAULTS Given so that it can be reset to original value
    STYLE_SEL      If spectral intervals are in the file this is set to
			'discrete'

 CALLS: ***
	ARR2STR [1], Arr2Str [2], BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3]
	CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], EXIST
	LOC_FILE [1], LOC_FILE [2], LOC_FILE [3], SINCE_VERSION [1], SINCE_VERSION [2]
	break_file [4], concat_dir [4], curdir [1], curdir [2], printx [1], printx [2]
	spex_current [1], spex_current [2]
 COMMON BLOCKS:
	None.

 SIDE EFFECTS:
	Changes name of dflts_file so that it has a .dflt extension

 RESTRICTIONS:
	None.

 MODIFICATION HISTORY:
	Written: TAK, September, 1994
	mod, ras, oct 1994
	Version 3, richard.schwartz@gsfc.nasa.gov, made file finding more robust.
	11-jan-2001. Added code to support up to 60 values in a parameter field.
; Version 4, ras, 6-nov-2002, enable up to 200 parameters in spex after 5.1


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

 PURPOSE:
	Plot the SPEX count rate as a function of time in one
	   or up to four scaled bands.

 CALLING SEQUENCE:
	spex_thistory, ut, rate, erate, command, data_tipe, edges, $
	  count_2_flux, uflux, title, $
	  t_hist_mode, energy_bands, scale_bands, th_yrange, th_ytype, $
	  real_eband = real_eband, sampav=sampav, ltime=ltime, linestyle=linestyle
 INPUTS:
	Ut - time array 2xnbin in secs. relative to getutbase()
	Rate - count rate (nchan,nbin) usually counts/cm2/s/keV
	Erate - sqrt uncertainties on rate
	Command - spex command, 'graph' - multichannels
	                        'time_history' - integrated standard channels
	Data_tipe- instrument and data format in SPEX
	Edges - 2xnchan - defined energy edges, standard is energy-loss
	Count_2_flux - conversion vector from counts/s to counts/s/kev/cm2
	Uflux - units on rate, a string variable
	Area  - detector area
	Title - string describing observation, instr. & detec & date
 	T_hist_mode - string, 'COUNTS' or 'FLUX' for counts/s or counts/s/kev/cm2
	Energy_bands - nominal bands for plotting
	Scale_bands  - scaling factors for energy_bands display
	Th_yrange   - yrange for plot
	Th_ytype    - ytype for plot, 0 linear, 1 log
	EDG_UNITS   - units of edges, normally keV
	PHOTONS     - If set, then 'Photons' replaces 'Counts' in ytitle
	EPLOTS      - if set, then plot rate uncertainties with error bars
	SAMPAV      - sample average for plotting
	LTIME       - sample livetimes
	LINESTYLE   - vector of linestyles
	OVERPLOT    - If set, overplot input time history
	COLORS	    - referenced to linecolors, defaults [!p.color,3,4,5] for each band
 OPTIONAL OUTPUTS:
	real_eband - actual energy bands displayed
	command(0) may return set to 't_hist_mode'
	RATES_OUT: Plotted Time-history
	UTR_OUT  : Times used for RATES_OUT in seconds from GETUTBASE()
 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHECKVAR [1], DATPLOT, EPLOT, FCHECK, FCOLOR [1], F_DIV
	GETUT [1], GETUT [2], GETUTBASE [1], GETUTBASE [2], GRAPHICS_PAGE, LIMITS
	RESET_XY [1], RESET_XY [2], STR2ARR [1], STR2ARR [2], UTIME [1], UTIME [2]
	UTPLOT [1], UTPLOT [2], UTPLOT [3], UTPLOT [4], UTPLOT [5], UTPLOT [6], checkvar [2]
	edge_products, fcolor [2], read_chanmask [1], read_chanmask [2]
	spex_intervals [1], spex_intervals [2]
 CALLED BY:
	SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_COMMONS [2], SPEX_COMMONS [4]
	SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2], SPEX_PROC [1], SPEX_PROC [2]
 COMMON BLOCKS:
	spex_thistory
 PROCEDURE:
	This procedure integrates over energies to get rates as a function of
	time and then plots them using utplot

 MODIFICATION HISTORY: ras, 15-apr-94
	ras, 20-oct-94, modified to use count_2_flux and multi-band livetime
	ras, 3-aug-95, fixed bug in sample averaging from new livetime array dimensions
	ras, 9-apr-1996, add overplot, RATES_OUT, UTR_OUT, COLORS


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

 PURPOSE:
	Plot the SPEX count rate as a function of time in one
	   or up to four scaled bands.

 CALLING SEQUENCE:
	spex_thistory, ut, rate, erate, command, data_tipe, edges, $
	  count_2_flux, uflux, title, $
	  t_hist_mode, energy_bands, scale_bands, th_yrange, th_ytype, $
	  real_eband = real_eband, sampav=sampav, ltime=ltime, linestyle=linestyle
 INPUTS:
	Ut - time array 2xnbin in secs. relative to getutbase()
	Rate - count rate (nchan,nbin) usually counts/cm2/s/keV
	Erate - sqrt uncertainties on rate
	Command - spex command, 'graph' - multichannels
	                        'time_history' - integrated standard channels
	Data_tipe- instrument and data format in SPEX
	Edges - 2xnchan - defined energy edges, standard is energy-loss
	Count_2_flux - conversion vector from counts/s to counts/s/kev/cm2
	Uflux - units on rate, a string variable
	Area  - detector area
	Title - string describing observation, instr. & detec & date
 	T_hist_mode - string, 'COUNTS' or 'FLUX' for counts/s or counts/s/kev/cm2
	Energy_bands - nominal bands for plotting
	Scale_bands  - scaling factors for energy_bands display
	Th_yrange   - yrange for plot
	Th_ytype    - ytype for plot, 0 linear, 1 log
	EDG_UNITS   - units of edges, normally keV
	PHOTONS     - If set, then 'Photons' replaces 'Counts' in ytitle
	EPLOTS      - if set, then plot rate uncertainties with error bars
	SAMPAV      - sample average for plotting
	LTIME       - sample livetimes
	LINESTYLE   - vector of linestyles
	OVERPLOT    - If set, overplot input time history
	COLORS	    - referenced to linecolors, defaults [!p.color,3,4,5] for each band
 OPTIONAL OUTPUTS:
	real_eband - actual energy bands displayed
	command(0) may return set to 't_hist_mode'
	RATES_OUT: Plotted Time-history
	UTR_OUT  : Times used for RATES_OUT in seconds from GETUTBASE()
 CALLS: ***
	ARR2STR [1], Arr2Str [2], CHECKVAR [1], DATPLOT, EPLOT, FCHECK, FCOLOR [1], F_DIV
	GETUT [1], GETUT [2], GETUTBASE [1], GETUTBASE [2], GRAPHICS_PAGE, LIMITS
	RESET_XY [1], RESET_XY [2], STR2ARR [1], STR2ARR [2], UTIME [1], UTIME [2]
	UTPLOT [1], UTPLOT [2], UTPLOT [3], UTPLOT [4], UTPLOT [5], UTPLOT [6], checkvar [2]
	edge_products, fcolor [2], read_chanmask [1], read_chanmask [2]
	spex_intervals [1], spex_intervals [2]
 CALLED BY:
	SPEX_BACKGROUND [1], SPEX_BACKGROUND [2], SPEX_COMMONS [2], SPEX_COMMONS [4]
	SPEX_PLOT_SAVED [1], SPEX_PLOT_SAVED [2], SPEX_PROC [1], SPEX_PROC [2]
 COMMON BLOCKS:
	spex_thistory
 PROCEDURE:
	This procedure integrates over energies to get rates as a function of
	time and then plots them using utplot

 MODIFICATION HISTORY: ras, 15-apr-94
	ras, 20-oct-94, modified to use count_2_flux and multi-band livetime
	ras, 3-aug-95, fixed bug in sample averaging from new livetime array dimensions
	ras, 9-apr-1996, add overplot, RATES_OUT, UTR_OUT, COLORS


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

 Purpose: Widget to set albedo options in ospex

 CATEGORY:  SPEX

 Calling sequence:  o->xalbedo

 Input arguments:
   group - widget id of calling widget

 Output: the changed values are set in the ospex object


 Written:  Kim, 8-Sep-2004
 Modifications:


spex_xsm_fits2drm $SSW/packages/spex/idl/object_spex/xsm/spex_xsm_fits2drm.pro
[Previous] [Next]

 NAME:
   spex_xsm_fits2drm

 PURPOSE:
   Read FITS formatted XSM response matrix File (RMF) and Ancilliary Response File (ARF),
   multiply the two to create the Detector Response Matrix (DRM) and return information of
   interest to OSpex.
 CALLED BY:
	SPEX_DRM__DEFINE
   NOTE: This procedure is based on spex_hessi_fits2drm.


 CATEGORY:
       SPECTRAL FITTING, SPEX - XSM

 CALLING SEQUENCE:

 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FITSREAD, FXPAR [1], FXPAR [2], GET_EDGES, GET_FITS_INSTR
	LOC_FILE [1], LOC_FILE [2], LOC_FILE [3], break_file [4], concat_dir [4], fits2rm
	st2num
 INPUTS:

 OUTPUTS:

 INPUT KEYWORDS:
   RMFFILE - name of FITS file to read (contains RMF).

   SFILE - not used.  Included for Spex comptability.

 OUTPUT KEYWORDS:
     drm_str - structure with drm info

 PROCEDURE:

 Written 23-Nov-2004  - Sandhia Bansal

 Modification History:
 12/08/04 - Sandhia Bansal - Modified a comment.
   23-jun-2005, richard.schwartz@gsfc.nasa.gov - removed ancrfile from arg list
     ancrfile name given by rmffile header and these two
   are combined based on the number of channels in the files, does not assume 512
   24-jun-2005, ras, corrected drm normalization, removed division by photon bin width
   27-jun-2005, ras, normalized arf by nominal geometric area


spex_xsm_specfile__define $SSW/packages/spex/idl/object_spex/xsm/spex_xsm_specfile__define.pro
[Previous] [Next]

 NAME:
   spex_xsm_specfile__define

 PURPOSE:
   Provides read_data method for the XSM instrument.
   NOTE: This procedure is based on spex_hessi_specfile__define.


 CATEGORY:
       SPECTRAL FITTING, SPEX - XSM

 CALLING SEQUENCE:

 CALLS: ***
	SPEX_XSM_SPECFILE::READ_DATA, SPEX_XSM_SPECFILE_TEST, UTIME [1], UTIME [2]
	read_xsm_4_ospex
 INPUTS:

 OUTPUTS:

 INPUT KEYWORDS:

 OUTPUT KEYWORDS:

 PROCEDURE:

 Written 23-Nov-2004  - Sandhia Bansal

 Modification History:
 Sandhia Bansal - 12/08/04 - Specified a xsm file in the test routine.


SPEXGUI $SSW/packages/spex/idl/object_spex/spex__gui.pro
[Previous] [Next]
 Name: SPEX::GUI

 Purpose: OSPEX method to provide main widget to handle everything.

 Category: OSPEX

 Calling sequence:  o -> gui  (o is an ospex object)

 Modifications:
 20-Jul-2004, Kim.  Added buttons to send setup and fit summary to printer or file as
     well as the screen.
 09-Aug-2004, Sandhia, Added an option to set parameters manually.
 24-Aug-2004, Sandhia, Added buttons for FITS or IDL save (genx) output file for results
 5-Oct-2004, Kim.  Added buttons to set params from script procedure.
 18-Nov-2004, Sandhia.  Added buttons to write rate files with following options:
                       - binned background-subtracted data
                       - binned data/background data
                       - background-subtracted data in original time intervals
                       - data/background in original time intevals
 9-Feb-2006, Kim.  clearall changed to init_params
 15-Mar-2006, Kim. added gui_label to put on title bar of spex widget interfaces
 9-May-2006, Kim.  Disabled option to write fit results in save (genx) file


SPEXXFIT $SSW/packages/spex/idl/object_spex/spex__xfit.pro
[Previous] [Next]
 Name: SPEX::XFIT

 Purpose: OSPEX method to provide widget to handle fit intervals and fit options.

 Category: OSPEX

 Calling sequence:  o -> xfit  (o is an ospex object)

 Modifications:
 22-Jun-2004, Kim.  Replaced spex_interval_range with spex_intervals_tofit
 20-Jul-2004, Kim.  Added 'Remove Bad Intervals' and 'Show Filter States' buttons, and
	changed show erange and show fit intervals so they show on current plot if the
   right type, rather than drawing new plot every time.
 12-Aug-2004, Kim.  Made the Remove Bad Intervals and Show Fit Intervals menu buttons with
   two options each.  For remove, choose whether to remove from defined or selected list.
   For show, choose whether to show all or just selected intervals.  Also, when drawing intervals
   if a utplot is already up, refresh it just to clear what was already on it.
 16-Sep-2004, Kim.  Added 'Show Error' button for plots.
 5-Oct-2004, Kim.  Made an Adjust Intervals button and moved remove bad options to menu items
	under that button, and added another item - force to data boundaries.
 11-Apr-2005, Kim.  Got rid of Show Filter States button (now all time plots show filters)
 18-Aug-2005, Kim.  'All raw time intervals' now only uses raw time intervals with non-zero
	data in at least some energy bin.  Also, use spex_deconvolved flag to decide whether
	Photon button should be sensitive.  Use new units_widget gen method to handle units.
	Also, added class_name where possible to speed up.
 10-Feb-2006, Kim.  Add 0. to dropdown list for systematic uncertainty
 15-Mar-2006, Kim. added gui_label to put on title bar of spex widget interfaces
 7-Apr-2006, Kim.  Added Show Function button and changed some wording on widget for clarity
 2-Jul-2006, Kim.  Added Set to 'spex_tband' button. And corrected spex__erange plot to plot intervals
  selected (before plotting minmax(sel_intervals))
 31-Oct-2006, Kim. If all fitint_filters aren't the same, show the filter for each interval in
  the list of times in parentheses.  Also change plot to show intervals to use plot_time method,
  and use /show_filter option.
 1-Nov-2006, Kim.  Added options to select intervals based on filter and plot limits.
 14-Nov-2006, Kim. In xfit_update_times, do getdata on fitint class to make sure we have
  the current filters.  (Unfortunately needed, but hopefully not too time-consuming). Also
  save filters in self, and compare to new - if same and times are same don't redo time int list.


SPEXXINPUT $SSW/packages/spex/idl/object_spex/spex__xinput.pro
[Previous] [Next]
 Name: SPEX::XINPUT

 Purpose: OSPEX method to provide widget to handle input file selection and plotting
   of raw data.

 Category: OSPEX

 Calling sequence:  o -> xinput  (o is an ospex object)

 Modifications:
 20-Jul-2004, Kim.  Added buttons to preview all spectrum or srm files in current dir.
 16-Sep-2004, Kim.  Added showing albedo settings, and change button for them
 ?-Dec-2004,  Kim.  Added roi stuff for SPEX_HESSI_IMAGE strategy
 17-Aug-2005, Kim.  If spex_pseudo_livetime set, don't allow counts to be plotted.
   Desensitize ROI stuff if input is not an image cube.  Use new units_widget gen
   method to handle units.  Use plot_time and plot_spectrum instead of plot method
   of data object.  Made 'Select Regions' button a pulldown with Config and Select.
	Added Region Number box.
 9-Feb-2006, Kim.  Added spex_image_full_srm option (added button on ROI line)
 15-Mar-2006, Kim. added gui_label to put on title bar of spex widget interfaces
 2-Jul-2006, Kim.  Added buttons for spex_tband
 28-Jul-2006, Kim.  Added timeshift widget, and de-sensitize drm if input is soxs


ssc_files [1] $SSW/packages/findstuff/idl/ssc_files.pro
[Previous] [Next]
   Name: ssc_files

   Purpose: return SXT ssc (or sss/sxh) file names from user times

   Input Parameters:
      time0 - time to match or start time of range
      time1 - end time of range

   Keyword Parameters:
      count - number of files returned
      topdir - optional top level path (default via env: DIR_SXT_{SSC/SSS/SXH
      sss_files (switch) if set, consider SSS files ("show" movie"
      sxh_files (switch) if set, consider SXH files (histograms)
      extension - ssc processing flags<=>file extension
      collapse - if set, assume all files in top level  
                 (default is yearly subdirect: <toplev>/YYYY/xxxyyyy...
      prefix - specilized file prefix (default is derived from file_type
               uaually 'ssc', 'sss', 'sxh' 
     
 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE2TIME, TIME2FILE
	UNIQ [1], UNIQ [2], UNIQ [3], anytim [1], anytim [2], anytim [3], anytim [4]
	anytim [5], concat_dir [4], data_chk [1], data_chk [2], get_logenv [1]
	get_logenv [2], get_yo_dates [1], get_yo_dates [2], get_yo_dates [3]
	reltime [1], reltime [2], sel_filetimes [1], sel_filetimes [2], strsplit
	tim2dset [1], tim2dset [2], time_window, timegrid
 CALLED BY:
	get_ssc_best, sxt_ssc2file
   History:
      6-July-2000 - S.L.Freeland - helper routine 
      9-May-2001  - S.L.Freeland - add PREFIX keyword

   Method: 
      ssw standards like anytim, sel_filetimes, get_logenv,...


ssw_findstuff2html $SSW/packages/findstuff/idl/ssw_findstuff2html.pro
[Previous] [Next]
   Name: ssw_findstuff2html

   Purpose: Provide summary HTML for one 2D image
 CALLS:


ssw_findstuff_struct $SSW/packages/findstuff/idl/ssw_findstuff_struct.pro
[Previous] [Next]
   Name: ssw_findstuff_struct

   Purpose: make the ssw_limb catalog structure (index+rinfo)

   Input Paramters:
      index,data,reg,rinfo (output of ssw_limbstuff.pro)
  
   Calling Sequence:
      catstruct=ssw_findstuff_struct(index,data,reg,rinfo)
  
 CALLS: ***
	JOIN_STRUCT [1], JOIN_STRUCT [2], data_chk [1], data_chk [2], str_subset
   History:
      Circa August 1996 - For EIT He304 investigations
      29-June-2000 - S.L.Freeland - for general SSW use


ssw_fs_cat2db $SSW/packages/findstuff/idl/ssw_fs_cat2db.pro
[Previous] [Next]
   Name: ssw_fs_cat2db

   Purpose: return reqion (blob) DB or original data for findstuff cat entries

   Input Parameters:
      cat - catalog entry/entries of interest

   Output Parameters:
      index,data - corresponding region (blob) DB or original data 

   Keyword Parameters:
      original - if set, output index,data is original data
                 (default is the region (blob) data base)

 CALLS: ***
	ALL_VALS [1], ALL_VALS [2], BOX_MESSAGE, FILE2TIME, FILE_EXIST [2], anytim [1]
	anytim [2], anytim [3], anytim [4], anytim [5], file_exist [1], file_exist [3]
	file_list [1], file_list [2], mreadfits, restgenx, tim2dset [1], tim2dset [2]
   History:
      31-August-2001 - S.L.Freeland


ssw_fs_maskdbase $SSW/packages/findstuff/idl/ssw_fs_maskdbase.pro
[Previous] [Next]
   Name: ssw_fs_maskdbase

   Purpose: return desired subsets of the findstuff region/blob dbase

   Input Parameters:
      dbindex,dbdata - index,data from dbase (FITS) file(s) / 3D OK

   Keyword Parameters:
      cat - optional catalog entry to match
      rnum - return mask for this region number
      rlevel - return subset of regions of this level
               original region numbering is preserved


   Calling Sequence:
      ssw_fs_maskdbase, dbindex, dbdata,omask, [OPTIONS]

   Calling Example:

      (explicit dbase file list or as derived from catalog search)

      IDL> mreadfits,dbasefiles,dbindex,dbdata       
      IDL> ssw_fs_maskdbase,dbindex,dbdata,mask,rlevel=0  
           This call masks/returns the data which falls in 
           the "first level" - see the following tags in DBINDEX
           IDL> help,dbindex,/str
           (...)
   INFILE          STRING    'crb_dc_AM_512_19911110_153557.fits' ; INPUT FILE
   LOWCUT          STRING    '1,16,100,1000'        ; lower threshold
   HICUT           STRING    '15,99,1001,50000'     ; uper threshold
   RLIMITS         STRING    '0,64,128,192'         ; boundries
  
 The above dbase contains 4 sets of regions:

    Count-Range    Region#(pixel values)
    Low   Hi   
     1    15       0   - 63        Note that for each level, pixel values
    16    99       64  - 127       equal to the boundries (0,64,128,192)
   100  1000       128 - 191       indicate all pixels which are NOT a 
  1001  (N/A)      192 - 255       member of any region in that level.
      

 CALLS: ***
	BOX_MESSAGE, STR2ARR [1], STR2ARR [2], data_chk [1], data_chk [2], gt_tagval [1]
	gt_tagval [2]
   History:
      31-August-2001 - S.L.Freeland


STEREO_LOOP $SSW/packages/stereo/idl/stereo_loop.pro
[Previous] [Next]
 Project     : YOHKOH/SXT,HXT - SOHO/EIT,CDS - TRACE 

 Name        : STEREO_LOOP()

 Purpose     : 3D Stereoscopic reconstruction of coronal loops 

 Category    : 3D Reconstruction, Stereoscopy, Data Analsis 

 Explanation : The user selects two solar images that contain
		a similar field of view with coronal loop structures.
		The images are then filtered to enhance the contrast
		and the user interactively traces a loop feature, from
		which a 3D reconstruction is attempted by stereoscopic
		correlation according to the "dynamic steroscopy"
		method described in the reference
		"3D-Stereoscopic Analysis of Solar Active Region Loops:
		I.SoHO/EIT Observations at Temperatures of 1.0-1.5 MK"
		(Aschwanden, Newmark, Delaboudiniere, Neupert,
		Klimchuk, Gary, Portier-Fozzani, and Zucker 1998, 
		THE ASTROPHYSICAL JOURNAL, in press). 
		URL="ftp://sag.lmsal.com/pub/aschwand/1998_stereo.ps.gz"

 Syntax      : IDL> stereo_loop,index1,data1,index2,data2 

 Examples    : IDL> ssw_packages,/stereo
		IDL> trace_cat,'1-jun-1998 12:00','1-jun-1998 13:00',cat1
               IDL> trace_cat,'2-jun-1998 12:00','2-jun-1998 13:00',cat2
		IDL> ind1=where((cat1.wave_len eq '171')and(cat1.naxis1 eq 1024))
		IDL> ind2=where((cat2.wave_len eq '171')and(cat2.naxis1 eq 1024))
		IDL> trace_cat2data,cat1(ind1(0)),index1,data1
		IDL> trace_cat2data,cat2(ind2(0)),index2,data2
               IDL> stereo_loop,index1,data1,index2,data2

 Inputs      : index1	- structure containing descriptors of data1 
		data1 	- image at time t1 (reference time)  
               index2	- structure containing descriptors of data2 
		data2 	- image at time t2 (e.g.from following or previous day) 

 Opt. Inputs : None 

 Outputs     : 3 files are written with a filename *** specified by the user,
		(Parameters are appended to these files in each subsequent run):
		***.trace :containing coordinates of loop traced by user
			     [iloop,i,x(i),y(i)]
		***.trace2:containing 3D coordinates of reconstructed loop
		             [iloop,i,base,az,th,x(i),y(i),zz(i),xl(i),zl(i)]
		***.para  :containing geometric parameters of reconstructed loop
			     (iloop,nw,l1,b1,base,dbase,az,daz,th,dth)

 Opt. Outputs: None

 Keywords    : None

 CALLS: ***
	ARCTAN, ARRAY_CURVE, CONCAT_STRUCT, COORD_ADDINDEX, COORD_CART_HELIO [1]
	COORD_CART_HELIO [2], COORD_HELIO_CART, FIG_CLOSE, FIG_MULTI_POS, FIG_MULTI_TV
	FIG_OPEN, HELIO_LOOPCOORD, HELIO_LOOPCOORD2, HELIO_TRANS, HELIO_TRANS2, LOADCT
	LOOP_INTERPOL, LOOP_SMOOTH, READCOL [1], READCOL [2], READCOL [3], REVERSE
	SMOOTH_EDGE, SMOOTH_FLATEDGE, STEREO_GUIDE, clearplot [1], clearplot [2]
 Common      : None

 Restrictions: None 

 Side effects: None

 History     :  6-Oct-1998, Version 1, Markus J. Aschwanden. Written
		12-Nov-1998, higphass filtering by subtracting smoothed image 
		24-Apr-2002, cos_b=cos( (!pi/180.)*(b1+b2)/2. ) corrected by Costis Gontikakis

 Contact     : aschwanden@sag.lmsal.com


STEREO_SIMUL $SSW/packages/stereo/idl/stereo_simul.pro
[Previous] [Next]
 Project     : STEREOSCOPY 

 Name        : STEREO_SIMUL()

 Purpose     : Test stereoscopy code 

 Category    : 3D data analysis, stereoscopy

 Explanation : simulates a "stereo pair" of images DATA and structures INDEX
		that mimic a static coronal loop with prescribed geometry and 
		is projected according to the solar rotation rate

 Syntax      : IDL> stereo_simul,date_obs,days,res,baseline,l1,b1,az,th,
			index1,data1,index2,data2

 Examples    : IDL> ssw_packages,/stereo
		 date_obs='2000-01-01T00:00:00.000Z
		 days    =[-4,2.]  ;time difference in days
		 res     =2.5      ;pixel size [in arcseconds]
		 baseline=100.     ;loop footpoint separation [in arcseconds]
		 l1      =30.      ;heliograph. long. of one footpoint [deg]
		 b1      =40.      ;heliograph. lat.  of one footpoint [deg]
		 az      =50.      ;azimuth angle of loop baseline to EW direction
		 th      =60.      ;inclination angle of loop plane to vertical 
		 stereo_simul,date_obs,days,res,baseline,l1,b1,az,th,
			     index1,data1,index2,data2
		 stereo_loop,index1,data1,index2,data2

 Inputs      : date_obs	=Date of observation 
		days		=day difference to reference time [date_obs] 
		res		=resolution of image [arcseconds]
		baseline	=footpoint separation in heliographic degrees
		l1		=heliographic longitude of 1st loop footpoint
		b1		=heliographic latitude  of 1st loop footpoint
		az		=aziumuth angle of loop baseline to EW direction
		th		=inclination angle of loop plane

 Opt. Inputs : None

 Outputs     : index1		=structure of 1st stereo image 
  		data1		=image     of 1st stereo image 
  		index2		=structure of 2nd stereo image 
  		data2		=image     of 2nd stereo image 

 Opt. Outputs: None

 Keywords    : None

 CALLS: ***
	GET_SUN [1], GET_SUN [2], HELIO_LOOPCOORD, HELIO_TRANS2, LOADCT, anytim [1]
	anytim [2], anytim [3], anytim [4], anytim [5], sswfits_struct [1]
	sswfits_struct [2], timegrid
 Common      : None

 Restrictions: None

 Side effects: None

 History     : Version 1,  14-OCT-1998,  Markus J. Aschwanden.  Written
		update documentation, 7-NOV-1998, MJA

 Contact     : aschwand@sag.lmsal.com 


struct_eq $SSW/packages/ztools/util/struct_eq.pro
[Previous] [Next]
 NAME:
	struct_eq

 PURPOSE:
	Return whether two structures have equal values to a set list of tags

 USAGE:
	eq = struct_eq(a,b,tags)

 Inputs:
	A	- a structure (or array of structures)
	B	- a structure (or array of structures)
	TAGS	- an array of tag names to check
 CALLS:


sum_dt_genx $SSW/packages/lparl/idl/ucon/tarbell/sum_dt_genx.pro
[Previous] [Next]
NAME:
       sum_dt_genx
PURPOSE:
       To summarize a set of detune GENX data results
SAMPLE CALLING SEQUENCE:
      sum_dt_genx,dt
INPUT:
       dt = structure (presumably averaged) of GENX detune results
 CALLS: ***
	v_orbital
 CALLED BY:
	av_dt_genx
OPTIONAL KEYWORD INPUT:
OUTPUT:
	This version simply prints out the means of M1 & M2 using the mask dt.m
HISTORY:
       Written 30-Dec-97 by T. Tarbell
	27-Mar-00 (TDT) - put online, compute the means using standard IDL


SUNEARTHDIST $SSW/packages/ztools/vectors/sunearthdist.pro
[Previous] [Next]
 NAME:
	SUNEARTHDIST
 PURPOSE:
	Returns the distance from the Sun to the Earth
	in a convenient calling package
 METHOD:
 	Very cheesey.  We call PB0R and use the R coordinate
	to calculate the solar distance.  There's almost
	certainly a better way.
 CALLING SEQUENCE:
	r = sunearthdist("12-Sep-1997")
 	r = sunearthdist("12-Sep-1997","inches")

 RETURNS:
	Distance from earth to Sun in kilometers, or in 
	the unit you specify in the second parameter.

 AUTHOR:
	Craig DeForest
 CALLS: ***
	ISVALID [1], ISVALID [2], ISVALID [3], NLM [1], NLM [2], zpb0r [1], zpb0r [2], zunits
 CALLED BY:
	V4XS2SC, V4XSC2S
 HISTORY:
	9-Oct-1997 initial implementation
	10-Oct-1997 made vector-safe.


SUTHERLAND $SSW/packages/chianti/idl/low_level/continuum/sutherland.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:
	SUTHERLAND

 PURPOSE:

	Calculate the free-free continuum from an hot, low density plasma

       Uses the free-free gaunt factor calculations of Sutherland, 1998, 
       MNRAS, 300, 321.

       Note that Sutherland's Eq.(15) has units of erg/cm^3/s. Comparing 
       with Rybicki & Lightman's Eq.5.14(a) (in their book 'Radiative 
       Processes in Astrophysics'), suggests that Sutherland's units 
       should be erg/cm^3/s/sr/Hz. We are assuming the latter to be 
       correct in this routine.

       When using the DEM_INT optional input, FREEFREE expects the 
       differential emission measure to have been derived from a product 
       of N_e*N_H rather than N_e*N_e. This can be important when dealing 
       with a regime (typically T < 10^4.5) where H and He are not fully 
       ionised.

 CALLING SEQUENCE:

       SUTHERLAND,temperature, wavelength, intensity


 INPUTS:

	T	   Temperature in degrees Kelvin, can be a 1 D array

       WVL        Wavelength in Angstroms. If /keV is set, then WVL is
                  assumed to contain energies in keV units.


 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.  
                  This can speed up the calculations. ;

	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.

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

       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.
	
       KEV        If set, then WVL is assumed to contain energies in keV
                  units rather than wavelengths in Angstroms.

 OUTPUTS:

	RAD        Free-free continuum intensity in units
                  10^-40 erg cm^3 s^-1 str^-1 angstrom^-1 per unit 
                  emission measure [ integral (N_e N_H dh) in cm^-5 ]. 
                  If T is given as a 1-D array, then RAD will be output 
                  as 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

 PROGRAMMING NOTES

     The gaunt factors from Sutherland (MNRAS 300, 321, 1998) are a 
     function of uu and gg (see his Eq. 14). uu is a function of both 
     wavelength and T, while gg is a function of T only.

     The gaunt factor (gff) is tabulated for values of uu and gg at 
     fixed intervals in log(uu) and log(gg). The log(uu) values go from 
     -4 to 4 in 0.2 steps; the log(gg) values go from -4 to 4 in 0.1 steps.

     A particular (input) temperature and wavelength give rise to values 
     uu0 and gg0, the logs of which lie between -4 and 4. To derive the 
     corresponding gff0 value, I use the IDL routine BILINEAR. 

     BILINEAR requires, not uu and gg values as input, but indices. 
     E.g., the indices corresponding to the tabulated values of uu are 
     0 (=-4.0), 1 (=-3.8), 2 (=-3.6), etc. Thus, if log(uu0)=-3.76, then 
     i_uu0=1.20 is the index of uu0.

     In order to make significant time-savings, I give BILINEAR all of 
     the wavelengths and temperatures in the same call for a particular 
     ion. To do this, I make my i_uu and i_gg values 2-D arrays of size 
     (nwvl x nT), and BILINEAR then produces a (nwvl x nT) array 
     containing the gff values.

     A problem occurred if nT=1, as BILINEAR will turn the input uu and 
     gg vectors into 2-D arrays of size (nwvl x nwvl). If there are a 
     large number of wavelengths, this uses a lot of memory. To solve 
     this I make a 2 element temperature vector whose values are 
     identical, and then change this back to a 1 element vector after 
     BILINEAR has been called. See the parts of the code where I use 
     'tst1'.


 CALLS: ***
	BILINEAR, READ_GFFGU, REVERSE, SETUP_ELEMENTS
 CALLED BY:
	freefree
 COMMON BLOCKS:

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

 CALLS

       READ_IP, READ_GFFGU, SETUP_ELEMENTS

 EXAMPLES:

       IDL> freefree,1.e+6,wvl,int
       IDL> freefree,1.e+6,wvl,int,min_abund=3.e-5
       IDL> freefree,1.e+6,wvl,int,/no_setup,min_abund=1.e-6

       IDL> wvl=findgen(5001)/10. + 50.
       IDL> temp=10.^(findgen(41)/10. +4.)
       IDL> freefree,temp,wvl,int


 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	March 1999:     Version 2.0
       September 1999:  Version 3.0

       Ver.3.1, 11-Aug-00, Peter Young
           Improved call to bilinear, allowing routine to solve for 
           all temperatures in one go. This makes the routine quicker, 
           and also lowers the memory usage of the routine when dealing 
           with many wavelengths.

       Ver.3.2, 16-Aug-00, Peter Young
           Corrected expression for 'gg', replacing ip with z^2.

       Ver.3.3, 16-Oct-00, Peter Young
           Now deals with dem_int correctly

       Ver.3.4, 10-Oct-01, Ken Dere
           Corrected for labelling errors in Sutherland's gffgu.dat file
           No longer reads ionization potential file

       Ver.3.5, 5-Dec-01, Peter Young
           Corrected expression for gamma^2
           Renamed routine sutherland.pro
           Restructured code to make it run quicker.

       Ver.3.6, 22-May-01, Peter Young
           Re-instated the MIN_ABUND optional input. 
           Changed ioneq_t to ioneq_logt (GDZ).

       Ver.3.7, 18-Aug-03, Peter Young
           Activated /PHOTONS keyword

       Ver.3.8, 5-Nov-03, Peter Young
           Corrected bug found by Jim McTiernan when multiple temperatures
           were input. The quantity 'newfactor' was not being calculated
           correctly due to indexing problems.

       Ver. 4, 9-Mar-2006, Peter Young
           Added /keV keyword.


sxt_decomp [1] $SSW/packages/andril/idl/sxt_deco.pro
[Previous] [Next]
  NAME:
       sxt_decomp

  PURPOSE:
       Decompress an SXT image
	Optionally return decompression uncertainty

  CALLING SEQUENCE:
	u_data = sxt_decomp(data,unc_data)
	u_data = sxt_decomp(data,unc_data)
	u_data = sxt_decomp(data,/silent)
	unc_data = sxt_decomp(data,/uncertainty)   ; return uncertainties only

  INPUT:
	data	= Compressed DN (byte-type)
		  data MUST be byte type.  If not, data is returned
		  and an informational message is displayed at tty.

  OPTIONAL INPUT PARAMETER:
	silent	= If set, don't send a message if data is not byte type
	uncertainty = If set, return uncertainties.

  OUTPUT:
	Returns decompressed data (integer type) 
	or      uncertainties (byte type) if the /uncertainty switch is set.

  OPTIONAL OUTPUT:
	unc_data= Decompression uncertainty

 CALLS: ***
	SXT_DECO
 CALLED BY:
	BONEHEAD_MASS_ESTIMATE, BOXLC_DISPLAY, COMPOSITE, FILT4_SIM, GLITCH_TRACKER
	GO_FIND_LIM2, GO_FIND_LIMB, LWA_TE, PFI_TOTALIZER, QUICKDARK [2], QUICKSTRAY [2]
	RD_AR, RESTORE_FFI, RESTORE_LOW8 [1], RESTORE_LOW8 [3], SDC_VERIFY, SXT_PREP0
	SXT_TE, SXT_TEEM1 [1], SXT_TEEM1 [2], SXT_TEEM1 [3], WL_CUBE_II, ars_exp, change_res
	dark_sub [1], dark_sub [2], dark_sub [3], deka_norm [1], deka_norm [2], dn2ph
	exp_norm [1], exp_norm [2], exp_norm2, fit_limb, get_dc_image [2]
	get_dc_image [3], get_sdl_avg, go_lasdisk golaserdisk, go_lasdisk2 golaserdisk
	go_nvs4, go_nvs5, interp_img, lwa_te_intact, mc_unc, mk_desat, mk_sdm, mk_sdmi
	mk_sfd [1], mk_sfd [2], mk_sfd [3], mk_sfd [4], mk_sl [1], mk_sl [2], mk_strip_file
	ocenter, ptv_sxt, rest_low8_cube [1], rest_low8_cube [2], rest_low8_ffi, rm_df
	sho_max, sxt_dn2ph, sxt_prep [1], sxt_prep [2], sxt_prep [3], unsharp_mask
  HISTORY:
	28-jan-93, J. Lemen, Added uncertainty code.  
			     Adapted from J. Mctiernan Spring '92 version
	22-feb-93, JRL, Force unc_data to be byte type
	 9-mar-93, JRL, Added the /uncertainty switch


sxt_psd $SSW/packages/andril/idl/sxt_psd.pro
[Previous] [Next]
NAME:
	sxt_psd

PURPOSE:
	Returns an image of the SXT point-spread-function.

INPUT PARAMETERS:
	index = SXT image index, used to get image center, filter.
				OR
       filter = number of the X-ray analysis filter, GT-FILTB convention.
	xc, yc = center of FOV in CCD Full Resolution pixels.

OUTPUT:
       psf = image of the psf, full-resolution pixels.  Default is:
               odd dimension (65x65), array centered,
               normalized to unit integral.  This is
               intended for use by IDL procedure CONVOL.

 OPTIONAL INPUT KEYWORDS:
	dim = size of output PSF image in Full-resolution pixels.  Default = 65.

       div = No of divisions per pixel	;JS

	fourier = Return psf ready for use by IDL procedure FFT.
		Psf image is dimensioned power of 2 (64 x 64),
		corner centered, normalized to unit mean.

	moffat = returns Moffat psf only.  Scattering wings not
		included.

	log10t = Log10 of temperature.  The Moffat parameters
		are wavelength, and therefore, temperature
		dependent.  Default uses values derived
		assuming equal emission measures at all
		temperatures  5.5 <= log10t <= 8.0.


 CALLING EXAMPLES:
	psf = SXT_PSF(index)
	psf = SXT_PSF(filter, xc, yc)

 METHOD:
	Uses the Moffat function fits described by Piet Martins.
	Adds scattering wings described by Acton.
	Wavelength weighting done by SXT_WEIGHT procedure.

 RESTRICTION:
	Scattering is only known for thin filters.  Scattering
	for the thick filters is unknown but is expected to be larger.

 CALLS: ***
	STDEV, gt_center, gt_filtb
 CALLED BY:
	ANDRIL_SXT
 HISTORY:
	Written April 4, 1994   Barry LaBonte
	Added /DIM keyword  May 23, 1994  BJL
	Added /FOURIER, /MOFFAT keywords, scattering wings.  June 27, 1994 BJL
	Modified to use Moffat parameters weighted
		by SXT passband - Mewe spectrum product,
		added /LOG10T keyword.  March 24, 1995  BJL
		added /DIV  keyword and made it double precision JS Jan. 98


SYNTHETIC $SSW/packages/chianti/idl/synthetic.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:
	SYNTHETIC

 PURPOSE:

       calculates a synthetic spectrum


 PROCEDURE:

                 Calculations are done assuming either constant density or
                 constant pressure. See CH_SYNTHETIC for details.


 CALLING SEQUENCE:

       SYNTHETIC,Wmin, Wmax, Fwhm, Pressure= , Lambda, Spectrum ,List_wvl, List_ident
                 ,[/all, density=, /cont, min_abund=]


 INPUTS:


	Wmin:   lower limit of the wavelength/energy range of interest (Angstroms)

	Wmax:   upper limit of the wavelength/energy range of interest (Angstroms)

       Pressure:  pressure in emitting region (cm^-3 K), or 
       Density:   density in emitting region (cm^-3).

       Fwhm:  gaussian full width at half maximum of the resolution of the output 
                  spectrum, for example, to correspond to an observed spectrum


 OPTIONAL INPUTS:

	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   


       MIN_ABUND:  If set, calculates the continuum only from those elements which 
                   have an abundance greater than min_abund. 

	DEM_NAME:  Name of the DEM file to used.  If not passed, then the user
		   is prompted for it.

	ABUND_NAME:  Name of the abundance file to use.  If not passed, then
		     the user is prompted for it.

	IONEQ_NAME:  Name of the ionization equilization name to use.  If not
		     passed, then the user is prompted for it.

       RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

       RADTEMP The blackbody radiation field temperature (default 6000 K).
 

 OUTPUTS:

       Lambda:  wavelength array of calculated synthetic spectrum
       Spectrum:  intensity array (erg cm^-2 s^-1 str^-1 Ang^-1),
                  unless keyword photons is set then output is is
                  photons cm^-2 s^-1 str^-1 Ang^-1
       List_wvl:  a list of wavelengths for use with synthetic_plot.pro
       List_ident:  a list of line identifications for use with 
                        synthetic_plot.pro

 OPTIONAL OUTPUTS:

	
 KEYWORD PARAMETERS:

     
	ALL:  if set, then all lines are included.  This means that lines for which
             only an approximate wavelength is known (only theoretical energy
             levels are known) are included.

	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   

       CONTINUUM:   if set, then the continuum (free-free, free-bound and
                  two-photon) are  included 

       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, from Allen (1973):
                   abundance (H)  = 1.
                   abundance (He) = 0.085
                   abundance (C)  = 3.3e-4
                   abundance (O)  = 6.6e-4
                   abundance (Si) = 3.3e-5
                   abundance (Fe) = 3.9e-5



	PHOTONS:  if set, intensities are in photons cm^-2 s^-1 sr^-1 Ang^-1

	DEM_NAME:  Name of the DEM file to used.  If not passed, then the user
		   is prompted for it.

	ABUND_NAME:  Name of the abundance file to use.  If not passed, then
		     the user is prompted for it.

	IONEQ_NAME:  Name of the ionization equilization name to use.  If not
		     passed, then the user is prompted for it.

       NOPROT   If set, then proton rates are not included.

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

 CALLS: ***
	CH_SYNTHETIC, MAKE_CHIANTI_SPEC, READ_ABUND, STRPAD
 COMMON BLOCKS: None


 RESTRICTIONS:

 SIDE EFFECTS:


 EXAMPLE:

       > synthetic,100.,200.,.1, pressure=1.e+16,lambda,spectrum,list_wvl,list_ident


 CATEGORY:

	spectral synthesis.

 WRITTEN     : 

       Version 1, 8-Nov-01, Giulio Del Zanna (GDZ). 

       Rewritten as a wrapper routine using the new procedures.

       Compared to the previous SYNTHETIC, these are the main changes:

       1-Now the PRESSURE value is a keyword as the DENSITY value
       2-The keyword CONT is now renamed CONTINUUM
       3-Added keywords PHOTONS, DEM_NAME, ABUND_NAME, IONEQ_NAME
       4-MASTERLIST can now be used both as an input string or as a keyword.
       5-The description of the line details now has the spectroscopic 
         designation at the end.


 MODIFICATION HISTORY:

       Version 2, 18-Nov-01, Peter Young
           Added /noprot, rphot and radtemp keywords.

       Version 3, 11-Dec-01, Peter Young
           Changed call to ch_strpad to strpad.

       Version 4, 28-Apr-02, GDZ, changed the call to make_chianti_spec and the
       continuum keyword.

       V. 5, 22-May-2002 GDZ.  Removed const_net definitions.

       V.6, 14-Feb-2003 GDZ.
             Fixed a bug (keyword PHOTONS was not active). 
             
 VERSION     : 6, 14-Feb-2003



synthetic_plot $SSW/packages/chianti/idl/synthetic_plot.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:
	synthetic_plot

 PURPOSE:

       to plot out synthetic spectra calculated with Synthetic
       and interactively identify spectral lines


 CATEGORY:
	
	spectroscopy

 CALLING SEQUENCE:

       SYNTHETIC_PLOT,Wvl,Spectrum,List_wvl,List_ident,fwhm


 INPUTS:

       Wvl:  wavelength array from synthetic
       Spectrum:  spectrum intensity array from synthetic
       List_wvl:  string array of spectral line wavelengths
       List_ident:  string array of spectral line identifications
       Fwhm:  when the cursor is clicked, spectral lines with fwhm
              (Angstroms) of the cursor are printed out


 KEYWORDS

	xrange:  similar to IDL keyword to determine wavelength range of plot

 OUTPUTS:

       None


 PROCEDURE:

	Click the left mouse button to select a wavelength
       Click the right mouse button to exit

 CALLS: ***
	STR_SEP
 EXAMPLE:

      > synthetic,100.,200.,.1,1.e+15,wvl,spectrum,list_wvl,list_ident
      > synthetic_plot,wvl,spectrum,list_wvl,list_ident,0.1
                     
      note:  it is not necessary for the two fwhm values to be the same      

 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	May 1996:     Version 2.0
       Dec. 1998:    revised by Ken Dere
       V.4,  23 Oct 2000 GDZ, added the log keyword, and changed a few things
       in the plot. 

       Ver.5, 12-Dec-2001, Peter Young
           Changed style of printing, and made method of extracting the 
           intensity from list_ident compatible with the new version of 
           isothermal.pro.

 VERSION 5   12 Dec 2001 Peter Young