Analyzing Flare X-ray Spectra Using SPEX

Command Interpreter:

The command interpreter for SPEX can be used to change the value of registered 
OPTIONS(VARIABLES), main program variables, start command sequences, issue normal IDL
commands.  

++++++++++++++++++++++++++++++++++++++++++++++++++++
To change value of an option,

SPEX> OPTION, new_value1,new_value2,...,new_valueN

The options in SPEX are described at the end of this document.  Each one is a structure
tag in PRM_SPEX.  The OPTION is specified by the minimum unique string.  Scalar OPTIONs
take only new_value1.  Whitespace is compressed except in strings.  Vector OPTIONS may have
any or all of their values changed,

SPEX> OPTION, ,new_value2,

would only change the second element of OPTION.

++++++++++++++++++++++++++++++++++++++++++++++++++++
To change the value of a main program variable (only for experts)

SPEX> Variable = new_value

Option can sometimes be changed this way, although the action of the command interpreter
may be difficult to predict in this case.

++++++++++++++++++++++++++++++++++++++++++++++++++++
Command sequences may be started with the minimum number of unique characters.  The commands
available are found at the top menu.

SPEX> /
Command: /                                                                      
                                                                                                                       
 Change options by entering item, comma, new value.  After setting options,                                             
 enter one of the available commands.  Parameters and commands may be                                                   
 abbreviated to shortest unambiguous abbreviation and may be strung together                                            
 by inserting !! between entries.  To delete a string field,                                                            
 place a '' in the field                                                                                                
                                                                                                                        
      Spectral Analysis Executive  (SPEX)                                                                               
                                                                                                                        
           START_TIME_DATA    01-Jan-79 00:00:00.000                                                                    
           END_TIME_DATA      10-Feb-98 15:36:02.221                                                                    
           QUIET              1                                                                                         
           CHECK_DEFAULTS     1                                                                                         
           DFLTS_FILE         spex_dflts.dat                                                                            
           DATA_TIPE          BATSE        CONT                                                                         
           _1FILE                                                                                                       
           _2FILE                                                                                                       
           DIRECTORY                                                                                                    
           FLARE              3030                                                                                      
           DET_ID             3                                                                                         
           COSINE             0.680594                                                                                  
           SOURCE_RADEC       0.00000      0.00000                                                                      
           PSSTYLE            PORTRAIT                                                                                  
                                                                                                                        
 Commands:  /drm /fitting /interval /summary /time_history ? batse_menu comments erase execute exit find_files hard idl 
  initialize kleanplot list merge_batse online? preview pspreview reset_event restore_dflts save_dflts script steps_help
  stop tek zoom                                                                                                         
                                                                                                                        
 Additional commands:  / accum background_interval bspectrum build_drm cal_restore cal_save ch_bands clear_ut           
  count_spectrum create_ps display_intervals enrange fitting force_apar graph multidrm nospec_bands photon_spectrum     
  read_drm recalibrate restore_event save_event select_interval spec_bands t_hist_mode time_history                     
                                                                                                                        
Change parameters or enter a command

++++++++++++++++++++++++++++++++++++++++++++++++++++
Some commands also have modifying values,

such as 

background,clear (reset the background, background selection still needed)
background,null  (set the background to zero everywhere, background selection finished)
fit,plot    (plot without fitting)
fit,noplot  (fit without plotting)

++++++++++++++++++++++++++++++++++++++++++++++++++++
ISSUING IDL COMMANDS:

IDL expressions are entered using IDL

SPEX> idl, idl_proc, arg1, arg2

Expressions containing "=", "xdoc", "print", "help" don't require the preceding IDL.

++++++++++++++++++++++++++++++++++++++++++++++++++++
RUNNING SPEX:

0. Start SPEX in command line mode.

spex_proc
WIDGET MENUS ARE ENABLED!!!
The last ten lines from the COMMENTS command:
New datatypes have been integrated into SPEX:
From Yohkoh the HXT and the WBS instruments, SXS, HXS, and GRS.  However,
the SXS is still not understood and should only be used with that understanding.  
SMM HXRBS has been added with all of the flare files soon to be on-line in the 
FITS format expected by the default readers within SPEX.
Hey!!!  There is lots of good stuff here in COMMENTS.  Enter the command COMMENTS
 
