
;+
;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
;-
function spex_f_label, function_name

@function_com

Ep = string(Epivot,'(f'+strtrim(fix(alog10(Epivot)+3),2)+'.1)') ;make a string out of the 
par_list={par_list, $
		name:bytarr(30), $		;Parameter, i.e. Temperature
		exp_offset: 0, $	 	;Exponential offset
		normalize: 0 , $		;Set, if this is a norm. param.
		format: bytarr(20), $		;i.e. '(f4.1)'
		units:bytarr(30) }		;i.e. 'keV'

labels = {labels, funct_name:bytarr(30), $ 	;THBREM_BPOW
		 model:bytarr(80), $   		;THERMAL BREMSSTRAHLUNG +
					$ 	;BROKEN	POWERLAW	
                 num_params:0 , $		;Number of active Parameters
		 desc:bytarr(1000), $		;Describe the function
		 params: replicate(par_list,50) } ;allow up to 50 Parameters

if strupcase(function_name) eq 'F_VTH' then begin
	labels.funct_name= byte('F_VTH')
	labels.model     = byte('THERMAL BREMSSTRAHLUNG')
	labels.num_params= 2

	buff = labels.params.normalize 
	buff(0,0) = [1,0]
	labels.params.normalize = buff

	buff = labels.params.name
	buff(0,0) = byte(['Emission Measure', 'Temperature'])
	labels.params.name = buff 

	buff = labels.params.units
	buff(0,0) = byte(['cm!u-3!n', 'keV'])
	labels.params.units=buff
	
	labels.params(0).exp_offset = 49  ;scale the emission measure by 10^49


	buff = labels.params.format	  ; 
	buff(0,0) = byte(['(f5.2)','(f4.1)'])
	labels.params.format = buff

;ASCII description of function including format control
	desc = "(' ####### ',/,'F_VTH (E, (A0,A1) ) - Thermal Bremsstrahlung',/,"+ $
		"' = A0 * Gef * EXP( -(E/A1) ) / E / A1^0.5',/,"+ $
		"' = A0 is the emission measure in 10^49 cm-3',//,"+$
		"'E is the photon energy in keV.',/," +$
		"'Gef is the effective Gaunt factor',/," +$
		"'A1 is the temperature in keV',/,' #######')" 
        labels.desc = byte(desc)
endif
if strupcase(function_name) eq 'F_BPOW' then begin
	labels.funct_name= byte('F_BPOW')
	labels.model     = byte('BROKEN POWERLAW')
	labels.num_params= 6

	buff = labels.params.normalize 
	buff(0,0) = [1,intarr(5)]
	labels.params.normalize = buff


	buff = labels.params.name
	buff(0,0) = byte(['Powerlaw 1 at 50 keV', 'Powerlaw 1 Index', $
		'Break Energy', 'Powerlaw 2 Index', $
		'Low Energy Cutoff', 'Index Below Cutoff'])
	labels.params.name = buff 

	buff = labels.params.units
	buff(0,0) = byte(['cm!u-2!n s!u-1!n keV!u-1!n', ' ', 'keV',$
		' ','keV',' '])
	labels.params.units=buff
	
	buff = labels.params.format	  ; 
	buff(0,0) = byte(['(f7.4)','(f4.1)','(f7.2)','(f4.1)',$
		'(f4.1)', '(f4.1)'])
	labels.params.format = buff

;ASCII description of function including format control
	desc = "(' ####### ',/,'F_BPOW (E, (A0,...,A5) )  - Broken Power Law',/,"+ $
	"' = A0 * (E/"+Ep+")^(-A1) for E < A2',/," + $
	"' = A0 * (A2/"+Ep+")^(A1) * (E/A2)^(-A3) for E > A2',/," + $
	"' = A0 * ("+Ep+"/A4)^(A1-A5) * (E/"+Ep+")^(-A5) for E < A4',//," + $
	"'E is the is the photon energy in keV.' ,/," + $
	"'A0 is the flux in photons / (cm2 s keV) at "+ $
        "the pivot energy, "+Ep+" keV.',/, " + $
	"'A1 is the spectral index at E < A2, the break energy in keV.',/," +$
	"'A3 is the spectral index at E > A2.',/," +$
     "'A4 is the low energy cutoff in keV.',/," +$
	"'A5 is index of the slope with a range of 1.5-2.0 below A4.',/,' #######')"
        labels.desc = byte(desc)

endif
if strupcase(function_name) eq 'F_VTH_BPOW' then begin
	labels.funct_name= byte('F_VTH_BPOW')
	labels.model     = byte('THERMAL BREMSSTRAHLUNG + !cBROKEN POWERLAW')
	labels.num_params= 8

;If the parameter normalizes an independent function, then set this.
;This can be used to identify separate spectral components in the plotting
;routine.
	buff = labels.params.normalize 
	buff(0,0) = [1,0,0,intarr(5)]
	labels.params.normalize = buff

	buff = labels.params.name
	buff(0,0) = byte(['Emission Measure', 'Temperature',$
		'Powerlaw 1 at 50 keV', 'Powerlaw 1 Index', $
		'Break Energy', 'Powerlaw 2 Index', $
		'Low Energy Cutoff', 'Index Below Cutoff'])
	labels.params.name = buff 

	buff = labels.params.units
	buff(0,0) = byte(['cm!u-3!n', 'keV','cm!u-2!n s!u-1!n keV!u-1!n', ' ', 'keV',$
		' ','keV',' '])
	labels.params.units=buff
	
	labels.params(0).exp_offset = 49  ;scale the emission measure by 10^49


	buff = labels.params.format	  ; 
	buff(0,0) = byte(['(f5.2)','(f4.1)','(f7.4)','(f4.1)','(f7.2)','(f4.1)',$
		'(f4.1)', '(f4.1)'])
	labels.params.format = buff

;ASCII description of function including format control

	desc = "(' ####### ',/,'F_VTH_BPOW - Thermal Bremsstrahlung + Broken Power Law',/,"+ $
		"' = A0 * Gef * EXP( -(E/A1) ) / E / A1^0.5 + ',/,"+ $
	"'    A2 * (E/"+Ep+")^(-A3) for E < A4',/," + $
	"'    A2 * (A4/"+Ep+")^(A3) * (E/A4)^(-A5) for E > A4',/," + $
	"'    A2 * ("+Ep+"/A6)^(A3-A7) * (E/"+Ep+")^(-A7) for E < A6',//," + $
		"'E is the photon energy in keV',/," + $
		"'Gef is the effective Gaunt factor',/," +$
		"'A0 is the emission measure in 10^49 cm-3',/,"+$
		"'A1 is the temperature in keV',/," + $
	"'A2 is the flux in photons / (cm2 s keV) at "+ $
        " the pivot energy, "+Ep+" keV.',/," + $
	"'A3 is the spectral index at E < A4, the break energy in keV.',/," +$
	"'A5 is the spectral index at E > A4.',/," +$
     "'A6 is the low energy cutoff in keV.',/," +$
	"'A7 is index of the slope with a range of 1.5-2.0 below A6.',/,' #######')"

        labels.desc = byte(desc)

endif


return, labels
end
