Documentation for  xanes_normalize.pro
----- Documentation for xanes_normalize.pro -----

 NAME:
	XANES_NORMALIZE

 PURPOSE:
	This function normalizes a XANES spectrum.

 CATEGORY:
	XAID xafs data analysis package. 

 CALLING SEQUENCE:

	i) setOut = XANES_NORMALIZE(setIn)
	ii) yOut = XANES_NORMALIZE(y,x)

 INPUTS:
       Input either: 
	  setIn:  fltarr(2,npoints) set of data (usually (E,Mu))
	  y:  Array with ordinates (usually Mu)

 OPTIONAL INPUTS:
	  x:  Array with abscissas (usually Energy)
	
 KEYWORD PARAMETERS (INPUT):
	METHOD:	Normalization method: 
               0 Use the jump (constant) value
		1 use a polynomial fit of the postEdge (default)

       JUMP: (when Method=0) defines the Jump. If undefined, the 
             jump is calculated using getJump() function.

       DEGREE: (when Method=1) defines the polynomial degree for the
             post-edge fit. Default=3

       E0:   The edge value in eV or keV. If not set, it is calculated
             using getEo()

       ESTART: The number of eV or keV (same units as the abscissas)
             for defining the preedge fit interval. 
             Xmin for the fit is the minimum of the abscissas plus EMIN
	      Default=5. (Set ESTART='0' for forcing zero because ESTART=0 takes
                         the default)
             
       EEND: The number of eV or keV (same units as the abscissas)
             for defining the preedge and postedge fit intervals. 
             Xmax for the preedge fit is e0 minus EEND
             Xmin for the postedge fit is e0 plus EEND
	      Default=20. (Set EEND='0' for forcing zero because EEND=0 takes
                         the default)
             
	XPLOT:	Set this keyword to inject results into an Xplot window

	VERBOSE: Set this keyword for a verbose output

 KEYWORD PARAMETERS (OUTPUT):

      preRANGE: a two elements array with the limits for the preedge fit

      postRANGE: a two elements array with the limits for the postedge fit

      SET: a multicolumn array containing the output and intermediate 
           calculations.
    
      COLTITLES: a string array with the labels of set

      TXT: a string array with the called command and used keyword values

 OUTPUTS:
	This function returns the normalized xanes spectrum in either
       a 1-dim array or a fltarr(2,npoints) set of data, depending 
       how the input is passed.

 PROCEDURE:
	A linear fit of the preedge is substracted. The resulting 
       spectrum divided by either a constant (jump, when method=0) 
       or by a polynomial fit of the postedge.

 MODIFICATION HISTORY:
 	Written by:	Manuel Sanchez del Rio. ESRF
       2009-05-13 srio@esrf.eu written.