Reading BATSE flare catalog ...                                                 
                                                                                                                       
 Change options by entering item, comma, new value.  After setting options,                                             
 enter one of the available commands.  Parameters and commands may be                                                   
 abbreviated to shortest unambiguous abbreviation and may be strung together                                            
 by inserting !! between entries.  To delete a string field,                                                            
 place a '' in the field                                                                                                
                                                                                                                        
      Spectral Analysis Executive  (SPEX)                                                                               
                                                                                                                        
           START_TIME_DATA                                                                                              
           END_TIME_DATA                                                                                                
           QUIET              1                                                                                         
           CHECK_DEFAULTS     1                                                                                         
           DFLTS_FILE         spex_dflts.dat                                                                            
           DATA_TIPE          BATSE        CONT                                                                         
           _1FILE                                                                                                       
           _2FILE                                                                                                       
           DIRECTORY                                                                                                    
           FLARE              665                                                                                       
           DET_ID             1                                                                                         
           COSINE             0.00000                                                                                   
           SOURCE_RADEC       0.00000      0.00000                                                                      
           PSSTYLE            PORTRAIT                                                                                  
                                                                                                                        
 Commands:  /drm /fitting /interval /summary /time_history ? batse_menu comments erase execute exit find_files hard idl 
  initialize kleanplot list merge_batse online? preview pspreview reset_event restore_dflts save_dflts script steps_help
  stop tek zoom                                                                                                         
                                                                                                                        
 Additional commands:  / accum background_interval bspectrum build_drm cal_restore cal_save ch_bands clear_ut           
  count_spectrum create_ps display_intervals enrange fitting force_apar graph multidrm nospec_bands photon_spectrum     
  read_drm recalibrate restore_event save_event select_interval spec_bands t_hist_mode time_history                     
                                                                                                                        
        1. Select flare and data files using parameter input.   

Change parameters or enter a command
SPEX>  data,batse,cont

Change parameters or enter a command
SPEX>  flare,3030

########  2. Select the detector id, Det_id based on detector cosines.  Also, look for the file
	for the first time.                                             

Change parameters or enter a command
SPEX>  preview

Command: preview                                                                
920626_1707.cont_3030 opened:
       File Start Time =  92/06/26, 1707:19.274
       File End Time   =  92/06/26, 1717:54.154
Found this file: /service/batse/batse0/cont/920626_1707.cont_3030               
                                                                                                        
 These are the detector cosines for BATSE CONT                                                           
      0.461496     0.521233     0.620856     0.680594    -0.680594    -0.620856    -0.521233    -0.461496
 Data file name returned: /service/batse/batse0/cont/920626_1707.cont_3030                               
Change parameters or enter a command
SPEX>  det_id,3

########  3. Read in flare files using GRAPH command.  Graph will both plot the light curves for the selected
	energy bands and read the data into memory if needed.  The detector response matrix, DRM, is also created
	and read into memory when data is initially read.                            

Change parameters or enter a command
SPEX>  graph

Command: graph                                                                  
920626_1707.cont_3030 opened:
       File Start Time =  92/06/26, 1707:19.274
       File End Time   =  92/06/26, 1717:54.154
Found this file: /service/batse/batse0/cont/920626_1707.cont_3030               
                                                                                                        
 These are the detector cosines for BATSE CONT                                                           
      0.461496     0.521233     0.620856     0.680594    -0.680594    -0.620856    -0.521233    -0.461496
 Data file name returned: /service/batse/batse0/cont/920626_1707.cont_3030                               
/service/batse/batse0/cont/920626_1707.cont_3030 opened:
       File Start Time =  92/06/26, 1707:19.274
       File End Time   =  92/06/26, 1717:54.154
 
Accumulation start time = 92/06/26, 1707:20.298
             end time   = 92/06/26, 1717:51.082
             number of points =          302
Using BATSE LAD CONT data from detector ID        3                             
Note: Erange reset after reading new data to ==>>      25.8785      11058.0     
ut_lim=  92/06/26, 1707:19.274 92/06/26, 1717:52.106                            
 uts_test,ute_test=                                                              
 92/06/26, 1707:19.274 92/06/26, 1717:54.154                                     
Command: build_drm                                                              
Building DRM for  BATSE CONT                                                    
Building LAD DRM from database files, extracting fluxes.
Not correcting for energy/light conversion!!
minmax(drm) -2.24097e-06    0.0168085
Change parameters or enter a command

######### 4. Select background using Background command.  The background may be fit using a polynomial
	of order 0-3, controlled by setting BACK_ORDER ( <back_order, 1>  gives a linear fit and is the
	default.  Each channel is fit individually.)  A widget is brought up for the time selection.
	Up to 6 intervals may be chosen. Follow the directions in the applets.  I will probably be
	changing the selection to use the BOX_CURSOR procedure.  Be sure to wait 1 or 2 seconds after
	each selection, ever after seeing the vertical line appear.  Otherwise the selection may not
	have registered.                          
                       
SPEX>  background

Command: background_interval                                                    
Select points for discrete intervals using any mouse button.                    
x =       61690.9                                                               
Select points for discrete intervals using any mouse button.                    
x =       61690.9                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x =       61745.8                                                               
Select points for discrete intervals using any mouse button.                    
x =       61745.8                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x =       61810.4                                                               
Select points for discrete intervals using any mouse button.                    
x =       61810.4                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x =       61839.2                                                               
Select points for discrete intervals using any mouse button.                    
x =       61839.2                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x =       62185.3                                                               
Select points for discrete intervals using any mouse button.                    
x =       62185.3                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x =       62259.5                                                               
Select points for discrete intervals using any mouse button.                    
x =       62259.5                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x = null                                                                        
Command: graph                                                                  
Change parameters or enter a command

######### 5. Use Zoom command to expand region of interest.                              
                       
SPEX>  zoom

Command: zoom                                                                   
Select two points 1 range using any mouse button.                               
x =       61752.7                                                               
Select two points 1 range using any mouse button.                               
x =       61752.7                                                               
Suspected double entry on last selection.  Last point rejected                  
Select two points 1 range using any mouse button.                               
x =       61832.4                                                               
Select two points 1 range using any mouse button.                               
Command: graph                                                                  
Change parameters or enter a command

########	6. Use Grap to replot the zoomed interval.                                     
	Plots the background subtracted flux from the selected detector.                 
	The 4 energy bands are selected from the 8 values in ENERGY_BANDS.  
 	The T_HIST_MODE option can be used to change the units from (T_HIST,COUNTS) COUNTS/s
	to COUNTS/s/keV/cm2 (T_HIST, FLUX).		                     

SPEX>  help,energy_bands
Command: idl                                                                    
IDL> help,energy_bands                                                          
ENERGY_BANDS    FLOAT     = Array[8]

SPEX>  t_history,count

Change parameters or enter a command
SPEX>  graph

Command: graph                                                                  
Change parameters or enter a command
SPEX>  print,edges

Command: idl                                                                    
IDL> print,edges                                                                
      18.3421      25.8785
      25.8785      33.8887
      33.8887      44.2625
      44.2625      56.5090
      56.5090      73.7531
      73.7531      98.8427
      98.8427      123.899
      123.899      164.205
      164.205      231.910
      231.910      317.104
      317.104      425.514
      425.514      590.733
      590.733      746.843
      746.843      1108.08
      1108.08      1841.15
      1841.15      8000.00
Change parameters or enter a command
SPEX>  energy_bands,19,31, 35,55, 58,150, 165, 2000

Change parameters or enter a command
SPEX>  gra

Command: graph                                                                  
Change parameters or enter a command
SPEX>  /t

Command: /time_history                                                          
                                                                                                                     
      Time plotting parameters:                                                                                       
                                                                                                                      
           UTS                92/06/26, 1709:12.703                                                                   
           UTE                92/06/26, 1710:32.359                                                                   
           T_HIST_MODE        COUNTS                                                                                  
           TAVG               1                                                                                       
           ENERGY_BANDS       19.0000      31.0000      35.0000      55.0000                                          
                              58.0000      150.000      165.000      2000.00                                          
           BACK_ORDER         1            1            1            1                                                
                              1                                                                                       
           SCALE_BANDS        1.00000      2.00000      4.00000      8.00000                                          
           EPLOTS             0                                                                                       
           TH_YTYPE           0                                                                                       
           TH_YRANGE          0.00000      0.00000                                                                    
                                                                                                                      
 Commands:  / accum background_interval bspectrum clear_ut create_ps display_intervals erase graph hard kleanplot list
  nospec_bands pspreview spec_bands t_hist_mode tek time_history zoom                                                 
                                                                                                                      
########	7. Select the integration intervals.                                           
	Use Grap to replot lightcurves of energy bands and Select_intervals commands.                  
	The selection may be done in one of 3 modes controlled by the applets:
	A. Contiguous intervals. Select single boundaries for adjacent intervals. 
	B. Discrete intervals. Select two boundaries for each interval.
	C. Regualar intervals. Select start and end boundary and grouping factor.
                     
Change parameters or enter a command
SPEX>  select_interval

Command: select_interval                                                        
Select two points for range to be subdivided using any mouse button.            
x =       61785.5                                                               
Select two points for range to be subdivided using any mouse button.            
x =       61785.5                                                               
Suspected double entry on last selection.  Last point rejected                  
Select two points for range to be subdivided using any mouse button.            
x =       61791.9                                                               
Select two points for range to be subdivided using any mouse button.            
Change parameters or enter a command

########	8. Set free and fixed parameters for the model.  Here, thermal + double power-law.

SPEX>  free,0,0,1,1,0,0

########	9. Plot the background spectrum and select the fit energy range.
	The indices of WUSE are those energy bins included in the fit.
	The ENRANGE command allows a graphic selection in the SPECTRAL WINDOW.

Change parameters or enter a command
SPEX>  bspec

Command: bspectrum                                                              
Change parameters or enter a command
SPEX>  print,wuse

Command: idl                                                                    
IDL> print,wuse                                                                 
           1           2           3           4           5           6           7           8           9          10
          11          12          13          14          15
Change parameters or enter a command
SPEX>  enra

Command: enrange                                                                
Select points for discrete intervals using any mouse button.                    
x =       32.0029                                                               
Select points for discrete intervals using any mouse button.                    
x =       32.0029                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x =       139.063                                                               
Select points for discrete intervals using any mouse button.                    
x =       139.063                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x = null                                                                        
Change parameters or enter a command
	
########	10. Start the initial fit over all intervals.  Specific interval
	range can be controlled by setting IFIRST and ILAST.  Interval indices
	start at 0.

SPEX>  fit

Command: fitting                                                                
Free Parameters:        0       0       1       1       0       0               
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000      3.92000      2.66000      400.000      1.93000  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       4.1159796
CHISQR, CHI_CURVATURE
       4.1159796       4.1159792
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       3.7708805
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       3.7401195
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       3.7352377
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000    0.0425372      4.18354      400.000      1.93000  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.72080378
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.57789227
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.57503924
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.57487708
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000     0.217373      3.28668      400.000      1.93000  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       1.7767054
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.97096117
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.97251248
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.97262792
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.97263195
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000     0.304969      3.36886      400.000      1.93000  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.34038143
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.85783910
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.85841825
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.85844421
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.85844421
Change parameters or enter a command
SPEX>  print,wuse

Command: idl                                                                    
IDL> print,wuse                                                                 
           1           2           3           4           5           6
Change parameters or enter a command
SPEX>  enrange

Command: enrange                                                                
Select points for discrete intervals using any mouse button.                    
x =       30.2011                                                               
Select points for discrete intervals using any mouse button.                    
x =       30.2011                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x =       842.044                                                               
Select points for discrete intervals using any mouse button.                    
x =       842.044                                                               
Suspected double entry on last selection.  Last point rejected                  
Select points for discrete intervals using any mouse button.                    
x = null                                                                        
Change parameters or enter a command
SPEX>  free,0,0,1,1,1,1

Change parameters or enter a command
SPEX>  fit

Command: fitting                                                                
Free Parameters:        0       0       1       1       1       1               
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000    0.0425372      4.18354      400.000      1.93000  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       2.1494407
CHISQR, CHI_CURVATURE
       2.1494407       2.1492256
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       2.1486017
CHISQR, CHI_CURVATURE
       2.1486017       2.1485996
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       2.1484507
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000    0.0424662      4.19027      508.790      12.0000  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       1.6157234
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       1.4209897
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       1.4127456
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       1.4124087
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000     0.217496      3.19669      1225.43      12.0000  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       16.465529
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       11.199480
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       10.749857
CHISQR, CHI_CURVATURE
       10.749857       10.749857
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       10.697991
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       10.692924
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000     0.303126      3.08355      1225.43      12.0000  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       2.2796824
CHISQR, CHI_CURVATURE
       2.2796824       2.2796816
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       3.9047872
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       4.0537033
CHISQR, CHI_CURVATURE
       4.0537033       4.0537027
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       4.0621021
CHISQR, CHI_CURVATURE
       4.0621021       4.0621011
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       4.0626949
Change parameters or enter a command
SPEX>  print,apar_arr

Command: idl                                                                    
IDL> print,apar_arr                                                             
  1.00000e-05      1.00000    0.0424662      4.19027      508.790      12.0000
  1.00000e-05      1.00000     0.217496      3.19669      1225.43      12.0000
  1.00000e-05      1.00000     0.303126      3.08355      1225.43      12.0000
  1.00000e-05      1.00000     0.185689      3.17744      1225.43      12.0000
Change parameters or enter a command
SPEX>  print,wuse

Command: idl                                                                    
IDL> print,wuse                                                                 
           1           2           3           4           5           6           7           8           9          10
          11          12
Change parameters or enter a command
	
########	11. Adjust the starting parameters for the model using the PHOTON command which gives
	a applet where new values may be entered.

SPEX>  photon

Command: photon_spectrum                                                        
Parameters for f_vth_bpow:  1.00000e-05      1.00000    0.0424662      4.19027      508.790      12.0000
Change parameters or enter a command
SPEX>  fit

Command: fitting                                                                
Free Parameters:        0       0       1       1       1       1               
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000    0.0424662      4.19027      100.000      3.00000  
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000    0.0555138      3.55323      39.0827      4.52035  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.33438432
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.33229289
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.33229250
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000     0.214927      3.35845      86.2922      2.96141  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=       1.6294483
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.65040640
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.63524622
CHISQR, CHI_CURVATURE
      0.63524622      0.63524567
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.62672783
CHISQR, CHI_CURVATURE
      0.62672783      0.62672746
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.62391863
RUN_CURVEFIT                                                                    
Input parameters for f_vth_bpow on entering loop:                               
  1.00000e-05      1.00000     0.302238      3.41094      112.371      2.40650  
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.25708645
CHISQR, CHI_CURVATURE
      0.25708645      0.25708614
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.27938682
CHISQR, CHI_CURVATURE
      0.27938682      0.27938668
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.28590754
USE CURVATURE MATRIX WITH FLAMBDA=0, CHISQ=      0.28782100
Change parameters or enter a command
SPEX>  print,apar_arr

Command: idl                                                                    
IDL> print,apar_arr                                                             
  1.00000e-05      1.00000    0.0555138      3.55323      39.0827      4.52035
  1.00000e-05      1.00000     0.214927      3.35845      86.2922      2.96141
  1.00000e-05      1.00000     0.302238      3.41094      112.371      2.40650
  1.00000e-05      1.00000     0.182741      3.42086      95.1389      2.67969
Change parameters or enter a command

########	12. Save the results of the fit into an IDL save file.  Both the setup options
	and fit results are saved.

SPEX>  /summ

Command: /summary                                                               
                                                                                
      Summary Procedure Parameters:                                              
                                                                                 
           SUMDIRECTORY                                                          
           SUMFILE            summary.dat                                        
                                                                                 
 Commands:  / list restore_event save_event                                      
                                                                                 
Change parameters or enter a command
SPEX>  save_event

Command: save_event                                                             
Writing event file, summary.dat                                                 
Command: save_dflts                                                             
Writing defaults file, spex_dflts.dat                                           
Change parameters or enter a command
                                     
Change parameters or enter a command
SPEX>  idl,dir,'*summ*'

Command: idl                                                                    
IDL> dir,'*summ*'                                                               
Change parameters or enter a command
SPEX>  exit

IDL> restore,/verb,'summary.dat'
% RESTORE: Portable (XDR) SAVE/RESTORE file.
% RESTORE: Save file written by richard@hxrbs.nascom.nasa.gov, Tue Feb 10 10:45:37 1998.
% RESTORE: IDL version 5.0.2 (OSF, alpha).
% RESTORE: Restored variable: APAR_LAST.
% RESTORE: Restored variable: CHI.
% RESTORE: Restored variable: XSELECT.
% RESTORE: Restored variable: ISELECT.
% RESTORE: Restored variable: TB.
% RESTORE: Restored variable: PRM_SPEX.

++++++++++++++++++++++++++++++++++++++++++++++++++++

Here is a summary of variables used with SPEX.  They are available from the SPEX command line using
the normal IDL commands prefaced with IDL, or without for HELP, PRINT, XDOC or any string using '=',e.g

SPEX> help,apar
Command: idl                                                                    
IDL> help,apar                                                                  
APAR (SPEX_PROC_COM)
                FLOAT     = Array[6]
Change parameters or enter a command
SPEX> print,apar
Command: idl                                                                    
IDL> print,apar                                                                 
  1.00000e-05      1.00000    0.0555138      3.55323      39.0827      4.52035
Change parameters or enter a command
SPEX> 

IDL> dir,'*.txt                                                                 
spex_help_19980210.txt  spex_list.txt           temp.txt
Change parameters or enter a command

Outside of SPEX, values may be obtained by using SPEX_CURRENT:
IDL> apar=spex_current('apar')
IDL> print,apar
  1.00000e-05      1.00000    0.0555138      3.55323      39.0827      4.52035

;	These are all of the important input and output variables in
;	the SPEX environment:
; Parameters may be changed using the syntax
SPEX> PARAMETER, NEWVALUE
The values are held in PRM_SPEX a structure inside of SPEX.
; 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)

The models available for fitting are in MODEL_COMPONENTS
        models = ['f_vth_bpow','f_2therm_pow','f_vth','f_nuclear','f_th_nt',$
                'f_multi_spec','f_bpow_nline', 'f_3pow', 'f_con_lin']

Each function is in the packages/xray/idl directory.

        ACCUM 
Integrate the spectral data in FLUX over the selected
time intervals.
        TIME_HISTORY 
Read the data files for the chosen event into FLUX
and UT and plot the light curve in the time history window.
        COUNT_SPECTRUM
Plot the count rate spectrum for the current interval, IFIRST, and overlay the
calculated count rate from the given by F_MODEL and the current fit parameters
for the interval in APAR, APAR_ARR, or APAR_LAST.
        PHOTON_SPECTRUM 
Plot the photon spectrum for the current interval, IFIRST, and overlay the
calculated photon spectrum from the given by F_MODEL and the current fit
parameters for the interval in APAR, APAR_ARR, or APAR_LAST.  The opportunity
is also presented to graphically select the model parameters.
        LIST 
Print a list of the control parameters and their values as well as the 
commands to the screen.
        EXIT 
Exit the SPEX procedure and return to IDL at the main program level.
        FITTING 
After the data is read by TIME_HISTORY, the DRM created under
the DRM menu, the intervals selected using SELECT_INTERVAL, the model
parameters initialized using PHOTON_SPECTRUM, the free parameters determined by
the value of the FREE array, the allowed energy range selected by the value of
ERANGE, the intervals are fit using a modified curvefit running from IFIRST to
ILAST.
        EXECUTE 
Prompts for an IDL command line to be input for the IDL EXECUTE function.
        STOP 
IDL STOP.  Resume by entering .c at the IDL prompt.
        ZOOM 
Interactive selection of a reduced xrange.  Restore full scale with
CLEAR_UT.
        DISPLAY_INTERVAL 
In the time history window, which must be the active window, overlay lines at 
the boundaries of the accumulation intervals.
        SELECT_INTERVAL 
In the time history window, which must be the active window,
interactively select the time  intervals for integration prior to FITTING. 
Also, the time intervals may be input directly  into the array, XSELECT =
fltarr(2,N) where the times are referenced to the same base as the data
intervals in UT and each interval is specified by its boundaries.
        BACKGROUND_INTERVAL 
In the time history window, which must be the active window, interactively
select the time  intervals for background accumulation.  The default background
model is a linear interpolation in time over the data points in two 
selected background intervals.  Experienced users may change the order
of the polynomial fit used by changing the parameter BACK_ORDER from its
default value of 1.
        INITIALIZE
Restore some of the original defaults. 
        GRAPH
Plot light curves in the time history window.  Light curves are integrated in
energy over the ranges specified by ENERGY_BANDS or CHANMASK and may
be rescaled by changing SCALE_BANDS.
        DRM
Enter the DRM menu to READ or BUILD load the detector response matrix, DRM.
        READ_DRM
Read the DRM files specified by DFILE for the direct response matrix and
SCATTERFILE for the response matrix due to scattering off the earth.  The
response matrix is interpolated to fine bins and then integrated over the
output bin energies for the specific data type on the date of the event.
        BUILD_DRM
Create the DRM direct detector response matrix, DRM, by interpolating in 
the source aspect angle over a stored set of response matrices.  The
response matrix is then interpolated to fine bins and integrated over the
output bin energies for the specific data type on the date of the event.
        TOP
Return to the main SPEX menu from a branch menu.
        STEPS_HELP
Describes the step-by-step procedure for processing spectra through
the SPEX menu.
        SUMMARY
Enter the SUMMARY menu to save and restore processed spectra and fit
parameters.  
        ERASE
Clears a Tektronix graphics page.
        TEK
Sets the graphic display to Tektronix.
        FIND_FILES
Find the filenames or verify the filenames specified under the parameters
_1FILE and _2FILE.  Mostly unneeded using automatic file finding defaults
with the filename parameters left blank.
        ENRANGE
With the SPECTRAL WINDOW active (last plotted to), graphically select 
the energy limits on the spectra to be fit.
        CH_BANDS
With the SPECTRAL WINDOW active (last plotted to), graphically select 
the four ranges in the ENERGY_BANDS parameter.
        SPEC_BANDS
With the SPECTRAL WINDOW active (last plotted to), graphically select 
the groups of channels to be summed together for display.  Does not affect
binning for fitting which uses individual channels within the limits
specified by ERANGE.
        NOSPEC_BANDS
Resets the grouping of SPEC_BANDS to single channels without any grouping.
        BSPECTRUM
Displays the background count rate energy spectrum.
        RESTORE_DFLTS
Reads the parameter values saved in the file given by the parameter,
DFLTS_FILE.
        SAVE_DFLTS
Saves the parameter values saved in the file given by the parameter,
DFLTS_FILE.  Use to save the setup for a particular data set.  The file
will be named in a systematic fashion if DFLTS_FILE is set to AUTO.
        CLEAR_UT
Resets the timerange in the TIME HISTORY WINDOW to the limits of the vector
UT, i.e. to the extent of the time interval covered by the current data set
input through TIME_HISTORY.
        KLEANPLOT
Runs the routine CLEANPLOT which resets the system plotting structures
to their defaults.
        FORCE_APAR
Sets the fitting parameters in each interval in the arrays APAR_ARR and
APAR_LAST to the values in APAR.  APAR_ARR and APAR_LAST are dimensioned
fltarr( npar, nint) where npar is the number of parameters in the fitting
model (see F_MODEL) and nint is the number of fitting time intervals (see
the parameters XSELECT and WINT).
        COMMENTS
Print recent messages about the status of SPEX including problem reports
and new features.
        T_HIST_MODE
Set the display mode for the TIME_HISTORY and GRAPH commands to COUNTS or
FLUX to see the light curves in units of COUNTS/S or COUNTS/S/KEV/CM2,
respectively.
        ?
Get help on SPEX parameters, arrays, and commands.  Syntax is
?,<item> where <item> is them name of a parameter, array, or command.